Skip to content
Permalink
Browse files
document.open() should abort all loads when the document is navigating
https://bugs.webkit.org/show_bug.cgi?id=245407

Reviewed by Youenn Fablet.

document.open() should abort all loads when the document is navigating or there is a queued navigation:
- whatwg/html#3975

This aligns our behavior with Blink and Gecko, as they already already passing those WPT tests.

* LayoutTests/TestExpectations:
* LayoutTests/imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/abort-refresh-immediate.window-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/abort-while-navigating.window-expected.txt:
* Source/WebCore/dom/Document.cpp:
(WebCore::Document::open):
* Source/WebCore/loader/NavigationScheduler.cpp:
(WebCore::NavigationScheduler::hasQueuedNavigation const):
* Source/WebCore/loader/NavigationScheduler.h:

Canonical link: https://commits.webkit.org/254699@main
  • Loading branch information
cdumez committed Sep 20, 2022
1 parent bef8dea commit 952f3c7c8ab8baa4279db4a804712201c998c389
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 20 deletions.
@@ -376,8 +376,6 @@ imported/w3c/web-platform-tests/service-workers/service-worker/update-bytecheck.
imported/w3c/web-platform-tests/service-workers/service-worker/clients-matchall-include-uncontrolled.https.html [ Skip ]

# Skip html/webappapis that are timing out.
imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/abort-refresh-immediate.window.html [ Skip ]
imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/abort-while-navigating.window.html [ Skip ]
imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/bailout-exception-vs-return-xml.window.html [ Skip ]
imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/ignore-opens-during-unload.window.html [ Skip ]
imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/tasks.window.html [ Skip ]
@@ -1,10 +1,8 @@

Harness Error (TIMEOUT), message = null

TIMEOUT document.open() aborts documents that are queued for navigation through <meta> refresh with timeout 0 (XMLHttpRequest) Test timed out
FAIL document.open() aborts documents that are queued for navigation through <meta> refresh with timeout 0 (fetch()) assert_unreached: Fetch should have been aborted Reached unreachable code
PASS document.open() aborts documents that are queued for navigation through <meta> refresh with timeout 0 (XMLHttpRequest)
PASS document.open() aborts documents that are queued for navigation through <meta> refresh with timeout 0 (fetch())
PASS document.open() aborts documents that are queued for navigation through <meta> refresh with timeout 0 (image loading)
TIMEOUT document.open() aborts documents that are queued for navigation through Refresh header with timeout 0 (XMLHttpRequest) Test timed out
FAIL document.open() aborts documents that are queued for navigation through Refresh header with timeout 0 (fetch()) assert_unreached: Fetch should have been aborted Reached unreachable code
PASS document.open() aborts documents that are queued for navigation through Refresh header with timeout 0 (XMLHttpRequest)
PASS document.open() aborts documents that are queued for navigation through Refresh header with timeout 0 (fetch())
PASS document.open() aborts documents that are queued for navigation through Refresh header with timeout 0 (image loading)

@@ -1,13 +1,11 @@

Harness Error (TIMEOUT), message = null

TIMEOUT document.open() aborts documents that are navigating through Location (XMLHttpRequest) Test timed out
FAIL document.open() aborts documents that are navigating through Location (fetch()) assert_unreached: Fetch should have been aborted Reached unreachable code
FAIL document.open() aborts documents that are navigating through Location (image loading) assert_unreached: Image loading should not have succeeded Reached unreachable code
TIMEOUT document.open() aborts documents that are navigating through iframe loading (XMLHttpRequest) Test timed out
FAIL document.open() aborts documents that are navigating through iframe loading (fetch()) assert_unreached: Fetch should have been aborted Reached unreachable code
FAIL document.open() aborts documents that are navigating through iframe loading (image loading) assert_unreached: Image loading should not have succeeded Reached unreachable code
TIMEOUT document.open() aborts documents that are queued for navigation through .click() (XMLHttpRequest) Test timed out
FAIL document.open() aborts documents that are queued for navigation through .click() (fetch()) assert_unreached: Fetch should have been aborted Reached unreachable code
FAIL document.open() aborts documents that are queued for navigation through .click() (image loading) assert_unreached: Image loading should not have succeeded Reached unreachable code
PASS document.open() aborts documents that are navigating through Location (XMLHttpRequest)
PASS document.open() aborts documents that are navigating through Location (fetch())
PASS document.open() aborts documents that are navigating through Location (image loading)
PASS document.open() aborts documents that are navigating through iframe loading (XMLHttpRequest)
PASS document.open() aborts documents that are navigating through iframe loading (fetch())
PASS document.open() aborts documents that are navigating through iframe loading (image loading)
PASS document.open() aborts documents that are queued for navigation through .click() (XMLHttpRequest)
PASS document.open() aborts documents that are queued for navigation through .click() (fetch())
PASS document.open() aborts documents that are queued for navigation through .click() (image loading)

@@ -0,0 +1,16 @@
CONSOLE MESSAGE: XMLHttpRequest cannot load http://localhost:8800/common/blank.html due to access control checks.
CONSOLE MESSAGE: Fetch API cannot load http://localhost:8800/common/blank.html due to access control checks.

Harness Error (TIMEOUT), message = null

PASS document.open() aborts documents that are navigating through Location (XMLHttpRequest)
PASS document.open() aborts documents that are navigating through Location (fetch())
PASS document.open() aborts documents that are navigating through Location (image loading)
TIMEOUT document.open() aborts documents that are navigating through iframe loading (XMLHttpRequest) Test timed out
PASS document.open() aborts documents that are navigating through iframe loading (fetch())
PASS document.open() aborts documents that are navigating through iframe loading (image loading)
PASS document.open() aborts documents that are queued for navigation through .click() (XMLHttpRequest)
PASS document.open() aborts documents that are queued for navigation through .click() (fetch())
PASS document.open() aborts documents that are queued for navigation through .click() (image loading)


@@ -3019,9 +3019,10 @@ ExceptionOr<void> Document::open(Document* entryDocument)
}
}

bool isNavigating = m_frame->loader().policyChecker().delegateIsDecidingNavigationPolicy() || m_frame->loader().state() == FrameState::Provisional || m_frame->navigationScheduler().hasQueuedNavigation();
if (m_frame->loader().policyChecker().delegateIsDecidingNavigationPolicy())
m_frame->loader().policyChecker().stopCheck();
if (m_frame && m_frame->loader().state() == FrameState::Provisional)
if (isNavigating)
m_frame->loader().stopAllLoaders();
}

@@ -653,4 +653,9 @@ void NavigationScheduler::cancel(NewLoadInProgress newLoadInProgress)
redirect->didStopTimer(m_frame, newLoadInProgress);
}

bool NavigationScheduler::hasQueuedNavigation() const
{
return m_redirect && !m_redirect->delay();
}

} // namespace WebCore
@@ -66,6 +66,8 @@ class NavigationScheduler {
void cancel(NewLoadInProgress = NewLoadInProgress::No);
void clear();

bool hasQueuedNavigation() const;

private:
bool shouldScheduleNavigation() const;
bool shouldScheduleNavigation(const URL&) const;

0 comments on commit 952f3c7

Please sign in to comment.