Bug 1739369 - [marionette] Improve logging for load events in waitForLoadEvent. r=webdriver-reviewers,jdescottes

Differential Revision: https://phabricator.services.mozilla.com/D130353
This commit is contained in:
Henrik Skupin 2021-11-04 19:15:37 +00:00
parent 6d87d7f287
commit 8e2ddef4de

View File

@ -30,6 +30,7 @@ XPCOMUtils.defineLazyModuleGetters(this, {
EventDispatcher:
"chrome://remote/content/marionette/actors/MarionetteEventsParent.jsm",
Log: "chrome://remote/content/shared/Log.jsm",
truncate: "chrome://remote/content/shared/Format.jsm",
});
XPCOMUtils.defineLazyGetter(this, "logger", () =>
@ -547,11 +548,16 @@ function waitForLoadEvent(eventName, browsingContextFn) {
let onPageLoad;
return new Promise(resolve => {
onPageLoad = (_, data) => {
logger.trace(`Received event ${data.type} for ${data.documentURI}`);
if (
data.browsingContext === browsingContextFn() &&
data.type === eventName
) {
// Ignore load events from other browsing contexts
if (data.browsingContext !== browsingContextFn()) {
return;
}
logger.trace(
truncate`[${data.browsingContext.id}] Received event ${data.type} for ${data.documentURI}`
);
if (data.type === eventName) {
EventDispatcher.off("page-load", onPageLoad);
resolve(data);
}