Skip to content

Truly independent web browser

Tests/LibWeb: Import navigation Server Timing coverage

Andreas Kling5a9f74456db4
diff --git a/Tests/LibWeb/TestConfig.ini b/Tests/LibWeb/TestConfig.ini
index 28cf40dbf12..1b58bbff8cc 100644
--- a/Tests/LibWeb/TestConfig.ini
+++ b/Tests/LibWeb/TestConfig.ini
@@ -978,6 +978,7 @@ Text/input/wpt-import/preload/link-header-preload-non-html.html
Text/input/wpt-import/preload/link-header-preload-nonce.html
Text/input/wpt-import/preload/preload-referrer-policy.html
Text/input/wpt-import/server-timing/server_timing_header-parsing.https.html
+Text/input/wpt-import/server-timing/test_server_timing.https.html
Text/input/HTML/link-header-parsing.html
Text/input/HTML/link-header-image-source-set.html
Text/input/HTML/link-header-media-document.html
diff --git a/Tests/LibWeb/Text/expected/wpt-import/server-timing/test_server_timing.https.txt b/Tests/LibWeb/Text/expected/wpt-import/server-timing/test_server_timing.https.txt
new file mode 100644
index 00000000000..399f9dc4388
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/server-timing/test_server_timing.https.txt
@@ -0,0 +1,13 @@
+Harness status: OK
+
+Found 7 tests
+
+4 Pass
+3 Fail
+Fail test_server_timing
+Fail Entry {"duration":1.1,"name":"metric1","description":"document"} could not be found.
+Fail Entry {"duration":1.2,"name":"metric1","description":"document"} could not be found.
+Pass test_server_timing 1
+Pass Entry {"duration":2.1,"name":"metric2","description":"blue.png"} could not be found.
+Pass test_server_timing 2
+Pass Entry {"duration":3.1,"name":"metric3","description":"green.png"} could not be found.
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/input/wpt-import/server-timing/resources/green.png b/Tests/LibWeb/Text/input/wpt-import/server-timing/resources/green.png
new file mode 100644
index 00000000000..28a1faab377
Binary files /dev/null and b/Tests/LibWeb/Text/input/wpt-import/server-timing/resources/green.png differ
diff --git a/Tests/LibWeb/Text/input/wpt-import/server-timing/resources/green.png.sub.headers b/Tests/LibWeb/Text/input/wpt-import/server-timing/resources/green.png.sub.headers
new file mode 100644
index 00000000000..b135472f865
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/server-timing/resources/green.png.sub.headers
@@ -0,0 +1 @@
+Server-Timing: metric3; dur=3.1; desc=green.png
diff --git a/Tests/LibWeb/Text/input/wpt-import/server-timing/test_server_timing.https.html b/Tests/LibWeb/Text/input/wpt-import/server-timing/test_server_timing.https.html
new file mode 100644
index 00000000000..aa92da0bd87
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/server-timing/test_server_timing.https.html
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<head>
+ <meta charset='utf-8' />
+ <script src="../resources/testharness.js"></script>
+ <script src="../resources/testharnessreport.js"></script>
+ <script src="../common/performance-timeline-utils.js"></script>
+ <script>
+ setup({explicit_done: true})
+
+ delayedLoadListener(function() {
+ // there should be exactly three server-timing entries, 2 for document, 1 for img#one
+ test_entries(performance.getEntriesByType('navigation')[0].serverTiming, [{
+ duration: 1.1,
+ name: 'metric1',
+ description: 'document',
+ }, {
+ duration: 1.2,
+ name: 'metric1',
+ description: 'document',
+ }])
+ test_entries(performance.getEntriesByName(document.querySelector('img#one').src)[0].serverTiming, [{
+ duration: 2.1,
+ name: 'metric2',
+ description: 'blue.png',
+ }])
+
+ new PerformanceObserver(function(entryList, observer) {
+ // there should be exactly one server-timing entry, 1 for img#two
+ test_entries(entryList.getEntriesByName(document.querySelector('img#two').src)[0].serverTiming, [{
+ duration: 3.1,
+ name: 'metric3',
+ description: 'green.png',
+ }])
+ observer.disconnect()
+ done()
+ }).observe({entryTypes: ['resource']})
+
+ var img = document.createElement('img')
+ img.id = 'two'
+ img.src = './resources/green.png'
+ document.getElementsByTagName('script')[0].parentNode.appendChild(img)
+ })
+ </script>
+</head>
+<img id='one' src='resources/blue.png'>
diff --git a/Tests/LibWeb/Text/input/wpt-import/server-timing/test_server_timing.https.html.sub.headers b/Tests/LibWeb/Text/input/wpt-import/server-timing/test_server_timing.https.html.sub.headers
new file mode 100644
index 00000000000..ad018b70fd8
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/server-timing/test_server_timing.https.html.sub.headers
@@ -0,0 +1 @@
+Server-Timing: metric1; dur=1.1; desc=document, metric1; dur=1.2; desc=document