mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-17 07:15:46 +00:00
Bug 717749 - Part 3: Terminate instead of resume debuggee script on tab closure. (r=past)
This commit is contained in:
parent
48684ab5b7
commit
8f91f2c8db
@ -78,6 +78,7 @@ support-files =
|
||||
doc_script-switching-01.html
|
||||
doc_script-switching-02.html
|
||||
doc_step-out.html
|
||||
doc_terminate-on-tab-close.html
|
||||
doc_tracing-01.html
|
||||
doc_watch-expressions.html
|
||||
doc_watch-expression-button.html
|
||||
@ -237,6 +238,7 @@ skip-if = true # Bug 933950 (leaky test)
|
||||
[browser_dbg_step-out.js]
|
||||
[browser_dbg_tabactor-01.js]
|
||||
[browser_dbg_tabactor-02.js]
|
||||
[browser_dbg_terminate-on-tab-close.js]
|
||||
[browser_dbg_tracing-01.js]
|
||||
[browser_dbg_tracing-02.js]
|
||||
[browser_dbg_tracing-03.js]
|
||||
|
@ -0,0 +1,38 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/**
|
||||
* Tests that debuggee scripts are terminated on tab closure.
|
||||
*/
|
||||
|
||||
const TAB_URL = EXAMPLE_URL + "doc_terminate-on-tab-close.html";
|
||||
|
||||
let gTab, gDebuggee, gDebugger, gPanel;
|
||||
|
||||
function test() {
|
||||
initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
|
||||
gTab = aTab;
|
||||
gDebuggee = aDebuggee;
|
||||
gPanel = aPanel;
|
||||
gDebugger = gPanel.panelWin;
|
||||
|
||||
testTerminate();
|
||||
});
|
||||
}
|
||||
|
||||
function testTerminate() {
|
||||
gDebugger.gThreadClient.addOneTimeListener("paused", () => {
|
||||
resumeDebuggerThenCloseAndFinish(gPanel).then(function () {
|
||||
ok(true, "should not throw after this point");
|
||||
});
|
||||
});
|
||||
|
||||
gDebuggee.debuggerThenThrow();
|
||||
}
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
gTab = null;
|
||||
gDebuggee = null;
|
||||
gPanel = null;
|
||||
gDebugger = null;
|
||||
});
|
@ -0,0 +1,20 @@
|
||||
<!-- 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 debuggerThenThrow() {
|
||||
debugger;
|
||||
throw "unreachable";
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
@ -509,6 +509,7 @@ function ThreadActor(aHooks, aGlobal)
|
||||
|
||||
this._gripDepth = 0;
|
||||
this._threadLifetimePool = null;
|
||||
this._tabClosed = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -887,7 +888,10 @@ ThreadActor.prototype = {
|
||||
reportError(e, "Got an exception during TA__pauseAndRespond: ");
|
||||
}
|
||||
|
||||
return undefined;
|
||||
// If the browser tab has been closed, terminate the debuggee script
|
||||
// instead of continuing. Executing JS after the content window is gone is
|
||||
// a bad idea.
|
||||
return this._tabClosed ? null : undefined;
|
||||
},
|
||||
|
||||
/**
|
||||
@ -1011,7 +1015,7 @@ ThreadActor.prototype = {
|
||||
// in to each function.
|
||||
const steppingHookState = {
|
||||
pauseAndRespond: (aFrame, onPacket=(k)=>k) => {
|
||||
this._pauseAndRespond(aFrame, { type: "resumeLimit" }, onPacket);
|
||||
return this._pauseAndRespond(aFrame, { type: "resumeLimit" }, onPacket);
|
||||
},
|
||||
createValueGrip: this.createValueGrip.bind(this),
|
||||
thread: this,
|
||||
|
@ -668,6 +668,12 @@ TabActor.prototype = {
|
||||
return;
|
||||
}
|
||||
|
||||
// Tell the thread actor that the tab is closed, so that it may terminate
|
||||
// instead of resuming the debuggee script.
|
||||
if (this._attached) {
|
||||
this.threadActor._tabClosed = true;
|
||||
}
|
||||
|
||||
if (this._detach()) {
|
||||
this.conn.send({ from: this.actorID,
|
||||
type: "tabDetached" });
|
||||
|
Loading…
Reference in New Issue
Block a user