Bug 1682757 - [marionette] Register MarionetteEventsActor globally. r=marionette-reviewers,jgraham

To not miss certain events the event actor has to stay registered
throughout the whole lifetime of the session.

Differential Revision: https://phabricator.services.mozilla.com/D99884
This commit is contained in:
Henrik Skupin 2020-12-16 16:31:10 +00:00
Родитель 5c6194a73d
Коммит d1940ce560
3 изменённых файлов: 6 добавлений и 14 удалений

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

@ -51,12 +51,16 @@ XPCOMUtils.defineLazyModuleGetters(this, {
reftest: "chrome://marionette/content/reftest.js", reftest: "chrome://marionette/content/reftest.js",
registerCommandsActor: registerCommandsActor:
"chrome://marionette/content/actors/MarionetteCommandsParent.jsm", "chrome://marionette/content/actors/MarionetteCommandsParent.jsm",
registerEventsActor:
"chrome://marionette/content/actors/MarionetteEventsParent.jsm",
Sandboxes: "chrome://marionette/content/evaluate.js", Sandboxes: "chrome://marionette/content/evaluate.js",
TimedPromise: "chrome://marionette/content/sync.js", TimedPromise: "chrome://marionette/content/sync.js",
Timeouts: "chrome://marionette/content/capabilities.js", Timeouts: "chrome://marionette/content/capabilities.js",
UnhandledPromptBehavior: "chrome://marionette/content/capabilities.js", UnhandledPromptBehavior: "chrome://marionette/content/capabilities.js",
unregisterCommandsActor: unregisterCommandsActor:
"chrome://marionette/content/actors/MarionetteCommandsParent.jsm", "chrome://marionette/content/actors/MarionetteCommandsParent.jsm",
unregisterEventsActor:
"chrome://marionette/content/actors/MarionetteEventsParent.jsm",
waitForEvent: "chrome://marionette/content/sync.js", waitForEvent: "chrome://marionette/content/sync.js",
waitForLoadEvent: "chrome://marionette/content/sync.js", waitForLoadEvent: "chrome://marionette/content/sync.js",
waitForObserverTopic: "chrome://marionette/content/sync.js", waitForObserverTopic: "chrome://marionette/content/sync.js",
@ -888,6 +892,7 @@ GeckoDriver.prototype.newSession = async function(cmd) {
if (MarionettePrefs.useActors) { if (MarionettePrefs.useActors) {
registerCommandsActor(); registerCommandsActor();
registerEventsActor();
} }
if (this.mainFrame) { if (this.mainFrame) {
@ -3087,6 +3092,7 @@ GeckoDriver.prototype.deleteSession = function() {
clearActionInputState(); clearActionInputState();
unregisterCommandsActor(); unregisterCommandsActor();
unregisterEventsActor();
} }
// reset to the top-most frame, and clear browsing context references // reset to the top-most frame, and clear browsing context references

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

@ -19,12 +19,8 @@ XPCOMUtils.defineLazyModuleGetters(this, {
MarionettePrefs: "chrome://marionette/content/prefs.js", MarionettePrefs: "chrome://marionette/content/prefs.js",
modal: "chrome://marionette/content/modal.js", modal: "chrome://marionette/content/modal.js",
PageLoadStrategy: "chrome://marionette/content/capabilities.js", PageLoadStrategy: "chrome://marionette/content/capabilities.js",
registerEventsActor:
"chrome://marionette/content/actors/MarionetteEventsParent.jsm",
TimedPromise: "chrome://marionette/content/sync.js", TimedPromise: "chrome://marionette/content/sync.js",
truncate: "chrome://marionette/content/format.js", truncate: "chrome://marionette/content/format.js",
unregisterEventsActor:
"chrome://marionette/content/actors/MarionetteEventsParent.jsm",
}); });
XPCOMUtils.defineLazyGetter(this, "logger", () => Log.get()); XPCOMUtils.defineLazyGetter(this, "logger", () => Log.get());
@ -355,8 +351,6 @@ navigate.waitForNavigationCompleted = async function waitForNavigationCompleted(
); );
if (MarionettePrefs.useActors) { if (MarionettePrefs.useActors) {
// Register the JSWindowActor pair for events as used by Marionette
registerEventsActor();
EventDispatcher.on("page-load", onNavigation); EventDispatcher.on("page-load", onNavigation);
} else { } else {
driver.mm.addMessageListener( driver.mm.addMessageListener(
@ -409,7 +403,6 @@ navigate.waitForNavigationCompleted = async function waitForNavigationCompleted(
if (MarionettePrefs.useActors) { if (MarionettePrefs.useActors) {
EventDispatcher.off("page-load", onNavigation); EventDispatcher.off("page-load", onNavigation);
unregisterEventsActor();
} else { } else {
driver.mm.removeMessageListener( driver.mm.removeMessageListener(
"Marionette:NavigationEvent", "Marionette:NavigationEvent",

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

@ -30,11 +30,7 @@ XPCOMUtils.defineLazyModuleGetters(this, {
EventDispatcher: EventDispatcher:
"chrome://marionette/content/actors/MarionetteEventsParent.jsm", "chrome://marionette/content/actors/MarionetteEventsParent.jsm",
Log: "chrome://marionette/content/log.js", Log: "chrome://marionette/content/log.js",
registerEventsActor:
"chrome://marionette/content/actors/MarionetteEventsParent.jsm",
truncate: "chrome://marionette/content/format.js", truncate: "chrome://marionette/content/format.js",
unregisterEventsActor:
"chrome://marionette/content/actors/MarionetteEventsParent.jsm",
}); });
XPCOMUtils.defineLazyGetter(this, "logger", () => Log.get()); XPCOMUtils.defineLazyGetter(this, "logger", () => Log.get());
@ -554,9 +550,6 @@ function waitForLoadEvent(eventName, browsingContextFn) {
} }
}; };
EventDispatcher.on("page-load", onPageLoad); EventDispatcher.on("page-load", onPageLoad);
registerEventsActor();
}).finally(() => {
unregisterEventsActor();
}); });
} }