tor-browser

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

browser_test_xfo_embed_object.js (1500B)


      1 "use strict";
      2 
      3 const kTestPath = getRootDirectory(gTestPath).replace(
      4  "chrome://mochitests/content",
      5  "https://example.com"
      6 );
      7 const kTestXFOEmbedURI = kTestPath + "file_framing_xfo_embed.html";
      8 const kTestXFOObjectURI = kTestPath + "file_framing_xfo_object.html";
      9 
     10 const errorMessage = `The loading of “https://example.com/browser/dom/security/test/general/file_framing_xfo_embed_object.sjs” in a frame is denied by “X-Frame-Options“ directive set to “deny“`;
     11 
     12 let xfoBlocked = false;
     13 
     14 function onXFOMessage(msgObj) {
     15  const message = msgObj.message;
     16 
     17  if (message.includes(errorMessage)) {
     18    ok(true, "XFO error message logged");
     19    xfoBlocked = true;
     20  }
     21 }
     22 
     23 add_task(async function open_test_xfo_embed_blocked() {
     24  xfoBlocked = false;
     25  await BrowserTestUtils.withNewTab("about:blank", async function (browser) {
     26    Services.console.registerListener(onXFOMessage);
     27    BrowserTestUtils.startLoadingURIString(browser, kTestXFOEmbedURI);
     28    await BrowserTestUtils.waitForCondition(() => xfoBlocked);
     29    Services.console.unregisterListener(onXFOMessage);
     30  });
     31 });
     32 
     33 add_task(async function open_test_xfo_object_blocked() {
     34  xfoBlocked = false;
     35  await BrowserTestUtils.withNewTab("about:blank", async function (browser) {
     36    Services.console.registerListener(onXFOMessage);
     37    BrowserTestUtils.startLoadingURIString(browser, kTestXFOObjectURI);
     38    await BrowserTestUtils.waitForCondition(() => xfoBlocked);
     39    Services.console.unregisterListener(onXFOMessage);
     40  });
     41 });