1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
4 export class DocShellHelpersParent extends JSWindowActorParent {
7 // These static variables should be set when registering the actor
8 // (currently doPageNavigation in docshell_helpers.js).
9 static eventsToListenFor;
15 receiveMessage({ name, data }) {
16 if (name == "docshell_helpers:event") {
17 let { event, originalTargetIsHTMLDocument } = data;
19 if (this.constructor.eventsToListenFor.includes(event.type)) {
20 this.constructor.eventListener(event, originalTargetIsHTMLDocument);
22 } else if (name == "docshell_helpers:observe") {
25 this.constructor.observers.get(topic).call();
30 export class DocShellHelpersChild extends JSWindowActorChild {
34 receiveMessage({ name }) {
35 if (name == "docshell_helpers:preventBFCache") {
36 // Add an RTCPeerConnection to prevent the page from being bfcached.
37 let win = this.contentWindow;
38 win.blockBFCache = new win.RTCPeerConnection();
43 Document.isInstance(event.originalTarget) &&
44 event.originalTarget.isInitialDocument
46 dump(`TEST: ignoring a ${event.type} event for an initial about:blank\n`);
50 this.sendAsyncMessage("docshell_helpers:event", {
53 persisted: event.persisted,
55 title: event.originalTarget.title,
56 location: event.originalTarget.location.href,
57 visibilityState: event.originalTarget.visibilityState,
58 hidden: event.originalTarget.hidden,
61 originalTargetIsHTMLDocument: HTMLDocument.isInstance(
66 observe(subject, topic) {
67 if (Window.isInstance(subject) && subject.document.isInitialDocument) {
68 dump(`TEST: ignoring a topic notification for an initial about:blank\n`);
72 this.sendAsyncMessage("docshell_helpers:observe", { topic });