зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1675320 - [marionette] Add register/unregisterEventsActor helpers to MarionetteEventsParent r=marionette-reviewers,whimboo
Expose the boilerplate code to register the MarionetteEventsActor to later reuse it from driver.js Differential Revision: https://phabricator.services.mozilla.com/D96117
This commit is contained in:
Родитель
c5072b6139
Коммит
30c0f10791
|
@ -4,7 +4,12 @@
|
|||
|
||||
("use strict");
|
||||
|
||||
const EXPORTED_SYMBOLS = ["EventDispatcher", "MarionetteEventsParent"];
|
||||
const EXPORTED_SYMBOLS = [
|
||||
"EventDispatcher",
|
||||
"MarionetteEventsParent",
|
||||
"registerEventsActor",
|
||||
"unregisterEventsActor",
|
||||
];
|
||||
|
||||
const { XPCOMUtils } = ChromeUtils.import(
|
||||
"resource://gre/modules/XPCOMUtils.jsm"
|
||||
|
@ -36,3 +41,36 @@ class MarionetteEventsParent extends JSWindowActorParent {
|
|||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register Events actors to listen for page load events via EventDispatcher.
|
||||
*/
|
||||
function registerEventsActor() {
|
||||
// Register the JSWindowActor pair for events as used by Marionette
|
||||
ChromeUtils.registerWindowActor("MarionetteEvents", {
|
||||
kind: "JSWindowActor",
|
||||
parent: {
|
||||
moduleURI:
|
||||
"chrome://marionette/content/actors/MarionetteEventsParent.jsm",
|
||||
},
|
||||
child: {
|
||||
moduleURI: "chrome://marionette/content/actors/MarionetteEventsChild.jsm",
|
||||
events: {
|
||||
beforeunload: { capture: true },
|
||||
DOMContentLoaded: { mozSystemGroup: true },
|
||||
hashchange: { mozSystemGroup: true },
|
||||
pagehide: { mozSystemGroup: true },
|
||||
pageshow: { mozSystemGroup: true },
|
||||
// popstate doesn't bubble, as such use capturing phase
|
||||
popstate: { capture: true, mozSystemGroup: true },
|
||||
},
|
||||
},
|
||||
|
||||
allFrames: true,
|
||||
includeChrome: true,
|
||||
});
|
||||
}
|
||||
|
||||
function unregisterEventsActor() {
|
||||
ChromeUtils.unregisterWindowActor("MarionetteEvents");
|
||||
}
|
||||
|
|
|
@ -19,8 +19,12 @@ 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());
|
||||
|
@ -330,30 +334,7 @@ navigate.waitForNavigationCompleted = async function waitForNavigationCompleted(
|
|||
|
||||
if (MarionettePrefs.useActors) {
|
||||
// Register the JSWindowActor pair for events as used by Marionette
|
||||
ChromeUtils.registerWindowActor("MarionetteEvents", {
|
||||
kind: "JSWindowActor",
|
||||
parent: {
|
||||
moduleURI:
|
||||
"chrome://marionette/content/actors/MarionetteEventsParent.jsm",
|
||||
},
|
||||
child: {
|
||||
moduleURI:
|
||||
"chrome://marionette/content/actors/MarionetteEventsChild.jsm",
|
||||
events: {
|
||||
beforeunload: { capture: true },
|
||||
DOMContentLoaded: { mozSystemGroup: true },
|
||||
hashchange: { mozSystemGroup: true },
|
||||
pagehide: { mozSystemGroup: true },
|
||||
pageshow: { mozSystemGroup: true },
|
||||
// popstate doesn't bubble, as such use capturing phase
|
||||
popstate: { capture: true, mozSystemGroup: true },
|
||||
},
|
||||
},
|
||||
|
||||
allFrames: true,
|
||||
includeChrome: true,
|
||||
});
|
||||
|
||||
registerEventsActor();
|
||||
EventDispatcher.on("page-load", onNavigation);
|
||||
} else {
|
||||
driver.mm.addMessageListener(
|
||||
|
@ -406,7 +387,7 @@ navigate.waitForNavigationCompleted = async function waitForNavigationCompleted(
|
|||
|
||||
if (MarionettePrefs.useActors) {
|
||||
EventDispatcher.off("page-load", onNavigation);
|
||||
ChromeUtils.unregisterWindowActor("MarionetteEvents");
|
||||
unregisterEventsActor();
|
||||
} else {
|
||||
driver.mm.removeMessageListener(
|
||||
"Marionette:NavigationEvent",
|
||||
|
|
Загрузка…
Ссылка в новой задаче