Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /*
2 * Any copyright is dedicated to the Public Domain.
3 * http://creativecommons.org/publicdomain/zero/1.0/
4 */
6 // Check that inspecting a closure in the variables view sidebar works when
7 // execution is paused.
9 const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-closures.html";
11 let gWebConsole, gJSTerm, gVariablesView;
13 function test()
14 {
15 registerCleanupFunction(() => {
16 gWebConsole = gJSTerm = gVariablesView = null;
17 });
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 });
38 let button = content.document.querySelector("button");
39 ok(button, "button element found");
40 button.click();
42 return deferred.promise;
43 });
44 });
45 }, true);
46 }
48 function consoleOpened(hud)
49 {
50 gWebConsole = hud;
51 gJSTerm = hud.jsterm;
52 gJSTerm.execute("window.george.getName");
54 waitForMessages({
55 webconsole: gWebConsole,
56 messages: [{
57 text: "function _pfactory/<.getName()",
58 category: CATEGORY_OUTPUT,
59 objects: true,
60 }],
61 }).then(onExecuteGetName);
62 }
64 function onExecuteGetName(aResults)
65 {
66 let clickable = aResults[0].clickableElements[0];
67 ok(clickable, "clickable object found");
69 gJSTerm.once("variablesview-fetched", onGetNameFetch);
70 EventUtils.synthesizeMouse(clickable, 2, 2, {}, gWebConsole.iframeWindow)
71 }
73 function onGetNameFetch(aEvent, aVar)
74 {
75 gVariablesView = aVar._variablesView;
76 ok(gVariablesView, "variables view object");
78 findVariableViewProperties(aVar, [
79 { name: /_pfactory/, value: "" },
80 ], { webconsole: gWebConsole }).then(onExpandClosure);
81 }
83 function onExpandClosure(aResults)
84 {
85 let prop = aResults[0].matchedProp;
86 ok(prop, "matched the name property in the variables view");
88 gVariablesView.window.focus();
89 gJSTerm.once("sidebar-closed", finishTest);
90 EventUtils.synthesizeKey("VK_ESCAPE", {}, gVariablesView.window);
91 }