|
1 /* vim:set ts=2 sw=2 sts=2 et: */ |
|
2 /* Any copyright is dedicated to the Public Domain. |
|
3 * http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
4 |
|
5 // Test that objects given to console.log() are inspectable. |
|
6 |
|
7 function test() |
|
8 { |
|
9 waitForExplicitFinish(); |
|
10 |
|
11 addTab("data:text/html;charset=utf8,test for bug 676722 - inspectable objects for window.console"); |
|
12 |
|
13 gBrowser.selectedBrowser.addEventListener("load", function onLoad() { |
|
14 gBrowser.selectedBrowser.removeEventListener("load", onLoad, true); |
|
15 openConsole(null, performTest); |
|
16 }, true); |
|
17 } |
|
18 |
|
19 function performTest(hud) |
|
20 { |
|
21 hud.jsterm.clearOutput(true); |
|
22 |
|
23 hud.jsterm.execute("myObj = {abba: 'omgBug676722'}"); |
|
24 hud.jsterm.execute("console.log('fooBug676722', myObj)"); |
|
25 |
|
26 waitForMessages({ |
|
27 webconsole: hud, |
|
28 messages: [{ |
|
29 text: "fooBug676722", |
|
30 category: CATEGORY_WEBDEV, |
|
31 severity: SEVERITY_LOG, |
|
32 objects: true, |
|
33 }], |
|
34 }).then(([result]) => { |
|
35 let msg = [...result.matched][0]; |
|
36 ok(msg, "message element"); |
|
37 let body = msg.querySelector(".message-body"); |
|
38 ok(body, "message body"); |
|
39 let clickable = result.clickableElements[0]; |
|
40 ok(clickable, "the console.log() object anchor was found"); |
|
41 ok(body.textContent.contains('{ abba: "omgBug676722" }'), |
|
42 "clickable node content is correct"); |
|
43 |
|
44 hud.jsterm.once("variablesview-fetched", |
|
45 (aEvent, aVar) => { |
|
46 ok(aVar, "object inspector opened on click"); |
|
47 |
|
48 findVariableViewProperties(aVar, [{ |
|
49 name: "abba", |
|
50 value: "omgBug676722", |
|
51 }], { webconsole: hud }).then(finishTest); |
|
52 }); |
|
53 |
|
54 executeSoon(function() { |
|
55 EventUtils.synthesizeMouse(clickable, 2, 2, {}, hud.iframeWindow); |
|
56 }); |
|
57 }); |
|
58 } |