tor-browser

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

browser_bug388121-2.js (1747B)


      1 function test() {
      2  waitForExplicitFinish();
      3 
      4  var w;
      5  var iteration = 1;
      6  const uris = ["", "about:blank"];
      7  var uri;
      8  var origWgp;
      9 
     10  function testLoad() {
     11    let wgp = w.gBrowser.selectedBrowser.browsingContext.currentWindowGlobal;
     12    var prin = wgp.documentPrincipal;
     13    isnot(prin, null, "Loaded principal must not be null when adding " + uri);
     14    isnot(
     15      prin,
     16      undefined,
     17      "Loaded principal must not be undefined when loading " + uri
     18    );
     19    is(
     20      prin.isSystemPrincipal,
     21      false,
     22      "Loaded principal must not be system when loading " + uri
     23    );
     24    w.close();
     25 
     26    if (iteration == uris.length) {
     27      finish();
     28    } else {
     29      ++iteration;
     30      doTest();
     31    }
     32  }
     33 
     34  function doTest() {
     35    uri = uris[iteration - 1];
     36    window.open(uri, "_blank", "width=10,height=10,noopener");
     37    w = Services.wm.getMostRecentWindow("navigator:browser");
     38    origWgp = w.gBrowser.selectedBrowser.browsingContext.currentWindowGlobal;
     39    var prin = origWgp.documentPrincipal;
     40    if (!uri) {
     41      uri = undefined;
     42    }
     43    isnot(prin, null, "Forced principal must not be null when loading " + uri);
     44    isnot(
     45      prin,
     46      undefined,
     47      "Forced principal must not be undefined when loading " + uri
     48    );
     49    is(
     50      prin.isSystemPrincipal,
     51      false,
     52      "Forced principal must not be system when loading " + uri
     53    );
     54    if (uri == undefined) {
     55      // No actual load here, so just move along.
     56      w.close();
     57      ++iteration;
     58      doTest();
     59    } else {
     60      // Need to poll, because load listeners on the content window won't
     61      // survive the load.
     62      // eslint-disable-next-line mozilla/no-arbitrary-setTimeout
     63      setTimeout(testLoad, 10);
     64    }
     65  }
     66 
     67  doTest();
     68 }