browser/devtools/webconsole/test/browser_warn_user_about_replaced_api.js

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:5cc3095f85e1
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/. */
5
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";
8
9 function test() {
10 waitForExplicitFinish();
11
12 const PREF = "devtools.webconsole.persistlog";
13 Services.prefs.setBoolPref(PREF, true);
14 registerCleanupFunction(() => Services.prefs.clearUserPref(PREF));
15
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);
23
24 function testWarningNotPresent(hud)
25 {
26 is(hud.outputNode.textContent.indexOf("logging API"), -1,
27 "no warning displayed");
28
29 // Bug 862024: make sure the warning doesn't show after page reload.
30 info("reload " + TEST_URI);
31 executeSoon(() => content.location.reload());
32
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");
42
43 closeConsole(null, loadTestPage);
44 }));
45 }
46
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 }
56
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 };
68
69 waitForMessages(warning).then(() => {
70 hud.jsterm.clearOutput();
71
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 }

mercurial