tor-browser

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

browser_test_assert_systemprincipal_documents.js (1251B)


      1 //"use strict"
      2 
      3 const kTestPath = getRootDirectory(gTestPath);
      4 const kTestURI = kTestPath + "file_assert_systemprincipal_documents.html";
      5 
      6 add_setup(async function () {
      7  // We expect the assertion in function
      8  // CheckSystemPrincipalLoads as defined in
      9  // file dom/security/nsContentSecurityManager.cpp
     10  SimpleTest.expectAssertions(1);
     11 
     12  await SpecialPowers.pushPrefEnv({
     13    set: [
     14      ["security.disallow_non_local_systemprincipal_in_tests", true],
     15      ["security.allow_unsafe_parent_loads", true],
     16    ],
     17  });
     18 });
     19 
     20 add_task(async function open_test_iframe_in_tab() {
     21  // This looks at the iframe (load type SUBDOCUMENT)
     22  await BrowserTestUtils.withNewTab(
     23    { gBrowser, url: kTestURI },
     24    async browser => {
     25      await SpecialPowers.spawn(browser, [], async function () {
     26        let outerPrincipal = content.document.nodePrincipal;
     27        ok(
     28          outerPrincipal.isSystemPrincipal,
     29          "Sanity: Using SystemPrincipal for test file on chrome://"
     30        );
     31        const iframeDoc =
     32          content.document.getElementById("testframe").contentDocument;
     33        is(
     34          iframeDoc.body.innerHTML,
     35          "",
     36          "iframe with systemprincipal should be empty document"
     37        );
     38      });
     39    }
     40  );
     41 });