[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor-browser] 02/76: Bug 1736323 - [marionette] "WebDriver:NewSession" has to wait for the very first tab to finish loading. r=jdescottes, a=RyanVM
This is an automated email from the git hooks/post-receive script.
richard pushed a commit to branch tor-browser-91.8.0esr-11.0-1
in repository tor-browser.
commit dc541281fdef7c2033bcc663e2ad1492192c4785
Author: Henrik Skupin <mail@xxxxxxxxxxxx>
AuthorDate: Mon Feb 28 22:14:23 2022 +0100
Bug 1736323 - [marionette] "WebDriver:NewSession" has to wait for the very first tab to finish loading. r=jdescottes, a=RyanVM
---
remote/marionette/driver.js | 19 ++++++++++++++-----
remote/marionette/navigate.js | 8 +++++++-
.../marionette_harness/tests/unit/test_navigation.py | 16 ++++++++++++++++
3 files changed, 37 insertions(+), 6 deletions(-)
diff --git a/remote/marionette/driver.js b/remote/marionette/driver.js
index efa4f62d48ba3..9560b051752c5 100644
--- a/remote/marionette/driver.js
+++ b/remote/marionette/driver.js
@@ -564,20 +564,29 @@ GeckoDriver.prototype.newSession = async function(cmd) {
this.registerListenersForWindow(win);
}
+ // Setup observer for modal dialogs
+ this.dialogObserver = new modal.DialogObserver(() => this.curBrowser);
+ this.dialogObserver.add(this.handleModalDialog.bind(this));
+
if (this.mainFrame) {
this.currentSession.chromeBrowsingContext = this.mainFrame.browsingContext;
this.mainFrame.focus();
}
if (this.curBrowser.tab) {
- this.currentSession.contentBrowsingContext = this.curBrowser.contentBrowser.browsingContext;
+ const browsingContext = this.curBrowser.contentBrowser.browsingContext;
+ this.currentSession.contentBrowsingContext = browsingContext;
+ // If the currently selected tab is loading, wait until it's done.
+ if (browsingContext.webProgress.isLoadingDocument) {
+ await navigate.waitForNavigationCompleted(this, () => {}, {
+ loadEventExpected: true,
+ unknownState: true,
+ });
+ }
+
this.curBrowser.contentBrowser.focus();
}
- // Setup observer for modal dialogs
- this.dialogObserver = new modal.DialogObserver(() => this.curBrowser);
- this.dialogObserver.add(this.handleModalDialog.bind(this));
-
// Check if there is already an open dialog for the selected browser window.
this.dialog = modal.findModalDialogs(this.curBrowser);
diff --git a/remote/marionette/navigate.js b/remote/marionette/navigate.js
index 50a0bce413d5a..dbb02b55fd43a 100644
--- a/remote/marionette/navigate.js
+++ b/remote/marionette/navigate.js
@@ -201,6 +201,9 @@ navigate.refresh = async function(browsingContext) {
* @param {boolean=} requireBeforeUnload
* If false and no beforeunload event is fired, abort waiting
* for the navigation. Defaults to true.
+ * @param {boolean=} unknownState
+ * Needs to be true if a navigation check is resumed and the current
+ * state of navigation is unknown. Defaults to false.
*/
navigate.waitForNavigationCompleted = async function waitForNavigationCompleted(
driver,
@@ -211,6 +214,7 @@ navigate.waitForNavigationCompleted = async function waitForNavigationCompleted(
browsingContextFn = driver.getBrowsingContext.bind(driver),
loadEventExpected = true,
requireBeforeUnload = true,
+ unknownState = false,
} = options;
const chromeWindow = browsingContextFn().topChromeWindow;
@@ -227,7 +231,9 @@ navigate.waitForNavigationCompleted = async function waitForNavigationCompleted(
let browsingContextChanged = false;
let seenBeforeUnload = false;
- let seenUnload = false;
+
+ // With an unknown state assume that unload has already been received.
+ let seenUnload = unknownState;
let unloadTimer;
diff --git a/testing/marionette/harness/marionette_harness/tests/unit/test_navigation.py b/testing/marionette/harness/marionette_harness/tests/unit/test_navigation.py
index 30aaac59c969a..63dd7fd4f6201 100644
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_navigation.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_navigation.py
@@ -858,6 +858,22 @@ class TestPageLoadStrategy(BaseNavigationTestCase):
)
self.marionette.find_element(By.ID, "slow")
+ def test_none_with_new_session_waits_for_page_loaded(self):
+ self.marionette.delete_session()
+ self.marionette.start_session({"pageLoadStrategy": "none"})
+
+ # Navigate will return immediately.
+ self.marionette.navigate(self.test_page_slow_resource)
+
+ # Make sure that when creating a new session right away it waits
+ # until the page has been finished loading.
+ self.marionette.delete_session()
+ self.marionette.start_session()
+
+ self.assertEqual(self.test_page_slow_resource, self.marionette.get_url())
+ self.assertEqual("complete", self.ready_state)
+ self.marionette.find_element(By.ID, "slow")
+
def test_eager(self):
self.marionette.delete_session()
self.marionette.start_session({"pageLoadStrategy": "eager"})
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits