mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-09 04:25:38 +00:00
Bug 1006489 - Scopes in the debugger don't always reexpand after stepping, r=rcampbell
This commit is contained in:
parent
2818e1245a
commit
1404c7bd24
@ -834,8 +834,8 @@ StackFrames.prototype = {
|
||||
|
||||
// The innermost scope is always automatically expanded, because it
|
||||
// contains the variables in the current stack frame which are likely to
|
||||
// be inspected.
|
||||
if (innermost) {
|
||||
// be inspected. The previously expanded scopes are also reexpanded here.
|
||||
if (innermost || DebuggerView.Variables.wasExpanded(scope)) {
|
||||
scope.expand();
|
||||
}
|
||||
} while ((environment = environment.parent));
|
||||
|
@ -73,6 +73,7 @@ support-files =
|
||||
doc_scope-variable.html
|
||||
doc_scope-variable-2.html
|
||||
doc_scope-variable-3.html
|
||||
doc_scope-variable-4.html
|
||||
doc_script-switching-01.html
|
||||
doc_script-switching-02.html
|
||||
doc_step-out.html
|
||||
@ -286,6 +287,7 @@ skip-if = (os == 'mac' || os == 'win') && (debug == false) # Bug 986166
|
||||
[browser_dbg_variables-view-popup-15.js]
|
||||
[browser_dbg_variables-view-reexpand-01.js]
|
||||
[browser_dbg_variables-view-reexpand-02.js]
|
||||
[browser_dbg_variables-view-reexpand-03.js]
|
||||
[browser_dbg_variables-view-webidl.js]
|
||||
[browser_dbg_watch-expressions-01.js]
|
||||
[browser_dbg_watch-expressions-02.js]
|
||||
|
@ -0,0 +1,129 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/**
|
||||
* Make sure that the variables view correctly re-expands *scopes* after pauses.
|
||||
*/
|
||||
|
||||
const TAB_URL = EXAMPLE_URL + "doc_scope-variable-4.html";
|
||||
|
||||
let gTab, gDebuggee, gPanel, gDebugger;
|
||||
let gBreakpoints, gSources, gVariables;
|
||||
|
||||
function test() {
|
||||
// Debug test slaves are a bit slow at this test.
|
||||
requestLongerTimeout(4);
|
||||
|
||||
initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
|
||||
gTab = aTab;
|
||||
gDebuggee = aDebuggee;
|
||||
gPanel = aPanel;
|
||||
gDebugger = gPanel.panelWin;
|
||||
gBreakpoints = gDebugger.DebuggerController.Breakpoints;
|
||||
gSources = gDebugger.DebuggerView.Sources;
|
||||
gVariables = gDebugger.DebuggerView.Variables;
|
||||
|
||||
// Always expand all items between pauses.
|
||||
gVariables.commitHierarchyIgnoredItems = Object.create(null);
|
||||
|
||||
waitForSourceShown(gPanel, ".html")
|
||||
.then(addBreakpoint)
|
||||
.then(() => ensureThreadClientState(gPanel, "resumed"))
|
||||
.then(pauseDebuggee)
|
||||
.then(prepareScopes)
|
||||
.then(resumeDebuggee)
|
||||
.then(testVariablesExpand)
|
||||
.then(() => resumeDebuggerThenCloseAndFinish(gPanel))
|
||||
.then(null, aError => {
|
||||
ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function addBreakpoint() {
|
||||
return gBreakpoints.addBreakpoint({ url: gSources.selectedValue, line: 18 });
|
||||
}
|
||||
|
||||
function pauseDebuggee() {
|
||||
// Spin the event loop before causing the debuggee to pause, to allow
|
||||
// this function to return first.
|
||||
executeSoon(() => {
|
||||
gDebuggee.test();
|
||||
});
|
||||
|
||||
return waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES);
|
||||
}
|
||||
|
||||
function resumeDebuggee() {
|
||||
// Spin the event loop before causing the debuggee to pause, to allow
|
||||
// this function to return first.
|
||||
executeSoon(() => {
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
gDebugger.document.querySelector("#resume"),
|
||||
gDebugger);
|
||||
});
|
||||
|
||||
return waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES);
|
||||
}
|
||||
|
||||
function testVariablesExpand() {
|
||||
let localScope = gVariables.getScopeAtIndex(0);
|
||||
let functionScope = gVariables.getScopeAtIndex(1);
|
||||
let globalScope = gVariables.getScopeAtIndex(2);
|
||||
|
||||
is(localScope.target.querySelector(".arrow").hasAttribute("open"), true,
|
||||
"The localScope arrow should still be expanded.");
|
||||
is(functionScope.target.querySelector(".arrow").hasAttribute("open"), true,
|
||||
"The functionScope arrow should still be expanded.");
|
||||
is(globalScope.target.querySelector(".arrow").hasAttribute("open"), false,
|
||||
"The globalScope arrow should not be expanded.");
|
||||
|
||||
is(localScope.target.querySelector(".variables-view-element-details").hasAttribute("open"), true,
|
||||
"The localScope enumerables should still be expanded.");
|
||||
is(functionScope.target.querySelector(".variables-view-element-details").hasAttribute("open"), true,
|
||||
"The functionScope enumerables should still be expanded.");
|
||||
is(globalScope.target.querySelector(".variables-view-element-details").hasAttribute("open"), false,
|
||||
"The globalScope enumerables should not be expanded.");
|
||||
|
||||
is(localScope.expanded, true,
|
||||
"The localScope expanded getter should return true.");
|
||||
is(functionScope.expanded, true,
|
||||
"The functionScope expanded getter should return true.");
|
||||
is(globalScope.expanded, false,
|
||||
"The globalScope expanded getter should return false.");
|
||||
}
|
||||
|
||||
function prepareScopes() {
|
||||
let localScope = gVariables.getScopeAtIndex(0);
|
||||
let functionScope = gVariables.getScopeAtIndex(1);
|
||||
let globalScope = gVariables.getScopeAtIndex(2);
|
||||
|
||||
is(localScope.expanded, true,
|
||||
"The localScope should be expanded.");
|
||||
is(functionScope.expanded, false,
|
||||
"The functionScope should not be expanded yet.");
|
||||
is(globalScope.expanded, false,
|
||||
"The globalScope should not be expanded yet.");
|
||||
|
||||
localScope.collapse();
|
||||
functionScope.expand();
|
||||
|
||||
// Don't for any events to be triggered, because the Function scope is
|
||||
// an environment to which scope arguments and variables are already attached.
|
||||
is(localScope.expanded, false,
|
||||
"The localScope should not be expanded anymore.");
|
||||
is(functionScope.expanded, true,
|
||||
"The functionScope should now be expanded.");
|
||||
is(globalScope.expanded, false,
|
||||
"The globalScope should still not be expanded.");
|
||||
}
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
gTab = null;
|
||||
gDebuggee = null;
|
||||
gPanel = null;
|
||||
gDebugger = null;
|
||||
gBreakpoints = null;
|
||||
gSources = null;
|
||||
gVariables = null;
|
||||
});
|
25
browser/devtools/debugger/test/doc_scope-variable-4.html
Normal file
25
browser/devtools/debugger/test/doc_scope-variable-4.html
Normal file
@ -0,0 +1,25 @@
|
||||
<!-- Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ -->
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title>Debugger test page</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<script type="text/javascript">
|
||||
function test() {
|
||||
var a = "first scope";
|
||||
nest();
|
||||
|
||||
function nest() {
|
||||
var a = "second scope";
|
||||
debugger;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
x
Reference in New Issue
Block a user