* The formers JSWindow Actors used independently to create Target Actor for WindowGlobals, Web workers and Service workers are all unified behind a single JSProcess Actor pair which was only used to create target actors for DOM Content Processes. * The DevToolsProcess JSProcess actor now actively monitor the currently watched target types in order to start and stop listeners specific to each target type. We no longer rely on JSWindow Actors to observe WindowGlobal instantiations. * `watchedByDevTools` is now consistantly set from each WindowGlobal's content process, via the WindowGlobalTargetActor. With the new setup, the parent process no longer track WindowGlobal/BrowsingContext's and so there is no natural place to flag them. While, in the content process, the target actor is an obvious place. There is just one trick in window global target watcher in order to also set this flag on initial about blank documents. * `browser-element-host` Session Data is now slightly more simple. It works like any other similar session data attribute. But we have to ignore any pending exception coming up from updateDomainSessionDataForServiceWorkers call as that be still pending while the toolbox closes, which make the JS Process Actor be unregistered, and ultimately make the underlying sendQuery promise be rejected. * The `loader` is made specific to each Watcher/connection and put in the connections map, so that we can better support content toolbox & browser toolbox usecases and we have a unique place to define the loader per watcher/connection. * browser_target_command_detach.js: detach is no longer enough. It wouldn't stop watching and prevent the re-instantiation of the target actor. We now have to stop watching for targets. This actually better match what happens on toolbox closing. This test was meant as a unit test for covering remote debugging reusing the same DevToolsClient for debugger the same tab. * `browser_toolbox_watchedByDevTools`. The management of watchedByDevTools is now driven from the content process. And because the DevTools Server and especially the watcher actor is destroyed without an explicit RDP request that the toolbox destruction is waiting for, we can't rely on closeToolbox to know when the server is fully cleaned up. Differential Revision: https://phabricator.services.mozilla.com/D203409
60 lines
1.9 KiB
JavaScript
60 lines
1.9 KiB
JavaScript
/* Any copyright is dedicated to the Public Domain.
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
"use strict";
|
|
|
|
// Test the TargetCommand's when detaching the top target
|
|
//
|
|
// Do this with the "remote tab" codepath, which will avoid
|
|
// destroying the DevToolsClient when the target is destroyed.
|
|
// Otherwise, with "local tab", the client is closed and everything is destroy
|
|
// on both client and server side.
|
|
|
|
const TEST_URL = "data:text/html,test-page";
|
|
|
|
add_task(async function () {
|
|
info(" ### Test detaching the top target");
|
|
|
|
// Create a TargetCommand for a given test tab
|
|
const tab = await addTab(TEST_URL);
|
|
|
|
info("Create a first commands, which will destroy its top target");
|
|
const commands = await CommandsFactory.forRemoteTab(
|
|
tab.linkedBrowser.browserId
|
|
);
|
|
const targetCommand = commands.targetCommand;
|
|
|
|
// We have to start listening in order to ensure having a targetFront available
|
|
await targetCommand.startListening();
|
|
|
|
info("Call any target front method, to ensure it works fine");
|
|
await targetCommand.targetFront.focus();
|
|
|
|
// Simulate a toolbox closing by the cleanup of TargetCommand.
|
|
// This will stop watching for all target types and destroy all target actors/fronts.
|
|
await targetCommand.stopListening();
|
|
|
|
info(
|
|
"Now create a second commands after destroy, to see if we can spawn a new, functional target"
|
|
);
|
|
const secondCommands = await CommandsFactory.forRemoteTab(
|
|
tab.linkedBrowser.browserId,
|
|
{
|
|
client: commands.client,
|
|
}
|
|
);
|
|
const secondTargetCommand = secondCommands.targetCommand;
|
|
|
|
// We have to start listening in order to ensure having a targetFront available
|
|
await secondTargetCommand.startListening();
|
|
|
|
info("Call any target front method, to ensure it works fine");
|
|
await secondTargetCommand.targetFront.focus();
|
|
|
|
BrowserTestUtils.removeTab(tab);
|
|
|
|
info("Close the two commands");
|
|
await commands.destroy();
|
|
await secondCommands.destroy();
|
|
});
|