browser/components/safebrowsing/content/test/browser_bug400731.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/components/safebrowsing/content/test/browser_bug400731.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,49 @@
     1.4 +/* Check for the intended visibility of the "Ignore this warning" text*/
     1.5 +
     1.6 +function test() {
     1.7 +  waitForExplicitFinish();
     1.8 +  
     1.9 +  gBrowser.selectedTab = gBrowser.addTab();
    1.10 +  
    1.11 +  // Navigate to malware site.  Can't use an onload listener here since
    1.12 +  // error pages don't fire onload.  Also can't register the DOMContentLoaded
    1.13 +  // handler here because registering it too soon would mean that we might
    1.14 +  // get it for about:blank, and not about:blocked.
    1.15 +  gBrowser.addTabsProgressListener({
    1.16 +    onLocationChange: function(aTab, aWebProgress, aRequest, aLocation, aFlags) {
    1.17 +      if (aFlags & Ci.nsIWebProgressListener.LOCATION_CHANGE_ERROR_PAGE) {
    1.18 +        gBrowser.removeTabsProgressListener(this);
    1.19 +        window.addEventListener("DOMContentLoaded", testMalware, true);
    1.20 +      }
    1.21 +    }
    1.22 +  });
    1.23 +  content.location = "http://www.itisatrap.org/firefox/its-an-attack.html";
    1.24 +}
    1.25 +
    1.26 +function testMalware() {
    1.27 +  window.removeEventListener("DOMContentLoaded", testMalware, true);
    1.28 +
    1.29 +  // Confirm that "Ignore this warning" is visible - bug 422410
    1.30 +  var el = content.document.getElementById("ignoreWarningButton");
    1.31 +  ok(el, "Ignore warning button should be present for malware");
    1.32 +  
    1.33 +  var style = content.getComputedStyle(el, null);
    1.34 +  is(style.display, "inline-block", "Ignore Warning button should be display:inline-block for malware");
    1.35 +  
    1.36 +  // Now launch the phishing test
    1.37 +  window.addEventListener("DOMContentLoaded", testPhishing, true);
    1.38 +  content.location = "http://www.itisatrap.org/firefox/its-a-trap.html";
    1.39 +}
    1.40 +
    1.41 +function testPhishing() {
    1.42 +  window.removeEventListener("DOMContentLoaded", testPhishing, true);
    1.43 +  
    1.44 +  var el = content.document.getElementById("ignoreWarningButton");
    1.45 +  ok(el, "Ignore warning button should be present for phishing");
    1.46 +  
    1.47 +  var style = content.getComputedStyle(el, null);
    1.48 +  is(style.display, "inline-block", "Ignore Warning button should be display:inline-block for phishing");
    1.49 +  
    1.50 +  gBrowser.removeCurrentTab();
    1.51 +  finish();
    1.52 +}

mercurial