Skip to content

Commit

Permalink
[Navigation] Consolidate "document is fully active" check in navigate
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=273972

Reviewed by Alex Christensen.

The navigate method starts of by (partly) checking whether the document is fully active by
checking that the frame exists, however the "document is fully active" check should be done
in step 7 (see [1]). So remove the frame check and rely on the later call to isFullyActive
to get the correct order of handling possible errors.

[1] https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-navigation-navigate

* LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigation-methods/return-value/navigate-rejection-order-detached-unserializablestate-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigation-methods/return-value/navigate-rejection-order-invalidurl-detached-expected.txt:
* Source/WebCore/page/Navigation.cpp:
(WebCore::Navigation::navigate):

Canonical link: https://commits.webkit.org/278627@main
  • Loading branch information
rwlbuis committed May 10, 2024
1 parent fffbee3 commit df4f811
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@

FAIL navigate() with unserializable state in a detached iframe throws "DataCloneError", not "InvalidStateError" assert_throws_dom: function "() => { throw committedReason; }" threw object "InvalidStateError: Invalid state" that is not a DOMException DataCloneError: property "code" is equal to 11, expected 25
PASS navigate() with unserializable state in a detached iframe throws "DataCloneError", not "InvalidStateError"

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@

FAIL navigate() with an invalid URL in a detached iframe throws "SyntaxError", not "InvalidStateError" assert_throws_dom: function "() => { throw committedReason; }" threw object "InvalidStateError: Invalid state" that is not a DOMException SyntaxError: property "code" is equal to 11, expected 12
PASS navigate() with an invalid URL in a detached iframe throws "SyntaxError", not "InvalidStateError"

5 changes: 1 addition & 4 deletions Source/WebCore/page/Navigation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,7 @@ Navigation::Result Navigation::reload(ReloadOptions&& options, Ref<DeferredPromi
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-navigation-navigate
Navigation::Result Navigation::navigate(const String& url, NavigateOptions&& options, Ref<DeferredPromise>&& committed, Ref<DeferredPromise>&& finished)
{
if (!frame())
return createErrorResult(WTFMove(committed), WTFMove(finished), ExceptionCode::InvalidStateError, "Invalid state"_s);

auto newURL = frame()->document()->completeURL(url);
auto newURL = window()->document()->completeURL(url);
const URL& currentURL = scriptExecutionContext()->url();

if (!newURL.isValid())
Expand Down

0 comments on commit df4f811

Please sign in to comment.