aboutsummaryrefslogtreecommitdiff
path: root/e2e/ambassador/src/content
diff options
context:
space:
mode:
Diffstat (limited to 'e2e/ambassador/src/content')
-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
4 files changed, 0 insertions, 121 deletions
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 };