tor-browser

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

test_ext_tabs_reload.html (1695B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <meta charset="utf-8">
      5  <title>Tabs reload Test</title>
      6  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
      7  <script type="text/javascript" src="/tests/SimpleTest/ExtensionTestUtils.js"></script>
      8  <script type="text/javascript" src="head.js"></script>
      9  <link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
     10 </head>
     11 <body>
     12 
     13 <script type="text/javascript">
     14 "use strict";
     15 
     16 add_task(async function() {
     17  const extension = ExtensionTestUtils.loadExtension({
     18    files: {
     19      "tab.js": function() {
     20        browser.runtime.sendMessage("tab-loaded");
     21      },
     22      "tab.html":
     23        `<head>
     24          <meta charset="utf-8">
     25          <script src="tab.js"><\/script>
     26        </head>`,
     27    },
     28 
     29    async background() {
     30      let tabLoadedCount = 0;
     31      // eslint-disable-next-line prefer-const
     32      let tab;
     33 
     34      browser.runtime.onMessage.addListener(msg => {
     35        if (msg == "tab-loaded") {
     36          tabLoadedCount++;
     37 
     38          if (tabLoadedCount == 1) {
     39            // Reload the tab once passing no arguments.
     40            return browser.tabs.reload();
     41          }
     42 
     43          if (tabLoadedCount == 2) {
     44            // Reload the tab again with explicit arguments.
     45            return browser.tabs.reload(tab.id, {
     46              bypassCache: false,
     47            });
     48          }
     49 
     50          if (tabLoadedCount == 3) {
     51            browser.test.notifyPass("tabs.reload");
     52          }
     53        }
     54      });
     55      tab = await browser.tabs.create({url: "tab.html", active: true});
     56    },
     57  });
     58 
     59  await extension.startup();
     60  await extension.awaitFinish("tabs.reload");
     61  await extension.unload();
     62 });
     63 </script>
     64 
     65 </body>
     66 </html>