+
+
diff --git a/test/fixtures/wpt/performance-timeline/po-takeRecords.any.js b/test/fixtures/wpt/performance-timeline/po-takeRecords.any.js
new file mode 100644
index 00000000000000..86ad397b0a5c37
--- /dev/null
+++ b/test/fixtures/wpt/performance-timeline/po-takeRecords.any.js
@@ -0,0 +1,34 @@
+// META: title=PerformanceObserver: takeRecords
+// META: script=performanceobservers.js
+
+async_test(function (t) {
+ const observer = new PerformanceObserver(function (entryList, observer) {
+ assert_unreached('This callback should not have been called.')
+ });
+ let entries = observer.takeRecords();
+ checkEntries(entries, [], 'No records before observe');
+ observer.observe({entryTypes: ['mark']});
+ assert_equals(typeof(observer.takeRecords), 'function');
+ entries = observer.takeRecords();
+ checkEntries(entries, [], 'No records just from observe');
+ performance.mark('a');
+ performance.mark('b');
+ entries = observer.takeRecords();
+ checkEntries(entries, [
+ {entryType: 'mark', name: 'a'},
+ {entryType: 'mark', name: 'b'}
+ ]);
+ performance.mark('c');
+ performance.mark('d');
+ performance.mark('e');
+ entries = observer.takeRecords();
+ checkEntries(entries, [
+ {entryType: 'mark', name: 'c'},
+ {entryType: 'mark', name: 'd'},
+ {entryType: 'mark', name: 'e'}
+ ]);
+ entries = observer.takeRecords();
+ checkEntries(entries, [], 'No entries right after takeRecords');
+ observer.disconnect();
+ t.done();
+ }, "Test PerformanceObserver's takeRecords()");
diff --git a/test/fixtures/wpt/performance-timeline/resources/postmessage-entry.html b/test/fixtures/wpt/performance-timeline/resources/postmessage-entry.html
new file mode 100644
index 00000000000000..ef5be73395b49d
--- /dev/null
+++ b/test/fixtures/wpt/performance-timeline/resources/postmessage-entry.html
@@ -0,0 +1,17 @@
+
+
diff --git a/test/fixtures/wpt/performance-timeline/resources/square.png b/test/fixtures/wpt/performance-timeline/resources/square.png
new file mode 100644
index 00000000000000..be211bc3771803
Binary files /dev/null and b/test/fixtures/wpt/performance-timeline/resources/square.png differ
diff --git a/test/fixtures/wpt/performance-timeline/resources/worker-invalid-entries.js b/test/fixtures/wpt/performance-timeline/resources/worker-invalid-entries.js
new file mode 100644
index 00000000000000..bd7fba2ccf4b6a
--- /dev/null
+++ b/test/fixtures/wpt/performance-timeline/resources/worker-invalid-entries.js
@@ -0,0 +1,6 @@
+performance.mark('workerMark');
+postMessage({
+ 'invalid' : performance.getEntriesByType('invalid').length,
+ 'mark' : performance.getEntriesByType('mark').length,
+ 'measure' : performance.getEntriesByType('measure').length
+});
diff --git a/test/fixtures/wpt/performance-timeline/resources/worker-with-performance-observer.js b/test/fixtures/wpt/performance-timeline/resources/worker-with-performance-observer.js
new file mode 100644
index 00000000000000..a72fe81c47feac
--- /dev/null
+++ b/test/fixtures/wpt/performance-timeline/resources/worker-with-performance-observer.js
@@ -0,0 +1,6 @@
+try {
+ new PerformanceObserver(() => true);
+ postMessage("SUCCESS");
+} catch (ex) {
+ postMessage("FAILURE");
+}
diff --git a/test/fixtures/wpt/performance-timeline/supportedEntryTypes.any.js b/test/fixtures/wpt/performance-timeline/supportedEntryTypes.any.js
new file mode 100644
index 00000000000000..25f195939e7b69
--- /dev/null
+++ b/test/fixtures/wpt/performance-timeline/supportedEntryTypes.any.js
@@ -0,0 +1,19 @@
+test(() => {
+ if (typeof PerformanceObserver.supportedEntryTypes === "undefined")
+ assert_unreached("supportedEntryTypes is not supported.");
+ const types = PerformanceObserver.supportedEntryTypes;
+ assert_greater_than(types.length, 0,
+ "There should be at least one entry in supportedEntryTypes.");
+ for (let i = 1; i < types.length; i++) {
+ assert_true(types[i-1] < types[i],
+ "The strings '" + types[i-1] + "' and '" + types[i] +
+ "' are repeated or they are not in alphabetical order.")
+ }
+}, "supportedEntryTypes exists and returns entries in alphabetical order");
+
+test(() => {
+ if (typeof PerformanceObserver.supportedEntryTypes === "undefined")
+ assert_unreached("supportedEntryTypes is not supported.");
+ assert_true(PerformanceObserver.supportedEntryTypes ===
+ PerformanceObserver.supportedEntryTypes);
+}, "supportedEntryTypes caches result");
diff --git a/test/fixtures/wpt/performance-timeline/webtiming-resolution.any.js b/test/fixtures/wpt/performance-timeline/webtiming-resolution.any.js
new file mode 100644
index 00000000000000..d869c7c52d55d6
--- /dev/null
+++ b/test/fixtures/wpt/performance-timeline/webtiming-resolution.any.js
@@ -0,0 +1,25 @@
+function testTimeResolution(highResTimeFunc, funcString) {
+ test(() => {
+ const t0 = highResTimeFunc();
+ let t1 = highResTimeFunc();
+ while (t0 == t1) {
+ t1 = highResTimeFunc();
+ }
+ const epsilon = 1e-5;
+ assert_greater_than_equal(t1 - t0, 0.005 - epsilon, 'The second ' + funcString + ' should be much greater than the first');
+ }, 'Verifies the resolution of ' + funcString + ' is at least 5 microseconds.');
+}
+
+function timeByPerformanceNow() {
+ return performance.now();
+}
+
+function timeByUserTiming() {
+ performance.mark('timer');
+ const time = performance.getEntriesByName('timer')[0].startTime;
+ performance.clearMarks('timer');
+ return time;
+}
+
+testTimeResolution(timeByPerformanceNow, 'performance.now()');
+testTimeResolution(timeByUserTiming, 'entry.startTime');
diff --git a/test/fixtures/wpt/performance-timeline/worker-with-performance-observer.html b/test/fixtures/wpt/performance-timeline/worker-with-performance-observer.html
new file mode 100644
index 00000000000000..fc92bc971003f2
--- /dev/null
+++ b/test/fixtures/wpt/performance-timeline/worker-with-performance-observer.html
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/test/fixtures/wpt/user-timing/META.yml b/test/fixtures/wpt/user-timing/META.yml
new file mode 100644
index 00000000000000..5cb2a789c09c89
--- /dev/null
+++ b/test/fixtures/wpt/user-timing/META.yml
@@ -0,0 +1,4 @@
+spec: https://w3c.github.io/user-timing/
+suggested_reviewers:
+ - plehegar
+ - igrigorik
diff --git a/test/fixtures/wpt/user-timing/buffered-flag.any.js b/test/fixtures/wpt/user-timing/buffered-flag.any.js
new file mode 100644
index 00000000000000..f938c8522d829a
--- /dev/null
+++ b/test/fixtures/wpt/user-timing/buffered-flag.any.js
@@ -0,0 +1,27 @@
+async_test(t => {
+ // First observer creates second in callback to ensure the entry has been dispatched by the time
+ // the second observer begins observing.
+ new PerformanceObserver(() => {
+ // Second observer requires 'buffered: true' to see an entry.
+ new PerformanceObserver(t.step_func_done(list => {
+ const entries = list.getEntries();
+ assert_equals(entries.length, 1, 'There should be 1 mark entry.');
+ assert_equals(entries[0].entryType, 'mark');
+ })).observe({type: 'mark', buffered: true});
+ }).observe({entryTypes: ['mark']});
+ performance.mark('foo');
+}, 'PerformanceObserver with buffered flag sees previous marks');
+
+async_test(t => {
+ // First observer creates second in callback to ensure the entry has been dispatched by the time
+ // the second observer begins observing.
+ new PerformanceObserver(() => {
+ // Second observer requires 'buffered: true' to see an entry.
+ new PerformanceObserver(t.step_func_done(list => {
+ const entries = list.getEntries();
+ assert_equals(entries.length, 1, 'There should be 1 measure entry.');
+ assert_equals(entries[0].entryType, 'measure');
+ })).observe({type: 'measure', buffered: true});
+ }).observe({entryTypes: ['measure']});
+ performance.measure('bar');
+}, 'PerformanceObserver with buffered flag sees previous measures');
diff --git a/test/fixtures/wpt/user-timing/case-sensitivity.any.js b/test/fixtures/wpt/user-timing/case-sensitivity.any.js
new file mode 100644
index 00000000000000..1c0b0dcac361fe
--- /dev/null
+++ b/test/fixtures/wpt/user-timing/case-sensitivity.any.js
@@ -0,0 +1,25 @@
+ test(function () {
+ assert_equals(typeof self.performance, "object");
+ assert_equals(typeof self.performance.getEntriesByType, "function");
+
+ self.performance.mark("mark1");
+ self.performance.measure("measure1");
+
+ const type = [
+ 'mark',
+ 'measure',
+ ];
+ type.forEach(function(entryType) {
+ if (PerformanceObserver.supportedEntryTypes.includes(entryType)) {
+ const entryTypeUpperCased = entryType.toUpperCase();
+ const entryTypeCapitalized = entryType[0].toUpperCase() + entryType.substring(1);
+ const lowerList = self.performance.getEntriesByType(entryType);
+ const upperList = self.performance.getEntriesByType(entryTypeUpperCased);
+ const mixedList = self.performance.getEntriesByType(entryTypeCapitalized);
+
+ assert_greater_than(lowerList.length, 0, "Entries exist");
+ assert_equals(upperList.length, 0, "getEntriesByType('" + entryTypeCapitalized + "').length");
+ assert_equals(mixedList.length, 0, "getEntriesByType('" + entryTypeCapitalized + "').length");
+ }
+ });
+ }, "getEntriesByType values are case sensitive");
diff --git a/test/fixtures/wpt/user-timing/clearMarks.html b/test/fixtures/wpt/user-timing/clearMarks.html
new file mode 100644
index 00000000000000..92c60a3bbb856b
--- /dev/null
+++ b/test/fixtures/wpt/user-timing/clearMarks.html
@@ -0,0 +1,84 @@
+
+
+
+
+functionality test of window.performance.clearMarks
+
+
+
+
+
+
+
+
+
+
+
Description
+
This test validates functionality of the interface window.performance.clearMarks.
+
+
+
diff --git a/test/fixtures/wpt/user-timing/clearMeasures.html b/test/fixtures/wpt/user-timing/clearMeasures.html
new file mode 100644
index 00000000000000..54d41005698305
--- /dev/null
+++ b/test/fixtures/wpt/user-timing/clearMeasures.html
@@ -0,0 +1,77 @@
+
+
+
+
+functionality test of window.performance.clearMeasures
+
+
+
+
+
+
+
+
+
+
+
Description
+
This test validates functionality of the interface window.performance.clearMeasures.
+
+
+
diff --git a/test/fixtures/wpt/user-timing/clear_all_marks.any.js b/test/fixtures/wpt/user-timing/clear_all_marks.any.js
new file mode 100644
index 00000000000000..35cd2a04f61036
--- /dev/null
+++ b/test/fixtures/wpt/user-timing/clear_all_marks.any.js
@@ -0,0 +1,17 @@
+test(function() {
+ self.performance.mark("mark1");
+ self.performance.mark("mark2");
+
+ // test that two marks have been created
+ var entries = self.performance.getEntriesByType("mark");
+ assert_equals(entries.length, 2, "Two marks have been created for this test.");
+
+ // clear all marks
+ self.performance.clearMarks();
+
+ // test that all marks were cleared
+ entries = self.performance.getEntriesByType("mark");
+
+ assert_equals(entries.length, 0, "All marks have been cleared.");
+
+}, "Clearing all marks remove all of them.");
diff --git a/test/fixtures/wpt/user-timing/clear_all_measures.any.js b/test/fixtures/wpt/user-timing/clear_all_measures.any.js
new file mode 100644
index 00000000000000..32c993f2827a30
--- /dev/null
+++ b/test/fixtures/wpt/user-timing/clear_all_measures.any.js
@@ -0,0 +1,21 @@
+test(function()
+{
+ self.performance.mark("mark1");
+ self.performance.measure("measure1", "mark1");
+ self.performance.mark("mark2");
+ self.performance.measure("measure2", "mark2");
+
+ // test that two measures have been created
+ var entries = self.performance.getEntriesByType("measure");
+ assert_equals(entries.length, 2, "Two measures have been created for this test.");
+
+ // clear all measures
+ self.performance.clearMeasures();
+
+ // test that all measures were cleared
+ entries = self.performance.getEntriesByType("measure");
+ assert_equals(entries.length, 0,
+ "After a call to self.performance.clearMeasures(), " +
+ "self.performance.getEntriesByType(\"measure\") returns an empty object.");
+
+}, "Clearing all marks remove all of them.");
diff --git a/test/fixtures/wpt/user-timing/clear_non_existent_mark.any.js b/test/fixtures/wpt/user-timing/clear_non_existent_mark.any.js
new file mode 100644
index 00000000000000..c7d8b478613401
--- /dev/null
+++ b/test/fixtures/wpt/user-timing/clear_non_existent_mark.any.js
@@ -0,0 +1,26 @@
+test(function() {
+ self.performance.mark("mark1");
+ self.performance.mark("mark2");
+
+ // test that two marks have been created
+ var entries = self.performance.getEntriesByType("mark");
+ assert_equals(entries.length, 2, "Two marks have been created for this test.");
+
+ // clear non-existent mark
+ self.performance.clearMarks("mark3");
+
+ // test that "mark1" still exists
+ entries = self.performance.getEntriesByName("mark1");
+ assert_equals(entries[0].name, "mark1",
+ "After a call to self.performance.clearMarks(\"mark3\"), where \"mark3" +
+ "\" is a non-existent mark, self.performance.getEntriesByName(\"mark1\") " +
+ "returns an object containing the \"mark1\" mark.");
+
+ // test that "mark2" still exists
+ entries = self.performance.getEntriesByName("mark2");
+ assert_equals(entries[0].name, "mark2",
+ "After a call to self.performance.clearMarks(\"mark3\"), where \"mark3" +
+ "\" is a non-existent mark, self.performance.getEntriesByName(\"mark2\") " +
+ "returns an object containing the \"mark2\" mark.");
+
+}, "Clearing a non-existent mark doesn't affect existing marks");
diff --git a/test/fixtures/wpt/user-timing/clear_non_existent_measure.any.js b/test/fixtures/wpt/user-timing/clear_non_existent_measure.any.js
new file mode 100644
index 00000000000000..9de0b5f266d4e2
--- /dev/null
+++ b/test/fixtures/wpt/user-timing/clear_non_existent_measure.any.js
@@ -0,0 +1,29 @@
+test(function()
+{
+ self.performance.mark("mark1");
+ self.performance.measure("measure1", "mark1");
+ self.performance.mark("mark2");
+ self.performance.measure("measure2", "mark2");
+
+ // test that two measures have been created
+ var entries = self.performance.getEntriesByType("measure");
+ assert_equals(entries.length, 2, "Two measures have been created for this test.");
+
+ // clear non-existent measure
+ self.performance.clearMeasures("measure3");
+
+ // test that "measure1" still exists
+ entries = self.performance.getEntriesByName("measure1");
+ assert_equals(entries[0].name, "measure1",
+ "After a call to self.performance.clearMeasures(\"measure3\"), where \"measure3" +
+ "\" is a non-existent measure, self.performance.getEntriesByName(\"measure1\") " +
+ "returns an object containing the \"measure1\" measure.");
+
+ // test that "measure2" still exists
+ entries = self.performance.getEntriesByName("measure2");
+ assert_equals(entries[0].name, "measure2",
+ "After a call to self.performance.clearMeasures(\"measure3\"), where \"measure3" +
+ "\" is a non-existent measure, self.performance.getEntriesByName(\"measure2\") " +
+ "returns an object containing the \"measure2\" measure.");
+
+}, "Clearing a non-existent measure doesn't affect existing measures");
diff --git a/test/fixtures/wpt/user-timing/clear_one_mark.any.js b/test/fixtures/wpt/user-timing/clear_one_mark.any.js
new file mode 100644
index 00000000000000..c180199d8c9f92
--- /dev/null
+++ b/test/fixtures/wpt/user-timing/clear_one_mark.any.js
@@ -0,0 +1,26 @@
+test(function() {
+ self.performance.mark("mark1");
+ self.performance.mark("mark2");
+
+ // test that two marks have been created
+ var entries = self.performance.getEntriesByType("mark");
+ assert_equals(entries.length, 2, "Two marks have been created for this test.");
+
+ // clear existent mark
+ self.performance.clearMarks("mark1");
+
+ // test that "mark1" was cleared
+ entries = self.performance.getEntriesByName("mark1");
+
+ assert_equals(entries.length, 0,
+ "After a call to self.performance.clearMarks(\"mark1\"), " +
+ "window.performance.getEntriesByName(\"mark1\") returns an empty object.");
+
+ // test that "mark2" still exists
+ entries = self.performance.getEntriesByName("mark2");
+ assert_equals(entries[0].name, "mark2",
+ "After a call to self.performance.clearMarks(\"mark1\"), " +
+ "window.performance.getEntriesByName(\"mark2\") returns an object containing the " +
+ "\"mark2\" mark.");
+
+}, "Clearing an existent mark doesn't affect other existing marks");
diff --git a/test/fixtures/wpt/user-timing/clear_one_measure.any.js b/test/fixtures/wpt/user-timing/clear_one_measure.any.js
new file mode 100644
index 00000000000000..a5e663772c8bbe
--- /dev/null
+++ b/test/fixtures/wpt/user-timing/clear_one_measure.any.js
@@ -0,0 +1,29 @@
+test(function()
+{
+ self.performance.mark("mark1");
+ self.performance.measure("measure1", "mark1");
+ self.performance.mark("mark2");
+ self.performance.measure("measure2", "mark2");
+
+ // test that two measures have been created
+ var entries = self.performance.getEntriesByType("measure");
+ assert_equals(entries.length, 2, "Two measures have been created for this test.");
+
+ // clear existent measure
+ self.performance.clearMeasures("measure1");
+
+ // test that "measure1" was cleared
+ entries = self.performance.getEntriesByName("measure1");
+
+ assert_equals(entries.length, 0,
+ "After a call to self.performance.clearMeasures(\"measure1\"), " +
+ "self.performance.getEntriesByName(\"measure1\") returns an empty object.");
+
+ // test that "measure2" still exists
+ entries = self.performance.getEntriesByName("measure2");
+ assert_equals(entries[0].name, "measure2",
+ "After a call to self.performance.clearMeasures(\"measure1\"), " +
+ "self.performance.getEntriesByName(\"measure2\") returns an object containing the " +
+ "\"measure2\" measure.");
+
+}, "Clearing an existent measure doesn't affect other existing measures");
diff --git a/test/fixtures/wpt/user-timing/entry_type.any.js b/test/fixtures/wpt/user-timing/entry_type.any.js
new file mode 100644
index 00000000000000..1e37453d09d42e
--- /dev/null
+++ b/test/fixtures/wpt/user-timing/entry_type.any.js
@@ -0,0 +1,13 @@
+test(function () {
+ self.performance.mark('mark');
+ var mark_entry = self.performance.getEntriesByName('mark')[0];
+
+ assert_equals(Object.prototype.toString.call(mark_entry), '[object PerformanceMark]', 'Class name of mark entry should be PerformanceMark.');
+}, "Validate the user timing entry type PerformanceMark");
+
+test(function () {
+ self.performance.measure('measure');
+ var measure_entry = self.performance.getEntriesByName('measure')[0];
+
+ assert_equals(Object.prototype.toString.call(measure_entry), '[object PerformanceMeasure]', 'Class name of measure entry should be PerformanceMeasure.');
+}, "Validate the user timing entry type PerformanceMeasure");
diff --git a/test/fixtures/wpt/user-timing/idlharness.any.js b/test/fixtures/wpt/user-timing/idlharness.any.js
new file mode 100644
index 00000000000000..511f2d0455b833
--- /dev/null
+++ b/test/fixtures/wpt/user-timing/idlharness.any.js
@@ -0,0 +1,33 @@
+// META: global=window,worker
+// META: script=/resources/WebIDLParser.js
+// META: script=/resources/idlharness.js
+// META: timeout=long
+
+// https://w3c.github.io/user-timing/
+
+'use strict';
+
+idl_test(
+ ['user-timing'],
+ ['hr-time', 'performance-timeline', 'dom'],
+ idl_array => {
+ try {
+ performance.mark('test');
+ performance.measure('test');
+ for (const m of performance.getEntriesByType('mark')) {
+ self.mark = m;
+ }
+ for (const m of performance.getEntriesByType('measure')) {
+ self.measure = m;
+ }
+ } catch (e) {
+ // Will be surfaced when mark is undefined below.
+ }
+
+ idl_array.add_objects({
+ Performance: ['performance'],
+ PerformanceMark: ['mark'],
+ PerformanceMeasure: ['measure'],
+ });
+ }
+);
diff --git a/test/fixtures/wpt/user-timing/invoke_with_timing_attributes.html b/test/fixtures/wpt/user-timing/invoke_with_timing_attributes.html
new file mode 100644
index 00000000000000..1df94a3006d7fb
--- /dev/null
+++ b/test/fixtures/wpt/user-timing/invoke_with_timing_attributes.html
@@ -0,0 +1,35 @@
+
+
+
+
+ exception test of performance.mark and performance.measure
+
+
+
+
+
+
+
Description
+
This test validates exception scenarios of invoking mark() and measure() with timing attributes as value.
+
+
+
+
diff --git a/test/fixtures/wpt/user-timing/invoke_with_timing_attributes.worker.js b/test/fixtures/wpt/user-timing/invoke_with_timing_attributes.worker.js
new file mode 100644
index 00000000000000..32677c64d3bd5f
--- /dev/null
+++ b/test/fixtures/wpt/user-timing/invoke_with_timing_attributes.worker.js
@@ -0,0 +1,25 @@
+importScripts("/resources/testharness.js");
+importScripts("resources/webperftestharness.js");
+
+function emit_test(attrName) {
+ test(function() {
+ performance.mark(attrName);
+ performance.clearMarks(attrName);
+ }, "performance.mark should not throw if used with timing attribute " + attrName
+ + " in workers");
+}
+for (var i in timingAttributes) {
+ emit_test(timingAttributes[i]);
+}
+
+function emit_test2(attrName) {
+ test(function() {
+ performance.measure(attrName);
+ performance.clearMeasures(attrName);
+ }, "performance.measure should not throw if used with timing attribute " + attrName
+ + " in workers");
+}
+for (var i in timingAttributes) {
+ emit_test2(timingAttributes[i]);
+}
+done();
diff --git a/test/fixtures/wpt/user-timing/invoke_without_parameter.html b/test/fixtures/wpt/user-timing/invoke_without_parameter.html
new file mode 100644
index 00000000000000..114435e59befbb
--- /dev/null
+++ b/test/fixtures/wpt/user-timing/invoke_without_parameter.html
@@ -0,0 +1,26 @@
+
+
+
+
+ exception test of performance.mark and performance.measure
+
+
+
+
+
+
+
+
Description
+
This test validates exception scenarios of invoking mark() and measure() without parameter.
+
+
+
+
diff --git a/test/fixtures/wpt/user-timing/mark-entry-constructor.any.js b/test/fixtures/wpt/user-timing/mark-entry-constructor.any.js
new file mode 100644
index 00000000000000..ef9c403dda6723
--- /dev/null
+++ b/test/fixtures/wpt/user-timing/mark-entry-constructor.any.js
@@ -0,0 +1,40 @@
+// META: script=resources/user-timing-helper.js
+
+test(()=>{
+ const entry = new PerformanceMark("name");
+ assert_true(entry instanceof PerformanceMark);
+ checkEntry(entry, {name: "name", entryType: "mark"});
+}, "Mark entry can be created by 'new PerformanceMark(string)'.");
+
+test(()=>{
+ const entry = new PerformanceMark("name", {});
+ assert_true(entry instanceof PerformanceMark);
+ checkEntry(entry, {name: "name", entryType: "mark"});
+}, "Mark entry can be created by 'new PerformanceMark(string, {})'.");
+
+test(()=>{
+ const entry = new PerformanceMark("name", {startTime: 1});
+ assert_true(entry instanceof PerformanceMark);
+ checkEntry(entry, {name: "name", entryType: "mark", startTime: 1});
+}, "Mark entry can be created by 'new PerformanceMark(string, {startTime})'.");
+
+test(()=>{
+ const entry = new PerformanceMark("name", {detail: {info: "abc"}});
+ assert_true(entry instanceof PerformanceMark);
+ checkEntry(entry, {name: "name", entryType: "mark", detail: {info: "abc"}});
+}, "Mark entry can be created by 'new PerformanceMark(string, {detail})'.");
+
+test(()=>{
+ const entry =
+ new PerformanceMark("name", {startTime: 1, detail: {info: "abc"}});
+ assert_true(entry instanceof PerformanceMark);
+ checkEntry(entry, {name: "name", entryType: "mark", startTime: 1, detail: {info: "abc"}});
+}, "Mark entry can be created by " +
+ "'new PerformanceMark(string, {startTime, detail})'.");
+
+test(()=>{
+ const entry = new PerformanceMark("name");
+ assert_true(entry instanceof PerformanceMark);
+ checkEntry(entry, {name: "name", entryType: "mark"});
+ assert_equals(performance.getEntriesByName("name").length, 0);
+}, "Using new PerformanceMark() shouldn't add the entry to performance timeline.");
diff --git a/test/fixtures/wpt/user-timing/mark-errors.any.js b/test/fixtures/wpt/user-timing/mark-errors.any.js
new file mode 100644
index 00000000000000..dcd36695e22f2c
--- /dev/null
+++ b/test/fixtures/wpt/user-timing/mark-errors.any.js
@@ -0,0 +1,15 @@
+test(function() {
+ assert_throws_js(TypeError, function() { self.performance.mark("mark1", 123); }, "Number passed as a dict argument should cause type-error.")
+}, "Number should be rejected as the mark-options.")
+
+test(function() {
+ assert_throws_js(TypeError, function() { self.performance.mark("mark1", NaN); }, "NaN passed as a dict argument should cause type-error.")
+}, "NaN should be rejected as the mark-options.")
+
+test(function() {
+ assert_throws_js(TypeError, function() { self.performance.mark("mark1", Infinity); }, "Infinity passed as a dict argument should cause type-error.")
+}, "Infinity should be rejected as the mark-options.")
+
+test(function() {
+ assert_throws_js(TypeError, function() { self.performance.mark("mark1", "string"); }, "String passed as a dict argument should cause type-error.")
+}, "String should be rejected as the mark-options.")
diff --git a/test/fixtures/wpt/user-timing/mark-l3.any.js b/test/fixtures/wpt/user-timing/mark-l3.any.js
new file mode 100644
index 00000000000000..407a5c8bba6a3c
--- /dev/null
+++ b/test/fixtures/wpt/user-timing/mark-l3.any.js
@@ -0,0 +1,39 @@
+// META: script=resources/user-timing-helper.js
+
+async_test(function (t) {
+ let mark_entries = [];
+ const expected_entries =
+ [{ entryType: "mark", name: "mark1", detail: null},
+ { entryType: "mark", name: "mark2", detail: null},
+ { entryType: "mark", name: "mark3", detail: null},
+ { entryType: "mark", name: "mark4", detail: null},
+ { entryType: "mark", name: "mark5", detail: null},
+ { entryType: "mark", name: "mark6", detail: {}},
+ { entryType: "mark", name: "mark7", detail: {info: 'abc'}},
+ { entryType: "mark", name: "mark8", detail: null, startTime: 234.56},
+ { entryType: "mark", name: "mark9", detail: {count: 3}, startTime: 345.67}];
+ const observer = new PerformanceObserver(
+ t.step_func(function (entryList, obs) {
+ mark_entries =
+ mark_entries.concat(entryList.getEntries());
+ if (mark_entries.length >= expected_entries.length) {
+ checkEntries(mark_entries, expected_entries);
+ observer.disconnect();
+ t.done();
+ }
+ })
+ );
+ self.performance.clearMarks();
+ observer.observe({entryTypes: ["mark"]});
+ const returned_entries = [];
+ returned_entries.push(self.performance.mark("mark1"));
+ returned_entries.push(self.performance.mark("mark2", undefined));
+ returned_entries.push(self.performance.mark("mark3", null));
+ returned_entries.push(self.performance.mark("mark4", {}));
+ returned_entries.push(self.performance.mark("mark5", {detail: null}));
+ returned_entries.push(self.performance.mark("mark6", {detail: {}}));
+ returned_entries.push(self.performance.mark("mark7", {detail: {info: 'abc'}}));
+ returned_entries.push(self.performance.mark("mark8", {startTime: 234.56}));
+ returned_entries.push(self.performance.mark("mark9", {detail: {count: 3}, startTime: 345.67}));
+ checkEntries(returned_entries, expected_entries);
+}, "mark entries' detail and startTime are customizable.");
diff --git a/test/fixtures/wpt/user-timing/mark-measure-feature-detection.html b/test/fixtures/wpt/user-timing/mark-measure-feature-detection.html
new file mode 100644
index 00000000000000..6f1ad489e95680
--- /dev/null
+++ b/test/fixtures/wpt/user-timing/mark-measure-feature-detection.html
@@ -0,0 +1,36 @@
+
+
+User Timing: L2 vs L3 feature detection
+
+
+
diff --git a/test/fixtures/wpt/user-timing/mark-measure-return-objects.any.js b/test/fixtures/wpt/user-timing/mark-measure-return-objects.any.js
new file mode 100644
index 00000000000000..bb15c5839818ba
--- /dev/null
+++ b/test/fixtures/wpt/user-timing/mark-measure-return-objects.any.js
@@ -0,0 +1,37 @@
+async_test(function (t) {
+ self.performance.clearMeasures();
+ const measure = self.performance.measure("measure1");
+ assert_true(measure instanceof PerformanceMeasure);
+ t.done();
+}, "L3: performance.measure(name) should return an entry.");
+
+async_test(function (t) {
+ self.performance.clearMeasures();
+ const measure = self.performance.measure("measure2",
+ { start: 12, end: 23 });
+ assert_true(measure instanceof PerformanceMeasure);
+ t.done();
+}, "L3: performance.measure(name, param1) should return an entry.");
+
+async_test(function (t) {
+ self.performance.clearMeasures();
+ self.performance.mark("1");
+ self.performance.mark("2");
+ const measure = self.performance.measure("measure3", "1", "2");
+ assert_true(measure instanceof PerformanceMeasure);
+ t.done();
+}, "L3: performance.measure(name, param1, param2) should return an entry.");
+
+async_test(function (t) {
+ self.performance.clearMarks();
+ const mark = self.performance.mark("mark1");
+ assert_true(mark instanceof PerformanceMark);
+ t.done();
+}, "L3: performance.mark(name) should return an entry.");
+
+async_test(function (t) {
+ self.performance.clearMarks();
+ const mark = self.performance.mark("mark2", { startTime: 34 });
+ assert_true(mark instanceof PerformanceMark);
+ t.done();
+}, "L3: performance.mark(name, param) should return an entry.");
diff --git a/test/fixtures/wpt/user-timing/mark.any.js b/test/fixtures/wpt/user-timing/mark.any.js
new file mode 100644
index 00000000000000..7e814d2074ca8b
--- /dev/null
+++ b/test/fixtures/wpt/user-timing/mark.any.js
@@ -0,0 +1,118 @@
+// test data
+var testThreshold = 20;
+
+var expectedTimes = new Array();
+
+function match_entries(entries, index)
+{
+ var entry = entries[index];
+ var match = self.performance.getEntriesByName("mark")[index];
+ assert_equals(entry.name, match.name, "entry.name");
+ assert_equals(entry.startTime, match.startTime, "entry.startTime");
+ assert_equals(entry.entryType, match.entryType, "entry.entryType");
+ assert_equals(entry.duration, match.duration, "entry.duration");
+}
+
+function filter_entries_by_type(entryList, entryType)
+{
+ var testEntries = new Array();
+
+ // filter entryList
+ for (var i in entryList)
+ {
+ if (entryList[i].entryType == entryType)
+ {
+ testEntries.push(entryList[i]);
+ }
+ }
+
+ return testEntries;
+}
+
+test(function () {
+ // create first mark
+ self.performance.mark("mark");
+
+ expectedTimes[0] = self.performance.now();
+
+ const entries = self.performance.getEntriesByName("mark");
+ assert_equals(entries.length, 1);
+}, "Entry 0 is properly created");
+
+test(function () {
+ // create second, duplicate mark
+ self.performance.mark("mark");
+
+ expectedTimes[1] = self.performance.now();
+
+ const entries = self.performance.getEntriesByName("mark");
+ assert_equals(entries.length, 2);
+
+}, "Entry 1 is properly created");
+
+function test_mark(index) {
+ test(function () {
+ const entries = self.performance.getEntriesByName("mark");
+ assert_equals(entries[index].name, "mark", "Entry has the proper name");
+ }, "Entry " + index + " has the proper name");
+
+ test(function () {
+ const entries = self.performance.getEntriesByName("mark");
+ assert_approx_equals(entries[index].startTime, expectedTimes[index], testThreshold);
+ }, "Entry " + index + " startTime is approximately correct (up to " + testThreshold +
+ "ms difference allowed)");
+
+ test(function () {
+ const entries = self.performance.getEntriesByName("mark");
+ assert_equals(entries[index].entryType, "mark");
+ }, "Entry " + index + " has the proper entryType");
+
+ test(function () {
+ const entries = self.performance.getEntriesByName("mark");
+ assert_equals(entries[index].duration, 0);
+ }, "Entry " + index + " duration == 0");
+
+ test(function () {
+ const entries = self.performance.getEntriesByName("mark", "mark");
+ assert_equals(entries[index].name, "mark");
+ }, "getEntriesByName(\"mark\", \"mark\")[" + index + "] returns an " +
+ "object containing a \"mark\" mark");
+
+ test(function () {
+ const entries = self.performance.getEntriesByName("mark", "mark");
+ match_entries(entries, index);
+ }, "The mark returned by getEntriesByName(\"mark\", \"mark\")[" + index
+ + "] matches the mark returned by " +
+ "getEntriesByName(\"mark\")[" + index + "]");
+
+ test(function () {
+ const entries = filter_entries_by_type(self.performance.getEntries(), "mark");
+ assert_equals(entries[index].name, "mark");
+ }, "getEntries()[" + index + "] returns an " +
+ "object containing a \"mark\" mark");
+
+ test(function () {
+ const entries = filter_entries_by_type(self.performance.getEntries(), "mark");
+ match_entries(entries, index);
+ }, "The mark returned by getEntries()[" + index
+ + "] matches the mark returned by " +
+ "getEntriesByName(\"mark\")[" + index + "]");
+
+ test(function () {
+ const entries = self.performance.getEntriesByType("mark");
+ assert_equals(entries[index].name, "mark");
+ }, "getEntriesByType(\"mark\")[" + index + "] returns an " +
+ "object containing a \"mark\" mark");
+
+ test(function () {
+ const entries = self.performance.getEntriesByType("mark");
+ match_entries(entries, index);
+ }, "The mark returned by getEntriesByType(\"mark\")[" + index
+ + "] matches the mark returned by " +
+ "getEntriesByName(\"mark\")[" + index + "]");
+
+}
+
+for (var i = 0; i < expectedTimes.length; i++) {
+ test_mark(i);
+}
diff --git a/test/fixtures/wpt/user-timing/mark.html b/test/fixtures/wpt/user-timing/mark.html
new file mode 100644
index 00000000000000..e03e9e6247adab
--- /dev/null
+++ b/test/fixtures/wpt/user-timing/mark.html
@@ -0,0 +1,58 @@
+
+
+
+
+functionality test of window.performance.mark
+
+
+
+
+
+
+
+
+
+
+
Description
+
This test validates functionality of the interface window.performance.mark.
+
+
+
diff --git a/test/fixtures/wpt/user-timing/mark_exceptions.html b/test/fixtures/wpt/user-timing/mark_exceptions.html
new file mode 100644
index 00000000000000..b445c6b8778ae7
--- /dev/null
+++ b/test/fixtures/wpt/user-timing/mark_exceptions.html
@@ -0,0 +1,41 @@
+
+
+
+
+ window.performance User Timing mark() method is throwing the proper exceptions
+
+
+
+
+
+
+
+
+
+
Description
+
This test validates that the performance.mark() method throws a SYNTAX_ERR exception whenever a navigation
+ timing attribute is provided for the name parameter.
+
+
+
+
+
diff --git a/test/fixtures/wpt/user-timing/measure-exceptions.html b/test/fixtures/wpt/user-timing/measure-exceptions.html
new file mode 100644
index 00000000000000..2836eaee2a86c1
--- /dev/null
+++ b/test/fixtures/wpt/user-timing/measure-exceptions.html
@@ -0,0 +1,49 @@
+
+
+
+ This tests that 'performance.measure' throws exceptions with reasonable messages.
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test/fixtures/wpt/user-timing/measure-l3.any.js b/test/fixtures/wpt/user-timing/measure-l3.any.js
new file mode 100644
index 00000000000000..24c27c483515ed
--- /dev/null
+++ b/test/fixtures/wpt/user-timing/measure-l3.any.js
@@ -0,0 +1,35 @@
+// META: script=resources/user-timing-helper.js
+
+function endTime(entry) {
+ return entry.startTime + entry.duration;
+}
+
+test(function() {
+ performance.clearMarks();
+ performance.clearMeasures();
+ const markEntry = performance.mark("mark", {startTime: 123});
+ const measureEntry = performance.measure("A", undefined, "mark");
+ assert_equals(measureEntry.startTime, 0);
+ assert_equals(endTime(measureEntry), markEntry.startTime);
+}, "When the end mark is given and the start is unprovided, the end time of the measure entry should be the end mark's time, the start time should be 0.");
+
+test(function() {
+ performance.clearMarks();
+ performance.clearMeasures();
+ const markEntry = performance.mark("mark", {startTime: 123});
+ const endMin = performance.now();
+ const measureEntry = performance.measure("A", "mark", undefined);
+ const endMax = performance.now();
+ assert_equals(measureEntry.startTime, markEntry.startTime);
+ assert_greater_than_equal(endTime(measureEntry), endMin);
+ assert_greater_than_equal(endMax, endTime(measureEntry));
+}, "When the start mark is given and the end is unprovided, the start time of the measure entry should be the start mark's time, the end should be now.");
+
+test(function() {
+ performance.clearMarks();
+ performance.clearMeasures();
+ const markEntry = performance.mark("mark", {startTime: 123});
+ const measureEntry = performance.measure("A", "mark", "mark");
+ assert_equals(endTime(measureEntry), markEntry.startTime);
+ assert_equals(measureEntry.startTime, markEntry.startTime);
+}, "When start and end mark are both given, the start time and end time of the measure entry should be the the marks' time, repectively");
diff --git a/test/fixtures/wpt/user-timing/measure-with-dict.any.js b/test/fixtures/wpt/user-timing/measure-with-dict.any.js
new file mode 100644
index 00000000000000..b452feb0de6fbb
--- /dev/null
+++ b/test/fixtures/wpt/user-timing/measure-with-dict.any.js
@@ -0,0 +1,112 @@
+// META: script=resources/user-timing-helper.js
+
+function cleanupPerformanceTimeline() {
+ performance.clearMarks();
+ performance.clearMeasures();
+}
+
+async_test(function (t) {
+ this.add_cleanup(cleanupPerformanceTimeline);
+ let measureEntries = [];
+ const timeStamp1 = 784.4;
+ const timeStamp2 = 1234.5;
+ const timeStamp3 = 66.6;
+ const timeStamp4 = 5566;
+ const expectedEntries =
+ [{ entryType: "measure", name: "measure1", detail: null, startTime: 0 },
+ { entryType: "measure", name: "measure2", detail: null, startTime: 0 },
+ { entryType: "measure", name: "measure3", detail: null, startTime: 0 },
+ { entryType: "measure", name: "measure4", detail: null },
+ { entryType: "measure", name: "measure5", detail: null, startTime: 0 },
+ { entryType: "measure", name: "measure6", detail: null, startTime: timeStamp1 },
+ { entryType: "measure", name: "measure7", detail: null, startTime: timeStamp1, duration: timeStamp2 - timeStamp1 },
+ { entryType: "measure", name: "measure8", detail: null, startTime: 0 },
+ { entryType: "measure", name: "measure9", detail: null, startTime: 0 },
+ { entryType: "measure", name: "measure10", detail: null, startTime: timeStamp1 },
+ { entryType: "measure", name: "measure11", detail: null, startTime: timeStamp3 },
+ { entryType: "measure", name: "measure12", detail: null, startTime: 0 },
+ { entryType: "measure", name: "measure13", detail: null, startTime: 0 },
+ { entryType: "measure", name: "measure14", detail: null, startTime: timeStamp3, duration: timeStamp1 - timeStamp3 },
+ { entryType: "measure", name: "measure15", detail: null, startTime: timeStamp1, duration: timeStamp2 - timeStamp1 },
+ { entryType: "measure", name: "measure16", detail: null, startTime: timeStamp1 },
+ { entryType: "measure", name: "measure17", detail: { customInfo: 159 }, startTime: timeStamp3, duration: timeStamp2 - timeStamp3 },
+ { entryType: "measure", name: "measure18", detail: null, startTime: timeStamp1, duration: timeStamp2 - timeStamp1 },
+ { entryType: "measure", name: "measure19", detail: null, startTime: timeStamp1, duration: timeStamp2 - timeStamp1 },
+ { entryType: "measure", name: "measure20", detail: null, startTime: 0 },
+ { entryType: "measure", name: "measure21", detail: null, startTime: 0 },
+ { entryType: "measure", name: "measure22", detail: null, startTime: 0 },
+ { entryType: "measure", name: "measure23", detail: null, startTime: 0 }];
+ const observer = new PerformanceObserver(
+ t.step_func(function (entryList, obs) {
+ measureEntries =
+ measureEntries.concat(entryList.getEntries());
+ if (measureEntries.length >= expectedEntries.length) {
+ checkEntries(measureEntries, expectedEntries);
+ observer.disconnect();
+ t.done();
+ }
+ })
+ );
+ observer.observe({ entryTypes: ["measure"] });
+ self.performance.mark("mark1", { detail: { randomInfo: 3 }, startTime: timeStamp1 });
+ self.performance.mark("mark2", { startTime: timeStamp2 });
+
+ const returnedEntries = [];
+ returnedEntries.push(self.performance.measure("measure1"));
+ returnedEntries.push(self.performance.measure("measure2", undefined));
+ returnedEntries.push(self.performance.measure("measure3", null));
+ returnedEntries.push(self.performance.measure("measure4", 'mark1'));
+ returnedEntries.push(
+ self.performance.measure("measure5", null, 'mark1'));
+ returnedEntries.push(
+ self.performance.measure("measure6", 'mark1', undefined));
+ returnedEntries.push(
+ self.performance.measure("measure7", 'mark1', 'mark2'));
+ returnedEntries.push(
+ self.performance.measure("measure8", {}));
+ returnedEntries.push(
+ self.performance.measure("measure9", { start: undefined }));
+ returnedEntries.push(
+ self.performance.measure("measure10", { start: 'mark1' }));
+ returnedEntries.push(
+ self.performance.measure("measure11", { start: timeStamp3 }));
+ returnedEntries.push(
+ self.performance.measure("measure12", { end: undefined }));
+ returnedEntries.push(
+ self.performance.measure("measure13", { end: 'mark1' }));
+ returnedEntries.push(
+ self.performance.measure("measure14", { start: timeStamp3, end: 'mark1' }));
+ returnedEntries.push(
+ self.performance.measure("measure15", { start: timeStamp1, end: timeStamp2, detail: undefined }));
+ returnedEntries.push(
+ self.performance.measure("measure16", { start: 'mark1', end: undefined, detail: null }));
+ returnedEntries.push(
+ self.performance.measure("measure17", { start: timeStamp3, end: 'mark2', detail: { customInfo: 159 }}));
+ returnedEntries.push(
+ self.performance.measure("measure18", { start: timeStamp1, duration: timeStamp2 - timeStamp1 }));
+ returnedEntries.push(
+ self.performance.measure("measure19", { duration: timeStamp2 - timeStamp1, end: timeStamp2 }));
+ // {}, null, undefined, invalid-dict passed to startOrOptions are interpreted as start time being 0.
+ returnedEntries.push(self.performance.measure("measure20", {}, 'mark1'));
+ returnedEntries.push(self.performance.measure("measure21", null, 'mark1'));
+ returnedEntries.push(self.performance.measure("measure22", undefined, 'mark1'));
+ returnedEntries.push(self.performance.measure("measure23", { invalidDict:1 }, 'mark1'));
+ checkEntries(returnedEntries, expectedEntries);
+}, "measure entries' detail and start/end are customizable");
+
+test(function() {
+ this.add_cleanup(cleanupPerformanceTimeline);
+ assert_throws_js(TypeError, function() {
+ self.performance.measure("optionsAndNumberEnd", {'start': 2}, 12);
+ }, "measure should throw a TypeError when passed an options object and an end time");
+ assert_throws_js(TypeError, function() {
+ self.performance.measure("optionsAndMarkEnd", {'start': 2}, 'mark1');
+ }, "measure should throw a TypeError when passed an options object and an end mark");
+ assert_throws_js(TypeError, function() {
+ self.performance.measure("negativeStartInOptions", {'start': -1});
+ }, "measure cannot have a negative time stamp.");
+ assert_throws_js(TypeError, function() {
+ self.performance.measure("negativeEndInOptions", {'end': -1});
+ }, "measure cannot have a negative time stamp for end.");
+}, "measure should throw a TypeError when passed an invalid argument combination");
+
diff --git a/test/fixtures/wpt/user-timing/measure.html b/test/fixtures/wpt/user-timing/measure.html
new file mode 100644
index 00000000000000..40f71a3362b581
--- /dev/null
+++ b/test/fixtures/wpt/user-timing/measure.html
@@ -0,0 +1,362 @@
+
+
+
+
+
+ window.performance User Timing measure() method is working properly
+
+
+
+
+
+
+
+
+
+
+
Description
+
This test validates that the performance.measure() method is working properly. This test creates the
+ following measures to test this method:
+
+
"measure_no_start_no_end": created using a measure() call without a startMark or endMark
+ provided
+
"measure_start_no_end": created using a measure() call with only the startMark provided
+
"measure_start_end": created using a measure() call with both a startMark or endMark provided
+
"measure_no_start_end": created using a measure() call with only the endMark provided
+
"measure_no_start_no_end": duplicate of the first measure, used to confirm names can be re-used
+
+ After creating each measure, the existence of these measures is validated by calling
+ performance.getEntriesByName() (both with and without the entryType parameter provided),
+ performance.getEntriesByType(), and performance.getEntries()
+
This test validates functionality of the interface window.performance.measure using keywords from the Navigation Timing spec.
+
+
+
diff --git a/test/fixtures/wpt/user-timing/measure_exception.html b/test/fixtures/wpt/user-timing/measure_exception.html
new file mode 100644
index 00000000000000..5c1aa086c0fc88
--- /dev/null
+++ b/test/fixtures/wpt/user-timing/measure_exception.html
@@ -0,0 +1,34 @@
+
+
+
+
+exception test of window.performance.measure
+
+
+
+
+
+
+
+
+
+
+
Description
+
This test validates all exception scenarios of method window.performance.measure in User Timing API
+
+
+
+
+
diff --git a/test/fixtures/wpt/user-timing/measure_exceptions_navigation_timing.html b/test/fixtures/wpt/user-timing/measure_exceptions_navigation_timing.html
new file mode 100644
index 00000000000000..b1868b2cb6b3cb
--- /dev/null
+++ b/test/fixtures/wpt/user-timing/measure_exceptions_navigation_timing.html
@@ -0,0 +1,70 @@
+
+
+
+
+ window.performance User Timing measure() method is throwing the proper exceptions
+
+
+
+
+
+
+
+
+
+
Description
+
window.performance.measure() method throws a InvalidAccessError
+ whenever a navigation timing attribute with a value of zero is provided as the startMark or endMark.
+
+
+
+
+
diff --git a/test/fixtures/wpt/user-timing/measure_navigation_timing.html b/test/fixtures/wpt/user-timing/measure_navigation_timing.html
new file mode 100644
index 00000000000000..d6480d27a261c9
--- /dev/null
+++ b/test/fixtures/wpt/user-timing/measure_navigation_timing.html
@@ -0,0 +1,205 @@
+
+
+
+
+
+ window.performance User Timing clearMeasures() method is working properly with navigation timing
+ attributes
+
+
+
+
+
+
+
+
+
+
+
Description
+
This test validates that the performance.measure() method is working properly when navigation timing
+ attributes are used in place of mark names. This test creates the following measures to test this method:
+
+
"measure_nav_start_no_end": created using a measure() call with a navigation timing attribute
+ provided as the startMark and nothing provided as the endMark
+
"measure_nav_start_mark_end": created using a measure() call with a navigation timing attribute
+ provided as the startMark and a mark name provided as the endMark
+
"measure_mark_start_nav_end": created using a measure() call with a mark name provided as the
+ startMark and a navigation timing attribute provided as the endMark
+
"measure_nav_start_nav_end":created using a measure() call with a navigation timing attribute
+ provided as both the startMark and endMark
+
+ After creating each measure, the existence of these measures is validated by calling
+ performance.getEntriesByName() with each measure name
+
+
+
+
+
diff --git a/test/fixtures/wpt/user-timing/measure_syntax_err.any.js b/test/fixtures/wpt/user-timing/measure_syntax_err.any.js
new file mode 100644
index 00000000000000..9b762a40906351
--- /dev/null
+++ b/test/fixtures/wpt/user-timing/measure_syntax_err.any.js
@@ -0,0 +1,33 @@
+test(function () {
+ self.performance.mark("existing_mark");
+ var entries = self.performance.getEntriesByName("existing_mark");
+ assert_equals(entries.length, 1);
+ self.performance.measure("measure", "existing_mark");
+}, "Create a mark \"existing_mark\"");
+test(function () {
+ assert_throws_dom("SyntaxError", function () {
+ self.performance.measure("measure", "mark");
+ });
+}, "self.performance.measure(\"measure\", \"mark\"), where \"mark\" is a non-existent mark, " +
+ "throws a SyntaxError exception.");
+
+test(function () {
+ assert_throws_dom("SyntaxError", function () {
+ self.performance.measure("measure", "mark", "existing_mark");
+ });
+}, "self.performance.measure(\"measure\", \"mark\", \"existing_mark\"), where \"mark\" is a " +
+ "non-existent mark, throws a SyntaxError exception.");
+
+test(function () {
+ assert_throws_dom("SyntaxError", function () {
+ self.performance.measure("measure", "existing_mark", "mark");
+ });
+}, "self.performance.measure(\"measure\", \"existing_mark\", \"mark\"), where \"mark\" " +
+ "is a non-existent mark, throws a SyntaxError exception.");
+
+test(function () {
+ assert_throws_dom("SyntaxError", function () {
+ self.performance.measure("measure", "mark", "mark");
+ });
+}, "self.performance.measure(\"measure\", \"mark\", \"mark\"), where \"mark\" is a " +
+ "non-existent mark, throws a SyntaxError exception.");
diff --git a/test/fixtures/wpt/user-timing/measures.html b/test/fixtures/wpt/user-timing/measures.html
new file mode 100644
index 00000000000000..0de68965ddb9c7
--- /dev/null
+++ b/test/fixtures/wpt/user-timing/measures.html
@@ -0,0 +1,66 @@
+
+
+
+
+functionality test of window.performance.measure
+
+
+
+
+
+
+
+
+
+
+
Description
+
This test validates functionality of the interface window.performance.measure.
+
+
+
diff --git a/test/fixtures/wpt/user-timing/performance-measure-invalid.worker.js b/test/fixtures/wpt/user-timing/performance-measure-invalid.worker.js
new file mode 100644
index 00000000000000..29efb729992cc6
--- /dev/null
+++ b/test/fixtures/wpt/user-timing/performance-measure-invalid.worker.js
@@ -0,0 +1,9 @@
+importScripts("/resources/testharness.js");
+
+test(() => {
+ assert_throws_js(TypeError, () => {
+ performance.measure('name', 'navigationStart', 'navigationStart');
+ });
+}, "When converting 'navigationStart' to a timestamp, the global object has to be a Window object.");
+
+done();
diff --git a/test/fixtures/wpt/user-timing/resources/user-timing-helper.js b/test/fixtures/wpt/user-timing/resources/user-timing-helper.js
new file mode 100644
index 00000000000000..8d43768ec28196
--- /dev/null
+++ b/test/fixtures/wpt/user-timing/resources/user-timing-helper.js
@@ -0,0 +1,30 @@
+// Compares a list of performance entries to a predefined one.
+// actualEntries is an array of performance entries from the user agent,
+// and expectedEntries is an array of performance entries minted by the test.
+// The comparison doesn't assert the order of the entries.
+function checkEntries(actualEntries, expectedEntries) {
+ assert_equals(actualEntries.length, expectedEntries.length,
+ `The length of actual and expected entries should match.
+ actual: ${JSON.stringify(actualEntries)},
+ expected: ${JSON.stringify(expectedEntries)}`);
+ const actualEntrySet = new Set(actualEntries.map(ae=>ae.name));
+ assert_equals(actualEntrySet.size, actualEntries.length, `Actual entry names are not unique: ${JSON.stringify(actualEntries)}`);
+ const expectedEntrySet = new Set(expectedEntries.map(ee=>ee.name));
+ assert_equals(expectedEntrySet.size, expectedEntries.length, `Expected entry names are not unique: ${JSON.stringify(expectedEntries)}`);
+ actualEntries.forEach(ae=>{
+ const expectedEntry = expectedEntries.find(e=>e.name === ae.name);
+ assert_true(!!expectedEntry, `Entry name '${ae.name}' was not found.`);
+ checkEntry(ae, expectedEntry);
+ });
+}
+
+function checkEntry(entry, {name, entryType, startTime, detail, duration}) {
+ assert_equals(entry.name, name);
+ assert_equals(entry.entryType, entryType);
+ if (startTime !== undefined)
+ assert_equals(entry.startTime, startTime);
+ if (detail !== undefined)
+ assert_equals(JSON.stringify(entry.detail), JSON.stringify(detail));
+ if (duration !== undefined)
+ assert_equals(entry.duration, duration);
+}
diff --git a/test/fixtures/wpt/user-timing/resources/webperftestharness.js b/test/fixtures/wpt/user-timing/resources/webperftestharness.js
new file mode 100644
index 00000000000000..2fbd0210de906d
--- /dev/null
+++ b/test/fixtures/wpt/user-timing/resources/webperftestharness.js
@@ -0,0 +1,124 @@
+//
+// Helper functions for User Timing tests
+//
+
+var timingAttributes = [
+ "navigationStart",
+ "unloadEventStart",
+ "unloadEventEnd",
+ "redirectStart",
+ "redirectEnd",
+ "fetchStart",
+ "domainLookupStart",
+ "domainLookupEnd",
+ "connectStart",
+ "connectEnd",
+ "secureConnectionStart",
+ "requestStart",
+ "responseStart",
+ "responseEnd",
+ "domLoading",
+ "domInteractive",
+ "domContentLoadedEventStart",
+ "domContentLoadedEventEnd",
+ "domComplete",
+ "loadEventStart",
+ "loadEventEnd"
+];
+
+function has_required_interfaces()
+{
+ if (window.performance.mark == undefined ||
+ window.performance.clearMarks == undefined ||
+ window.performance.measure == undefined ||
+ window.performance.clearMeasures == undefined ||
+ window.performance.getEntriesByName == undefined ||
+ window.performance.getEntriesByType == undefined ||
+ window.performance.getEntries == undefined) {
+ return false;
+ }
+
+ return true;
+}
+
+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);
+}
+
+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);
+}
diff --git a/test/fixtures/wpt/user-timing/resources/webperftestharnessextension.js b/test/fixtures/wpt/user-timing/resources/webperftestharnessextension.js
new file mode 100644
index 00000000000000..8640918d4f255e
--- /dev/null
+++ b/test/fixtures/wpt/user-timing/resources/webperftestharnessextension.js
@@ -0,0 +1,202 @@
+//
+// Helper functions for User Timing tests
+//
+
+var mark_names = [
+ '',
+ '1',
+ 'abc',
+];
+
+var measures = [
+ [''],
+ ['2', 1],
+ ['aaa', 'navigationStart', ''],
+];
+
+function test_method_exists(method, method_name, properties)
+{
+ var msg;
+ if (typeof method === 'function')
+ msg = 'performance.' + method.name + ' is supported!';
+ else
+ msg = 'performance.' + method_name + ' is supported!';
+ wp_test(function() { assert_equals(typeof method, 'function', msg); }, msg, properties);
+}
+
+function test_method_throw_exception(func_str, exception, msg)
+{
+ let exception_name;
+ let test_func;
+ if (typeof exception == "function") {
+ exception_name = exception.name;
+ test_func = assert_throws_js;
+ } else {
+ exception_name = exception;
+ test_func = assert_throws_dom;
+ }
+ var msg = 'Invocation of ' + func_str + ' should throw ' + exception_name + ' Exception.';
+ wp_test(function() { test_func(exception, function() {eval(func_str)}, msg); }, msg);
+}
+
+function test_noless_than(value, greater_than, msg, properties)
+{
+ wp_test(function () { assert_true(value >= greater_than, msg); }, msg, properties);
+}
+
+function test_fail(msg, properties)
+{
+ wp_test(function() { assert_unreached(); }, msg, properties);
+}
+
+function test_resource_entries(entries, expected_entries)
+{
+ // This is slightly convoluted so that we can sort the output.
+ var actual_entries = {};
+ var origin = window.location.protocol + "//" + window.location.host;
+
+ for (var i = 0; i < entries.length; ++i) {
+ var entry = entries[i];
+ var found = false;
+ for (var expected_entry in expected_entries) {
+ if (entry.name == origin + expected_entry) {
+ found = true;
+ if (expected_entry in actual_entries) {
+ test_fail(expected_entry + ' is not expected to have duplicate entries');
+ }
+ actual_entries[expected_entry] = entry;
+ break;
+ }
+ }
+ if (!found) {
+ test_fail(entries[i].name + ' is not expected to be in the Resource Timing buffer');
+ }
+ }
+
+ sorted_urls = [];
+ for (var i in actual_entries) {
+ sorted_urls.push(i);
+ }
+ sorted_urls.sort();
+ for (var i in sorted_urls) {
+ var url = sorted_urls[i];
+ test_equals(actual_entries[url].initiatorType,
+ expected_entries[url],
+ origin + url + ' is expected to have initiatorType ' + expected_entries[url]);
+ }
+ for (var j in expected_entries) {
+ if (!(j in actual_entries)) {
+ test_fail(origin + j + ' is expected to be in the Resource Timing buffer');
+ }
+ }
+}
+
+function performance_entrylist_checker(type)
+{
+ const entryType = type;
+
+ function entry_check(entry, expectedNames, testDescription = '')
+ {
+ const msg = testDescription + 'Entry \"' + entry.name + '\" should be one that we have set.';
+ wp_test(function() { assert_in_array(entry.name, expectedNames, msg); }, msg);
+ test_equals(entry.entryType, entryType, testDescription + 'entryType should be \"' + entryType + '\".');
+ if (type === "measure") {
+ test_true(isFinite(entry.startTime), testDescription + 'startTime should be a number.');
+ test_true(isFinite(entry.duration), testDescription + 'duration should be a number.');
+ } else if (type === "mark") {
+ test_greater_than(entry.startTime, 0, testDescription + 'startTime should greater than 0.');
+ test_equals(entry.duration, 0, testDescription + 'duration of mark should be 0.');
+ }
+ }
+
+ function entrylist_order_check(entryList)
+ {
+ let inOrder = true;
+ for (let i = 0; i < entryList.length - 1; ++i)
+ {
+ if (entryList[i + 1].startTime < entryList[i].startTime) {
+ inOrder = false;
+ break;
+ }
+ }
+ return inOrder;
+ }
+
+ function entrylist_check(entryList, expectedLength, expectedNames, testDescription = '')
+ {
+ test_equals(entryList.length, expectedLength, testDescription + 'There should be ' + expectedLength + ' entries.');
+ test_true(entrylist_order_check(entryList), testDescription + 'Entries in entrylist should be in order.');
+ for (let i = 0; i < entryList.length; ++i)
+ {
+ entry_check(entryList[i], expectedNames, testDescription + 'Entry_list ' + i + '. ');
+ }
+ }
+
+ return{"entrylist_check":entrylist_check};
+}
+
+function PerformanceContext(context)
+{
+ this.performanceContext = context;
+}
+
+PerformanceContext.prototype =
+{
+
+ initialMeasures: function(item, index, array)
+ {
+ this.performanceContext.measure.apply(this.performanceContext, item);
+ },
+
+ mark: function()
+ {
+ this.performanceContext.mark.apply(this.performanceContext, arguments);
+ },
+
+ measure: function()
+ {
+ this.performanceContext.measure.apply(this.performanceContext, arguments);
+ },
+
+ clearMarks: function()
+ {
+ this.performanceContext.clearMarks.apply(this.performanceContext, arguments);
+ },
+
+ clearMeasures: function()
+ {
+ this.performanceContext.clearMeasures.apply(this.performanceContext, arguments);
+
+ },
+
+ getEntries: function()
+ {
+ return this.performanceContext.getEntries.apply(this.performanceContext, arguments);
+ },
+
+ getEntriesByType: function()
+ {
+ return this.performanceContext.getEntriesByType.apply(this.performanceContext, arguments);
+ },
+
+ getEntriesByName: function()
+ {
+ return this.performanceContext.getEntriesByName.apply(this.performanceContext, arguments);
+ },
+
+ setResourceTimingBufferSize: function()
+ {
+ return this.performanceContext.setResourceTimingBufferSize.apply(this.performanceContext, arguments);
+ },
+
+ registerResourceTimingBufferFullCallback: function(func)
+ {
+ this.performanceContext.onresourcetimingbufferfull = func;
+ },
+
+ clearResourceTimings: function()
+ {
+ this.performanceContext.clearResourceTimings.apply(this.performanceContext, arguments);
+ }
+
+};
diff --git a/test/fixtures/wpt/user-timing/structured-serialize-detail.any.js b/test/fixtures/wpt/user-timing/structured-serialize-detail.any.js
new file mode 100644
index 00000000000000..78771b2f7663d4
--- /dev/null
+++ b/test/fixtures/wpt/user-timing/structured-serialize-detail.any.js
@@ -0,0 +1,64 @@
+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_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_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/test/fixtures/wpt/user-timing/supported-usertiming-types.any.js b/test/fixtures/wpt/user-timing/supported-usertiming-types.any.js
new file mode 100644
index 00000000000000..ea3b2fe9dc90f7
--- /dev/null
+++ b/test/fixtures/wpt/user-timing/supported-usertiming-types.any.js
@@ -0,0 +1,37 @@
+test(() => {
+ if (typeof PerformanceObserver.supportedEntryTypes === "undefined")
+ assert_unreached("supportedEntryTypes is not supported.");
+ const types = PerformanceObserver.supportedEntryTypes;
+ assert_true(types.includes("mark"),
+ "There should be 'mark' in PerformanceObserver.supportedEntryTypes");
+ assert_true(types.includes("measure"),
+ "There should be 'measure' in PerformanceObserver.supportedEntryTypes");
+ assert_greater_than(types.indexOf("measure"), types.indexOf('mark'),
+ "The 'measure' entry should appear after the 'mark' entry");
+}, "supportedEntryTypes contains 'mark' and 'measure'.");
+
+if (typeof PerformanceObserver.supportedEntryTypes !== "undefined") {
+ const entryTypes = {
+ "mark": () => {
+ performance.mark('foo');
+ },
+ "measure": () => {
+ performance.measure('bar');
+ }
+ }
+ for (let entryType in entryTypes) {
+ if (PerformanceObserver.supportedEntryTypes.includes(entryType)) {
+ promise_test(async() => {
+ await new Promise((resolve) => {
+ new PerformanceObserver(function (list, observer) {
+ observer.disconnect();
+ resolve();
+ }).observe({entryTypes: [entryType]});
+
+ // Force the PerformanceEntry.
+ entryTypes[entryType]();
+ })
+ }, `'${entryType}' entries should be observable.`)
+ }
+ }
+}
diff --git a/test/fixtures/wpt/user-timing/user-timing-tojson.html b/test/fixtures/wpt/user-timing/user-timing-tojson.html
new file mode 100644
index 00000000000000..6aef7fa904ab95
--- /dev/null
+++ b/test/fixtures/wpt/user-timing/user-timing-tojson.html
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/test/fixtures/wpt/user-timing/user_timing_exists.any.js b/test/fixtures/wpt/user-timing/user_timing_exists.any.js
new file mode 100644
index 00000000000000..adf9052ebd58d8
--- /dev/null
+++ b/test/fixtures/wpt/user-timing/user_timing_exists.any.js
@@ -0,0 +1,12 @@
+test(function() {
+ assert_not_equals(self.performance.mark, undefined);
+}, "self.performance.mark is defined.");
+test(function() {
+ assert_not_equals(self.performance.clearMarks, undefined);
+}, "self.performance.clearMarks is defined.");
+test(function() {
+ assert_not_equals(self.performance.measure, undefined);
+}, "self.performance.measure is defined.");
+test(function() {
+ assert_not_equals(self.performance.clearMeasures, undefined);
+}, "self.performance.clearMeasures is defined.");
diff --git a/test/fixtures/wpt/versions.json b/test/fixtures/wpt/versions.json
index fb10c7d403d730..fb49e36cc07747 100644
--- a/test/fixtures/wpt/versions.json
+++ b/test/fixtures/wpt/versions.json
@@ -36,9 +36,13 @@
"path": "html/webappapis/timers"
},
"interfaces": {
- "commit": "fcb671ed8b068b25cee87429d803833777f35c2c",
+ "commit": "80a417662387b6eda904607d78ad246c5d8bf191",
"path": "interfaces"
},
+ "performance-timeline": {
+ "commit": "17ebc3aea0d6321e69554067c39ab5855e6fb67e",
+ "path": "performance-timeline"
+ },
"resources": {
"commit": "972ca5b6693bffebebc5805e1b9da68a6876e1f6",
"path": "resources"
@@ -50,5 +54,9 @@
"url": {
"commit": "77d54aa9e0405f737987b59331f3584e3e1c26f9",
"path": "url"
+ },
+ "user-timing": {
+ "commit": "df24fb604e2d40528ac1d1b5dd970e32fc5c2978",
+ "path": "user-timing"
}
}
\ No newline at end of file
diff --git a/test/parallel/test-perf-hooks-usertiming.js b/test/parallel/test-perf-hooks-usertiming.js
index 401d0a6816481a..e7ef26889eae0f 100644
--- a/test/parallel/test-perf-hooks-usertiming.js
+++ b/test/parallel/test-perf-hooks-usertiming.js
@@ -29,7 +29,7 @@ assert(measure);
assert.strictEqual(m.entryType, 'mark');
assert.strictEqual(typeof m.startTime, 'number');
assert.strictEqual(m.duration, 0);
- assert.strictEqual(m.details, undefined);
+ assert.strictEqual(m.detail, null);
});
clearMarks();
@@ -38,11 +38,18 @@ assert.throws(() => mark(Symbol('a')), {
message: /Cannot convert a Symbol value to a string/
});
-[undefined, null, 1, 'any', {}, []].forEach((detail) => {
+[undefined, null].forEach((detail) => {
const m = mark('a', { detail });
assert.strictEqual(m.name, 'a');
assert.strictEqual(m.entryType, 'mark');
- assert.strictEqual(m.detail, detail);
+ assert.deepStrictEqual(m.detail, null);
+});
+[1, 'any', {}, []].forEach((detail) => {
+ const m = mark('a', { detail });
+ assert.strictEqual(m.name, 'a');
+ assert.strictEqual(m.entryType, 'mark');
+ // Value of detail is structured cloned.
+ assert.deepStrictEqual(m.detail, detail);
});
clearMarks();
diff --git a/test/wpt/status/performance-timeline.json b/test/wpt/status/performance-timeline.json
new file mode 100644
index 00000000000000..0967ef424bce67
--- /dev/null
+++ b/test/wpt/status/performance-timeline.json
@@ -0,0 +1 @@
+{}
diff --git a/test/wpt/status/user-timing.json b/test/wpt/status/user-timing.json
new file mode 100644
index 00000000000000..b1110e6a5e798d
--- /dev/null
+++ b/test/wpt/status/user-timing.json
@@ -0,0 +1,11 @@
+{
+ "invoke_with_timing_attributes.worker.js": {
+ "skip": "importScripts not supported"
+ },
+ "performance-measure-invalid.worker.js": {
+ "skip": "importScripts not supported"
+ },
+ "idlharness.any.js": {
+ "skip": "idlharness cannot recognize Node.js environment"
+ }
+}
diff --git a/test/wpt/test-performance-timeline.js b/test/wpt/test-performance-timeline.js
new file mode 100644
index 00000000000000..36d13297ba57cc
--- /dev/null
+++ b/test/wpt/test-performance-timeline.js
@@ -0,0 +1,27 @@
+'use strict';
+require('../common');
+const { WPTRunner } = require('../common/wpt');
+
+const runner = new WPTRunner('user-timing');
+
+// Needed to access to DOMException.
+runner.setFlags(['--expose-internals']);
+
+runner.setInitScript(`
+ const {
+ PerformanceMark,
+ PerformanceMeasure,
+ PerformanceObserver,
+ performance,
+ } = require('perf_hooks');
+ global.PerformanceMark = performance;
+ global.PerformanceMeasure = performance;
+ global.PerformanceObserver = PerformanceObserver;
+ global.performance = performance;
+
+ const { internalBinding } = require('internal/test/binding');
+ const { DOMException } = internalBinding('messaging');
+ global.DOMException = DOMException;
+`);
+
+runner.runJsTests();
diff --git a/test/wpt/test-user-timing.js b/test/wpt/test-user-timing.js
new file mode 100644
index 00000000000000..36d13297ba57cc
--- /dev/null
+++ b/test/wpt/test-user-timing.js
@@ -0,0 +1,27 @@
+'use strict';
+require('../common');
+const { WPTRunner } = require('../common/wpt');
+
+const runner = new WPTRunner('user-timing');
+
+// Needed to access to DOMException.
+runner.setFlags(['--expose-internals']);
+
+runner.setInitScript(`
+ const {
+ PerformanceMark,
+ PerformanceMeasure,
+ PerformanceObserver,
+ performance,
+ } = require('perf_hooks');
+ global.PerformanceMark = performance;
+ global.PerformanceMeasure = performance;
+ global.PerformanceObserver = PerformanceObserver;
+ global.performance = performance;
+
+ const { internalBinding } = require('internal/test/binding');
+ const { DOMException } = internalBinding('messaging');
+ global.DOMException = DOMException;
+`);
+
+runner.runJsTests();