Bug 1675820 - Part 7: Fix marionette BrowsingContext replace detection logic, r=whimboo,marionette-reviewers,farre

Differential Revision: https://phabricator.services.mozilla.com/D108866
This commit is contained in:
Nika Layzell 2021-03-18 19:24:51 +00:00
Родитель c733984c4b
Коммит d14469fe31
2 изменённых файлов: 13 добавлений и 6 удалений

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

@ -833,8 +833,14 @@ void BrowsingContext::Detach(bool aFromIPC) {
}
if (nsCOMPtr<nsIObserverService> obs = services::GetObserverService()) {
obs->NotifyObservers(ToSupports(this), "browsing-context-discarded",
nullptr);
// Why the context is being discarded. This will always be "discard" in the
// content process, but may be "replace" if it's known the context being
// replaced in the parent process.
const char16_t* why = u"discard";
if (XRE_IsParentProcess() && IsTop() && !Canonical()->GetWebProgress()) {
why = u"replace";
}
obs->NotifyObservers(ToSupports(this), "browsing-context-discarded", why);
}
// NOTE: Doesn't use SetClosed, as it will be set in all processes

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

@ -313,10 +313,11 @@ navigate.waitForNavigationCompleted = async function waitForNavigationCompleted(
// In the case when the currently selected frame is closed,
// there will be no further load events. Stop listening immediately.
const onBrowsingContextDiscarded = (subject, topic) => {
// With the currentWindowGlobal gone the browsing context hasn't been
// replaced due to a remoteness change but closed.
if (subject == browsingContextFn() && !subject.currentWindowGlobal) {
const onBrowsingContextDiscarded = (subject, topic, why) => {
// If the BrowsingContext is being discarded to be replaced by another
// context, we don't want to stop waiting for the pageload to complete, as
// we will continue listening to the newly created context.
if (subject == browsingContextFn() && why != "replace") {
logger.trace(
"Canceled page load listener " +
`because browsing context with id ${subject.id} has been removed`