diff --git a/testing/marionette/driver.js b/testing/marionette/driver.js index 9e75f3f75f47..7c5927e1c6f5 100644 --- a/testing/marionette/driver.js +++ b/testing/marionette/driver.js @@ -51,12 +51,16 @@ XPCOMUtils.defineLazyModuleGetters(this, { reftest: "chrome://marionette/content/reftest.js", registerCommandsActor: "chrome://marionette/content/actors/MarionetteCommandsParent.jsm", + registerEventsActor: + "chrome://marionette/content/actors/MarionetteEventsParent.jsm", Sandboxes: "chrome://marionette/content/evaluate.js", TimedPromise: "chrome://marionette/content/sync.js", Timeouts: "chrome://marionette/content/capabilities.js", UnhandledPromptBehavior: "chrome://marionette/content/capabilities.js", unregisterCommandsActor: "chrome://marionette/content/actors/MarionetteCommandsParent.jsm", + unregisterEventsActor: + "chrome://marionette/content/actors/MarionetteEventsParent.jsm", waitForEvent: "chrome://marionette/content/sync.js", waitForLoadEvent: "chrome://marionette/content/sync.js", waitForObserverTopic: "chrome://marionette/content/sync.js", @@ -888,6 +892,7 @@ GeckoDriver.prototype.newSession = async function(cmd) { if (MarionettePrefs.useActors) { registerCommandsActor(); + registerEventsActor(); } if (this.mainFrame) { @@ -3087,6 +3092,7 @@ GeckoDriver.prototype.deleteSession = function() { clearActionInputState(); unregisterCommandsActor(); + unregisterEventsActor(); } // reset to the top-most frame, and clear browsing context references diff --git a/testing/marionette/navigate.js b/testing/marionette/navigate.js index d58be87c4b72..4392045e9367 100644 --- a/testing/marionette/navigate.js +++ b/testing/marionette/navigate.js @@ -19,12 +19,8 @@ XPCOMUtils.defineLazyModuleGetters(this, { MarionettePrefs: "chrome://marionette/content/prefs.js", modal: "chrome://marionette/content/modal.js", PageLoadStrategy: "chrome://marionette/content/capabilities.js", - registerEventsActor: - "chrome://marionette/content/actors/MarionetteEventsParent.jsm", TimedPromise: "chrome://marionette/content/sync.js", truncate: "chrome://marionette/content/format.js", - unregisterEventsActor: - "chrome://marionette/content/actors/MarionetteEventsParent.jsm", }); XPCOMUtils.defineLazyGetter(this, "logger", () => Log.get()); @@ -355,8 +351,6 @@ navigate.waitForNavigationCompleted = async function waitForNavigationCompleted( ); if (MarionettePrefs.useActors) { - // Register the JSWindowActor pair for events as used by Marionette - registerEventsActor(); EventDispatcher.on("page-load", onNavigation); } else { driver.mm.addMessageListener( @@ -409,7 +403,6 @@ navigate.waitForNavigationCompleted = async function waitForNavigationCompleted( if (MarionettePrefs.useActors) { EventDispatcher.off("page-load", onNavigation); - unregisterEventsActor(); } else { driver.mm.removeMessageListener( "Marionette:NavigationEvent", diff --git a/testing/marionette/sync.js b/testing/marionette/sync.js index 40674fc5da4e..4b135809c2ac 100644 --- a/testing/marionette/sync.js +++ b/testing/marionette/sync.js @@ -30,11 +30,7 @@ XPCOMUtils.defineLazyModuleGetters(this, { EventDispatcher: "chrome://marionette/content/actors/MarionetteEventsParent.jsm", Log: "chrome://marionette/content/log.js", - registerEventsActor: - "chrome://marionette/content/actors/MarionetteEventsParent.jsm", truncate: "chrome://marionette/content/format.js", - unregisterEventsActor: - "chrome://marionette/content/actors/MarionetteEventsParent.jsm", }); XPCOMUtils.defineLazyGetter(this, "logger", () => Log.get()); @@ -554,9 +550,6 @@ function waitForLoadEvent(eventName, browsingContextFn) { } }; EventDispatcher.on("page-load", onPageLoad); - registerEventsActor(); - }).finally(() => { - unregisterEventsActor(); }); }