tor-browser

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

browser_bug400731.js (1950B)


      1 /* Check presence of the "Ignore this warning" button */
      2 
      3 function checkWarningState() {
      4  return SpecialPowers.spawn(gBrowser.selectedBrowser, [], () => {
      5    return !!content.document.getElementById("ignore_warning_link");
      6  });
      7 }
      8 
      9 add_task(async function testMalware() {
     10  await new Promise(resolve => waitForDBInit(resolve));
     11 
     12  await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank");
     13 
     14  const url = "http://www.itisatrap.org/firefox/its-an-attack.html";
     15  BrowserTestUtils.startLoadingURIString(gBrowser.selectedBrowser, url);
     16  await BrowserTestUtils.browserLoaded(
     17    gBrowser.selectedBrowser,
     18    false,
     19    url,
     20    true
     21  );
     22 
     23  let buttonPresent = await checkWarningState();
     24  ok(buttonPresent, "Ignore warning link should be present for malware");
     25 });
     26 
     27 add_task(async function testUnwanted() {
     28  Services.prefs.setBoolPref("browser.safebrowsing.allowOverride", false);
     29 
     30  // Now launch the unwanted software test
     31  const url = "http://www.itisatrap.org/firefox/unwanted.html";
     32  BrowserTestUtils.startLoadingURIString(gBrowser.selectedBrowser, url);
     33  await BrowserTestUtils.browserLoaded(
     34    gBrowser.selectedBrowser,
     35    false,
     36    url,
     37    true
     38  );
     39 
     40  // Confirm that "Ignore this warning" is visible - bug 422410
     41  let buttonPresent = await checkWarningState();
     42  ok(
     43    !buttonPresent,
     44    "Ignore warning link should be missing for unwanted software"
     45  );
     46 });
     47 
     48 add_task(async function testPhishing() {
     49  Services.prefs.setBoolPref("browser.safebrowsing.allowOverride", true);
     50 
     51  // Now launch the phishing test
     52  const url = "http://www.itisatrap.org/firefox/its-a-trap.html";
     53  BrowserTestUtils.startLoadingURIString(gBrowser.selectedBrowser, url);
     54  await BrowserTestUtils.browserLoaded(
     55    gBrowser.selectedBrowser,
     56    false,
     57    url,
     58    true
     59  );
     60 
     61  let buttonPresent = await checkWarningState();
     62  ok(buttonPresent, "Ignore warning link should be present for phishing");
     63 
     64  gBrowser.removeCurrentTab();
     65 });