DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (192e0e33eb59)

VCS Links

Line Code
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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
<!DOCTYPE HTML>
<html>
<head>
  <title>WebNavigation onCommitted Test</title>
  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <script type="text/javascript" src="/tests/SimpleTest/ExtensionTestUtils.js"></script>
  <script type="text/javascript" src="head.js"></script>
  <link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
</head>
<body>

<script type="text/javascript">
"use strict";

add_task(async function() {
  let extension = ExtensionTestUtils.loadExtension({
    manifest: {
      permissions: ["webNavigation", "tabs"],
      applications: {
        gecko: {
          id: "test_ext_webNavigation_onCommitted@tests.mozilla.org",
        },
      },
    },
    useAddonManager: "permanent",
    async background() {
      const url = "http://mochi.test:8888/";
      const [tab, tabDetails] = await Promise.all([
        browser.tabs.create({url}),
        new Promise(resolve => {
          browser.webNavigation.onCommitted.addListener(details => {
            if (details.url === "about:blank") {
              // skip initial about:blank
              return;
            }
            resolve(details);
          });
        }),
      ]);

      browser.test.assertEq(url, tabDetails.url, "webNavigation.onCommitted detects correct url");
      browser.test.assertEq(tab.id, tabDetails.tabId, "webNavigation.onCommitted fire for proper tabId");
      await browser.tabs.remove(tab.id);
      browser.test.notifyPass("webNavigation.onCommitted");
    },
  });

  await extension.startup();
  await extension.awaitFinish("webNavigation.onCommitted");
  await extension.unload();
});
</script>

</body>
</html>