gecko/browser/components/certerror/test/browser_bug431826.js
Johnathan Nightingale 0ee5089bb6 Bug 425001 - Tests for bugs 400731 and 431826 rely on timers and are therefore fragile. TEST ONLY FIX.
Replace with DOMContentLoaded listeners, since onload doesn't work for error pages.
2009-04-21 16:17:14 -04:00

46 lines
1.8 KiB
JavaScript

var newBrowser
function test() {
waitForExplicitFinish();
var newTab = gBrowser.addTab();
gBrowser.selectedTab = newTab;
newBrowser = gBrowser.getBrowserForTab(newTab);
// Navigate to a site with a broken cert
window.addEventListener("DOMContentLoaded", testBrokenCert, true);
newBrowser.contentWindow.location = 'https://nocert.example.com/';
}
function testBrokenCert() {
window.removeEventListener("DOMContentLoaded", testBrokenCert, true);
// Confirm that we are displaying the contributed error page, not the default
ok(/^about:certerror/.test(gBrowser.contentWindow.document.documentURI), "Broken page should go to about:certerror, not about:neterror");
// Confirm that the expert section is collapsed
var expertDiv = gBrowser.contentWindow.document.getElementById("expertContent");
ok(expertDiv, "Expert content div should exist");
ok(expertDiv.hasAttribute("collapsed"), "Expert content should be collapsed by default");
// Tweak the expert mode pref
Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch)
.setBoolPref("browser.xul.error_pages.expert_bad_cert", true);
window.addEventListener("DOMContentLoaded", testExpertPref, true);
newBrowser.reload();
}
function testExpertPref() {
window.removeEventListener("DOMContentLoaded", testExpertPref, true);
var expertDiv = gBrowser.contentWindow.document.getElementById("expertContent");
var technicalDiv = gBrowser.contentWindow.document.getElementById("technicalContent");
ok(!expertDiv.hasAttribute("collapsed"), "Expert content should not be collapsed with the expert mode pref set");
ok(!technicalDiv.hasAttribute("collapsed"), "Technical content should not be collapsed with the expert mode pref set");
// Clean up
gBrowser.removeCurrentTab();
finish();
}