Skip to content

Commit fe0a068

Browse files
committed
Fixing eager page loading strategy on refresh
1 parent 4203f10 commit fe0a068

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

java/client/test/org/openqa/selenium/PageLoadingTest.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,30 @@ public void testShouldNotWaitForResourcesWithEagerStrategy() {
9595
assertTrue("Took too long to load page: " + duration, duration < 5 * 1000);
9696
}
9797

98+
@Ignore(value = {CHROME, IE, OPERA, SAFARI, MARIONETTE, PHANTOMJS, HTMLUNIT})
99+
@NeedsLocalEnvironment
100+
@Test
101+
public void testShouldNotWaitForResourcesOnRefreshWithEagerStrategy() {
102+
initLocalDriver("unstable");
103+
104+
String slowPage = appServer.whereIs("slowLoadingResourcePage.html");
105+
106+
localDriver.get(slowPage);
107+
// We discard the element, but want a check to make sure the GET actually completed.
108+
localDriver.findElement(By.id("peas"));
109+
110+
long start = System.currentTimeMillis();
111+
localDriver.navigate().refresh();
112+
// We discard the element, but want a check to make sure the refresh actually completed.
113+
localDriver.findElement(By.id("peas"));
114+
long end = System.currentTimeMillis();
115+
// The slow loading resource on that page takes 6 seconds to return. If we
116+
// waited for it, our load time should be over 6 seconds.
117+
long duration = end - start;
118+
119+
assertTrue("Took too long to refresh page: " + duration, duration < 5 * 1000);
120+
}
121+
98122
@Test
99123
public void testShouldWaitForDocumentToBeLoaded() {
100124
driver.get(pages.simpleTestPage);

javascript/firefox-driver/js/firefoxDriver.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ FirefoxDriver.prototype.refresh = function(respond) {
672672
var browser = respond.session.getBrowser();
673673
browser.contentWindow.location.reload(true);
674674
// Wait for the reload to finish before sending the response.
675-
new WebLoadingListener(respond.session.getBrowser(), function(timedOut) {
675+
new WebLoadingListener(browser, function(timedOut) {
676676
// Reset to the top window.
677677
respond.session.setWindow(browser.contentWindow);
678678
if (timedOut) {
@@ -681,7 +681,7 @@ FirefoxDriver.prototype.refresh = function(respond) {
681681
} else {
682682
respond.send();
683683
}
684-
}, respond.session.getPageLoadTimeout());
684+
}, respond.session.getPageLoadTimeout(), browser.contentWindow);
685685
};
686686

687687

0 commit comments

Comments
 (0)