tor-browser

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

browser_bug1629307.js (2214B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 "use strict";
      6 
      7 // Load a web page containing an iframe that requires authentication but includes the X-Frame-Options: SAMEORIGIN header.
      8 // Make sure that we don't needlessly show an authentication prompt for it.
      9 
     10 const { PromptTestUtils } = ChromeUtils.importESModule(
     11  "resource://testing-common/PromptTestUtils.sys.mjs"
     12 );
     13 
     14 add_task(async function () {
     15  SpecialPowers.pushPrefEnv({
     16    set: [["network.auth.supress_auth_prompt_for_XFO_failures", true]],
     17  });
     18 
     19  let URL =
     20    "https://example.com/browser/netwerk/test/browser/test_1629307.html";
     21 
     22  let hasPrompt = false;
     23 
     24  PromptTestUtils.handleNextPrompt(
     25    window,
     26    {
     27      modalType: Ci.nsIPrompt.MODAL_TYPE_TAB,
     28      promptType: "promptUserAndPass",
     29    },
     30    { buttonNumClick: 1 }
     31  )
     32    .then(function () {
     33      hasPrompt = true;
     34    })
     35    .catch(function () {});
     36 
     37  BrowserTestUtils.startLoadingURIString(gBrowser.selectedBrowser, URL);
     38 
     39  // wait until the page and its iframe page is loaded
     40  await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser, true, URL);
     41 
     42  Assert.equal(
     43    hasPrompt,
     44    false,
     45    "no prompt when loading page via iframe with x-auth options"
     46  );
     47 });
     48 
     49 add_task(async function () {
     50  SpecialPowers.pushPrefEnv({
     51    set: [["network.auth.supress_auth_prompt_for_XFO_failures", false]],
     52  });
     53 
     54  let URL =
     55    "https://example.com/browser/netwerk/test/browser/test_1629307.html";
     56 
     57  let hasPrompt = false;
     58 
     59  PromptTestUtils.handleNextPrompt(
     60    window,
     61    {
     62      modalType: Ci.nsIPrompt.MODAL_TYPE_TAB,
     63      promptType: "promptUserAndPass",
     64    },
     65    { buttonNumClick: 1 }
     66  )
     67    .then(function () {
     68      hasPrompt = true;
     69    })
     70    .catch(function () {});
     71 
     72  BrowserTestUtils.startLoadingURIString(gBrowser.selectedBrowser, URL);
     73 
     74  await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser, true, URL);
     75 
     76  Assert.equal(
     77    hasPrompt,
     78    true,
     79    "prompt when loading page via iframe with x-auth options with pref network.auth.supress_auth_prompt_for_XFO_failures disabled"
     80  );
     81 });