From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- ...er-transition-new-navigation-before-commit.html | 25 ++++++ .../commit-behavior/after-transition-push.html | 23 ++++++ .../commit-behavior/after-transition-reload.html | 19 +++++ .../commit-behavior/after-transition-replace.html | 19 +++++ ...versal-commit-new-navigation-before-commit.html | 36 ++++++++ .../commit-behavior/after-transition-traverse.html | 31 +++++++ .../after-transition-uncancelable.html | 23 ++++++ ...after-transition-window-stop-before-commit.html | 33 ++++++++ .../commit-behavior/commit-throws.html | 95 ++++++++++++++++++++++ .../commit-behavior/multiple-intercept.html | 83 +++++++++++++++++++ .../resources/after-transition-commit-helpers.js | 90 ++++++++++++++++++++ 11 files changed, 477 insertions(+) create mode 100644 testing/web-platform/tests/navigation-api/commit-behavior/after-transition-new-navigation-before-commit.html create mode 100644 testing/web-platform/tests/navigation-api/commit-behavior/after-transition-push.html create mode 100644 testing/web-platform/tests/navigation-api/commit-behavior/after-transition-reload.html create mode 100644 testing/web-platform/tests/navigation-api/commit-behavior/after-transition-replace.html create mode 100644 testing/web-platform/tests/navigation-api/commit-behavior/after-transition-traversal-commit-new-navigation-before-commit.html create mode 100644 testing/web-platform/tests/navigation-api/commit-behavior/after-transition-traverse.html create mode 100644 testing/web-platform/tests/navigation-api/commit-behavior/after-transition-uncancelable.html create mode 100644 testing/web-platform/tests/navigation-api/commit-behavior/after-transition-window-stop-before-commit.html create mode 100644 testing/web-platform/tests/navigation-api/commit-behavior/commit-throws.html create mode 100644 testing/web-platform/tests/navigation-api/commit-behavior/multiple-intercept.html create mode 100644 testing/web-platform/tests/navigation-api/commit-behavior/resources/after-transition-commit-helpers.js (limited to 'testing/web-platform/tests/navigation-api/commit-behavior') diff --git a/testing/web-platform/tests/navigation-api/commit-behavior/after-transition-new-navigation-before-commit.html b/testing/web-platform/tests/navigation-api/commit-behavior/after-transition-new-navigation-before-commit.html new file mode 100644 index 0000000000..2d09d40dc9 --- /dev/null +++ b/testing/web-platform/tests/navigation-api/commit-behavior/after-transition-new-navigation-before-commit.html @@ -0,0 +1,25 @@ + + + + + + + diff --git a/testing/web-platform/tests/navigation-api/commit-behavior/after-transition-push.html b/testing/web-platform/tests/navigation-api/commit-behavior/after-transition-push.html new file mode 100644 index 0000000000..34bdcf7cac --- /dev/null +++ b/testing/web-platform/tests/navigation-api/commit-behavior/after-transition-push.html @@ -0,0 +1,23 @@ + + + + + + + + diff --git a/testing/web-platform/tests/navigation-api/commit-behavior/after-transition-reload.html b/testing/web-platform/tests/navigation-api/commit-behavior/after-transition-reload.html new file mode 100644 index 0000000000..203150eb05 --- /dev/null +++ b/testing/web-platform/tests/navigation-api/commit-behavior/after-transition-reload.html @@ -0,0 +1,19 @@ + + + + + + + + diff --git a/testing/web-platform/tests/navigation-api/commit-behavior/after-transition-replace.html b/testing/web-platform/tests/navigation-api/commit-behavior/after-transition-replace.html new file mode 100644 index 0000000000..2fd48736a3 --- /dev/null +++ b/testing/web-platform/tests/navigation-api/commit-behavior/after-transition-replace.html @@ -0,0 +1,19 @@ + + + + + + + + diff --git a/testing/web-platform/tests/navigation-api/commit-behavior/after-transition-traversal-commit-new-navigation-before-commit.html b/testing/web-platform/tests/navigation-api/commit-behavior/after-transition-traversal-commit-new-navigation-before-commit.html new file mode 100644 index 0000000000..9e74e10676 --- /dev/null +++ b/testing/web-platform/tests/navigation-api/commit-behavior/after-transition-traversal-commit-new-navigation-before-commit.html @@ -0,0 +1,36 @@ + + + + + + + diff --git a/testing/web-platform/tests/navigation-api/commit-behavior/after-transition-traverse.html b/testing/web-platform/tests/navigation-api/commit-behavior/after-transition-traverse.html new file mode 100644 index 0000000000..d348a218ac --- /dev/null +++ b/testing/web-platform/tests/navigation-api/commit-behavior/after-transition-traverse.html @@ -0,0 +1,31 @@ + + + + + + + + diff --git a/testing/web-platform/tests/navigation-api/commit-behavior/after-transition-uncancelable.html b/testing/web-platform/tests/navigation-api/commit-behavior/after-transition-uncancelable.html new file mode 100644 index 0000000000..45bde9f090 --- /dev/null +++ b/testing/web-platform/tests/navigation-api/commit-behavior/after-transition-uncancelable.html @@ -0,0 +1,23 @@ + + + + + + + diff --git a/testing/web-platform/tests/navigation-api/commit-behavior/after-transition-window-stop-before-commit.html b/testing/web-platform/tests/navigation-api/commit-behavior/after-transition-window-stop-before-commit.html new file mode 100644 index 0000000000..0f5e57d5b6 --- /dev/null +++ b/testing/web-platform/tests/navigation-api/commit-behavior/after-transition-window-stop-before-commit.html @@ -0,0 +1,33 @@ + + + + + + + diff --git a/testing/web-platform/tests/navigation-api/commit-behavior/commit-throws.html b/testing/web-platform/tests/navigation-api/commit-behavior/commit-throws.html new file mode 100644 index 0000000000..54abdbfd0f --- /dev/null +++ b/testing/web-platform/tests/navigation-api/commit-behavior/commit-throws.html @@ -0,0 +1,95 @@ + + + + + + diff --git a/testing/web-platform/tests/navigation-api/commit-behavior/multiple-intercept.html b/testing/web-platform/tests/navigation-api/commit-behavior/multiple-intercept.html new file mode 100644 index 0000000000..848af6a65d --- /dev/null +++ b/testing/web-platform/tests/navigation-api/commit-behavior/multiple-intercept.html @@ -0,0 +1,83 @@ + + + + +
+
+ + diff --git a/testing/web-platform/tests/navigation-api/commit-behavior/resources/after-transition-commit-helpers.js b/testing/web-platform/tests/navigation-api/commit-behavior/resources/after-transition-commit-helpers.js new file mode 100644 index 0000000000..664e8d7280 --- /dev/null +++ b/testing/web-platform/tests/navigation-api/commit-behavior/resources/after-transition-commit-helpers.js @@ -0,0 +1,90 @@ +window.testAfterTransitionCommit = async (t, navigationType, mode, destinationIndex = 0) => { + let startHash = location.hash; + let destinationHash; + const err = new Error("boo!"); + + let popstate_fired = false; + window.addEventListener("popstate", () => popstate_fired = true, { once : true }); + let navigatesuccess_fired = false; + navigation.addEventListener("navigatesuccess", () => navigatesuccess_fired = true, { once : true }); + let navigateerror_fired = false; + navigation.addEventListener("navigateerror", () => navigateerror_fired = true, { once : true }); + + // mode-specific logic for the navigate event handler + let navigate_helpers = { + rejectBeforeCommit : async (e) => { + return Promise.reject(err); + }, + rejectAfterCommit : async (e) => { + e.commit(); + assert_equals(location.hash, destinationHash, "hash after commit"); + assert_true(popstate_fired, "popstate fired after commit"); + await new Promise(resolve => t.step_timeout(resolve, 0)); + return Promise.reject(err); + }, + successExplicitCommit : async (e) => { + e.commit(); + assert_equals(location.hash, destinationHash, "hash after commit"); + assert_true(popstate_fired, "popstate fired after commit"); + return new Promise(resolve => t.step_timeout(resolve, 0)); + }, + successNoExplicitCommit : async (e) => { + assert_equals(location.hash, startHash, "start has after first async step"); + assert_false(popstate_fired, "popstate fired after first async step"); + await new Promise(resolve => t.step_timeout(resolve, 0)); + assert_equals(location.hash, startHash, "start has after second async step"); + assert_false(popstate_fired, "popstate fired after second async step"); + return new Promise(resolve => t.step_timeout(resolve, 0)); + } + } + + navigation.addEventListener("navigate", e => { + e.intercept({ commit: "after-transition", + handler: t.step_func(async () => { + assert_equals(e.navigationType, navigationType); + assert_equals(location.hash, startHash, "start hash"); + assert_false(popstate_fired, "popstate fired at handler start"); + + await new Promise(resolve => t.step_timeout(resolve, 0)); + assert_equals(location.hash, startHash, "hash after first async step"); + assert_false(popstate_fired, "popstate fired after first async step"); + + return navigate_helpers[mode](e); + })}); + }, { once: true }); + + let promises; + if (navigationType === "push" || navigationType === "replace") { + destinationHash = (startHash === "" ? "#" : startHash) + "a"; + promises = navigation.navigate(destinationHash, { history: navigationType }); + } else if (navigationType === "reload") { + destinationHash = startHash; + promises = navigation.reload(); + } else if (navigationType === "traverse") { + let destinationEntry = navigation.entries()[destinationIndex]; + destinationHash = new URL(destinationEntry.url).hash; + promises = navigation.traverseTo(destinationEntry.key); + } + + if (mode === "rejectBeforeCommit") { + await assertBothRejectExactly(t, promises, err); + assert_equals(location.hash, startHash, "hash after promise resolution"); + assert_false(popstate_fired, "popstate fired after promise resolution"); + assert_false(navigatesuccess_fired, "navigatesuccess fired"); + assert_true(navigateerror_fired, "navigateerror fired"); + } else if (mode === "rejectAfterCommit") { + await promises.committed; + await assertCommittedFulfillsFinishedRejectsExactly(t, promises, navigation.currentEntry, err); + assert_equals(location.hash, destinationHash, "hash after promise resolution"); + assert_true(popstate_fired, "popstate fired after promise resolution"); + assert_false(navigatesuccess_fired, "navigatesuccess fired"); + assert_true(navigateerror_fired, "navigateerror fired"); + } else { + await promises.committed; + await assertBothFulfill(t, promises, navigation.currentEntry); + assert_equals(location.hash, destinationHash, "hash after promise resolution"); + assert_true(popstate_fired, "popstate fired after promise resolution"); + assert_true(navigatesuccess_fired, "navigatesuccess fired"); + assert_false(navigateerror_fired, "navigateerror fired"); + } +} -- cgit v1.2.3