Skip to content

Commit bd1fcca

Browse files
natechapinchromium-wpt-export-bot
authored andcommitted
Navigation API: match the spec on popstate firing behavior
When intercepting a navigation with the navigate event, the popstate event should only be fired if the navigation was a traversal (necessarily same-document, since cross-document traversals aren't interceptible), or if the navigation was a same-document fragment navigation (i.e., not originating from the history API or the navigation API). Follows whatwg/html#10989 and whatwg/html#10919 Fixed: 397377454, 398276373 Change-Id: I0f953cd10a8f2a80af0822e9ceafaaac965758fe
1 parent 36a5264 commit bd1fcca

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

navigation-api/commit-behavior/resources/after-transition-commit-helpers.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ window.testAfterTransitionCommit = async (t, navigationType, mode, destinationIn
1818
rejectAfterCommit : async (e) => {
1919
e.commit();
2020
assert_equals(location.hash, destinationHash, "hash after commit");
21-
assert_true(popstate_fired, "popstate fired after commit");
21+
assert_equals(navigationType == "traverse", popstate_fired, "popstate fired after commit");
2222
await new Promise(resolve => t.step_timeout(resolve, 0));
2323
return Promise.reject(err);
2424
},
2525
successExplicitCommit : async (e) => {
2626
e.commit();
2727
assert_equals(location.hash, destinationHash, "hash after commit");
28-
assert_true(popstate_fired, "popstate fired after commit");
28+
assert_equals(navigationType == "traverse", popstate_fired, "popstate fired after commit");
2929
return new Promise(resolve => t.step_timeout(resolve, 0));
3030
},
3131
successNoExplicitCommit : async (e) => {
@@ -76,14 +76,14 @@ window.testAfterTransitionCommit = async (t, navigationType, mode, destinationIn
7676
await promises.committed;
7777
await assertCommittedFulfillsFinishedRejectsExactly(t, promises, navigation.currentEntry, err);
7878
assert_equals(location.hash, destinationHash, "hash after promise resolution");
79-
assert_true(popstate_fired, "popstate fired after promise resolution");
79+
assert_equals(navigationType == "traverse", popstate_fired, "popstate fired after promise resolution");
8080
assert_false(navigatesuccess_fired, "navigatesuccess fired");
8181
assert_true(navigateerror_fired, "navigateerror fired");
8282
} else {
8383
await promises.committed;
8484
await assertBothFulfill(t, promises, navigation.currentEntry);
8585
assert_equals(location.hash, destinationHash, "hash after promise resolution");
86-
assert_true(popstate_fired, "popstate fired after promise resolution");
86+
assert_equals(navigationType == "traverse", popstate_fired, "popstate fired after promise resolution");
8787
assert_true(navigatesuccess_fired, "navigatesuccess fired");
8888
assert_false(navigateerror_fired, "navigateerror fired");
8989
}

0 commit comments

Comments
 (0)