tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test-popup-messaging.js (586B)


      1 browser.runtime.sendNativeMessage("badNativeApi", "errorerrorerror");
      2 
      3 async function runTest() {
      4  const response = await browser.runtime.sendNativeMessage(
      5    "browser",
      6    "testPopupMessage"
      7  );
      8 
      9  browser.runtime.sendNativeMessage("browser", `response: ${response}`);
     10 
     11  const port = browser.runtime.connectNative("browser");
     12  port.onMessage.addListener(response => {
     13    if (response.action === "disconnect") {
     14      port.disconnect();
     15      return;
     16    }
     17 
     18    port.postMessage(`response: ${response.message}`);
     19  });
     20 
     21  port.postMessage("testPopupPortMessage");
     22 }
     23 
     24 runTest();