From 88538854d75b8fb1837d96412cfe766397681d29 Mon Sep 17 00:00:00 2001 From: Henrik Skupin Date: Tue, 19 Nov 2019 19:42:18 +0000 Subject: [PATCH] Bug 1597259 - [remote] Implement Page.setLifecycleEventsEnabled. r=remote-protocol-reviewers,maja_zf Differential Revision: https://phabricator.services.mozilla.com/D53826 --HG-- extra : moz-landing-system : lando --- remote/domains/content/Page.jsm | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/remote/domains/content/Page.jsm b/remote/domains/content/Page.jsm index 88b63c61ce38..52488cc9f243 100644 --- a/remote/domains/content/Page.jsm +++ b/remote/domains/content/Page.jsm @@ -23,12 +23,15 @@ const { class Page extends ContentProcessDomain { constructor(session) { super(session); + this.enabled = false; + this.lifecycleEnabled = false; this.onFrameNavigated = this.onFrameNavigated.bind(this); } destructor() { + this.setLifecycleEventsEnabled({ enabled: false }); this.disable(); super.destructor(); @@ -121,10 +124,22 @@ class Page extends ContentProcessDomain { }; } - setLifecycleEventsEnabled() {} addScriptToEvaluateOnNewDocument() {} createIsolatedWorld() {} + /** + * Controls whether page will emit lifecycle events. + * + * @param {Object} options + * @param {boolean} options.enabled + * If true, starts emitting lifecycle events. + */ + setLifecycleEventsEnabled(options) { + const { enabled } = options; + + this.lifecycleEnabled = enabled; + } + url() { return this.content.location.href; } @@ -158,7 +173,7 @@ class Page extends ContentProcessDomain { break; case "pagehide": - // Maybe better to bound to "Network.responseReceived" once implemented + // Maybe better to bound to "unload" once we can register for this event this.emit("Page.frameStartedLoading", { frameId }); break;