1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/webconsole/test/browser_console.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,88 @@ 1.4 +/* 1.5 + * Any copyright is dedicated to the Public Domain. 1.6 + * http://creativecommons.org/publicdomain/zero/1.0/ 1.7 + */ 1.8 + 1.9 +// Test the basic features of the Browser Console, bug 587757. 1.10 + 1.11 +const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html?" + Date.now(); 1.12 + 1.13 +function test() 1.14 +{ 1.15 + Services.obs.addObserver(function observer(aSubject) { 1.16 + Services.obs.removeObserver(observer, "web-console-created"); 1.17 + aSubject.QueryInterface(Ci.nsISupportsString); 1.18 + 1.19 + let hud = HUDService.getBrowserConsole(); 1.20 + ok(hud, "browser console is open"); 1.21 + is(aSubject.data, hud.hudId, "notification hudId is correct"); 1.22 + 1.23 + executeSoon(() => consoleOpened(hud)); 1.24 + }, "web-console-created", false); 1.25 + 1.26 + let hud = HUDService.getBrowserConsole(); 1.27 + ok(!hud, "browser console is not open"); 1.28 + info("wait for the browser console to open with ctrl-shift-j"); 1.29 + EventUtils.synthesizeKey("j", { accelKey: true, shiftKey: true }, window); 1.30 +} 1.31 + 1.32 +function consoleOpened(hud) 1.33 +{ 1.34 + hud.jsterm.clearOutput(true); 1.35 + 1.36 + expectUncaughtException(); 1.37 + executeSoon(() => { 1.38 + foobarExceptionBug587757(); 1.39 + }); 1.40 + 1.41 + // Add a message from a chrome window. 1.42 + hud.iframeWindow.console.log("bug587757a"); 1.43 + 1.44 + // Add a message from a content window. 1.45 + content.console.log("bug587757b"); 1.46 + 1.47 + // Test eval. 1.48 + hud.jsterm.execute("document.location.href"); 1.49 + 1.50 + // Check for network requests. 1.51 + let xhr = new XMLHttpRequest(); 1.52 + xhr.onload = () => console.log("xhr loaded, status is: " + xhr.status); 1.53 + xhr.open("get", TEST_URI, true); 1.54 + xhr.send(); 1.55 + 1.56 + waitForMessages({ 1.57 + webconsole: hud, 1.58 + messages: [ 1.59 + { 1.60 + name: "chrome window console.log() is displayed", 1.61 + text: "bug587757a", 1.62 + category: CATEGORY_WEBDEV, 1.63 + severity: SEVERITY_LOG, 1.64 + }, 1.65 + { 1.66 + name: "content window console.log() is displayed", 1.67 + text: "bug587757b", 1.68 + category: CATEGORY_WEBDEV, 1.69 + severity: SEVERITY_LOG, 1.70 + }, 1.71 + { 1.72 + name: "jsterm eval result", 1.73 + text: "browser.xul", 1.74 + category: CATEGORY_OUTPUT, 1.75 + severity: SEVERITY_LOG, 1.76 + }, 1.77 + { 1.78 + name: "exception message", 1.79 + text: "foobarExceptionBug587757", 1.80 + category: CATEGORY_JS, 1.81 + severity: SEVERITY_ERROR, 1.82 + }, 1.83 + { 1.84 + name: "network message", 1.85 + text: "test-console.html", 1.86 + category: CATEGORY_NETWORK, 1.87 + severity: SEVERITY_LOG, 1.88 + }, 1.89 + ], 1.90 + }).then(finishTest); 1.91 +}