diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2018-02-11 15:40:34 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2018-02-12 22:04:55 +0900 |
commit | 3f8bbe11d96b751affa9e2bf0a1995008f9e3220 (patch) | |
tree | 70a6f389331ca93bf51b4a5e46a1833817a4bfcf /e2e/ambassador/src/content/ipc.js | |
parent | cf03d278eb8bb8f7544ae6395b76e1a1e0781053 (diff) |
send press key to tabs
Diffstat (limited to 'e2e/ambassador/src/content/ipc.js')
-rw-r--r-- | e2e/ambassador/src/content/ipc.js | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/e2e/ambassador/src/content/ipc.js b/e2e/ambassador/src/content/ipc.js index 62fcac1..917623c 100644 --- a/e2e/ambassador/src/content/ipc.js +++ b/e2e/ambassador/src/content/ipc.js @@ -1,9 +1,15 @@ import { METHOD_REQUEST, METHOD_RESPONSE } from '../shared/messages'; -const send = (message) => { +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; @@ -28,4 +34,7 @@ const receivePageMessage = (func) => { }); }; -export { send, receivePageMessage }; +export { + sendToBackground, receiveBackgroundMesssage, + receivePageMessage, +}; |