1
2
3
4
5
6
7
8
9
10
11
12
|
// Background
"use strict";
let xGCEWorker = new Worker("gce_worker.js");
function handleMessage (oRequest, xSender, sendResponse) {
console.log(`[background] received: ${oRequest.content}`);
sendResponse({response: "response from background script"});
}
browser.runtime.onMessage.addListener(handleMessage);
|
>
>
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
// Background
"use strict";
let xGCEWorker = new Worker("gce_worker.js");
xGCEWorker.postMessage(["init", browser.extension.getURL(".")]);
function handleMessage (oRequest, xSender, sendResponse) {
console.log(`[background] received: ${oRequest.content}`);
sendResponse({response: "response from background script"});
}
browser.runtime.onMessage.addListener(handleMessage);
|