tor-browser

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

browser_bug349769.js (2256B)


      1 add_task(async function test() {
      2  const uris = [undefined, "about:blank"];
      3 
      4  function checkContentProcess(newBrowser, uri) {
      5    return ContentTask.spawn(newBrowser, [uri], async function (uri) {
      6      var prin = content.document.nodePrincipal;
      7      Assert.notEqual(
      8        prin,
      9        null,
     10        "Loaded principal must not be null when adding " + uri
     11      );
     12      Assert.notEqual(
     13        prin,
     14        undefined,
     15        "Loaded principal must not be undefined when loading " + uri
     16      );
     17 
     18      Assert.equal(
     19        prin.isSystemPrincipal,
     20        false,
     21        "Loaded principal must not be system when loading " + uri
     22      );
     23    });
     24  }
     25 
     26  for (var uri of uris) {
     27    await BrowserTestUtils.withNewTab(
     28      { gBrowser },
     29      async function (newBrowser) {
     30        let loadedPromise = BrowserTestUtils.browserLoaded(newBrowser, {
     31          wantLoad: "about:blank",
     32        });
     33        BrowserTestUtils.startLoadingURIString(newBrowser, uri);
     34 
     35        var prin = newBrowser.contentPrincipal;
     36        isnot(
     37          prin,
     38          null,
     39          "Forced principal must not be null when loading " + uri
     40        );
     41        isnot(
     42          prin,
     43          undefined,
     44          "Forced principal must not be undefined when loading " + uri
     45        );
     46        is(
     47          prin.isSystemPrincipal,
     48          false,
     49          "Forced principal must not be system when loading " + uri
     50        );
     51 
     52        // Belt-and-suspenders e10s check: make sure that the same checks hold
     53        // true in the content process.
     54        await checkContentProcess(newBrowser, uri);
     55 
     56        await loadedPromise;
     57 
     58        prin = newBrowser.contentPrincipal;
     59        isnot(
     60          prin,
     61          null,
     62          "Loaded principal must not be null when adding " + uri
     63        );
     64        isnot(
     65          prin,
     66          undefined,
     67          "Loaded principal must not be undefined when loading " + uri
     68        );
     69        is(
     70          prin.isSystemPrincipal,
     71          false,
     72          "Loaded principal must not be system when loading " + uri
     73        );
     74 
     75        // Belt-and-suspenders e10s check: make sure that the same checks hold
     76        // true in the content process.
     77        await checkContentProcess(newBrowser, uri);
     78      }
     79    );
     80  }
     81 });