browser/devtools/webconsole/test/browser_webconsole_closure_inspection.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial