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.
michael@0 | 1 | /* |
michael@0 | 2 | * Any copyright is dedicated to the Public Domain. |
michael@0 | 3 | * http://creativecommons.org/publicdomain/zero/1.0/ |
michael@0 | 4 | */ |
michael@0 | 5 | |
michael@0 | 6 | // Test the basic features of the Browser Console, bug 587757. |
michael@0 | 7 | |
michael@0 | 8 | const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html?" + Date.now(); |
michael@0 | 9 | |
michael@0 | 10 | function test() |
michael@0 | 11 | { |
michael@0 | 12 | Services.obs.addObserver(function observer(aSubject) { |
michael@0 | 13 | Services.obs.removeObserver(observer, "web-console-created"); |
michael@0 | 14 | aSubject.QueryInterface(Ci.nsISupportsString); |
michael@0 | 15 | |
michael@0 | 16 | let hud = HUDService.getBrowserConsole(); |
michael@0 | 17 | ok(hud, "browser console is open"); |
michael@0 | 18 | is(aSubject.data, hud.hudId, "notification hudId is correct"); |
michael@0 | 19 | |
michael@0 | 20 | executeSoon(() => consoleOpened(hud)); |
michael@0 | 21 | }, "web-console-created", false); |
michael@0 | 22 | |
michael@0 | 23 | let hud = HUDService.getBrowserConsole(); |
michael@0 | 24 | ok(!hud, "browser console is not open"); |
michael@0 | 25 | info("wait for the browser console to open with ctrl-shift-j"); |
michael@0 | 26 | EventUtils.synthesizeKey("j", { accelKey: true, shiftKey: true }, window); |
michael@0 | 27 | } |
michael@0 | 28 | |
michael@0 | 29 | function consoleOpened(hud) |
michael@0 | 30 | { |
michael@0 | 31 | hud.jsterm.clearOutput(true); |
michael@0 | 32 | |
michael@0 | 33 | expectUncaughtException(); |
michael@0 | 34 | executeSoon(() => { |
michael@0 | 35 | foobarExceptionBug587757(); |
michael@0 | 36 | }); |
michael@0 | 37 | |
michael@0 | 38 | // Add a message from a chrome window. |
michael@0 | 39 | hud.iframeWindow.console.log("bug587757a"); |
michael@0 | 40 | |
michael@0 | 41 | // Add a message from a content window. |
michael@0 | 42 | content.console.log("bug587757b"); |
michael@0 | 43 | |
michael@0 | 44 | // Test eval. |
michael@0 | 45 | hud.jsterm.execute("document.location.href"); |
michael@0 | 46 | |
michael@0 | 47 | // Check for network requests. |
michael@0 | 48 | let xhr = new XMLHttpRequest(); |
michael@0 | 49 | xhr.onload = () => console.log("xhr loaded, status is: " + xhr.status); |
michael@0 | 50 | xhr.open("get", TEST_URI, true); |
michael@0 | 51 | xhr.send(); |
michael@0 | 52 | |
michael@0 | 53 | waitForMessages({ |
michael@0 | 54 | webconsole: hud, |
michael@0 | 55 | messages: [ |
michael@0 | 56 | { |
michael@0 | 57 | name: "chrome window console.log() is displayed", |
michael@0 | 58 | text: "bug587757a", |
michael@0 | 59 | category: CATEGORY_WEBDEV, |
michael@0 | 60 | severity: SEVERITY_LOG, |
michael@0 | 61 | }, |
michael@0 | 62 | { |
michael@0 | 63 | name: "content window console.log() is displayed", |
michael@0 | 64 | text: "bug587757b", |
michael@0 | 65 | category: CATEGORY_WEBDEV, |
michael@0 | 66 | severity: SEVERITY_LOG, |
michael@0 | 67 | }, |
michael@0 | 68 | { |
michael@0 | 69 | name: "jsterm eval result", |
michael@0 | 70 | text: "browser.xul", |
michael@0 | 71 | category: CATEGORY_OUTPUT, |
michael@0 | 72 | severity: SEVERITY_LOG, |
michael@0 | 73 | }, |
michael@0 | 74 | { |
michael@0 | 75 | name: "exception message", |
michael@0 | 76 | text: "foobarExceptionBug587757", |
michael@0 | 77 | category: CATEGORY_JS, |
michael@0 | 78 | severity: SEVERITY_ERROR, |
michael@0 | 79 | }, |
michael@0 | 80 | { |
michael@0 | 81 | name: "network message", |
michael@0 | 82 | text: "test-console.html", |
michael@0 | 83 | category: CATEGORY_NETWORK, |
michael@0 | 84 | severity: SEVERITY_LOG, |
michael@0 | 85 | }, |
michael@0 | 86 | ], |
michael@0 | 87 | }).then(finishTest); |
michael@0 | 88 | } |