summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/navigation-timing/navigation-type-post-backforward.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/navigation-timing/navigation-type-post-backforward.html
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/navigation-timing/navigation-type-post-backforward.html')
-rw-r--r--testing/web-platform/tests/navigation-timing/navigation-type-post-backforward.html64
1 files changed, 64 insertions, 0 deletions
diff --git a/testing/web-platform/tests/navigation-timing/navigation-type-post-backforward.html b/testing/web-platform/tests/navigation-timing/navigation-type-post-backforward.html
new file mode 100644
index 0000000000..1fbdf1ae9b
--- /dev/null
+++ b/testing/web-platform/tests/navigation-timing/navigation-type-post-backforward.html
@@ -0,0 +1,64 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+ <title>Navigation Type Post Back Forward</title>
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+</head>
+
+<body>
+ <script>
+ function execute_helper(fn, args) {
+ return new Promise(resolve => {
+ frame.addEventListener('load', () => {
+ resolve(frame);
+ }, { once: true });
+ fn.apply(null, args);
+ });
+ }
+
+ // Create an iframe.
+ function create_iframe(url) {
+ const frame = document.createElement('iframe');
+ frame.src = url;
+ return frame;
+ }
+
+ // Attach an iframe.
+ function attach_iframe(frame) {
+ document.body.appendChild(frame);
+ }
+
+ // Post by submit method.
+ function submit_form(frame) {
+ frame.contentWindow.document.getElementsByTagName("form")[0].submit();
+ }
+
+ // Navigate away by simulating a click on the link.
+ function navigate_away(frame) {
+ frame.contentWindow.document.getElementsByTagName("a")[0].click();
+ }
+
+ // Navigate back.
+ function navigate_back(frame) {
+ frame.contentWindow.history.back();
+ }
+
+ promise_test(async t => {
+ // Add an iframe and Load page in the iframe.
+ let url = 'resources/navigation-type-post-back.html';
+
+ frame = create_iframe(url);
+ await execute_helper(attach_iframe, [frame]);
+ await execute_helper(submit_form, [frame]);
+ await execute_helper(navigate_away, [frame]);
+ await execute_helper(navigate_back, [frame]);
+
+ assert_equals(frame.contentWindow.performance.getEntriesByType('navigation')[0].type,
+ 'back_forward');
+ }, "Navigation type after posting and navigating away and back should be back_forward.");
+ </script>
+</body>
+
+</html>