michael@0: /* michael@0: * Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ michael@0: */ michael@0: michael@0: // Test the basic features of the Browser Console, bug 587757. michael@0: michael@0: const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html?" + Date.now(); michael@0: michael@0: function test() michael@0: { michael@0: Services.obs.addObserver(function observer(aSubject) { michael@0: Services.obs.removeObserver(observer, "web-console-created"); michael@0: aSubject.QueryInterface(Ci.nsISupportsString); michael@0: michael@0: let hud = HUDService.getBrowserConsole(); michael@0: ok(hud, "browser console is open"); michael@0: is(aSubject.data, hud.hudId, "notification hudId is correct"); michael@0: michael@0: executeSoon(() => consoleOpened(hud)); michael@0: }, "web-console-created", false); michael@0: michael@0: let hud = HUDService.getBrowserConsole(); michael@0: ok(!hud, "browser console is not open"); michael@0: info("wait for the browser console to open with ctrl-shift-j"); michael@0: EventUtils.synthesizeKey("j", { accelKey: true, shiftKey: true }, window); michael@0: } michael@0: michael@0: function consoleOpened(hud) michael@0: { michael@0: hud.jsterm.clearOutput(true); michael@0: michael@0: expectUncaughtException(); michael@0: executeSoon(() => { michael@0: foobarExceptionBug587757(); michael@0: }); michael@0: michael@0: // Add a message from a chrome window. michael@0: hud.iframeWindow.console.log("bug587757a"); michael@0: michael@0: // Add a message from a content window. michael@0: content.console.log("bug587757b"); michael@0: michael@0: // Test eval. michael@0: hud.jsterm.execute("document.location.href"); michael@0: michael@0: // Check for network requests. michael@0: let xhr = new XMLHttpRequest(); michael@0: xhr.onload = () => console.log("xhr loaded, status is: " + xhr.status); michael@0: xhr.open("get", TEST_URI, true); michael@0: xhr.send(); michael@0: michael@0: waitForMessages({ michael@0: webconsole: hud, michael@0: messages: [ michael@0: { michael@0: name: "chrome window console.log() is displayed", michael@0: text: "bug587757a", michael@0: category: CATEGORY_WEBDEV, michael@0: severity: SEVERITY_LOG, michael@0: }, michael@0: { michael@0: name: "content window console.log() is displayed", michael@0: text: "bug587757b", michael@0: category: CATEGORY_WEBDEV, michael@0: severity: SEVERITY_LOG, michael@0: }, michael@0: { michael@0: name: "jsterm eval result", michael@0: text: "browser.xul", michael@0: category: CATEGORY_OUTPUT, michael@0: severity: SEVERITY_LOG, michael@0: }, michael@0: { michael@0: name: "exception message", michael@0: text: "foobarExceptionBug587757", michael@0: category: CATEGORY_JS, michael@0: severity: SEVERITY_ERROR, michael@0: }, michael@0: { michael@0: name: "network message", michael@0: text: "test-console.html", michael@0: category: CATEGORY_NETWORK, michael@0: severity: SEVERITY_LOG, michael@0: }, michael@0: ], michael@0: }).then(finishTest); michael@0: }