aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/background/controllers/OperationController.ts8
-rw-r--r--src/background/infrastructures/ContentMessageListener.ts2
-rw-r--r--src/content/client/OperationClient.ts8
-rw-r--r--src/content/controllers/KeymapController.ts6
-rw-r--r--src/content/usecases/KeymapUseCase.ts6
-rw-r--r--src/shared/messages.ts2
-rw-r--r--test/content/usecases/KeymapUseCase.test.ts32
7 files changed, 32 insertions, 32 deletions
diff --git a/src/background/controllers/OperationController.ts b/src/background/controllers/OperationController.ts
index 69b45c3..2f5d4a6 100644
--- a/src/background/controllers/OperationController.ts
+++ b/src/background/controllers/OperationController.ts
@@ -21,8 +21,8 @@ export default class OperationController {
) {
}
- async exec(count: number, op: operations.Operation): Promise<any> {
- await this.doOperation(count, op);
+ async exec(repeat: number, op: operations.Operation): Promise<any> {
+ await this.doOperation(repeat, op);
if (this.repeatUseCase.isRepeatable(op)) {
this.repeatUseCase.storeLastOperation(op);
}
@@ -30,7 +30,7 @@ export default class OperationController {
// eslint-disable-next-line complexity, max-lines-per-function
async doOperation(
- count: number,
+ repeat: number,
operation: operations.Operation,
): Promise<any> {
// eslint-disable-next-line complexity, max-lines-per-function
@@ -119,7 +119,7 @@ export default class OperationController {
}
})();
- for (let i = 0; i < count; ++i) {
+ for (let i = 0; i < repeat; ++i) {
// eslint-disable-next-line no-await-in-loop
await opFunc();
}
diff --git a/src/background/infrastructures/ContentMessageListener.ts b/src/background/infrastructures/ContentMessageListener.ts
index 51a9f82..f20340b 100644
--- a/src/background/infrastructures/ContentMessageListener.ts
+++ b/src/background/infrastructures/ContentMessageListener.ts
@@ -80,7 +80,7 @@ export default class ContentMessageListener {
senderTab.id as number,
message.background);
case messages.BACKGROUND_OPERATION:
- return this.onBackgroundOperation(message.count, message.operation);
+ return this.onBackgroundOperation(message.repeat, message.operation);
case messages.MARK_SET_GLOBAL:
return this.onMarkSetGlobal(message.key, message.x, message.y);
case messages.MARK_JUMP_GLOBAL:
diff --git a/src/content/client/OperationClient.ts b/src/content/client/OperationClient.ts
index 06077dc..9c72c75 100644
--- a/src/content/client/OperationClient.ts
+++ b/src/content/client/OperationClient.ts
@@ -2,7 +2,7 @@ import * as operations from '../../shared/operations';
import * as messages from '../../shared/messages';
export default interface OperationClient {
- execBackgroundOp(count: number, op: operations.Operation): Promise<void>;
+ execBackgroundOp(repeat: number, op: operations.Operation): Promise<void>;
internalOpenUrl(
url: string, newTab?: boolean, background?: boolean,
@@ -10,10 +10,10 @@ export default interface OperationClient {
}
export class OperationClientImpl implements OperationClient {
- execBackgroundOp(count: number, op: operations.Operation): Promise<void> {
+ execBackgroundOp(repeat: number, op: operations.Operation): Promise<void> {
return browser.runtime.sendMessage({
type: messages.BACKGROUND_OPERATION,
- count,
+ repeat,
operation: op,
});
}
@@ -23,7 +23,7 @@ export class OperationClientImpl implements OperationClient {
): Promise<void> {
return browser.runtime.sendMessage({
type: messages.BACKGROUND_OPERATION,
- count: 1,
+ repeat: 1,
operation: {
type: operations.INTERNAL_OPEN_URL,
url,
diff --git a/src/content/controllers/KeymapController.ts b/src/content/controllers/KeymapController.ts
index b8069f9..452e3d4 100644
--- a/src/content/controllers/KeymapController.ts
+++ b/src/content/controllers/KeymapController.ts
@@ -38,7 +38,7 @@ export default class KeymapController {
}
if (!operations.isNRepeatable(nextOp.op.type)) {
- nextOp.count = 1;
+ nextOp.repeat = 1;
}
const doFunc = ((op: operations.Operation) => {
@@ -91,9 +91,9 @@ export default class KeymapController {
// Do not await asynchronous methods to return a boolean immidiately. The
// caller requires the synchronous response from the callback to identify
// to continue of abandon the event propagations.
- this.operationClient.execBackgroundOp(nextOp.count, nextOp.op);
+ this.operationClient.execBackgroundOp(nextOp.repeat, nextOp.op);
} else {
- for (let i = 0; i < nextOp.count; ++i) {
+ for (let i = 0; i < nextOp.repeat; ++i) {
doFunc();
}
}
diff --git a/src/content/usecases/KeymapUseCase.ts b/src/content/usecases/KeymapUseCase.ts
index fab13f5..a2e7cc3 100644
--- a/src/content/usecases/KeymapUseCase.ts
+++ b/src/content/usecases/KeymapUseCase.ts
@@ -36,7 +36,7 @@ export default class KeymapUseCase {
}
// eslint-disable-next-line max-statements
- nextOps(key: Key): { count: number, op: operations.Operation } | null {
+ nextOps(key: Key): { repeat: number, op: operations.Operation } | null {
let sequence = this.repository.enqueueKey(key);
let baseSequence = sequence.trimNumericPrefix();
if (baseSequence.length() === 1 && this.blacklistKey(key)) {
@@ -53,13 +53,13 @@ export default class KeymapUseCase {
sequence.length() === matched[0][0].length()) {
// keys are matched with an operation
this.repository.clear();
- return { count: 1, op: matched[0][1] };
+ return { repeat: 1, op: matched[0][1] };
} else if (
baseMatched.length === 1 &&
baseSequence.length() === baseMatched[0][0].length()) {
// keys are matched with an operation with a numeric prefix
this.repository.clear();
- return { count: sequence.repeatCount(), op: baseMatched[0][1] };
+ return { repeat: sequence.repeatCount(), op: baseMatched[0][1] };
} else if (matched.length >= 1 || baseMatched.length >= 1) {
// keys are matched with an operation's prefix
return null;
diff --git a/src/shared/messages.ts b/src/shared/messages.ts
index 8032109..7f8bd5b 100644
--- a/src/shared/messages.ts
+++ b/src/shared/messages.ts
@@ -49,7 +49,7 @@ export const NAVIGATE_LINK_PREV = 'navigate.link.prev';
export interface BackgroundOperationMessage {
type: typeof BACKGROUND_OPERATION;
- count: number;
+ repeat: number;
operation: operations.Operation;
}
diff --git a/test/content/usecases/KeymapUseCase.test.ts b/test/content/usecases/KeymapUseCase.test.ts
index 904a180..598d5a3 100644
--- a/test/content/usecases/KeymapUseCase.test.ts
+++ b/test/content/usecases/KeymapUseCase.test.ts
@@ -72,10 +72,10 @@ describe('KeymapUseCase', () => {
});
it('returns matched operation', () => {
- expect(sut.nextOps(Key.fromMapKey('k'))).to.deep.equal({ count: 1, op: {type: 'scroll.vertically', count: -1}});
- expect(sut.nextOps(Key.fromMapKey('j'))).to.deep.equal({ count: 1, op: {type: 'scroll.vertically', count: 1}});
+ expect(sut.nextOps(Key.fromMapKey('k'))).to.deep.equal({ repeat: 1, op: {type: 'scroll.vertically', count: -1}});
+ expect(sut.nextOps(Key.fromMapKey('j'))).to.deep.equal({ repeat: 1, op: {type: 'scroll.vertically', count: 1}});
expect(sut.nextOps(Key.fromMapKey('g'))).to.be.null;
- expect(sut.nextOps(Key.fromMapKey('g'))).to.deep.equal({ count: 1, op: {type: 'scroll.top'}});
+ expect(sut.nextOps(Key.fromMapKey('g'))).to.deep.equal({ repeat: 1, op: {type: 'scroll.top'}});
expect(sut.nextOps(Key.fromMapKey('z'))).to.be.null;
});
@@ -83,7 +83,7 @@ describe('KeymapUseCase', () => {
expect(sut.nextOps(Key.fromMapKey('1'))).to.be.null;
expect(sut.nextOps(Key.fromMapKey('0'))).to.be.null;
expect(sut.nextOps(Key.fromMapKey('g'))).to.be.null;
- expect(sut.nextOps(Key.fromMapKey('g'))).to.deep.equal({ count: 10, op: {type: "scroll.top"}});
+ expect(sut.nextOps(Key.fromMapKey('g'))).to.deep.equal({ repeat: 10, op: {type: "scroll.top"}});
});
});
@@ -108,18 +108,18 @@ describe('KeymapUseCase', () => {
it('returns the matched operation ends with digit', () => {
expect(sut.nextOps(Key.fromMapKey('g'))).to.be.null;
- expect(sut.nextOps(Key.fromMapKey('5'))).to.be.deep.equal({ count: 1, op: { type: 'scroll.bottom'}});
+ expect(sut.nextOps(Key.fromMapKey('5'))).to.be.deep.equal({ repeat: 1, op: { type: 'scroll.bottom'}});
});
it('returns an operation matched the operation with digit keymaps', () => {
expect(sut.nextOps(Key.fromMapKey('2'))).to.be.null;
- expect(sut.nextOps(Key.fromMapKey('0'))).to.be.deep.equal({ count: 1, op: { type: 'scroll.top'}});
+ expect(sut.nextOps(Key.fromMapKey('0'))).to.be.deep.equal({ repeat: 1, op: { type: 'scroll.top'}});
});
it('returns operations repeated by numeric prefix', () => {
expect(sut.nextOps(Key.fromMapKey('2'))).to.be.null;
expect(sut.nextOps(Key.fromMapKey('g'))).to.be.null;
- expect(sut.nextOps(Key.fromMapKey('5'))).to.be.deep.equal({ count: 2, op: { type: 'scroll.bottom'}});
+ expect(sut.nextOps(Key.fromMapKey('5'))).to.be.deep.equal({ repeat: 2, op: { type: 'scroll.bottom'}});
});
it('does not matches with digit operation with numeric prefix', () => {
@@ -127,7 +127,7 @@ describe('KeymapUseCase', () => {
expect(sut.nextOps(Key.fromMapKey('2'))).to.be.null;
expect(sut.nextOps(Key.fromMapKey('0'))).to.be.null;
expect(sut.nextOps(Key.fromMapKey('g'))).to.be.null;
- expect(sut.nextOps(Key.fromMapKey('5'))).to.be.deep.equal({ count: 320, op: { type: 'scroll.bottom'}});
+ expect(sut.nextOps(Key.fromMapKey('5'))).to.be.deep.equal({ repeat: 320, op: { type: 'scroll.bottom'}});
});
});
@@ -154,7 +154,7 @@ describe('KeymapUseCase', () => {
expect(sut.nextOps(Key.fromMapKey('g'))).to.be.null;
expect(sut.nextOps(Key.fromMapKey('x'))).to.be.null; // clear
expect(sut.nextOps(Key.fromMapKey('g'))).to.be.null;
- expect(sut.nextOps(Key.fromMapKey('g'))).to.deep.equal({count: 1, op: {type: "scroll.top"}});
+ expect(sut.nextOps(Key.fromMapKey('g'))).to.deep.equal({repeat: 1, op: {type: "scroll.top"}});
});
it('clears input keys and the prefix with no-matched operations', () => {
@@ -165,7 +165,7 @@ describe('KeymapUseCase', () => {
expect(sut.nextOps(Key.fromMapKey('1'))).to.be.null;
expect(sut.nextOps(Key.fromMapKey('0'))).to.be.null;
expect(sut.nextOps(Key.fromMapKey('g'))).to.be.null;
- expect(sut.nextOps(Key.fromMapKey('g'))).to.deep.equal({ count: 10, op: {type: "scroll.top"}});
+ expect(sut.nextOps(Key.fromMapKey('g'))).to.deep.equal({ repeat: 10, op: {type: "scroll.top"}});
});
});
@@ -191,8 +191,8 @@ describe('KeymapUseCase', () => {
it('returns only ADDON_ENABLE and ADDON_TOGGLE_ENABLED operation', () => {
expect(sut.nextOps(Key.fromMapKey('k'))).to.be.null;
- expect(sut.nextOps(Key.fromMapKey('a'))).to.deep.equal({ count: 1, op: {type: 'addon.enable'}});
- expect(sut.nextOps(Key.fromMapKey('b'))).to.deep.equal({ count: 1, op: {type: 'addon.toggle.enabled'}});
+ expect(sut.nextOps(Key.fromMapKey('a'))).to.deep.equal({ repeat: 1, op: {type: 'addon.enable'}});
+ expect(sut.nextOps(Key.fromMapKey('b'))).to.deep.equal({ repeat: 1, op: {type: 'addon.toggle.enabled'}});
});
});
@@ -218,11 +218,11 @@ describe('KeymapUseCase', () => {
new MockAddressRepository(new URL('https://example.com')),
);
- expect(sut.nextOps(Key.fromMapKey('k'))).to.deep.equal({ count: 1, op: {type: 'scroll.vertically', count: -1}});
- expect(sut.nextOps(Key.fromMapKey('j'))).to.deep.equal({ count: 1, op: {type: 'scroll.vertically', count: 1}});
+ expect(sut.nextOps(Key.fromMapKey('k'))).to.deep.equal({ repeat: 1, op: {type: 'scroll.vertically', count: -1}});
+ expect(sut.nextOps(Key.fromMapKey('j'))).to.deep.equal({ repeat: 1, op: {type: 'scroll.vertically', count: 1}});
expect(sut.nextOps(Key.fromMapKey('g'))).to.be.null;
expect(sut.nextOps(Key.fromMapKey('g'))).to.be.null;
- expect(sut.nextOps(Key.fromMapKey('G'))).to.deep.equal({ count: 1, op: {type: 'scroll.bottom'}});
+ expect(sut.nextOps(Key.fromMapKey('G'))).to.deep.equal({ repeat: 1, op: {type: 'scroll.bottom'}});
sut = new KeymapUseCase(
new KeymapRepositoryImpl(),
@@ -232,7 +232,7 @@ describe('KeymapUseCase', () => {
);
expect(sut.nextOps(Key.fromMapKey('g'))).to.be.null;
- expect(sut.nextOps(Key.fromMapKey('g'))).to.deep.equal({ count: 1, op: {type: 'scroll.top'}});
+ expect(sut.nextOps(Key.fromMapKey('g'))).to.deep.equal({ repeat: 1, op: {type: 'scroll.top'}});
expect(sut.nextOps(Key.fromMapKey('G'))).to.be.null;
});
});