diff --git a/navigation-api/navigate-event/event-constructor.html b/navigation-api/navigate-event/event-constructor.html index a668730e35f1aa..863681ced730d1 100644 --- a/navigation-api/navigate-event/event-constructor.html +++ b/navigation-api/navigate-event/event-constructor.html @@ -18,7 +18,8 @@ signal: (new AbortController()).signal, formData: null, downloadRequest: null, - info: null + info: null, + sourceElement: null }); }); }, "destination is required"); @@ -35,7 +36,8 @@ hashChange: false, formData: null, downloadRequest: null, - info: null + info: null, + sourceElement: null }); }); }); @@ -50,6 +52,7 @@ const signal = (new AbortController()).signal; const downloadRequest = "abc"; const hasUAVisualTransition = true; + const sourceElement = document.createElement("a"); const event = new NavigateEvent("navigate", { navigationType: "replace", @@ -61,7 +64,8 @@ formData, downloadRequest, info, - hasUAVisualTransition + hasUAVisualTransition, + sourceElement }); assert_equals(event.navigationType, "replace"); @@ -74,6 +78,7 @@ assert_equals(event.downloadRequest, downloadRequest); assert_equals(event.info, info); assert_equals(event.hasUAVisualTransition, hasUAVisualTransition); + assert_equals(event.sourceElement, sourceElement); }); history.pushState(2, null, "#2"); }, "all properties are reflected back"); @@ -93,6 +98,7 @@ assert_equals(event.formData, null); assert_equals(event.downloadRequest, null); assert_equals(event.info, undefined); + assert_equals(event.sourceElement, null); }); history.pushState(3, null, "#3"); }, "defaults are as expected"); diff --git a/navigation-api/navigate-event/navigate-anchor-cross-origin.html b/navigation-api/navigate-event/navigate-anchor-cross-origin.html index ee0992485078fd..62e5adb20ae88c 100644 --- a/navigation-api/navigate-event/navigate-anchor-cross-origin.html +++ b/navigation-api/navigate-event/navigate-anchor-cross-origin.html @@ -17,6 +17,7 @@ assert_equals(e.destination.key, ""); assert_equals(e.destination.id, ""); assert_equals(e.destination.index, -1); + assert_equals(e.sourceElement, document.getElementById("a")); e.preventDefault(); }); a.click(); diff --git a/navigation-api/navigate-event/navigate-anchor-download-userInitiated.html b/navigation-api/navigate-event/navigate-anchor-download-userInitiated.html index b9506984dad8d8..69181425292e75 100644 --- a/navigation-api/navigate-event/navigate-anchor-download-userInitiated.html +++ b/navigation-api/navigate-event/navigate-anchor-download-userInitiated.html @@ -21,6 +21,7 @@ assert_equals(e.destination.key, ""); assert_equals(e.destination.id, ""); assert_equals(e.destination.index, -1); + assert_equals(e.sourceElement, document.getElementById("a")); e.preventDefault(); t.step_timeout(t.step_func_done(() => assert_equals(location.hash, "")), 0); }); diff --git a/navigation-api/navigate-event/navigate-anchor-download.html b/navigation-api/navigate-event/navigate-anchor-download.html index 05fb0ecf2fe6f6..d04245ec253ce0 100644 --- a/navigation-api/navigate-event/navigate-anchor-download.html +++ b/navigation-api/navigate-event/navigate-anchor-download.html @@ -25,6 +25,7 @@ assert_equals(e.destination.key, ""); assert_equals(e.destination.id, ""); assert_equals(e.destination.index, -1); + assert_equals(e.sourceElement, a); e.preventDefault(); }); a.click(); diff --git a/navigation-api/navigate-event/navigate-anchor-fragment.html b/navigation-api/navigate-event/navigate-anchor-fragment.html index 51221ebcad381b..6443ccecd1d702 100644 --- a/navigation-api/navigate-event/navigate-anchor-fragment.html +++ b/navigation-api/navigate-event/navigate-anchor-fragment.html @@ -17,6 +17,7 @@ assert_equals(e.destination.key, ""); assert_equals(e.destination.id, ""); assert_equals(e.destination.index, -1); + assert_equals(e.sourceElement, document.getElementById("a")); e.preventDefault(); t.step_timeout(t.step_func_done(() => assert_equals(location.hash, "")), 0); }); diff --git a/navigation-api/navigate-event/navigate-anchor-same-origin-cross-document.html b/navigation-api/navigate-event/navigate-anchor-same-origin-cross-document.html index 68f5bf0627c123..5a6dce7ec8bcc9 100644 --- a/navigation-api/navigate-event/navigate-anchor-same-origin-cross-document.html +++ b/navigation-api/navigate-event/navigate-anchor-same-origin-cross-document.html @@ -18,6 +18,7 @@ assert_equals(e.destination.key, ""); assert_equals(e.destination.id, ""); assert_equals(e.destination.index, -1); + assert_equals(e.sourceElement, document.getElementById("a")); e.preventDefault(); }); a.click(); diff --git a/navigation-api/navigate-event/navigate-anchor-userInitiated.html b/navigation-api/navigate-event/navigate-anchor-userInitiated.html index 39192c91513248..bb76e7a3fbe651 100644 --- a/navigation-api/navigate-event/navigate-anchor-userInitiated.html +++ b/navigation-api/navigate-event/navigate-anchor-userInitiated.html @@ -20,6 +20,7 @@ assert_equals(e.destination.key, ""); assert_equals(e.destination.id, ""); assert_equals(e.destination.index, -1); + assert_equals(e.sourceElement, document.getElementById("a")); e.preventDefault(); t.step_timeout(t.step_func_done(() => assert_equals(location.hash, "")), 0); }); diff --git a/navigation-api/navigate-event/navigate-anchor-with-target.html b/navigation-api/navigate-event/navigate-anchor-with-target.html index 6407b963beb7cd..e4b897d82f3ddc 100644 --- a/navigation-api/navigate-event/navigate-anchor-with-target.html +++ b/navigation-api/navigate-event/navigate-anchor-with-target.html @@ -23,6 +23,7 @@ assert_equals(e.destination.key, ""); assert_equals(e.destination.id, ""); assert_equals(e.destination.index, -1); + assert_equals(e.sourceElement, null); e.preventDefault(); }); a.click(); diff --git a/navigation-api/navigate-event/navigate-destination-getState-back-forward.html b/navigation-api/navigate-event/navigate-destination-getState-back-forward.html index c8b1043aba6f5e..869fc1648157b2 100644 --- a/navigation-api/navigate-event/navigate-destination-getState-back-forward.html +++ b/navigation-api/navigate-event/navigate-destination-getState-back-forward.html @@ -19,6 +19,7 @@ assert_equals(e.destination.key, ""); assert_equals(e.destination.id, ""); assert_equals(e.destination.index, -1); + assert_equals(e.sourceElement, null); }); navigation.back(); }), 0); diff --git a/navigation-api/navigate-event/navigate-destination-getState-navigate.html b/navigation-api/navigate-event/navigate-destination-getState-navigate.html index 5dac40de566e9e..d19a16851453a0 100644 --- a/navigation-api/navigate-event/navigate-destination-getState-navigate.html +++ b/navigation-api/navigate-event/navigate-destination-getState-navigate.html @@ -16,6 +16,7 @@ assert_equals(e.destination.key, ""); assert_equals(e.destination.id, ""); assert_equals(e.destination.index, -1); + assert_equals(e.sourceElement, null); }); navigation.navigate("#foo", { state: navState }); }, 0); diff --git a/navigation-api/navigate-event/navigate-destination-getState-reload.html b/navigation-api/navigate-event/navigate-destination-getState-reload.html index a180e086a94b08..ac6528ce7ef261 100644 --- a/navigation-api/navigate-event/navigate-destination-getState-reload.html +++ b/navigation-api/navigate-event/navigate-destination-getState-reload.html @@ -16,6 +16,7 @@ assert_equals(e.destination.key, ""); assert_equals(e.destination.id, ""); assert_equals(e.destination.index, -1); + assert_equals(e.sourceElement, null); e.intercept(); }); navigation.updateCurrentEntry({ state: navState }); diff --git a/navigation-api/navigate-event/navigate-form-get.html b/navigation-api/navigate-event/navigate-form-get.html index 87a102ddc0598f..7a71a1c3050a0c 100644 --- a/navigation-api/navigate-event/navigate-form-get.html +++ b/navigation-api/navigate-event/navigate-form-get.html @@ -21,6 +21,7 @@ // Because it's a GET, not a POST assert_equals(e.formData, null); + assert_equals(e.sourceElement, form); }); window.onload = t.step_func(() => form.submit()); }, "
submission with GET method fires navigate event but with formData null"); diff --git a/navigation-api/navigate-event/navigate-form-reload.html b/navigation-api/navigate-event/navigate-form-reload.html index f18a11ebdaca67..217169053722c2 100644 --- a/navigation-api/navigate-event/navigate-form-reload.html +++ b/navigation-api/navigate-event/navigate-form-reload.html @@ -12,6 +12,7 @@ iframe.contentWindow.navigation.onnavigate = t.step_func(e => { assert_equals(e.navigationType, "push"); assert_not_equals(e.formData, null); + assert_equals(e.sourceElement, null); iframe.onload = t.step_func(() => { iframe.contentWindow.navigation.onnavigate = t.step_func_done(e => { diff --git a/navigation-api/navigate-event/navigate-form-requestSubmit.html b/navigation-api/navigate-event/navigate-form-requestSubmit.html new file mode 100644 index 00000000000000..38dd9c7eee649f --- /dev/null +++ b/navigation-api/navigate-event/navigate-form-requestSubmit.html @@ -0,0 +1,35 @@ + + + + + + +