gecko/browser/components/certerror/test/browser_bug431826.js

42 lines
1.7 KiB
JavaScript
Raw Normal View History

function test() {
waitForExplicitFinish();
2009-09-16 03:21:19 -07:00
gBrowser.selectedTab = gBrowser.addTab();
// Navigate to a site with a broken cert
window.addEventListener("DOMContentLoaded", testBrokenCert, true);
2009-09-16 03:21:19 -07:00
content.location = "https://nocert.example.com/";
}
function testBrokenCert() {
window.removeEventListener("DOMContentLoaded", testBrokenCert, true);
2009-09-16 03:21:19 -07:00
// Confirm that we are displaying the contributed error page, not the default
2009-09-16 03:21:19 -07:00
ok(/^about:certerror/.test(gBrowser.contentDocument.documentURI), "Broken page should go to about:certerror, not about:neterror");
// Confirm that the expert section is collapsed
2009-09-16 03:21:19 -07:00
var expertDiv = gBrowser.contentDocument.getElementById("expertContent");
ok(expertDiv, "Expert content div should exist");
ok(expertDiv.hasAttribute("collapsed"), "Expert content should be collapsed by default");
2009-09-16 03:21:19 -07:00
// Tweak the expert mode pref
2009-09-16 03:21:19 -07:00
gPrefService.setBoolPref("browser.xul.error_pages.expert_bad_cert", true);
window.addEventListener("DOMContentLoaded", testExpertPref, true);
2009-09-16 03:21:19 -07:00
gBrowser.reload();
}
function testExpertPref() {
window.removeEventListener("DOMContentLoaded", testExpertPref, true);
2009-09-16 03:21:19 -07:00
var expertDiv = gBrowser.contentDocument.getElementById("expertContent");
var technicalDiv = gBrowser.contentDocument.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");
2009-09-16 03:21:19 -07:00
// Clean up
gBrowser.removeCurrentTab();
if (gPrefService.prefHasUserValue("browser.xul.error_pages.expert_bad_cert"))
gPrefService.clearUserPref("browser.xul.error_pages.expert_bad_cert");
finish();
}