summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/navigation-timing/resources
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
commit0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch)
treea31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /testing/web-platform/tests/navigation-timing/resources
parentInitial commit. (diff)
downloadfirefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.tar.xz
firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.zip
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/navigation-timing/resources')
-rw-r--r--testing/web-platform/tests/navigation-timing/resources/blank-page-green-with-onunload.html11
-rw-r--r--testing/web-platform/tests/navigation-timing/resources/blank-page-green.html10
-rw-r--r--testing/web-platform/tests/navigation-timing/resources/blank-page-meta-redirect.html11
-rw-r--r--testing/web-platform/tests/navigation-timing/resources/blank-page-unload.html25
-rw-r--r--testing/web-platform/tests/navigation-timing/resources/blank-page-yellow-with-onunload.html11
-rw-r--r--testing/web-platform/tests/navigation-timing/resources/blank-page-yellow.html10
-rw-r--r--testing/web-platform/tests/navigation-timing/resources/blank_page_prefetch.html27
-rw-r--r--testing/web-platform/tests/navigation-timing/resources/blank_page_prefetch.html.headers1
-rw-r--r--testing/web-platform/tests/navigation-timing/resources/iframe-prefetch-transfer-size.html31
-rw-r--r--testing/web-platform/tests/navigation-timing/resources/navigation-type-post-back.html10
-rw-r--r--testing/web-platform/tests/navigation-timing/resources/navigation_type_post_back.py12
-rw-r--r--testing/web-platform/tests/navigation-timing/resources/performance-attribute-sender.html13
-rw-r--r--testing/web-platform/tests/navigation-timing/resources/respond-slowly.py29
-rw-r--r--testing/web-platform/tests/navigation-timing/resources/secure-connection-interim.html8
-rw-r--r--testing/web-platform/tests/navigation-timing/resources/secure-connection-interim.html.headers3
-rw-r--r--testing/web-platform/tests/navigation-timing/resources/secure-connection-test.html13
-rw-r--r--testing/web-platform/tests/navigation-timing/resources/webperftestharness.js113
17 files changed, 338 insertions, 0 deletions
diff --git a/testing/web-platform/tests/navigation-timing/resources/blank-page-green-with-onunload.html b/testing/web-platform/tests/navigation-timing/resources/blank-page-green-with-onunload.html
new file mode 100644
index 0000000000..2f401747b0
--- /dev/null
+++ b/testing/web-platform/tests/navigation-timing/resources/blank-page-green-with-onunload.html
@@ -0,0 +1,11 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
+ <title>Green Test Page</title>
+ </head>
+ <!-- use onunload to ensure this does not trigger bfcache -->
+ <body style="background-color:#00FF00;" onunload="1;">
+ <h1>Placeholder</h1>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/navigation-timing/resources/blank-page-green.html b/testing/web-platform/tests/navigation-timing/resources/blank-page-green.html
new file mode 100644
index 0000000000..b8a1947b77
--- /dev/null
+++ b/testing/web-platform/tests/navigation-timing/resources/blank-page-green.html
@@ -0,0 +1,10 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
+ <title>Green Test Page</title>
+ </head>
+ <body style="background-color:#00FF00;">
+ <h1>Placeholder</h1>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/navigation-timing/resources/blank-page-meta-redirect.html b/testing/web-platform/tests/navigation-timing/resources/blank-page-meta-redirect.html
new file mode 100644
index 0000000000..4b4bda096c
--- /dev/null
+++ b/testing/web-platform/tests/navigation-timing/resources/blank-page-meta-redirect.html
@@ -0,0 +1,11 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
+ <meta http-equiv="refresh" content="1;URL='blank-page-green.html'" />
+ <title>Redirect Placeholder</title>
+ </head>
+ <body style="background-color:#FFFF00";>
+ <h1>Placeholder</h1>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/navigation-timing/resources/blank-page-unload.html b/testing/web-platform/tests/navigation-timing/resources/blank-page-unload.html
new file mode 100644
index 0000000000..bb2a27f168
--- /dev/null
+++ b/testing/web-platform/tests/navigation-timing/resources/blank-page-unload.html
@@ -0,0 +1,25 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
+
+ <title>Yellow Test Page</title>
+
+ <script type="text/javascript">
+ function onbeforeunload_handler()
+ {
+ var temp = "onbeforeunload";
+ }
+
+ function onunload_handler()
+ {
+ var temp = "onunload";
+ }
+ </script>
+ </head>
+ <body onbeforeunload="onbeforeunload_handler();"
+ onunload="onunload_handler();"
+ style="background-color:#FFFF00;">
+ <h1>Unload</h1>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/navigation-timing/resources/blank-page-yellow-with-onunload.html b/testing/web-platform/tests/navigation-timing/resources/blank-page-yellow-with-onunload.html
new file mode 100644
index 0000000000..771e0701d9
--- /dev/null
+++ b/testing/web-platform/tests/navigation-timing/resources/blank-page-yellow-with-onunload.html
@@ -0,0 +1,11 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
+ <title>Yellow Test Page</title>
+ </head>
+ <!-- use onunload to ensure this does not trigger bfcache -->
+ <body style="background-color:#FFFF00;" onunload="1;">
+ <h1>Placeholder</h1>
+ </body>
+</html> \ No newline at end of file
diff --git a/testing/web-platform/tests/navigation-timing/resources/blank-page-yellow.html b/testing/web-platform/tests/navigation-timing/resources/blank-page-yellow.html
new file mode 100644
index 0000000000..4e5e1a000c
--- /dev/null
+++ b/testing/web-platform/tests/navigation-timing/resources/blank-page-yellow.html
@@ -0,0 +1,10 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
+ <title>Yellow Test Page</title>
+ </head>
+ <body style="background-color:#FFFF00;">
+ <h1>Placeholder</h1>
+ </body>
+</html> \ No newline at end of file
diff --git a/testing/web-platform/tests/navigation-timing/resources/blank_page_prefetch.html b/testing/web-platform/tests/navigation-timing/resources/blank_page_prefetch.html
new file mode 100644
index 0000000000..1112ca28ec
--- /dev/null
+++ b/testing/web-platform/tests/navigation-timing/resources/blank_page_prefetch.html
@@ -0,0 +1,27 @@
+<!DOCTYPE HTML>
+<html>
+
+<head>
+ <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
+ <title>Page to be Prefetched</title>
+ <script src="/common/dispatcher/dispatcher.js"></script>
+</head>
+
+<body>
+ <script>
+ const pageshowPromise = new Promise(resolve => {
+ window.addEventListener('pageshow', resolve, { once: true });
+ });
+
+ async function getTransferSize() {
+ await pageshowPromise;
+ return window.performance.getEntriesByType('navigation')[0].transferSize;
+ }
+ const params = new URLSearchParams(window.location.search);
+ const uuid = params.get("uuid");
+ const executor = new Executor(uuid);
+ </script>
+
+</body>
+
+</html>
diff --git a/testing/web-platform/tests/navigation-timing/resources/blank_page_prefetch.html.headers b/testing/web-platform/tests/navigation-timing/resources/blank_page_prefetch.html.headers
new file mode 100644
index 0000000000..771aba7f94
--- /dev/null
+++ b/testing/web-platform/tests/navigation-timing/resources/blank_page_prefetch.html.headers
@@ -0,0 +1 @@
+Cache-Control: max-age=300
diff --git a/testing/web-platform/tests/navigation-timing/resources/iframe-prefetch-transfer-size.html b/testing/web-platform/tests/navigation-timing/resources/iframe-prefetch-transfer-size.html
new file mode 100644
index 0000000000..fde01775b7
--- /dev/null
+++ b/testing/web-platform/tests/navigation-timing/resources/iframe-prefetch-transfer-size.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+ <meta charset="utf-8" />
+ <title>Iframe Transfer Size Prefetch</title>
+</head>
+
+<body>
+ <p>Placeholder</p>
+ <script>
+ const urlToPrefetch = 'blank_page_prefetch.html';
+
+ function addLink() {
+ return new Promise(resolve => {
+ const link = document.createElement('link');
+ link.onload = function () { resolve(); };
+ link.rel = 'prefetch';
+ link.as = 'document';
+ link.href = urlToPrefetch;
+ document.body.appendChild(link);
+ });
+ };
+
+ function navigateToPrefetchedUrl() {
+ document.location.href = urlToPrefetch;
+ }
+ </script>
+</body>
+
+</html>
diff --git a/testing/web-platform/tests/navigation-timing/resources/navigation-type-post-back.html b/testing/web-platform/tests/navigation-timing/resources/navigation-type-post-back.html
new file mode 100644
index 0000000000..8c19a2f5a5
--- /dev/null
+++ b/testing/web-platform/tests/navigation-timing/resources/navigation-type-post-back.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+
+<body>
+ <form action="navigation_type_post_back.py" method="post">
+ Post to page <button type="submit">Press to POST page</button>
+ </form>
+</body>
+
+</html>
diff --git a/testing/web-platform/tests/navigation-timing/resources/navigation_type_post_back.py b/testing/web-platform/tests/navigation-timing/resources/navigation_type_post_back.py
new file mode 100644
index 0000000000..9da06f4f03
--- /dev/null
+++ b/testing/web-platform/tests/navigation-timing/resources/navigation_type_post_back.py
@@ -0,0 +1,12 @@
+# Accoridng to routes.py in the wpt server implementation, POST method is
+# handled by a Python script handler which requires this file to return an html.
+def main(request, response):
+ content = """
+ <!DOCTYPE html>
+ <html>
+ <body>
+ <a href="blank_page_green.html">navigate away</a>.
+ </body>
+ </html>
+ """
+ return content
diff --git a/testing/web-platform/tests/navigation-timing/resources/performance-attribute-sender.html b/testing/web-platform/tests/navigation-timing/resources/performance-attribute-sender.html
new file mode 100644
index 0000000000..99f544690d
--- /dev/null
+++ b/testing/web-platform/tests/navigation-timing/resources/performance-attribute-sender.html
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML>
+<html>
+<body>
+<script>
+parent.postMessage([
+ performance.timing.connectStart,
+ performance.timing.navigationStart,
+ performance.timing.secureConnectionStart,
+ performance.timing.connectEnd
+], '*');
+</script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/navigation-timing/resources/respond-slowly.py b/testing/web-platform/tests/navigation-timing/resources/respond-slowly.py
new file mode 100644
index 0000000000..e58e16f1f0
--- /dev/null
+++ b/testing/web-platform/tests/navigation-timing/resources/respond-slowly.py
@@ -0,0 +1,29 @@
+import time
+
+
+def main(request, response):
+ head = b"""<script>
+ let navigationTiming = performance.getEntriesByType('navigation')[0];
+ let originalResponseEnd = navigationTiming.responseEnd;
+ let originalDuration = navigationTiming.duration;
+ function checkResponseEnd() {
+ let responseEndDuringLoadEvent = navigationTiming.responseEnd;
+ let durationDuringLoadEvent = navigationTiming.duration;
+ setTimeout(function() {
+ parent.postMessage([
+ originalResponseEnd,
+ originalDuration,
+ responseEndDuringLoadEvent,
+ durationDuringLoadEvent,
+ navigationTiming.responseEnd,
+ navigationTiming.duration], '*');
+ }, 0);
+ }
+ </script><body onload='checkResponseEnd()'>"""
+ response.headers.set(b"Content-Length", str(len(head) + 1000))
+ response.headers.set(b"Content-Type", b"text/html")
+ response.write_status_headers()
+ response.writer.write_content(head)
+ for i in range(100):
+ response.writer.write_content(b"1234567890")
+ time.sleep(0.01)
diff --git a/testing/web-platform/tests/navigation-timing/resources/secure-connection-interim.html b/testing/web-platform/tests/navigation-timing/resources/secure-connection-interim.html
new file mode 100644
index 0000000000..e40b00bedb
--- /dev/null
+++ b/testing/web-platform/tests/navigation-timing/resources/secure-connection-interim.html
@@ -0,0 +1,8 @@
+<!doctype html>
+<script>
+ window.addEventListener("message", e => {
+ window.top.postMessage(e.data, "*");
+ });
+</script>
+<iframe src="secure-connection-test.html">
+
diff --git a/testing/web-platform/tests/navigation-timing/resources/secure-connection-interim.html.headers b/testing/web-platform/tests/navigation-timing/resources/secure-connection-interim.html.headers
new file mode 100644
index 0000000000..b70fbaf3b0
--- /dev/null
+++ b/testing/web-platform/tests/navigation-timing/resources/secure-connection-interim.html.headers
@@ -0,0 +1,3 @@
+Connection: Keep-Alive
+Content-Length: 170
+
diff --git a/testing/web-platform/tests/navigation-timing/resources/secure-connection-test.html b/testing/web-platform/tests/navigation-timing/resources/secure-connection-test.html
new file mode 100644
index 0000000000..63a80e062b
--- /dev/null
+++ b/testing/web-platform/tests/navigation-timing/resources/secure-connection-test.html
@@ -0,0 +1,13 @@
+<!doctype html>
+<script>
+const entries = performance.getEntriesByType("navigation");
+if (!entries) {
+ window.top.postMessage("FAIL - not supported", "*");
+}
+const entry = entries[0];
+if (entry.secureConnectionStart != entry.fetchStart) {
+ window.top.postMessage("FAIL - unexpected secureConnectionStart value of " +
+ entry.secureConnectionStart + " does not equal " + entry.fetchStart, "*");
+}
+window.top.postMessage("PASS", "*");
+</script>
diff --git a/testing/web-platform/tests/navigation-timing/resources/webperftestharness.js b/testing/web-platform/tests/navigation-timing/resources/webperftestharness.js
new file mode 100644
index 0000000000..afe09530d7
--- /dev/null
+++ b/testing/web-platform/tests/navigation-timing/resources/webperftestharness.js
@@ -0,0 +1,113 @@
+//
+// Helper functions for Navigation Timing tests
+//
+
+var timingAttributes = [
+ 'connectEnd',
+ 'connectStart',
+ 'domComplete',
+ 'domContentLoadedEventEnd',
+ 'domContentLoadedEventStart',
+ 'domInteractive',
+ 'domLoading',
+ 'domainLookupEnd',
+ 'domainLookupStart',
+ 'fetchStart',
+ 'loadEventEnd',
+ 'loadEventStart',
+ 'navigationStart',
+ 'redirectEnd',
+ 'redirectStart',
+ 'requestStart',
+ 'responseEnd',
+ 'responseStart',
+ 'unloadEventEnd',
+ 'unloadEventStart'
+];
+
+function test_namespace(child_name, skip_root)
+{
+ if (skip_root === undefined) {
+ var msg = 'window.performance is defined';
+ wp_test(function () { assert_not_equals(performanceNamespace, undefined, msg); }, msg);
+ }
+
+ if (child_name !== undefined) {
+ var msg2 = 'window.performance.' + child_name + ' is defined';
+ wp_test(function() { assert_not_equals(performanceNamespace[child_name], undefined, msg2); }, msg2);
+ }
+}
+
+function test_attribute_exists(parent_name, attribute_name, properties)
+{
+ var msg = 'window.performance.' + parent_name + '.' + attribute_name + ' is defined.';
+ wp_test(function() { assert_not_equals(performanceNamespace[parent_name][attribute_name], undefined, msg); }, msg, properties);
+}
+
+function test_enum(parent_name, enum_name, value, properties)
+{
+ var msg = 'window.performance.' + parent_name + '.' + enum_name + ' is defined.';
+ wp_test(function() { assert_not_equals(performanceNamespace[parent_name][enum_name], undefined, msg); }, msg, properties);
+
+ msg = 'window.performance.' + parent_name + '.' + enum_name + ' = ' + value;
+ wp_test(function() { assert_equals(performanceNamespace[parent_name][enum_name], value, msg); }, msg, properties);
+}
+
+function test_timing_order(attribute_name, greater_than_attribute, properties)
+{
+ // ensure it's not 0 first
+ var msg = "window.performance.timing." + attribute_name + " > 0";
+ wp_test(function() { assert_true(performanceNamespace.timing[attribute_name] > 0, msg); }, msg, properties);
+
+ // ensure it's in the right order
+ msg = "window.performance.timing." + attribute_name + " >= window.performance.timing." + greater_than_attribute;
+ wp_test(function() { assert_true(performanceNamespace.timing[attribute_name] >= performanceNamespace.timing[greater_than_attribute], msg); }, msg, properties);
+
+ // ensure we have at least 5 microseconds difference or it's 0
+ msg = "window.performance.timing." + attribute_name + " difference with window.performance.timing." + greater_than_attribute + " is 0 or at least 5 microseconds";
+ var diff = performanceNamespace.timing[attribute_name] - performanceNamespace.timing[greater_than_attribute];
+ wp_test(function() { assert_true((diff === 0) || ((diff * 1000) >= 5), msg); }, msg, properties);
+}
+
+function test_timing_greater_than(attribute_name, greater_than, properties)
+{
+ var msg = "window.performance.timing." + attribute_name + " > " + greater_than;
+ test_greater_than(performanceNamespace.timing[attribute_name], greater_than, msg, properties);
+}
+
+function test_timing_equals(attribute_name, equals, msg, properties)
+{
+ var test_msg = msg || "window.performance.timing." + attribute_name + " == " + equals;
+ test_equals(performanceNamespace.timing[attribute_name], equals, test_msg, properties);
+}
+
+//
+// Non-test related helper functions
+//
+
+function sleep_milliseconds(n)
+{
+ var start = new Date().getTime();
+ while (true) {
+ if ((new Date().getTime() - start) >= n) break;
+ }
+}
+
+//
+// Common helper functions
+//
+
+function test_greater_than(value, greater_than, msg, properties)
+{
+ wp_test(function () { assert_true(value > greater_than, msg); }, msg, properties);
+}
+
+function test_greater_or_equals(value, greater_than, msg, properties)
+{
+ wp_test(function () { assert_true(value >= greater_than, msg); }, msg, properties);
+}
+
+function test_not_equals(value, notequals, msg, properties)
+{
+ wp_test(function() { assert_not_equals(value, notequals, msg); }, msg, properties);
+}