зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1754132 - Use WebProgressListener to detect navigation start when PageLoadStrategy is "none". r=webdriver-reviewers,whimboo,jdescottes
Differential Revision: https://phabricator.services.mozilla.com/D144814
This commit is contained in:
Родитель
ab57d9eaba
Коммит
7f163ba39c
|
@ -18,6 +18,7 @@ XPCOMUtils.defineLazyModuleGetters(this, {
|
|||
Log: "chrome://remote/content/shared/Log.jsm",
|
||||
modal: "chrome://remote/content/marionette/modal.js",
|
||||
PageLoadStrategy: "chrome://remote/content/shared/webdriver/Capabilities.jsm",
|
||||
ProgressListener: "chrome://remote/content/shared/Navigate.jsm",
|
||||
TimedPromise: "chrome://remote/content/marionette/sync.js",
|
||||
truncate: "chrome://remote/content/shared/Format.jsm",
|
||||
});
|
||||
|
@ -213,15 +214,35 @@ navigate.waitForNavigationCompleted = async function waitForNavigationCompleted(
|
|||
requireBeforeUnload = true,
|
||||
} = options;
|
||||
|
||||
const chromeWindow = browsingContextFn().topChromeWindow;
|
||||
const browsingContext = browsingContextFn();
|
||||
const chromeWindow = browsingContext.topChromeWindow;
|
||||
const pageLoadStrategy = driver.currentSession.pageLoadStrategy;
|
||||
|
||||
// Return immediately if no load event is expected
|
||||
if (!loadEventExpected || pageLoadStrategy === PageLoadStrategy.None) {
|
||||
if (!loadEventExpected) {
|
||||
await callback();
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
// When not waiting for page load events, do not return until the navigation has actually started.
|
||||
if (pageLoadStrategy === PageLoadStrategy.None) {
|
||||
const listener = new ProgressListener(browsingContext.webProgress, {
|
||||
resolveWhenStarted: true,
|
||||
waitForExplicitStart: true,
|
||||
});
|
||||
const navigated = listener.start();
|
||||
navigated.finally(() => {
|
||||
if (listener.isStarted) {
|
||||
listener.stop();
|
||||
}
|
||||
});
|
||||
|
||||
await callback();
|
||||
await navigated;
|
||||
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
let rejectNavigation;
|
||||
let resolveNavigation;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче