blob: 20deb53ae7b4b06103b1aad0dfd2e470182be6e2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
browser.runtime.sendNativeMessage("badNativeApi", "errorerrorerror");
async function runTest() {
const response = await browser.runtime.sendNativeMessage(
"browser",
"testBackgroundBrowserMessage"
);
browser.runtime.sendNativeMessage("browser", `response: ${response}`);
const port = browser.runtime.connectNative("browser");
port.onMessage.addListener(response => {
if (response.action === "disconnect") {
port.disconnect();
return;
}
port.postMessage(`response: ${response.message}`);
});
port.onDisconnect.addListener(() =>
browser.runtime.sendNativeMessage("browser", { type: "portDisconnected" })
);
port.postMessage("testBackgroundPortMessage");
}
runTest();
|