summaryrefslogtreecommitdiffstats
path: root/comm/suite/components/tests/browser/browser_bug431826.js
blob: f4430fc95d25d5ebcbb57db94d30ec8aa7c85a61 (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
function test() {
  waitForExplicitFinish();

  getBrowser().selectedTab = gBrowser.addTab();

  // Navigate to a site with a broken cert
  window.addEventListener("DOMContentLoaded", testBrokenCert, true);
  content.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.contentDocument.documentURI), "Broken page should go to about:certerror, not about:neterror");

  // Confirm that the expert section is collapsed
  var expertDiv = gBrowser.contentDocument.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
  Services.prefs.setBoolPref("browser.xul.error_pages.expert_bad_cert", true);

  window.addEventListener("DOMContentLoaded", testExpertPref, true);
  getBrowser().reload();
}

function testExpertPref() {
  window.removeEventListener("DOMContentLoaded", testExpertPref, true);

  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");

  // Clean up
  getBrowser().removeCurrentTab();
  if (Services.prefs.prefHasUserValue("browser.xul.error_pages.expert_bad_cert"))
    Services.prefs.clearUserPref("browser.xul.error_pages.expert_bad_cert");
  finish();
}