browser_bug431826.js
Go to the documentation of this file.
1 var newBrowser
2 
3 function test() {
5 
6  var newTab = gBrowser.addTab();
7  gBrowser.selectedTab = newTab;
8  newBrowser = gBrowser.getBrowserForTab(newTab);
9 
10  // Navigate to a site with a broken cert
11  window.addEventListener("DOMContentLoaded", testBrokenCert, true);
12  newBrowser.contentWindow.location = 'https://nocert.example.com/';
13 }
14 
15 function testBrokenCert() {
16  window.removeEventListener("DOMContentLoaded", testBrokenCert, true);
17 
18  // Confirm that we are displaying the contributed error page, not the default
19  ok(/^about:certerror/.test(gBrowser.contentWindow.document.documentURI), "Broken page should go to about:certerror, not about:neterror");
20 
21  // Confirm that the expert section is collapsed
22  var expertDiv = gBrowser.contentWindow.document.getElementById("expertContent");
23  ok(expertDiv, "Expert content div should exist");
24  ok(expertDiv.hasAttribute("collapsed"), "Expert content should be collapsed by default");
25 
26  // Tweak the expert mode pref
27  Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch)
28  .setBoolPref("browser.xul.error_pages.expert_bad_cert", true);
29 
30  window.addEventListener("DOMContentLoaded", testExpertPref, true);
31  newBrowser.reload();
32 }
33 
34 function testExpertPref() {
35 
36  window.removeEventListener("DOMContentLoaded", testExpertPref, true);
37  var expertDiv = gBrowser.contentWindow.document.getElementById("expertContent");
38  var technicalDiv = gBrowser.contentWindow.document.getElementById("technicalContent");
39  ok(!expertDiv.hasAttribute("collapsed"), "Expert content should not be collapsed with the expert mode pref set");
40  ok(!technicalDiv.hasAttribute("collapsed"), "Technical content should not be collapsed with the expert mode pref set");
41 
42  // Clean up
43  gBrowser.removeCurrentTab();
44  finish();
45 }
const Cc
let window
var newBrowser
function testBrokenCert()
function newBrowser test()
waitForExplicitFinish()
const Ci
function testExpertPref()