зеркало из https://github.com/mozilla/gecko-dev.git
Bug 901271 - Add a test, r=fitzgen
This commit is contained in:
Родитель
b4270a5399
Коммит
702728f613
|
@ -15,6 +15,7 @@ MOCHITEST_BROWSER_TESTS = \
|
||||||
browser_dbg_breadcrumbs-access.js \
|
browser_dbg_breadcrumbs-access.js \
|
||||||
browser_dbg_breakpoints-actual-location.js \
|
browser_dbg_breakpoints-actual-location.js \
|
||||||
browser_dbg_breakpoints-contextmenu.js \
|
browser_dbg_breakpoints-contextmenu.js \
|
||||||
|
browser_dbg_breakpoints-disabled-reload.js \
|
||||||
browser_dbg_breakpoints-editor.js \
|
browser_dbg_breakpoints-editor.js \
|
||||||
browser_dbg_breakpoints-highlight.js \
|
browser_dbg_breakpoints-highlight.js \
|
||||||
browser_dbg_breakpoints-new-script.js \
|
browser_dbg_breakpoints-new-script.js \
|
||||||
|
|
|
@ -0,0 +1,115 @@
|
||||||
|
/* Any copyright is dedicated to the Public Domain.
|
||||||
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that disabled breakpoints survive target navigation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html";
|
||||||
|
|
||||||
|
function test() {
|
||||||
|
initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
|
||||||
|
let gDebugger = aPanel.panelWin;
|
||||||
|
let gEvents = gDebugger.EVENTS;
|
||||||
|
let gEditor = gDebugger.DebuggerView.editor;
|
||||||
|
let gSources = gDebugger.DebuggerView.Sources;
|
||||||
|
let gBreakpoints = gDebugger.DebuggerController.Breakpoints;
|
||||||
|
let gBreakpointLocation = { url: EXAMPLE_URL + "code_script-switching-01.js", line: 5 };
|
||||||
|
|
||||||
|
Task.spawn(function() {
|
||||||
|
yield waitForSourceShown(aPanel, "-01.js");
|
||||||
|
yield aPanel.addBreakpoint(gBreakpointLocation);
|
||||||
|
|
||||||
|
yield ensureThreadClientState(aPanel, "resumed");
|
||||||
|
yield testWhenBreakpointEnabledAndFirstSourceShown();
|
||||||
|
|
||||||
|
yield reloadActiveTab(aPanel, gEvents.SOURCE_SHOWN);
|
||||||
|
yield testWhenBreakpointEnabledAndSecondSourceShown();
|
||||||
|
|
||||||
|
yield gSources.disableBreakpoint(gBreakpointLocation);
|
||||||
|
yield reloadActiveTab(aPanel, gEvents.SOURCE_SHOWN);
|
||||||
|
yield testWhenBreakpointDisabledAndSecondSourceShown();
|
||||||
|
|
||||||
|
yield gSources.enableBreakpoint(gBreakpointLocation);
|
||||||
|
yield reloadActiveTab(aPanel, gEvents.SOURCE_SHOWN);
|
||||||
|
yield testWhenBreakpointEnabledAndSecondSourceShown();
|
||||||
|
|
||||||
|
yield resumeDebuggerThenCloseAndFinish(aPanel);
|
||||||
|
});
|
||||||
|
|
||||||
|
function verifyView({ disabled, visible }) {
|
||||||
|
return Task.spawn(function() {
|
||||||
|
// It takes a tick for the checkbox in the SideMenuWidget and the
|
||||||
|
// gutter in the SourceEditor to get updated.
|
||||||
|
yield waitForTick();
|
||||||
|
|
||||||
|
let breakpointItem = gSources.getBreakpoint(gBreakpointLocation);
|
||||||
|
let visibleBreakpoints = gEditor.getBreakpoints();
|
||||||
|
is(!!breakpointItem.attachment.disabled, disabled,
|
||||||
|
"The selected brekapoint state was correct.");
|
||||||
|
is(breakpointItem.attachment.view.checkbox.hasAttribute("checked"), !disabled,
|
||||||
|
"The selected brekapoint's checkbox state was correct.");
|
||||||
|
|
||||||
|
// Source editor starts counting line and column numbers from 0.
|
||||||
|
let breakpointLine = breakpointItem.attachment.line - 1;
|
||||||
|
let matchedBreakpoints = visibleBreakpoints.filter(e => e.line == breakpointLine);
|
||||||
|
is(!!matchedBreakpoints.length, visible,
|
||||||
|
"The selected breakpoint's visibility in the editor was correct.");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// All the following executeSoon()'s are required to spin the event loop
|
||||||
|
// before causing the debuggee to pause, to allow functions to yield first.
|
||||||
|
|
||||||
|
function testWhenBreakpointEnabledAndFirstSourceShown() {
|
||||||
|
return Task.spawn(function() {
|
||||||
|
yield ensureSourceIs(aPanel, "-01.js");
|
||||||
|
yield verifyView({ disabled: false, visible: true });
|
||||||
|
|
||||||
|
executeSoon(() => aDebuggee.firstCall());
|
||||||
|
yield waitForDebuggerEvents(aPanel, gEvents.FETCHED_SCOPES);
|
||||||
|
yield ensureSourceIs(aPanel, "-01.js");
|
||||||
|
yield ensureCaretAt(aPanel, 5);
|
||||||
|
yield verifyView({ disabled: false, visible: true });
|
||||||
|
|
||||||
|
executeSoon(() => gDebugger.gThreadClient.resume());
|
||||||
|
yield waitForSourceAndCaretAndScopes(aPanel, "-02.js", 6);
|
||||||
|
yield verifyView({ disabled: false, visible: false });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function testWhenBreakpointEnabledAndSecondSourceShown() {
|
||||||
|
return Task.spawn(function() {
|
||||||
|
yield ensureSourceIs(aPanel, "-02.js");
|
||||||
|
yield verifyView({ disabled: false, visible: false });
|
||||||
|
|
||||||
|
executeSoon(() => aDebuggee.firstCall());
|
||||||
|
yield waitForSourceAndCaretAndScopes(aPanel, "-01.js", 5);
|
||||||
|
yield verifyView({ disabled: false, visible: true });
|
||||||
|
|
||||||
|
executeSoon(() => gDebugger.gThreadClient.resume());
|
||||||
|
yield waitForSourceAndCaretAndScopes(aPanel, "-02.js", 6);
|
||||||
|
yield verifyView({ disabled: false, visible: false });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function testWhenBreakpointDisabledAndSecondSourceShown() {
|
||||||
|
return Task.spawn(function() {
|
||||||
|
yield ensureSourceIs(aPanel, "-02.js");
|
||||||
|
yield verifyView({ disabled: true, visible: false });
|
||||||
|
|
||||||
|
executeSoon(() => aDebuggee.firstCall());
|
||||||
|
yield waitForDebuggerEvents(aPanel, gEvents.FETCHED_SCOPES);
|
||||||
|
yield ensureSourceIs(aPanel, "-02.js");
|
||||||
|
yield ensureCaretAt(aPanel, 6);
|
||||||
|
yield verifyView({ disabled: true, visible: false });
|
||||||
|
|
||||||
|
executeSoon(() => gDebugger.gThreadClient.resume());
|
||||||
|
yield waitForDebuggerEvents(aPanel, gEvents.AFTER_FRAMES_CLEARED);
|
||||||
|
yield ensureSourceIs(aPanel, "-02.js");
|
||||||
|
yield ensureCaretAt(aPanel, 6);
|
||||||
|
yield verifyView({ disabled: true, visible: false });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
|
@ -457,12 +457,6 @@ function synthesizeKeyAndWaitForTick(aKey, aModifiers) {
|
||||||
return waitForTick();
|
return waitForTick();
|
||||||
}
|
}
|
||||||
|
|
||||||
function waitForTick() {
|
|
||||||
let deferred = promise.defer();
|
|
||||||
executeSoon(deferred.resolve);
|
|
||||||
return deferred.promise;
|
|
||||||
}
|
|
||||||
|
|
||||||
function waitForElement(aSelector, aExistence, aInterval = 10) {
|
function waitForElement(aSelector, aExistence, aInterval = 10) {
|
||||||
let deferred = promise.defer();
|
let deferred = promise.defer();
|
||||||
|
|
||||||
|
|
|
@ -205,6 +205,12 @@ function once(aTarget, aEventName, aUseCapture = false) {
|
||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function waitForTick() {
|
||||||
|
let deferred = promise.defer();
|
||||||
|
executeSoon(deferred.resolve);
|
||||||
|
return deferred.promise;
|
||||||
|
}
|
||||||
|
|
||||||
function waitForSourceShown(aPanel, aUrl) {
|
function waitForSourceShown(aPanel, aUrl) {
|
||||||
return waitForDebuggerEvents(aPanel, aPanel.panelWin.EVENTS.SOURCE_SHOWN).then(aSource => {
|
return waitForDebuggerEvents(aPanel, aPanel.panelWin.EVENTS.SOURCE_SHOWN).then(aSource => {
|
||||||
let sourceUrl = aSource.url;
|
let sourceUrl = aSource.url;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче