michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: // Test that optimized out variables aren't present in the variables view. michael@0: michael@0: function test() { michael@0: Task.spawn(function* () { michael@0: const TAB_URL = EXAMPLE_URL + "doc_closure-optimized-out.html"; michael@0: let panel, debuggee, gDebugger, sources; michael@0: michael@0: let [, debuggee, panel] = yield initDebugger(TAB_URL); michael@0: gDebugger = panel.panelWin; michael@0: sources = gDebugger.DebuggerView.Sources; michael@0: michael@0: yield waitForSourceShown(panel, ".html"); michael@0: yield panel.addBreakpoint({ url: sources.values[0], line: 18 }); michael@0: yield ensureThreadClientState(panel, "resumed"); michael@0: michael@0: // Spin the event loop before causing the debuggee to pause, to allow michael@0: // this function to return first. michael@0: executeSoon(() => { michael@0: EventUtils.sendMouseEvent({ type: "click" }, michael@0: debuggee.document.querySelector("button"), michael@0: debuggee); michael@0: }); michael@0: michael@0: yield waitForDebuggerEvents(panel, gDebugger.EVENTS.FETCHED_SCOPES); michael@0: let gVars = gDebugger.DebuggerView.Variables; michael@0: let outerScope = gVars.getScopeAtIndex(1); michael@0: outerScope.expand(); michael@0: michael@0: let upvarVar = outerScope.get("upvar"); michael@0: ok(!upvarVar, "upvar was optimized out."); michael@0: if (upvarVar) { michael@0: ok(false, "upvar = " + upvarVar.target.querySelector(".value").getAttribute("value")); michael@0: } michael@0: michael@0: let argVar = outerScope.get("arg"); michael@0: is(argVar.target.querySelector(".name").getAttribute("value"), "arg", michael@0: "Should have the right property name for |arg|."); michael@0: is(argVar.target.querySelector(".value").getAttribute("value"), 42, michael@0: "Should have the right property value for |arg|."); michael@0: michael@0: yield resumeDebuggerThenCloseAndFinish(panel); michael@0: }).then(null, aError => { michael@0: ok(false, "Got an error: " + aError.message + "\n" + aError.stack); michael@0: }); michael@0: }