2014-03-07 11:06:28 -08:00
|
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Bug 978019: Setting a breakpoint on the last line of a Debugger.Script and
|
|
|
|
* reloading should still hit the breakpoint.
|
|
|
|
*/
|
|
|
|
|
|
|
|
const TAB_URL = EXAMPLE_URL + "doc_breakpoints-break-on-last-line-of-script-on-reload.html";
|
|
|
|
const CODE_URL = EXAMPLE_URL + "code_breakpoints-break-on-last-line-of-script-on-reload.js";
|
|
|
|
|
|
|
|
function test() {
|
2014-05-07 10:43:10 -07:00
|
|
|
// Debug test slaves are a bit slow at this test.
|
|
|
|
requestLongerTimeout(2);
|
|
|
|
|
2014-03-07 11:06:28 -08:00
|
|
|
let gPanel, gDebugger, gThreadClient, gEvents;
|
|
|
|
|
2014-11-13 10:36:37 -08:00
|
|
|
initDebugger(TAB_URL).then(([aTab,, aPanel]) => {
|
2014-03-07 11:06:28 -08:00
|
|
|
gPanel = aPanel;
|
|
|
|
gDebugger = gPanel.panelWin;
|
|
|
|
gThreadClient = gDebugger.gThreadClient;
|
|
|
|
gEvents = gDebugger.EVENTS;
|
|
|
|
|
|
|
|
Task.spawn(function* () {
|
2014-03-11 09:42:49 -07:00
|
|
|
try {
|
|
|
|
|
2014-03-15 18:48:55 -07:00
|
|
|
// Refresh and hit the debugger statement before the location we want to
|
|
|
|
// set our breakpoints. We have to pause before the breakpoint locations
|
|
|
|
// so that GC doesn't get a chance to kick in and collect the IIFE's
|
|
|
|
// script, which would causes us to receive a 'noScript' error from the
|
|
|
|
// server when we try to set the breakpoints.
|
|
|
|
const [paused, ] = yield promise.all([
|
|
|
|
waitForThreadEvents(gPanel, "paused"),
|
|
|
|
reloadActiveTab(gPanel, gEvents.SOURCE_SHOWN),
|
|
|
|
]);
|
|
|
|
|
|
|
|
is(paused.why.type, "debuggerStatement");
|
2014-03-11 09:42:49 -07:00
|
|
|
|
2014-03-15 18:48:55 -07:00
|
|
|
// Set our breakpoints.
|
2014-03-11 09:42:49 -07:00
|
|
|
const [bp1, bp2, bp3] = yield promise.all([
|
|
|
|
setBreakpoint({
|
|
|
|
url: CODE_URL,
|
2014-03-15 18:48:55 -07:00
|
|
|
line: 3
|
2014-03-11 09:42:49 -07:00
|
|
|
}),
|
|
|
|
setBreakpoint({
|
|
|
|
url: CODE_URL,
|
2014-03-15 18:48:55 -07:00
|
|
|
line: 4
|
2014-03-11 09:42:49 -07:00
|
|
|
}),
|
|
|
|
setBreakpoint({
|
|
|
|
url: CODE_URL,
|
2014-03-15 18:48:55 -07:00
|
|
|
line: 5
|
2014-03-11 09:42:49 -07:00
|
|
|
})
|
|
|
|
]);
|
|
|
|
|
2014-03-15 18:48:55 -07:00
|
|
|
// Refresh and hit the debugger statement again.
|
2014-03-11 09:42:49 -07:00
|
|
|
yield promise.all([
|
|
|
|
reloadActiveTab(gPanel, gEvents.SOURCE_SHOWN),
|
2014-03-15 18:48:55 -07:00
|
|
|
waitForCaretAndScopes(gPanel, 1)
|
2014-03-11 09:42:49 -07:00
|
|
|
]);
|
|
|
|
|
2014-03-15 18:48:55 -07:00
|
|
|
// And we should hit the breakpoints as we resume.
|
|
|
|
yield promise.all([
|
2014-04-24 10:09:00 -07:00
|
|
|
doResume(gPanel),
|
2014-03-15 18:48:55 -07:00
|
|
|
waitForCaretAndScopes(gPanel, 3)
|
|
|
|
]);
|
2014-03-11 09:42:49 -07:00
|
|
|
yield promise.all([
|
2014-04-24 10:09:00 -07:00
|
|
|
doResume(gPanel),
|
2014-03-15 18:48:55 -07:00
|
|
|
waitForCaretAndScopes(gPanel, 4)
|
2014-03-11 09:42:49 -07:00
|
|
|
]);
|
|
|
|
yield promise.all([
|
2014-04-24 10:09:00 -07:00
|
|
|
doResume(gPanel),
|
2014-03-15 18:48:55 -07:00
|
|
|
waitForCaretAndScopes(gPanel, 5)
|
2014-03-11 09:42:49 -07:00
|
|
|
]);
|
|
|
|
|
|
|
|
// Clean up the breakpoints.
|
|
|
|
yield promise.all([
|
|
|
|
rdpInvoke(bp1, bp1.remove),
|
|
|
|
rdpInvoke(bp2, bp1.remove),
|
|
|
|
rdpInvoke(bp3, bp1.remove),
|
|
|
|
]);
|
|
|
|
|
|
|
|
yield resumeDebuggerThenCloseAndFinish(gPanel);
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
DevToolsUtils.reportException(
|
|
|
|
"browser_dbg_breakpoints-break-on-last-line-of-script-on-reload.js",
|
|
|
|
e
|
|
|
|
);
|
|
|
|
ok(false);
|
|
|
|
}
|
2014-03-07 11:06:28 -08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-03-11 09:42:49 -07:00
|
|
|
function setBreakpoint(location) {
|
|
|
|
let deferred = promise.defer();
|
|
|
|
gThreadClient.setBreakpoint(location, ({ error, message }, bpClient) => {
|
|
|
|
if (error) {
|
|
|
|
deferred.reject(error + ": " + message);
|
|
|
|
}
|
|
|
|
deferred.resolve(bpClient);
|
|
|
|
});
|
|
|
|
return deferred.promise;
|
|
|
|
}
|
2014-03-07 11:06:28 -08:00
|
|
|
}
|