From ced89134e32d793d8e091113cfb20867e1c3b572 Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Sun, 19 May 2019 16:52:40 +0900 Subject: [PATCH] Fix failed CircleCI --- e2e/follow_properties.test.js | 16 ++++++++++------ src/background/presenters/IndicatorPresenter.ts | 10 +++++----- src/background/usecases/CompletionsUseCase.ts | 4 ++-- src/background/usecases/LinkUseCase.ts | 15 +++++++++++---- 4 files changed, 28 insertions(+), 17 deletions(-) diff --git a/e2e/follow_properties.test.js b/e2e/follow_properties.test.js index 80040a3..5e82b50 100644 --- a/e2e/follow_properties.test.js +++ b/e2e/follow_properties.test.js @@ -126,9 +126,11 @@ describe('follow properties test', () => { }); await body.sendKeys('jj'); - let tabs = await browser.tabs.query({}); - assert.equal(tabs[0].active, false); - assert.equal(tabs[1].active, true); + await eventually(async() => { + let tabs = await browser.tabs.query({}); + assert.equal(tabs[0].active, false); + assert.equal(tabs[1].active, true); + }); }); it('should open tab in background by background:true', async () => { @@ -139,8 +141,10 @@ describe('follow properties test', () => { }); await body.sendKeys('jj'); - let tabs = await browser.tabs.query({}); - assert.equal(tabs[0].active, true); - assert.equal(tabs[1].active, false); + await eventually(async() => { + let tabs = await browser.tabs.query({}); + assert.equal(tabs[0].active, true); + assert.equal(tabs[1].active, false); + }); }); }); diff --git a/src/background/presenters/IndicatorPresenter.ts b/src/background/presenters/IndicatorPresenter.ts index 5d9c21f..1c81cf5 100644 --- a/src/background/presenters/IndicatorPresenter.ts +++ b/src/background/presenters/IndicatorPresenter.ts @@ -3,13 +3,13 @@ export default class IndicatorPresenter { let path = enabled ? 'resources/enabled_32x32.png' : 'resources/disabled_32x32.png'; - if (typeof browser.browserAction.setIcon === "function") { + if (typeof browser.browserAction.setIcon === 'function') { return browser.browserAction.setIcon({ path }); } - else { - // setIcon not supported on Android - return Promise.resolve(); - } + + // setIcon not supported on Android + return Promise.resolve(); + } onClick(listener: (arg: browser.tabs.Tab) => void): void { diff --git a/src/background/usecases/CompletionsUseCase.ts b/src/background/usecases/CompletionsUseCase.ts index 7f6322e..da36e3c 100644 --- a/src/background/usecases/CompletionsUseCase.ts +++ b/src/background/usecases/CompletionsUseCase.ts @@ -53,14 +53,14 @@ export default class CompletionsUseCase { groups.push({ name: 'Search Engines', items: engines }); } // browser.history not supported on Android - } else if (c === 'h' && typeof browser.history === "object") { + } else if (c === 'h' && typeof browser.history === 'object') { // eslint-disable-next-line no-await-in-loop let histories = await this.queryHistoryItems(name, keywords); if (histories.length > 0) { groups.push({ name: 'History', items: histories }); } // browser.bookmarks not supported on Android - } else if (c === 'b' && typeof browser.bookmarks === "object") { + } else if (c === 'b' && typeof browser.bookmarks === 'object') { // eslint-disable-next-line no-await-in-loop let bookmarks = await this.queryBookmarkItems(name, keywords); if (bookmarks.length > 0) { diff --git a/src/background/usecases/LinkUseCase.ts b/src/background/usecases/LinkUseCase.ts index 21cf0e7..480f6b5 100644 --- a/src/background/usecases/LinkUseCase.ts +++ b/src/background/usecases/LinkUseCase.ts @@ -11,10 +11,17 @@ export default class LinkUseCase { return this.tabPresenter.open(url, tabId); } - openNewTab(url: string, openerId: number, background: boolean): Promise { - // openerTabId not supported on Android - let properties = typeof browser.tabs.Tab === "object" ? - { openerTabId: openerId, active: !background } : { active: !background }; + async openNewTab( + url: string, openerId: number, background: boolean, + ): Promise { + let properties: any = { active: !background }; + + let platform = await browser.runtime.getPlatformInfo(); + if (platform.os !== 'android') { + // openerTabId not supported on Android + properties.openerTabId = openerId; + } + return this.tabPresenter.create(url, properties); } }