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: // Check that JS errors and CSS warnings open view source when their source link michael@0: // is clicked in the Browser Console. See bug 877778. michael@0: michael@0: const TEST_URI = "data:text/html;charset=utf8,
hello world from bug 877778 " + michael@0: ""; michael@0: function test() michael@0: { michael@0: let hud; michael@0: michael@0: addTab(TEST_URI); michael@0: browser.addEventListener("load", function onLoad() { michael@0: browser.removeEventListener("load", onLoad, true); michael@0: HUDService.toggleBrowserConsole().then(browserConsoleOpened); michael@0: }, true); michael@0: michael@0: function browserConsoleOpened(aHud) michael@0: { michael@0: hud = aHud; michael@0: ok(hud, "browser console opened"); michael@0: michael@0: let button = content.document.querySelector("button"); michael@0: ok(button, "button element found"); michael@0: michael@0: info("generate exception and wait for the message"); michael@0: executeSoon(() => { michael@0: expectUncaughtException(); michael@0: button.click(); michael@0: }); michael@0: michael@0: waitForMessages({ michael@0: webconsole: hud, michael@0: messages: [ michael@0: { michael@0: text: "ReferenceError: foobar is not defined", michael@0: category: CATEGORY_JS, michael@0: severity: SEVERITY_ERROR, michael@0: }, michael@0: { michael@0: text: "Unknown property 'test-color'", michael@0: category: CATEGORY_CSS, michael@0: severity: SEVERITY_WARNING, michael@0: }, michael@0: ], michael@0: }).then(onMessageFound); michael@0: } michael@0: michael@0: function onMessageFound(results) michael@0: { michael@0: let viewSource = hud.viewSource; michael@0: let viewSourceCalled = false; michael@0: hud.viewSource = () => viewSourceCalled = true; michael@0: michael@0: for (let result of results) { michael@0: viewSourceCalled = false; michael@0: michael@0: let msg = [...results[0].matched][0]; michael@0: ok(msg, "message element found for: " + result.text); michael@0: let locationNode = msg.querySelector(".message-location"); michael@0: ok(locationNode, "message location element found"); michael@0: michael@0: EventUtils.synthesizeMouse(locationNode, 2, 2, {}, hud.iframeWindow); michael@0: michael@0: ok(viewSourceCalled, "view source opened"); michael@0: } michael@0: michael@0: hud.viewSource = viewSource; michael@0: finishTest(); michael@0: } michael@0: }