Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* vim:set ts=2 sw=2 sts=2 et: */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 const TEST_REPLACED_API_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console-replaced-api.html";
7 const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/testscript.js";
9 function test() {
10 waitForExplicitFinish();
12 const PREF = "devtools.webconsole.persistlog";
13 Services.prefs.setBoolPref(PREF, true);
14 registerCleanupFunction(() => Services.prefs.clearUserPref(PREF));
16 // First test that the warning does not appear on a page that doesn't override
17 // the window.console object.
18 addTab(TEST_URI);
19 browser.addEventListener("load", function onLoad() {
20 browser.removeEventListener("load", onLoad, true);
21 openConsole(null, testWarningNotPresent);
22 }, true);
24 function testWarningNotPresent(hud)
25 {
26 is(hud.outputNode.textContent.indexOf("logging API"), -1,
27 "no warning displayed");
29 // Bug 862024: make sure the warning doesn't show after page reload.
30 info("reload " + TEST_URI);
31 executeSoon(() => content.location.reload());
33 waitForMessages({
34 webconsole: hud,
35 messages: [{
36 text: "testscript.js",
37 category: CATEGORY_NETWORK,
38 }],
39 }).then(() => executeSoon(() => {
40 is(hud.outputNode.textContent.indexOf("logging API"), -1,
41 "no warning displayed");
43 closeConsole(null, loadTestPage);
44 }));
45 }
47 function loadTestPage()
48 {
49 info("load test " + TEST_REPLACED_API_URI);
50 browser.addEventListener("load", function onLoad() {
51 browser.removeEventListener("load", onLoad, true);
52 openConsole(null, testWarningPresent);
53 }, true);
54 content.location = TEST_REPLACED_API_URI;
55 }
57 function testWarningPresent(hud)
58 {
59 info("wait for the warning to show");
60 let warning = {
61 webconsole: hud,
62 messages: [{
63 text: /logging API .+ disabled by a script/,
64 category: CATEGORY_JS,
65 severity: SEVERITY_WARNING,
66 }],
67 };
69 waitForMessages(warning).then(() => {
70 hud.jsterm.clearOutput();
72 executeSoon(() => {
73 info("reload the test page and wait for the warning to show");
74 waitForMessages(warning).then(finishTest);
75 content.location.reload();
76 });
77 });
78 }
79 }