aboutsummaryrefslogtreecommitdiff
path: root/e2e/ambassador
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2019-04-06 13:43:04 +0000
committerGitHub <noreply@github.com>2019-04-06 13:43:04 +0000
commit859d0372b5bb7297a0b8ed37a559d88a425f3799 (patch)
tree293adc0e1963b4ded2760107aa69d1f793751114 /e2e/ambassador
parentd37e0b92d39fe2f721bfe3330395043eb55861f3 (diff)
parentb604a942a84d7c5d54029b48ae698d15ffe4f5ac (diff)
Merge pull request #559 from ueokande/lanthan-integration-test
Replace E2E tests with lanthan
Diffstat (limited to 'e2e/ambassador')
-rw-r--r--e2e/ambassador/manifest.json28
-rw-r--r--e2e/ambassador/src/background/index.js49
-rw-r--r--e2e/ambassador/src/background/ipc.js7
-rw-r--r--e2e/ambassador/src/background/tabs.js28
-rw-r--r--e2e/ambassador/src/client/ipc.js29
-rw-r--r--e2e/ambassador/src/client/keys.js28
-rw-r--r--e2e/ambassador/src/client/scrolls.js20
-rw-r--r--e2e/ambassador/src/client/tabs.js60
-rw-r--r--e2e/ambassador/src/client/windows.js27
-rw-r--r--e2e/ambassador/src/content/events.js31
-rw-r--r--e2e/ambassador/src/content/index.js30
-rw-r--r--e2e/ambassador/src/content/ipc.js40
-rw-r--r--e2e/ambassador/src/content/scrolls.js20
-rw-r--r--e2e/ambassador/src/shared/messages.js40
-rw-r--r--e2e/ambassador/webpack.config.js24
15 files changed, 0 insertions, 461 deletions
diff --git a/e2e/ambassador/manifest.json b/e2e/ambassador/manifest.json
deleted file mode 100644
index d2253f6..0000000
--- a/e2e/ambassador/manifest.json
+++ /dev/null
@@ -1,28 +0,0 @@
-{
- "manifest_version": 2,
- "name": "ambassador",
- "description": "WebExtension test helper",
- "version": "0.1",
- "content_scripts": [
- {
- "all_frames": true,
- "matches": [ "<all_urls>" ],
- "js": [ "build/content.js" ],
- "run_at": "document_start",
- "match_about_blank": true
- }
- ],
- "background": {
- "scripts": [
- "build/background.js"
- ]
- },
- "permissions": [
- "history",
- "sessions",
- "storage",
- "tabs",
- "clipboardRead",
- "activeTab"
- ]
-}
diff --git a/e2e/ambassador/src/background/index.js b/e2e/ambassador/src/background/index.js
deleted file mode 100644
index ce21dc8..0000000
--- a/e2e/ambassador/src/background/index.js
+++ /dev/null
@@ -1,49 +0,0 @@
-import {
- WINDOWS_CREATE, WINDOWS_REMOVE, WINDOWS_GET,
- 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,
-} from '../shared/messages';
-import * as tabs from './tabs';
-import { receiveContentMessage } from './ipc';
-
-receiveContentMessage((message) => {
- switch (message.type) {
- case WINDOWS_CREATE:
- return browser.windows.create({ url: message.url });
- case WINDOWS_REMOVE:
- return browser.windows.remove(message.windowId);
- case WINDOWS_GET:
- return browser.windows.get(message.windowId, { populate: true });
- case TABS_CREATE:
- return tabs.create({
- url: message.url,
- windowId: message.windowId,
- });
- case TABS_SELECT_AT:
- return tabs.selectAt({
- windowId: message.windowId,
- index: message.index,
- });
- case TABS_GET:
- 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:
- return browser.tabs.setZoom(message.tabId, message.factor);
- case EVENT_KEYPRESS:
- case EVENT_KEYDOWN:
- case EVENT_KEYUP:
- case SCROLL_GET:
- case SCROLL_SET:
- return browser.tabs.sendMessage(
- message.tabId,
- message
- );
- }
-});
diff --git a/e2e/ambassador/src/background/ipc.js b/e2e/ambassador/src/background/ipc.js
deleted file mode 100644
index 95d2164..0000000
--- a/e2e/ambassador/src/background/ipc.js
+++ /dev/null
@@ -1,7 +0,0 @@
-const receiveContentMessage = (func) => {
- browser.runtime.onMessage.addListener((message) => {
- return func(message);
- });
-};
-
-export { receiveContentMessage };
diff --git a/e2e/ambassador/src/background/tabs.js b/e2e/ambassador/src/background/tabs.js
deleted file mode 100644
index 5594134..0000000
--- a/e2e/ambassador/src/background/tabs.js
+++ /dev/null
@@ -1,28 +0,0 @@
-const create = (props = {}) => {
- return new Promise((resolve) => {
- browser.tabs.create(props).then((createdTab) => {
- let callback = (tabId, changeInfo, tab) => {
- if (tab.url !== 'about:blank' && tabId === createdTab.id &&
- changeInfo.status === 'complete') {
- browser.tabs.onUpdated.removeListener(callback);
-
- // wait for 50 milliseconds to ensure plugin loaded;
- setTimeout(() => resolve(tab), 50);
- }
- };
- browser.tabs.onUpdated.addListener(callback);
- });
- });
-};
-
-const selectAt = (props = {}) => {
- return browser.tabs.query({ windowId: props.windowId }).then((tabs) => {
- let target = tabs[props.index];
- return browser.tabs.update(target.id, { active: true });
- });
-};
-
-
-export {
- create, selectAt
-};
diff --git a/e2e/ambassador/src/client/ipc.js b/e2e/ambassador/src/client/ipc.js
deleted file mode 100644
index 9f232ea..0000000
--- a/e2e/ambassador/src/client/ipc.js
+++ /dev/null
@@ -1,29 +0,0 @@
-import { METHOD_REQUEST, METHOD_RESPONSE } from '../shared/messages';
-
-const generateId = () => {
- return Math.random().toString();
-};
-
-const send = (message) => {
- return new Promise((resolve) => {
- let id = generateId();
- let callback = (e) => {
- let packet = e.data;
- if (e.source !== window || packet.method !== METHOD_RESPONSE ||
- packet.id !== id) {
- return;
- }
- window.removeEventListener('message', callback);
- resolve(packet.message);
- };
- window.addEventListener('message', callback);
-
- window.postMessage({
- id,
- method: METHOD_REQUEST,
- message
- }, window.origin);
- });
-};
-
-export { send };
diff --git a/e2e/ambassador/src/client/keys.js b/e2e/ambassador/src/client/keys.js
deleted file mode 100644
index 6b36c23..0000000
--- a/e2e/ambassador/src/client/keys.js
+++ /dev/null
@@ -1,28 +0,0 @@
-import { EVENT_KEYPRESS, EVENT_KEYDOWN, EVENT_KEYUP } from '../shared/messages';
-import * as ipc from './ipc';
-
-const NEUTRAL_MODIFIERS = { shiftKey: false, altKey: false, ctrlKey: false };
-
-const press = (tabId, key, modifiers = NEUTRAL_MODIFIERS) => {
- return ipc.send({ ...modifiers,
- type: EVENT_KEYPRESS,
- tabId,
- key, });
-};
-
-const down = (tabId, key, modifiers = NEUTRAL_MODIFIERS) => {
- return ipc.send({ modifiers,
- type: EVENT_KEYDOWN,
- tabId,
- key, });
-};
-
-
-const up = (tabId, key, modifiers = NEUTRAL_MODIFIERS) => {
- return ipc.send({ modifiers,
- type: EVENT_KEYUP,
- tabId,
- key, });
-};
-
-export { press, down, up };
diff --git a/e2e/ambassador/src/client/scrolls.js b/e2e/ambassador/src/client/scrolls.js
deleted file mode 100644
index f8f82e9..0000000
--- a/e2e/ambassador/src/client/scrolls.js
+++ /dev/null
@@ -1,20 +0,0 @@
-import { SCROLL_GET, SCROLL_SET } from '../shared/messages';
-import * as ipc from './ipc';
-
-const get = (tabId) => {
- return ipc.send({
- type: SCROLL_GET,
- tabId,
- });
-};
-
-const set = (tabId, x, y) => {
- return ipc.send({
- type: SCROLL_SET,
- tabId,
- x,
- y,
- });
-};
-
-export { get, set };
diff --git a/e2e/ambassador/src/client/tabs.js b/e2e/ambassador/src/client/tabs.js
deleted file mode 100644
index d0cd578..0000000
--- a/e2e/ambassador/src/client/tabs.js
+++ /dev/null
@@ -1,60 +0,0 @@
-import {
- 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';
-
-const create = (windowId, url) => {
- return ipc.send({
- type: TABS_CREATE,
- windowId,
- url,
- });
-};
-
-const selectAt = (windowId, index) => {
- return ipc.send({
- type: TABS_SELECT_AT,
- windowId,
- index,
- });
-};
-
-const get = (tabId) => {
- return ipc.send({
- type: TABS_GET,
- tabId,
- });
-};
-
-const update = (tabId, properties) => {
- return ipc.send({
- type: TABS_UPDATE,
- tabId,
- properties,
- });
-};
-
-const remove = (tabId) => {
- return ipc.send({
- type: TABS_REMOVE,
- tabId
- });
-};
-
-const getZoom = (tabId) => {
- return ipc.send({
- tabId,
- type: TABS_GET_ZOOM,
- });
-};
-
-const setZoom = (tabId, factor) => {
- return ipc.send({
- type: TABS_SET_ZOOM,
- tabId,
- factor,
- });
-};
-
-export { create, selectAt, get, update, remove, getZoom, setZoom };
diff --git a/e2e/ambassador/src/client/windows.js b/e2e/ambassador/src/client/windows.js
deleted file mode 100644
index f92405a..0000000
--- a/e2e/ambassador/src/client/windows.js
+++ /dev/null
@@ -1,27 +0,0 @@
-import {
- WINDOWS_CREATE, WINDOWS_REMOVE, WINDOWS_GET
-} from '../shared/messages';
-import * as ipc from './ipc';
-
-const create = (url) => {
- return ipc.send({
- type: WINDOWS_CREATE,
- url,
- });
-};
-
-const remove = (windowId) => {
- return ipc.send({
- type: WINDOWS_REMOVE,
- windowId,
- });
-};
-
-const get = (windowId) => {
- return ipc.send({
- type: WINDOWS_GET,
- windowId,
- });
-};
-
-export { create, remove, get };
diff --git a/e2e/ambassador/src/content/events.js b/e2e/ambassador/src/content/events.js
deleted file mode 100644
index 1e45909..0000000
--- a/e2e/ambassador/src/content/events.js
+++ /dev/null
@@ -1,31 +0,0 @@
-const keypress = (opts) => {
- let event = new KeyboardEvent('keypress', {
- key: opts.key,
- altKey: opts.altKey,
- shiftKey: opts.shiftKey,
- ctrlKey: opts.ctrlKey
- });
- document.body.dispatchEvent(event);
-};
-
-const keydown = (opts) => {
- let event = new KeyboardEvent('keydown', {
- key: opts.key,
- altKey: opts.altKey,
- shiftKey: opts.shiftKey,
- ctrlKey: opts.ctrlKey
- });
- document.body.dispatchEvent(event);
-};
-
-const keyup = (opts) => {
- let event = new KeyboardEvent('keyup', {
- key: opts.key,
- altKey: opts.altKey,
- shiftKey: opts.shiftKey,
- ctrlKey: opts.ctrlKey
- });
- document.body.dispatchEvent(event);
-};
-
-export { keypress, keydown, keyup };
diff --git a/e2e/ambassador/src/content/index.js b/e2e/ambassador/src/content/index.js
deleted file mode 100644
index fd19136..0000000
--- a/e2e/ambassador/src/content/index.js
+++ /dev/null
@@ -1,30 +0,0 @@
-import {
- EVENT_KEYPRESS, EVENT_KEYDOWN, EVENT_KEYUP,
- SCROLL_GET, SCROLL_SET,
-} from '../shared/messages';
-import * as ipc from './ipc';
-import * as events from './events';
-import * as scrolls from './scrolls';
-
-ipc.receivePageMessage((message) => {
- return ipc.sendToBackground(message);
-});
-
-ipc.receiveBackgroundMesssage((message) => {
- switch (message.type) {
- case EVENT_KEYPRESS:
- events.keypress(message);
- break;
- case EVENT_KEYDOWN:
- events.keydown(message);
- break;
- case EVENT_KEYUP:
- events.keyup(message);
- break;
- case SCROLL_GET:
- return Promise.resolve(scrolls.get());
- case SCROLL_SET:
- return Promise.resolve(scrolls.set(message.x, message.y));
- }
- return Promise.resolve({});
-});
diff --git a/e2e/ambassador/src/content/ipc.js b/e2e/ambassador/src/content/ipc.js
deleted file mode 100644
index 917623c..0000000
--- a/e2e/ambassador/src/content/ipc.js
+++ /dev/null
@@ -1,40 +0,0 @@
-import { METHOD_REQUEST, METHOD_RESPONSE } from '../shared/messages';
-
-const sendToBackground = (message) => {
- return browser.runtime.sendMessage(message);
-};
-
-const receiveBackgroundMesssage = (func) => {
- return browser.runtime.onMessage.addListener((message) => {
- return Promise.resolve(func(message));
- });
-};
-
-const receivePageMessage = (func) => {
- window.addEventListener('message', (e) => {
- let packet = e.data;
- if (e.origin !== window.origin || packet.method !== METHOD_REQUEST) {
- return;
- }
-
- let resp = {
- id: packet.id,
- method: METHOD_RESPONSE,
- };
- let respMessage = func(packet.message);
- if (respMessage instanceof Promise) {
- return respMessage.then((data) => {
- resp.message = data;
- e.source.postMessage(resp, e.origin);
- });
- } else if (respMessage) {
- resp.message = respMessage;
- }
- e.source.postMessage(resp, e.origin);
- });
-};
-
-export {
- sendToBackground, receiveBackgroundMesssage,
- receivePageMessage,
-};
diff --git a/e2e/ambassador/src/content/scrolls.js b/e2e/ambassador/src/content/scrolls.js
deleted file mode 100644
index 4227cf7..0000000
--- a/e2e/ambassador/src/content/scrolls.js
+++ /dev/null
@@ -1,20 +0,0 @@
-const get = () => {
- let element = document.documentElement;
- return {
- xMax: element.scrollWidth - element.clientWidth,
- yMax: element.scrollHeight - element.clientHeight,
- x: element.scrollLeft,
- y: element.scrollTop,
- frameWidth: element.clientWidth,
- frameHeight: element.clientHeight,
- };
-};
-
-const set = (x, y) => {
- let element = document.documentElement;
- element.scrollLeft = x;
- element.scrollTop = y;
- return get();
-};
-
-export { get, set };
diff --git a/e2e/ambassador/src/shared/messages.js b/e2e/ambassador/src/shared/messages.js
deleted file mode 100644
index 35c41d7..0000000
--- a/e2e/ambassador/src/shared/messages.js
+++ /dev/null
@@ -1,40 +0,0 @@
-const METHOD_REQUEST = 'request';
-const METHOD_RESPONSE = 'response';
-const WINDOWS_CREATE = 'windows.create';
-const WINDOWS_REMOVE = 'windows.remove';
-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_REMOVE = 'tabs.remove';
-const TABS_GET_ZOOM = 'tabs.get.zoom';
-const TABS_SET_ZOOM = 'tabs.set.zoom';
-const EVENT_KEYPRESS = 'event.keypress';
-const EVENT_KEYDOWN = 'event.keydown';
-const EVENT_KEYUP = 'event.keyup';
-const SCROLL_GET = 'scroll.get';
-const SCROLL_SET = 'scroll.set';
-
-export {
- METHOD_REQUEST,
- METHOD_RESPONSE,
-
- WINDOWS_CREATE,
- WINDOWS_REMOVE,
- WINDOWS_GET,
-
- TABS_GET,
- TABS_UPDATE,
- TABS_CREATE,
- TABS_SELECT_AT,
- TABS_GET_ZOOM,
- TABS_SET_ZOOM,
- TABS_REMOVE,
-
- EVENT_KEYPRESS,
- EVENT_KEYDOWN,
- EVENT_KEYUP,
- SCROLL_GET,
- SCROLL_SET,
-};
diff --git a/e2e/ambassador/webpack.config.js b/e2e/ambassador/webpack.config.js
deleted file mode 100644
index d292317..0000000
--- a/e2e/ambassador/webpack.config.js
+++ /dev/null
@@ -1,24 +0,0 @@
-const path = require('path');
-
-const src = path.resolve(__dirname, 'src');
-const dist = path.resolve(__dirname, 'build');
-
-config = {
- entry: {
- content: path.join(src, 'content'),
- background: path.join(src, 'background')
- },
-
- output: {
- path: dist,
- filename: '[name].js'
- },
-
- resolve: {
- extensions: [ '.js' ],
- modules: [path.join(__dirname, 'src'), 'node_modules']
- }
-};
-
-module.exports = config
-