1 /* Any copyright is dedicated to the Public Domain.
2 * http://creativecommons.org/publicdomain/zero/1.0/
5 const DUMMY = "browser/browser/base/content/test/dummy_page.html";
7 function loadNewTab(aURL, aCallback) {
8 gBrowser.selectedTab = gBrowser.addTab();
9 gBrowser.loadURI(aURL);
11 gBrowser.selectedBrowser.addEventListener("load", function() {
12 if (gBrowser.selectedBrowser.currentURI.spec != aURL)
14 gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
16 aCallback(gBrowser.selectedTab);
20 function getIdentityMode() {
21 return document.getElementById("identity-box").className;
25 function test_webpage() {
26 let oldTab = gBrowser.selectedTab;
28 loadNewTab("http://example.com/" + DUMMY, function(aNewTab) {
29 is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
31 gBrowser.selectedTab = oldTab;
32 is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
34 gBrowser.selectedTab = aNewTab;
35 is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
37 gBrowser.removeTab(aNewTab);
43 function test_blank() {
44 let oldTab = gBrowser.selectedTab;
46 loadNewTab("about:blank", function(aNewTab) {
47 is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
49 gBrowser.selectedTab = oldTab;
50 is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
52 gBrowser.selectedTab = aNewTab;
53 is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
55 gBrowser.removeTab(aNewTab);
61 function test_chrome() {
62 let oldTab = gBrowser.selectedTab;
64 loadNewTab("chrome://mozapps/content/extensions/extensions.xul", function(aNewTab) {
65 is(getIdentityMode(), "chromeUI", "Identity should be chrome");
67 gBrowser.selectedTab = oldTab;
68 is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
70 gBrowser.selectedTab = aNewTab;
71 is(getIdentityMode(), "chromeUI", "Identity should be chrome");
73 gBrowser.removeTab(aNewTab);
79 function test_https() {
80 let oldTab = gBrowser.selectedTab;
82 loadNewTab("https://example.com/" + DUMMY, function(aNewTab) {
83 is(getIdentityMode(), "verifiedDomain", "Identity should be verified");
85 gBrowser.selectedTab = oldTab;
86 is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
88 gBrowser.selectedTab = aNewTab;
89 is(getIdentityMode(), "verifiedDomain", "Identity should be verified");
91 gBrowser.removeTab(aNewTab);
97 function test_addons() {
98 let oldTab = gBrowser.selectedTab;
100 loadNewTab("about:addons", function(aNewTab) {
101 is(getIdentityMode(), "chromeUI", "Identity should be chrome");
103 gBrowser.selectedTab = oldTab;
104 is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
106 gBrowser.selectedTab = aNewTab;
107 is(getIdentityMode(), "chromeUI", "Identity should be chrome");
109 gBrowser.removeTab(aNewTab);
116 var gTestStart = null;
118 function runNextTest() {
120 info("Test part took " + (Date.now() - gTestStart) + "ms");
122 if (TESTS.length == 0) {
127 info("Running " + TESTS[0].name);
128 gTestStart = Date.now();
133 waitForExplicitFinish();