diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2018-05-13 00:12:11 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2018-05-13 01:01:10 +0900 |
commit | 5617f6f7650e0eb5711bea5b060e98f0d2e94f46 (patch) | |
tree | 6e7a1f48f82c15beddd0015c1a63ee3df0675d38 /e2e | |
parent | 82aad419a74a3061247d4e82656fa711e63f213c (diff) |
Add e2e test cases for deleting tabs
Diffstat (limited to 'e2e')
-rw-r--r-- | e2e/ambassador/src/background/index.js | 5 | ||||
-rw-r--r-- | e2e/ambassador/src/background/tabs.js | 4 | ||||
-rw-r--r-- | e2e/ambassador/src/client/tabs.js | 13 | ||||
-rw-r--r-- | e2e/ambassador/src/shared/messages.js | 2 | ||||
-rw-r--r-- | e2e/contents/tab.test.js | 32 |
5 files changed, 52 insertions, 4 deletions
diff --git a/e2e/ambassador/src/background/index.js b/e2e/ambassador/src/background/index.js index c40b4d8..046b8c1 100644 --- a/e2e/ambassador/src/background/index.js +++ b/e2e/ambassador/src/background/index.js @@ -1,6 +1,7 @@ import { WINDOWS_CREATE, WINDOWS_REMOVE, WINDOWS_GET, - TABS_CREATE, TABS_SELECT_AT, TABS_GET, TABS_GET_ZOOM, TABS_SET_ZOOM, + TABS_CREATE, TABS_SELECT_AT, TABS_GET, TABS_UPDATE, + TABS_GET_ZOOM, TABS_SET_ZOOM, EVENT_KEYPRESS, EVENT_KEYDOWN, EVENT_KEYUP, SCROLL_GET, SCROLL_SET, } from '../shared/messages'; @@ -27,6 +28,8 @@ receiveContentMessage((message) => { }); case TABS_GET: return browser.tabs.get(message.tabId); + case TABS_UPDATE: + return browser.tabs.update(message.tabId, message.properties); case TABS_GET_ZOOM: return browser.tabs.getZoom(message.tabId); case TABS_SET_ZOOM: diff --git a/e2e/ambassador/src/background/tabs.js b/e2e/ambassador/src/background/tabs.js index 37156c4..5594134 100644 --- a/e2e/ambassador/src/background/tabs.js +++ b/e2e/ambassador/src/background/tabs.js @@ -5,7 +5,9 @@ const create = (props = {}) => { if (tab.url !== 'about:blank' && tabId === createdTab.id && changeInfo.status === 'complete') { browser.tabs.onUpdated.removeListener(callback); - setTimeout(() => resolve(tab), 50) // wait for 50 milliseconds to ensure plugin loaded; + + // wait for 50 milliseconds to ensure plugin loaded; + setTimeout(() => resolve(tab), 50); } }; browser.tabs.onUpdated.addListener(callback); diff --git a/e2e/ambassador/src/client/tabs.js b/e2e/ambassador/src/client/tabs.js index 14d524d..290428c 100644 --- a/e2e/ambassador/src/client/tabs.js +++ b/e2e/ambassador/src/client/tabs.js @@ -1,5 +1,6 @@ import { - TABS_CREATE, TABS_SELECT_AT, TABS_GET, TABS_GET_ZOOM, TABS_SET_ZOOM, + TABS_CREATE, TABS_SELECT_AT, TABS_GET, TABS_UPDATE, + TABS_GET_ZOOM, TABS_SET_ZOOM, } from '../shared/messages'; import * as ipc from './ipc'; @@ -26,6 +27,14 @@ const get = (tabId) => { }); }; +const update = (tabId, properties) => { + return ipc.send({ + type: TABS_UPDATE, + tabId, + properties, + }); +}; + const getZoom = (tabId) => { return ipc.send({ tabId, @@ -41,4 +50,4 @@ const setZoom = (tabId, factor) => { }); }; -export { create, selectAt, get, getZoom, setZoom }; +export { create, selectAt, get, update, getZoom, setZoom }; diff --git a/e2e/ambassador/src/shared/messages.js b/e2e/ambassador/src/shared/messages.js index 34ec5d3..d148ca0 100644 --- a/e2e/ambassador/src/shared/messages.js +++ b/e2e/ambassador/src/shared/messages.js @@ -6,6 +6,7 @@ const WINDOWS_GET = 'windows.get'; const TABS_CREATE = 'tabs.create'; const TABS_SELECT_AT = 'tabs.selectAt'; const TABS_GET = 'tabs.get'; +const TABS_UPDATE = 'tabs.update'; const TABS_GET_ZOOM = 'tabs.get.zoom'; const TABS_SET_ZOOM = 'tabs.set.zoom'; const EVENT_KEYPRESS = 'event.keypress'; @@ -23,6 +24,7 @@ export { WINDOWS_GET, TABS_GET, + TABS_UPDATE, TABS_CREATE, TABS_SELECT_AT, TABS_GET_ZOOM, diff --git a/e2e/contents/tab.test.js b/e2e/contents/tab.test.js index 880deb8..f0b7449 100644 --- a/e2e/contents/tab.test.js +++ b/e2e/contents/tab.test.js @@ -212,4 +212,36 @@ describe("tab test", () => { expect(win.tabs).to.have.lengthOf(1); }); }); + + it('does not delete pinned tab by d', () => { + return Promise.resolve().then(() => { + return tabs.create(targetWindow.id, SERVER_URL + '#1'); + }).then((tab) => { + return tabs.update(tab.id, { pinned: true }); + }).then((tab) => { + return keys.press(tab.id, 'd'); + }).then(() => { + return windows.get(targetWindow.id); + }).then((win) => { + expect(win.tabs).to.have.lengthOf(2); + }); + }); + + it('deletes pinned tab by !d', () => { + let target; + return Promise.resolve().then(() => { + return tabs.create(targetWindow.id, SERVER_URL + '#1'); + }).then((tab) => { + return tabs.update(tab.id, { pinned: true }); + }).then((tab) => { + target = tab; + return keys.press(target.id, '!'); + }).then(() => { + return keys.press(target.id, 'd'); + }).then(() => { + return windows.get(targetWindow.id); + }).then((win) => { + expect(win.tabs).to.have.lengthOf(1); + }); + }); }); |