Bug 1714508 - [devtools] Use DOCUMENT_EVENT will-navigate in debugger. r=nchevobbe,bomsy

Clearing debugger state from onTargetAvaible should be fine,
as soon as we do it immediately.
But doing it from DOCUMENT_EVENT will-navigate may help
if we get some debugger related resources while the target is still attaching on the client.
It should better ensure that state is cleared at the right time, the earliest right time.

Differential Revision: https://phabricator.services.mozilla.com/D116810
This commit is contained in:
Alexandre Poirot 2021-06-07 08:52:16 +00:00
Родитель d513570bae
Коммит d89225f30d
1 изменённых файлов: 3 добавлений и 11 удалений

Просмотреть файл

@ -110,11 +110,6 @@ async function onTargetAvailable({ targetFront, isTargetSwitching }) {
return;
}
// The will-navigate event will be missed when using target switching,
// however `navigate` corresponds more or less to the load event, so it
// should still be received on the new target.
actions.willNavigate({ url: targetFront.url });
// At this point, we expect the target and its thread to be attached.
const { threadFront } = targetFront;
if (!threadFront) {
@ -122,8 +117,6 @@ async function onTargetAvailable({ targetFront, isTargetSwitching }) {
return;
}
targetFront.on("will-navigate", actions.willNavigate);
await threadFront.reconfigure({
observeAsmJS: true,
pauseWorkersUntilAttach: true,
@ -142,9 +135,6 @@ async function onTargetAvailable({ targetFront, isTargetSwitching }) {
}
function onTargetDestroyed({ targetFront }) {
if (targetFront.isTopLevel) {
targetFront.off("will-navigate", actions.willNavigate);
}
actions.removeTarget(targetFront);
}
@ -178,7 +168,9 @@ async function onBreakpointAvailable(breakpoints) {
function onDocumentEventAvailable(events) {
for (const event of events) {
if (event.name == "dom-complete") {
if (event.name == "will-navigate") {
actions.willNavigate({ url: event.newURI });
} else if (event.name == "dom-complete") {
actions.navigated();
}
}