summaryrefslogtreecommitdiffstats
path: root/browser/components/safebrowsing/content/test/browser_bug400731.js
blob: 39a048198b37d1b82b318b63d574680c9efec2db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/* Check presence of the "Ignore this warning" button */

function checkWarningState() {
  return SpecialPowers.spawn(gBrowser.selectedBrowser, [], () => {
    return !!content.document.getElementById("ignore_warning_link");
  });
}

add_task(async function testMalware() {
  await new Promise(resolve => waitForDBInit(resolve));

  await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank");

  const url = "http://www.itisatrap.org/firefox/its-an-attack.html";
  BrowserTestUtils.loadURIString(gBrowser.selectedBrowser, url);
  await BrowserTestUtils.browserLoaded(
    gBrowser.selectedBrowser,
    false,
    url,
    true
  );

  let buttonPresent = await checkWarningState();
  ok(buttonPresent, "Ignore warning link should be present for malware");
});

add_task(async function testUnwanted() {
  Services.prefs.setBoolPref("browser.safebrowsing.allowOverride", false);

  // Now launch the unwanted software test
  const url = "http://www.itisatrap.org/firefox/unwanted.html";
  BrowserTestUtils.loadURIString(gBrowser.selectedBrowser, url);
  await BrowserTestUtils.browserLoaded(
    gBrowser.selectedBrowser,
    false,
    url,
    true
  );

  // Confirm that "Ignore this warning" is visible - bug 422410
  let buttonPresent = await checkWarningState();
  ok(
    !buttonPresent,
    "Ignore warning link should be missing for unwanted software"
  );
});

add_task(async function testPhishing() {
  Services.prefs.setBoolPref("browser.safebrowsing.allowOverride", true);

  // Now launch the phishing test
  const url = "http://www.itisatrap.org/firefox/its-a-trap.html";
  BrowserTestUtils.loadURIString(gBrowser.selectedBrowser, url);
  await BrowserTestUtils.browserLoaded(
    gBrowser.selectedBrowser,
    false,
    url,
    true
  );

  let buttonPresent = await checkWarningState();
  ok(buttonPresent, "Ignore warning link should be present for phishing");

  gBrowser.removeCurrentTab();
});