summaryrefslogtreecommitdiffstats
path: root/mobile/android/geckoview/src/androidTest/assets/web_extensions/actions/test-popup-messaging.js
blob: 479f957564e7e9257aa08abc62effac49d527eec (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
browser.runtime.sendNativeMessage("badNativeApi", "errorerrorerror");

async function runTest() {
  const response = await browser.runtime.sendNativeMessage(
    "browser",
    "testPopupMessage"
  );

  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.postMessage("testPopupPortMessage");
}

runTest();