michael@0: /* michael@0: * Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ michael@0: */ michael@0: michael@0: // Check that inspecting a closure in the variables view sidebar works when michael@0: // execution is paused. michael@0: michael@0: const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-closures.html"; michael@0: michael@0: let gWebConsole, gJSTerm, gVariablesView; michael@0: michael@0: function test() michael@0: { michael@0: registerCleanupFunction(() => { michael@0: gWebConsole = gJSTerm = gVariablesView = null; michael@0: }); michael@0: michael@0: addTab(TEST_URI); michael@0: browser.addEventListener("load", function onLoad() { michael@0: browser.removeEventListener("load", onLoad, true); michael@0: openConsole(null, (hud) => { michael@0: openDebugger().then(({ toolbox, panelWin }) => { michael@0: let deferred = promise.defer(); michael@0: panelWin.gThreadClient.addOneTimeListener("resumed", (aEvent, aPacket) => { michael@0: ok(true, "Debugger resumed"); michael@0: deferred.resolve({ toolbox: toolbox, panelWin: panelWin }); michael@0: }); michael@0: return deferred.promise; michael@0: }).then(({ toolbox, panelWin }) => { michael@0: let deferred = promise.defer(); michael@0: panelWin.once(panelWin.EVENTS.FETCHED_SCOPES, (aEvent, aPacket) => { michael@0: ok(true, "Scopes were fetched"); michael@0: toolbox.selectTool("webconsole").then(() => consoleOpened(hud)); michael@0: deferred.resolve(); michael@0: }); michael@0: michael@0: let button = content.document.querySelector("button"); michael@0: ok(button, "button element found"); michael@0: button.click(); michael@0: michael@0: return deferred.promise; michael@0: }); michael@0: }); michael@0: }, true); michael@0: } michael@0: michael@0: function consoleOpened(hud) michael@0: { michael@0: gWebConsole = hud; michael@0: gJSTerm = hud.jsterm; michael@0: gJSTerm.execute("window.george.getName"); michael@0: michael@0: waitForMessages({ michael@0: webconsole: gWebConsole, michael@0: messages: [{ michael@0: text: "function _pfactory/<.getName()", michael@0: category: CATEGORY_OUTPUT, michael@0: objects: true, michael@0: }], michael@0: }).then(onExecuteGetName); michael@0: } michael@0: michael@0: function onExecuteGetName(aResults) michael@0: { michael@0: let clickable = aResults[0].clickableElements[0]; michael@0: ok(clickable, "clickable object found"); michael@0: michael@0: gJSTerm.once("variablesview-fetched", onGetNameFetch); michael@0: EventUtils.synthesizeMouse(clickable, 2, 2, {}, gWebConsole.iframeWindow) michael@0: } michael@0: michael@0: function onGetNameFetch(aEvent, aVar) michael@0: { michael@0: gVariablesView = aVar._variablesView; michael@0: ok(gVariablesView, "variables view object"); michael@0: michael@0: findVariableViewProperties(aVar, [ michael@0: { name: /_pfactory/, value: "" }, michael@0: ], { webconsole: gWebConsole }).then(onExpandClosure); michael@0: } michael@0: michael@0: function onExpandClosure(aResults) michael@0: { michael@0: let prop = aResults[0].matchedProp; michael@0: ok(prop, "matched the name property in the variables view"); michael@0: michael@0: gVariablesView.window.focus(); michael@0: gJSTerm.once("sidebar-closed", finishTest); michael@0: EventUtils.synthesizeKey("VK_ESCAPE", {}, gVariablesView.window); michael@0: }