Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 /*
2 * Any copyright is dedicated to the Public Domain.
3 * http://creativecommons.org/publicdomain/zero/1.0/
4 */
6 // Check that exceptions from scripts loaded with the addon-sdk loader are
7 // opened correctly in View Source from the Browser Console.
8 // See bug 866950.
10 const TEST_URI = "data:text/html;charset=utf8,<p>hello world from bug 866950";
12 function test()
13 {
14 requestLongerTimeout(2);
16 let webconsole, browserconsole;
18 Task.spawn(runner).then(finishTest);
20 function* runner() {
21 let {tab} = yield loadTab(TEST_URI);
22 webconsole = yield openConsole(tab);
23 ok(webconsole, "web console opened");
25 browserconsole = yield HUDService.toggleBrowserConsole();
26 ok(browserconsole, "browser console opened");
28 // Cause an exception in a script loaded with the addon-sdk loader.
29 let toolbox = gDevTools.getToolbox(webconsole.target);
30 let oldPanels = toolbox._toolPanels;
31 toolbox._toolPanels = null;
33 function fixToolbox() {
34 toolbox._toolPanels = oldPanels;
35 }
37 info("generate exception and wait for message");
39 executeSoon(() => {
40 executeSoon(fixToolbox);
41 expectUncaughtException();
42 toolbox.getToolPanels();
43 });
45 let [result] = yield waitForMessages({
46 webconsole: browserconsole,
47 messages: [{
48 text: "TypeError: can't convert null to object",
49 category: CATEGORY_JS,
50 severity: SEVERITY_ERROR,
51 }],
52 });
54 fixToolbox();
56 let msg = [...result.matched][0];
57 ok(msg, "message element found");
58 let locationNode = msg.querySelector(".message-location");
59 ok(locationNode, "message location element found");
61 let title = locationNode.getAttribute("title");
62 info("location node title: " + title);
63 isnot(title.indexOf(" -> "), -1, "error comes from a subscript");
65 let viewSource = browserconsole.viewSource;
66 let URL = null;
67 let clickPromise = promise.defer();
68 browserconsole.viewSource = (aURL) => {
69 info("browserconsole.viewSource() was invoked: " + aURL);
70 URL = aURL;
71 clickPromise.resolve(null);
72 };
74 msg.scrollIntoView();
75 EventUtils.synthesizeMouse(locationNode, 2, 2, {},
76 browserconsole.iframeWindow);
78 info("wait for click on locationNode");
79 yield clickPromise;
81 info("view-source url: " + URL);
82 ok(URL, "we have some source URL after the click");
83 isnot(URL.indexOf("toolbox.js"), -1, "we have the expected view source URL");
84 is(URL.indexOf("->"), -1, "no -> in the URL given to view-source");
86 browserconsole.viewSource = viewSource;
87 }
88 }