зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1695929 - [devtools] Remove redundant TargetFrontMixin's close event, in favor of target-destroyed. r=jdescottes,nchevobbe
This is mostly used by tests and we do not really benefit from having two distinct events. We are not using the fact that close is emitted immediately. Differential Revision: https://phabricator.services.mozilla.com/D107062
This commit is contained in:
Родитель
096363c840
Коммит
e2b9d85ac5
|
@ -358,7 +358,7 @@ var gDevToolsBrowser = (exports.gDevToolsBrowser = {
|
|||
// Ensure closing the connection in order to cleanup
|
||||
// the devtools client and also the server created in the
|
||||
// content process
|
||||
target.on("close", () => {
|
||||
target.on("target-destroyed", () => {
|
||||
client.close();
|
||||
});
|
||||
return target;
|
||||
|
|
|
@ -47,7 +47,7 @@ exports.TabTargetFactory = {
|
|||
target = await promise;
|
||||
// Then replace the promise with the target object
|
||||
targets.set(tab, target);
|
||||
target.once("close", () => {
|
||||
target.once("target-destroyed", () => {
|
||||
targets.delete(tab);
|
||||
});
|
||||
return target;
|
||||
|
@ -107,10 +107,8 @@ exports.TabTargetFactory = {
|
|||
},
|
||||
|
||||
/**
|
||||
* Creating a target for a tab that is being closed is a problem because it
|
||||
* allows a leak as a result of coming after the close event which normally
|
||||
* clears things up. This function allows us to ask if there is a known
|
||||
* target for a tab without creating a target
|
||||
* This function allows us to ask if there is a known
|
||||
* target for a tab without creating a target.
|
||||
* @return true/false
|
||||
*/
|
||||
isKnownTab: function(tab) {
|
||||
|
|
|
@ -18,8 +18,8 @@ add_task(async function() {
|
|||
await navigate;
|
||||
ok(true, "navigate event received");
|
||||
|
||||
const close = once(target, "close");
|
||||
const onTargetDestroyed = once(target, "target-destroyed");
|
||||
gBrowser.removeCurrentTab();
|
||||
await close;
|
||||
ok(true, "close event received");
|
||||
await onTargetDestroyed;
|
||||
ok(true, "target destroyed received");
|
||||
});
|
||||
|
|
|
@ -6,8 +6,8 @@ function test() {
|
|||
waitForExplicitFinish();
|
||||
|
||||
getParentProcessActors((client, target) => {
|
||||
target.on("close", () => {
|
||||
ok(true, "Target was closed");
|
||||
target.on("target-destroyed", () => {
|
||||
ok(true, "Target was destroyed");
|
||||
finish();
|
||||
});
|
||||
client.close();
|
||||
|
|
|
@ -39,8 +39,8 @@ function test() {
|
|||
}
|
||||
|
||||
function close(target, client) {
|
||||
target.on("close", () => {
|
||||
ok(true, "Target was closed");
|
||||
target.on("target-destroyed", () => {
|
||||
ok(true, "Target was destroyed");
|
||||
finish();
|
||||
});
|
||||
client.close();
|
||||
|
|
|
@ -139,14 +139,14 @@ async function initToolbox(url, host) {
|
|||
|
||||
// Display an error page if we are connected to a remote target and we lose it
|
||||
const onTargetDestroyed = function() {
|
||||
target.off("close", onTargetDestroyed);
|
||||
target.off("target-destroyed", onTargetDestroyed);
|
||||
// Prevent trying to display the error page if the toolbox tab is being destroyed
|
||||
if (host.contentDocument) {
|
||||
const error = new Error("Debug target was disconnected");
|
||||
showErrorPage(host.contentDocument, `${error}`);
|
||||
}
|
||||
};
|
||||
target.on("close", onTargetDestroyed);
|
||||
target.on("target-destroyed", onTargetDestroyed);
|
||||
|
||||
const options = { customIframe: host };
|
||||
await gDevTools.showToolbox(target, tool, Toolbox.HostType.PAGE, options);
|
||||
|
|
|
@ -611,9 +611,6 @@ function TargetMixin(parentClass) {
|
|||
}
|
||||
|
||||
async _destroyTarget() {
|
||||
// Before taking any action, notify listeners that destruction is imminent.
|
||||
this.emit("close");
|
||||
|
||||
// If the target is being attached, try to wait until it's done, to prevent having
|
||||
// pending connection to the server when the toolbox is destroyed.
|
||||
if (this._onThreadInitialized) {
|
||||
|
|
|
@ -16,7 +16,7 @@ add_task(async () => {
|
|||
const target = await createAndAttachTargetForTab(tab);
|
||||
|
||||
await testNavigate(target);
|
||||
await testDetach(target);
|
||||
await testTargetDestroyed(target);
|
||||
});
|
||||
|
||||
function testNavigate(target) {
|
||||
|
@ -45,10 +45,10 @@ function testNavigate(target) {
|
|||
});
|
||||
}
|
||||
|
||||
async function testDetach(target) {
|
||||
async function testTargetDestroyed(target) {
|
||||
// We can't listen for tabDetached at it is received by Target first
|
||||
// and target is destroyed
|
||||
const onDetached = target.once("close");
|
||||
const onDetached = target.once("target-destroyed");
|
||||
|
||||
removeTab(gBrowser.selectedTab);
|
||||
|
||||
|
|
|
@ -100,9 +100,7 @@ add_task(async function test_webextension_addon_debugging_reload() {
|
|||
// is finally uninstalled.
|
||||
|
||||
const {client} = addonTarget;
|
||||
const waitDebuggingClientClosed = new Promise(resolve => {
|
||||
addonTarget.once("close", resolve);
|
||||
});
|
||||
const waitDebuggingClientClosed = addonTarget.once("target-destroyed");
|
||||
|
||||
const waitShutdown = promiseWebExtensionShutdown();
|
||||
addon.uninstall();
|
||||
|
|
Загрузка…
Ссылка в новой задаче