diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2021-09-23 23:23:55 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2021-09-25 15:53:36 +0900 |
commit | b72728bdabf140c77f165b35813595dcaa060eea (patch) | |
tree | 774dc608f28101ac4a0ecce02e458e421b94dcdc /src/content/Application.ts | |
parent | 01242a2f0d174b4bf8b51fd5627edced465757e9 (diff) |
Create find targets by port connections
Diffstat (limited to 'src/content/Application.ts')
-rw-r--r-- | src/content/Application.ts | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/content/Application.ts b/src/content/Application.ts index a12c3c6..6b881fe 100644 --- a/src/content/Application.ts +++ b/src/content/Application.ts @@ -41,7 +41,21 @@ export default class Application { if (window.self === window.top) { this.routeMasterComponents(); } - return this.routeCommonComponents(); + this.routeCommonComponents(); + // Make sure the background script sends a message to the content script by + // establishing a connection. If the background script tries to send a + // message to a frame on which cannot run the content script, it fails with + // a message "Could not establish connection." + // + // The port is never used, and the messages are delivered via + // `browser.tabs.sendMessage` API because sending a message via port cannot + // receive returned value. + // + // /* on background script */ + // port.sendMessage({ type: "do something" }); <- returns void + // + browser.runtime.connect(undefined, { name: "vimvixen-find" }); + return Promise.resolve(); } private routeMasterComponents() { |