mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1438697 - Add inFrameSwap property on page transition. r=mrbkap
During a frame swap (using the `swapFrameLoaders` API on a frame loader owner), we dispatch `pagehide` events before swapping and `pageshow` events after swapping. For some consumers that watch these events (such as DevTools), it would be helpful to filter out the ones that sent because of frame swapping. This change adds a chrome-only `inFrameSwap` property to such events so that we can tell them apart. MozReview-Commit-ID: QzIDuaF2zC --HG-- extra : rebase_source : 3ac15e34c18b648c4cb060e69587e39e4ebaab60
This commit is contained in:
parent
467ed67c74
commit
bbd75cba2e
@ -8451,6 +8451,9 @@ nsDocument::DispatchPageTransition(EventTarget* aDispatchTarget,
|
||||
init.mCancelable = true;
|
||||
init.mPersisted = aPersisted;
|
||||
|
||||
nsDocShell* docShell = mDocumentContainer.get();
|
||||
init.mInFrameSwap = docShell && docShell->InFrameSwap();
|
||||
|
||||
RefPtr<PageTransitionEvent> event =
|
||||
PageTransitionEvent::Constructor(this, aType, init);
|
||||
|
||||
|
@ -121,6 +121,9 @@ Test swapFrameLoaders with different frame types and remoteness
|
||||
running: exists && !this.api._shuttingDown,
|
||||
});
|
||||
});
|
||||
addEventListener("pagehide", function({ inFrameSwap }) {
|
||||
sendAsyncMessage("pagehide", inFrameSwap);
|
||||
});
|
||||
}`;
|
||||
}
|
||||
|
||||
@ -169,9 +172,17 @@ Test swapFrameLoaders with different frame types and remoteness
|
||||
let mmA = frameA.frameLoader.messageManager;
|
||||
let mmB = frameB.frameLoader.messageManager;
|
||||
|
||||
let pagehideA = once(mmA, "pagehide");
|
||||
let pagehideB = once(mmB, "pagehide");
|
||||
|
||||
info("swapFrameLoaders");
|
||||
frameA.swapFrameLoaders(frameB);
|
||||
|
||||
let [ { data: inFrameSwapA } ] = await pagehideA;
|
||||
ok(inFrameSwapA, "Frame A got pagehide with inFrameSwap: true");
|
||||
let [ { data: inFrameSwapB } ] = await pagehideB;
|
||||
ok(inFrameSwapB, "Frame B got pagehide with inFrameSwap: true");
|
||||
|
||||
let inflightA = once(mmA, "pong");
|
||||
let inflightB = once(mmB, "pong");
|
||||
|
||||
|
@ -19,9 +19,14 @@ interface PageTransitionEvent : Event
|
||||
* session history, |persisted| is true for the PageHide event.
|
||||
*/
|
||||
readonly attribute boolean persisted;
|
||||
|
||||
// Whether the document is in the middle of a frame swap.
|
||||
[ChromeOnly]
|
||||
readonly attribute boolean inFrameSwap;
|
||||
};
|
||||
|
||||
dictionary PageTransitionEventInit : EventInit
|
||||
{
|
||||
boolean persisted = false;
|
||||
boolean inFrameSwap = false;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user