|
1 /* |
|
2 * Any copyright is dedicated to the Public Domain. |
|
3 * http://creativecommons.org/publicdomain/zero/1.0/ |
|
4 */ |
|
5 |
|
6 // Check that inspecting a closure in the variables view sidebar works when |
|
7 // execution is paused. |
|
8 |
|
9 const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-closures.html"; |
|
10 |
|
11 let gWebConsole, gJSTerm, gVariablesView; |
|
12 |
|
13 function test() |
|
14 { |
|
15 registerCleanupFunction(() => { |
|
16 gWebConsole = gJSTerm = gVariablesView = null; |
|
17 }); |
|
18 |
|
19 addTab(TEST_URI); |
|
20 browser.addEventListener("load", function onLoad() { |
|
21 browser.removeEventListener("load", onLoad, true); |
|
22 openConsole(null, (hud) => { |
|
23 openDebugger().then(({ toolbox, panelWin }) => { |
|
24 let deferred = promise.defer(); |
|
25 panelWin.gThreadClient.addOneTimeListener("resumed", (aEvent, aPacket) => { |
|
26 ok(true, "Debugger resumed"); |
|
27 deferred.resolve({ toolbox: toolbox, panelWin: panelWin }); |
|
28 }); |
|
29 return deferred.promise; |
|
30 }).then(({ toolbox, panelWin }) => { |
|
31 let deferred = promise.defer(); |
|
32 panelWin.once(panelWin.EVENTS.FETCHED_SCOPES, (aEvent, aPacket) => { |
|
33 ok(true, "Scopes were fetched"); |
|
34 toolbox.selectTool("webconsole").then(() => consoleOpened(hud)); |
|
35 deferred.resolve(); |
|
36 }); |
|
37 |
|
38 let button = content.document.querySelector("button"); |
|
39 ok(button, "button element found"); |
|
40 button.click(); |
|
41 |
|
42 return deferred.promise; |
|
43 }); |
|
44 }); |
|
45 }, true); |
|
46 } |
|
47 |
|
48 function consoleOpened(hud) |
|
49 { |
|
50 gWebConsole = hud; |
|
51 gJSTerm = hud.jsterm; |
|
52 gJSTerm.execute("window.george.getName"); |
|
53 |
|
54 waitForMessages({ |
|
55 webconsole: gWebConsole, |
|
56 messages: [{ |
|
57 text: "function _pfactory/<.getName()", |
|
58 category: CATEGORY_OUTPUT, |
|
59 objects: true, |
|
60 }], |
|
61 }).then(onExecuteGetName); |
|
62 } |
|
63 |
|
64 function onExecuteGetName(aResults) |
|
65 { |
|
66 let clickable = aResults[0].clickableElements[0]; |
|
67 ok(clickable, "clickable object found"); |
|
68 |
|
69 gJSTerm.once("variablesview-fetched", onGetNameFetch); |
|
70 EventUtils.synthesizeMouse(clickable, 2, 2, {}, gWebConsole.iframeWindow) |
|
71 } |
|
72 |
|
73 function onGetNameFetch(aEvent, aVar) |
|
74 { |
|
75 gVariablesView = aVar._variablesView; |
|
76 ok(gVariablesView, "variables view object"); |
|
77 |
|
78 findVariableViewProperties(aVar, [ |
|
79 { name: /_pfactory/, value: "" }, |
|
80 ], { webconsole: gWebConsole }).then(onExpandClosure); |
|
81 } |
|
82 |
|
83 function onExpandClosure(aResults) |
|
84 { |
|
85 let prop = aResults[0].matchedProp; |
|
86 ok(prop, "matched the name property in the variables view"); |
|
87 |
|
88 gVariablesView.window.focus(); |
|
89 gJSTerm.once("sidebar-closed", finishTest); |
|
90 EventUtils.synthesizeKey("VK_ESCAPE", {}, gVariablesView.window); |
|
91 } |