diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2018-10-20 16:43:38 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-20 16:43:38 +0900 |
commit | df9094e52066fb85a06d373cb3a82b670d69c88e (patch) | |
tree | e71ff2bb27b0946e79d80d64b5141653c8d69162 /e2e | |
parent | 958b931090e0cc012e36a9361ea6e4cd9be1471d (diff) | |
parent | 7acbdbfef25d04503d4a31dfa1953be29323cc87 (diff) |
Merge pull request #492 from ueokande/qa-0.19
QA 0.19
Diffstat (limited to 'e2e')
-rw-r--r-- | e2e/ambassador/src/background/index.js | 4 | ||||
-rw-r--r-- | e2e/ambassador/src/client/tabs.js | 11 | ||||
-rw-r--r-- | e2e/ambassador/src/shared/messages.js | 2 | ||||
-rw-r--r-- | e2e/contents/mark.test.js | 71 | ||||
-rw-r--r-- | e2e/contents/zoom.test.js | 3 | ||||
-rw-r--r-- | e2e/web-server/index.js | 2 |
6 files changed, 89 insertions, 4 deletions
diff --git a/e2e/ambassador/src/background/index.js b/e2e/ambassador/src/background/index.js index 046b8c1..ce21dc8 100644 --- a/e2e/ambassador/src/background/index.js +++ b/e2e/ambassador/src/background/index.js @@ -1,6 +1,6 @@ import { WINDOWS_CREATE, WINDOWS_REMOVE, WINDOWS_GET, - TABS_CREATE, TABS_SELECT_AT, TABS_GET, TABS_UPDATE, + TABS_CREATE, TABS_SELECT_AT, TABS_GET, TABS_UPDATE, TABS_REMOVE, TABS_GET_ZOOM, TABS_SET_ZOOM, EVENT_KEYPRESS, EVENT_KEYDOWN, EVENT_KEYUP, SCROLL_GET, SCROLL_SET, @@ -30,6 +30,8 @@ receiveContentMessage((message) => { return browser.tabs.get(message.tabId); case TABS_UPDATE: return browser.tabs.update(message.tabId, message.properties); + case TABS_REMOVE: + return browser.tabs.remove(message.tabId); case TABS_GET_ZOOM: return browser.tabs.getZoom(message.tabId); case TABS_SET_ZOOM: diff --git a/e2e/ambassador/src/client/tabs.js b/e2e/ambassador/src/client/tabs.js index 290428c..d0cd578 100644 --- a/e2e/ambassador/src/client/tabs.js +++ b/e2e/ambassador/src/client/tabs.js @@ -1,5 +1,5 @@ import { - TABS_CREATE, TABS_SELECT_AT, TABS_GET, TABS_UPDATE, + TABS_CREATE, TABS_SELECT_AT, TABS_GET, TABS_UPDATE, TABS_REMOVE, TABS_GET_ZOOM, TABS_SET_ZOOM, } from '../shared/messages'; import * as ipc from './ipc'; @@ -35,6 +35,13 @@ const update = (tabId, properties) => { }); }; +const remove = (tabId) => { + return ipc.send({ + type: TABS_REMOVE, + tabId + }); +}; + const getZoom = (tabId) => { return ipc.send({ tabId, @@ -50,4 +57,4 @@ const setZoom = (tabId, factor) => { }); }; -export { create, selectAt, get, update, getZoom, setZoom }; +export { create, selectAt, get, update, remove, getZoom, setZoom }; diff --git a/e2e/ambassador/src/shared/messages.js b/e2e/ambassador/src/shared/messages.js index d148ca0..35c41d7 100644 --- a/e2e/ambassador/src/shared/messages.js +++ b/e2e/ambassador/src/shared/messages.js @@ -7,6 +7,7 @@ const TABS_CREATE = 'tabs.create'; const TABS_SELECT_AT = 'tabs.selectAt'; const TABS_GET = 'tabs.get'; const TABS_UPDATE = 'tabs.update'; +const TABS_REMOVE = 'tabs.remove'; const TABS_GET_ZOOM = 'tabs.get.zoom'; const TABS_SET_ZOOM = 'tabs.set.zoom'; const EVENT_KEYPRESS = 'event.keypress'; @@ -29,6 +30,7 @@ export { TABS_SELECT_AT, TABS_GET_ZOOM, TABS_SET_ZOOM, + TABS_REMOVE, EVENT_KEYPRESS, EVENT_KEYDOWN, diff --git a/e2e/contents/mark.test.js b/e2e/contents/mark.test.js new file mode 100644 index 0000000..85566bd --- /dev/null +++ b/e2e/contents/mark.test.js @@ -0,0 +1,71 @@ +import * as windows from "../ambassador/src/client/windows"; +import * as tabs from "../ambassador/src/client/tabs"; +import * as keys from "../ambassador/src/client/keys"; +import * as scrolls from "../ambassador/src/client/scrolls"; +import { CLIENT_URL } from '../web-server/url'; + +describe("mark test", () => { + let targetWindow; + + before(async () => { + targetWindow = await windows.create(); + }); + + after(async () => { + await windows.remove(targetWindow.id); + }); + + it('set a local mark and jump to it', async () => { + let tab = await tabs.create(targetWindow.id, CLIENT_URL + '/mark#local'); + await scrolls.set(tab.id, 100, 100); + await keys.press(tab.id, 'm'); + await keys.press(tab.id, 'a'); + + await scrolls.set(tab.id, 200, 200); + await keys.press(tab.id, "'"); + await keys.press(tab.id, 'a'); + + let scroll = await scrolls.get(tab.id); + expect(scroll.x).to.be.equals(100); + expect(scroll.y).to.be.equals(100); + }); + + it('set a global mark and jump to it', async () => { + let tab1 = await tabs.create(targetWindow.id, CLIENT_URL + '/mark#global1'); + await scrolls.set(tab1.id, 100, 100); + await keys.press(tab1.id, 'm'); + await keys.press(tab1.id, 'A'); + await new Promise(resolve => { setTimeout(() => resolve(), 100) }); + await scrolls.set(tab1.id, 200, 200); + + let tab2 = await tabs.create(targetWindow.id, CLIENT_URL + '/mark#global2'); + await keys.press(tab2.id, "'"); + await keys.press(tab2.id, 'A'); + await new Promise(resolve => { setTimeout(() => resolve(), 100) }); + + tab1 = await tabs.get(tab1.id); + expect(tab1.active).to.be.true; + let scroll = await scrolls.get(tab1.id); + expect(scroll.x).to.be.equals(100); + expect(scroll.y).to.be.equals(100); + }); + + it('set a global mark and creates new tab from gone', async () => { + let tab1 = await tabs.create(targetWindow.id, CLIENT_URL + '/mark#gone'); + await scrolls.set(tab1.id, 100, 100); + await keys.press(tab1.id, 'm'); + await keys.press(tab1.id, 'A'); + await tabs.remove(tab1.id); + await new Promise(resolve => { setTimeout(() => resolve(), 100) }); + + let tab2 = await tabs.create(targetWindow.id, CLIENT_URL + '/mark#newtab'); + await keys.press(tab2.id, "'"); + await keys.press(tab2.id, 'A'); + await new Promise(resolve => { setTimeout(() => resolve(), 100) }); + + let win = await windows.get(targetWindow.id); + let found = win.tabs.find(tab => tab.url === CLIENT_URL + '/mark#gone') + expect(found).to.be.an('object'); + expect(found.id).to.not.equal(tab1.id); + }); +}); diff --git a/e2e/contents/zoom.test.js b/e2e/contents/zoom.test.js index 2d90e28..74d4f56 100644 --- a/e2e/contents/zoom.test.js +++ b/e2e/contents/zoom.test.js @@ -23,6 +23,7 @@ describe("zoom test", () => { let before = await tabs.getZoom(targetTab.id); await keys.press(targetTab.id, 'z'); await keys.press(targetTab.id, 'i'); + await new Promise(resolve => setTimeout(resolve, 100)); let actual = await tabs.getZoom(targetTab.id); expect(actual).to.be.greaterThan(before); @@ -32,6 +33,7 @@ describe("zoom test", () => { let before = await tabs.getZoom(targetTab.id); await keys.press(targetTab.id, 'z'); await keys.press(targetTab.id, 'o'); + await new Promise(resolve => setTimeout(resolve, 100)); let actual = await tabs.getZoom(targetTab.id); expect(actual).to.be.lessThan(before); @@ -42,6 +44,7 @@ describe("zoom test", () => { let before = await tabs.getZoom(targetTab.id); await keys.press(targetTab.id, 'z'); await keys.press(targetTab.id, 'z'); + await new Promise(resolve => setTimeout(resolve, 100)); let actual = await tabs.getZoom(targetTab.id); expect(actual).to.be.lessThan(before); diff --git a/e2e/web-server/index.js b/e2e/web-server/index.js index bf60078..376e118 100644 --- a/e2e/web-server/index.js +++ b/e2e/web-server/index.js @@ -72,7 +72,7 @@ http.createServer(function (req, res) { } let u = url.parse(req.url); - if (u.pathname === '/scroll') { + if (u.pathname === '/scroll' || u.pathname === '/mark') { handleScroll(req, res); } else if (u.pathname === '/a-pagenation') { handleAPagenation(req, res); |