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 exceptions from scripts loaded with the addon-sdk loader are michael@0: // opened correctly in View Source from the Browser Console. michael@0: // See bug 866950. michael@0: michael@0: const TEST_URI = "data:text/html;charset=utf8,

hello world from bug 866950"; michael@0: michael@0: function test() michael@0: { michael@0: requestLongerTimeout(2); michael@0: michael@0: let webconsole, browserconsole; michael@0: michael@0: Task.spawn(runner).then(finishTest); michael@0: michael@0: function* runner() { michael@0: let {tab} = yield loadTab(TEST_URI); michael@0: webconsole = yield openConsole(tab); michael@0: ok(webconsole, "web console opened"); michael@0: michael@0: browserconsole = yield HUDService.toggleBrowserConsole(); michael@0: ok(browserconsole, "browser console opened"); michael@0: michael@0: // Cause an exception in a script loaded with the addon-sdk loader. michael@0: let toolbox = gDevTools.getToolbox(webconsole.target); michael@0: let oldPanels = toolbox._toolPanels; michael@0: toolbox._toolPanels = null; michael@0: michael@0: function fixToolbox() { michael@0: toolbox._toolPanels = oldPanels; michael@0: } michael@0: michael@0: info("generate exception and wait for message"); michael@0: michael@0: executeSoon(() => { michael@0: executeSoon(fixToolbox); michael@0: expectUncaughtException(); michael@0: toolbox.getToolPanels(); michael@0: }); michael@0: michael@0: let [result] = yield waitForMessages({ michael@0: webconsole: browserconsole, michael@0: messages: [{ michael@0: text: "TypeError: can't convert null to object", michael@0: category: CATEGORY_JS, michael@0: severity: SEVERITY_ERROR, michael@0: }], michael@0: }); michael@0: michael@0: fixToolbox(); michael@0: michael@0: let msg = [...result.matched][0]; michael@0: ok(msg, "message element found"); michael@0: let locationNode = msg.querySelector(".message-location"); michael@0: ok(locationNode, "message location element found"); michael@0: michael@0: let title = locationNode.getAttribute("title"); michael@0: info("location node title: " + title); michael@0: isnot(title.indexOf(" -> "), -1, "error comes from a subscript"); michael@0: michael@0: let viewSource = browserconsole.viewSource; michael@0: let URL = null; michael@0: let clickPromise = promise.defer(); michael@0: browserconsole.viewSource = (aURL) => { michael@0: info("browserconsole.viewSource() was invoked: " + aURL); michael@0: URL = aURL; michael@0: clickPromise.resolve(null); michael@0: }; michael@0: michael@0: msg.scrollIntoView(); michael@0: EventUtils.synthesizeMouse(locationNode, 2, 2, {}, michael@0: browserconsole.iframeWindow); michael@0: michael@0: info("wait for click on locationNode"); michael@0: yield clickPromise; michael@0: michael@0: info("view-source url: " + URL); michael@0: ok(URL, "we have some source URL after the click"); michael@0: isnot(URL.indexOf("toolbox.js"), -1, "we have the expected view source URL"); michael@0: is(URL.indexOf("->"), -1, "no -> in the URL given to view-source"); michael@0: michael@0: browserconsole.viewSource = viewSource; michael@0: } michael@0: }