Truly independent web browser
Tests/LibWeb: Import user timing detail test
Andreas Kling85369d51ede5
diff --git a/Tests/LibWeb/TestConfig.ini b/Tests/LibWeb/TestConfig.iniindex c79543d5a9b..1f10b4d8784 100644--- a/Tests/LibWeb/TestConfig.ini+++ b/Tests/LibWeb/TestConfig.ini@@ -492,6 +492,7 @@ Text/input/wpt-import/trusted-types/DedicatedWorker-setTimeout-setInterval.htmlText/input/wpt-import/trusted-types/SharedWorker-setTimeout-setInterval.htmlText/input/wpt-import/trusted-types/block-string-assignment-to-DedicatedWorker-setTimeout-setInterval.htmlText/input/wpt-import/trusted-types/block-string-assignment-to-SharedWorker-setTimeout-setInterval.html+Text/input/wpt-import/user-timing/structured-serialize-detail.any.worker.htmlCrash/wpt-import/css/css-font-loading/fontfaceset-loading-worker-crash.html; CORS fetch failures.diff --git a/Tests/LibWeb/Text/expected/wpt-import/user-timing/structured-serialize-detail.any.txt b/Tests/LibWeb/Text/expected/wpt-import/user-timing/structured-serialize-detail.any.txtnew file mode 100644index 00000000000..a7b63d366b3--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/user-timing/structured-serialize-detail.any.txt@@ -0,0 +1,15 @@+Harness status: OK++Found 9 tests++8 Pass+1 Fail+Pass The detail property in the mark constructor should be structured-clone.+Pass The detail property in the mark method should be structured-clone.+Pass When accessing detail from a mark entry and the detail is not provided, just return a null value.+Pass Mark: Throw an exception when the detail property cannot be structured-serialized.+Pass The detail property in the measure method should be structured-clone.+Fail The detail property in the measure method should be the same reference.+Pass When accessing detail from a measure entry and the detail is not provided, just return a null value.+Pass Measure: Throw an exception when the detail property cannot be structured-serialized.+Pass The detail object is cloned when passed to mark API.\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/user-timing/structured-serialize-detail.any.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/user-timing/structured-serialize-detail.any.worker.txtnew file mode 100644index 00000000000..a7b63d366b3--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/user-timing/structured-serialize-detail.any.worker.txt@@ -0,0 +1,15 @@+Harness status: OK++Found 9 tests++8 Pass+1 Fail+Pass The detail property in the mark constructor should be structured-clone.+Pass The detail property in the mark method should be structured-clone.+Pass When accessing detail from a mark entry and the detail is not provided, just return a null value.+Pass Mark: Throw an exception when the detail property cannot be structured-serialized.+Pass The detail property in the measure method should be structured-clone.+Fail The detail property in the measure method should be the same reference.+Pass When accessing detail from a measure entry and the detail is not provided, just return a null value.+Pass Measure: Throw an exception when the detail property cannot be structured-serialized.+Pass The detail object is cloned when passed to mark API.\ No newline at end of filediff --git a/Tests/LibWeb/Text/input/wpt-import/user-timing/structured-serialize-detail.any.html b/Tests/LibWeb/Text/input/wpt-import/user-timing/structured-serialize-detail.any.htmlnew file mode 100644index 00000000000..4776683a256--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/user-timing/structured-serialize-detail.any.html@@ -0,0 +1,15 @@+<!doctype html>+<meta charset=utf-8>++<script>+self.GLOBAL = {+ isWindow: function() { return true; },+ isWorker: function() { return false; },+ isShadowRealm: function() { return false; },+};+</script>+<script src="../resources/testharness.js"></script>+<script src="../resources/testharnessreport.js"></script>++<div id=log></div>+<script src="../user-timing/structured-serialize-detail.any.js"></script>diff --git a/Tests/LibWeb/Text/input/wpt-import/user-timing/structured-serialize-detail.any.js b/Tests/LibWeb/Text/input/wpt-import/user-timing/structured-serialize-detail.any.jsnew file mode 100644index 00000000000..dcceffde278--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/user-timing/structured-serialize-detail.any.js@@ -0,0 +1,66 @@+test(function() {+ performance.clearMarks();+ const detail = { randomInfo: 123 }+ const markEntry = new PerformanceMark("A", { detail });+ assert_equals(markEntry.detail.randomInfo, detail.randomInfo);+ assert_not_equals(markEntry.detail, detail);+}, "The detail property in the mark constructor should be structured-clone.");++test(function() {+ performance.clearMarks();+ const detail = { randomInfo: 123 }+ const markEntry = performance.mark("A", { detail });+ assert_equals(markEntry.detail.randomInfo, detail.randomInfo);+ assert_not_equals(markEntry.detail, detail);+}, "The detail property in the mark method should be structured-clone.");++test(function() {+ performance.clearMarks();+ const markEntry = performance.mark("A");+ assert_equals(markEntry.detail, null);+}, "When accessing detail from a mark entry and the detail is not provided, just return a null value.");++test(function() {+ performance.clearMarks();+ const detail = { unserializable: Symbol() };+ assert_throws_dom("DataCloneError", ()=>{+ new PerformanceMark("A", { detail });+ }, "Trying to structured-serialize a Symbol.");+}, "Mark: Throw an exception when the detail property cannot be structured-serialized.");++test(function() {+ performance.clearMeasures();+ const detail = { randomInfo: 123 }+ const measureEntry = performance.measure("A", { start: 0, detail });+ assert_equals(measureEntry.detail.randomInfo, detail.randomInfo);+ assert_not_equals(measureEntry.detail, detail);+}, "The detail property in the measure method should be structured-clone.");++test(function() {+ performance.clearMeasures();+ const detail = { randomInfo: 123 }+ const measureEntry = performance.measure("A", { start: 0, detail });+ assert_equals(measureEntry.detail, measureEntry.detail);+}, "The detail property in the measure method should be the same reference.");++test(function() {+ performance.clearMeasures();+ const measureEntry = performance.measure("A");+ assert_equals(measureEntry.detail, null);+}, "When accessing detail from a measure entry and the detail is not provided, just return a null value.");++test(function() {+ performance.clearMeasures();+ const detail = { unserializable: Symbol() };+ assert_throws_dom("DataCloneError", ()=>{+ performance.measure("A", { start: 0, detail });+ }, "Trying to structured-serialize a Symbol.");+}, "Measure: Throw an exception when the detail property cannot be structured-serialized.");++test(function() {+ const bar = { 1: 2 };+ const detail = { foo: 1, bar };+ const mark = performance.mark("m", { detail });+ detail.foo = 2;+ assert_equals(mark.detail.foo, 1);+}, "The detail object is cloned when passed to mark API.");diff --git a/Tests/LibWeb/Text/input/wpt-import/user-timing/structured-serialize-detail.any.worker.html b/Tests/LibWeb/Text/input/wpt-import/user-timing/structured-serialize-detail.any.worker.htmlnew file mode 100644index 00000000000..5cdc7bd4dd5--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/user-timing/structured-serialize-detail.any.worker.html@@ -0,0 +1,9 @@+<!doctype html>+<meta charset=utf-8>++<script src="../resources/testharness.js"></script>+<script src="../resources/testharnessreport.js"></script>+<div id=log></div>+<script>+fetch_tests_from_worker(new Worker("../user-timing/structured-serialize-detail.any.worker.js"));+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/user-timing/structured-serialize-detail.any.worker.js b/Tests/LibWeb/Text/input/wpt-import/user-timing/structured-serialize-detail.any.worker.jsnew file mode 100644index 00000000000..4e70b1f77dc--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/user-timing/structured-serialize-detail.any.worker.js@@ -0,0 +1,10 @@++self.GLOBAL = {+ isWindow: function() { return false; },+ isWorker: function() { return true; },+ isShadowRealm: function() { return false; },+};+importScripts("/resources/testharness.js");++importScripts("/user-timing/structured-serialize-detail.any.js");+done();