Add a debugger test for inspection of optimized out variables (bug 1002456). r=vporof

This commit is contained in:
Panos Astithas 2014-05-08 22:09:29 +03:00
parent 10b1e04a4d
commit 85d9e370f8
3 changed files with 84 additions and 0 deletions

View File

@ -42,6 +42,7 @@ support-files =
doc_blackboxing.html
doc_breakpoints-break-on-last-line-of-script-on-reload.html
doc_closures.html
doc_closure-optimized-out.html
doc_cmd-break.html
doc_cmd-dbg.html
doc_conditional-breakpoints.html
@ -161,6 +162,7 @@ skip-if = true # Bug 933950 (leaky test)
[browser_dbg_navigation.js]
[browser_dbg_no-page-sources.js]
[browser_dbg_on-pause-highlight.js]
[browser_dbg_optimized-out-vars.js]
[browser_dbg_panel-size.js]
[browser_dbg_parser-01.js]
[browser_dbg_parser-02.js]

View File

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

View File

@ -0,0 +1,34 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset='utf-8'/>
<title>Debugger Test for Inspecting Optimized-Out Variables</title>
<!-- Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ -->
<script type="text/javascript">
window.addEventListener("load", function onload() {
window.removeEventListener("load", onload);
function clickHandler(event) {
button.removeEventListener("click", clickHandler, false);
function outer(arg) {
var upvar = arg * 2;
// The inner lambda only aliases arg, so the frontend alias analysis decides
// that upvar is not aliased and is not in the CallObject.
return function () {
arg += 2;
};
}
var f = outer(42);
f();
}
var button = document.querySelector("button");
button.addEventListener("click", clickHandler, false);
});
</script>
</head>
<body>
<button>Click me!</button>
</body>
</html>