From 60c9c857584bf5180dd0f7b937683dd9691aef84 Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Wed, 6 Jan 2021 02:56:40 +0100 Subject: [PATCH] fix: align performance API to spec using WPT (#9012) --- cli/tests/wpt.jsonc | 42 +++++++++++++++++++++++++++++++++--- runtime/js/40_performance.js | 10 ++++++++- test_util/wpt | 2 +- 3 files changed, 49 insertions(+), 5 deletions(-) diff --git a/cli/tests/wpt.jsonc b/cli/tests/wpt.jsonc index 479b6a7475..3099d3b48e 100644 --- a/cli/tests/wpt.jsonc +++ b/cli/tests/wpt.jsonc @@ -135,13 +135,49 @@ "Encoding argument supported for decode: UTF-16LE", "Encoding argument supported for decode: x-user-defined" ] - }, + } // TODO(lucacasonato): enable when we support utf-16 // "textencoder-utf16-surrogates", // TODO(lucacasonato): uses XMLHttpRequest unnecessarily. should be fixed upstream before enabling // "unsupported-encodings", ], - "dom": [ - "abort/event" + "dom": ["abort/event"], + "hr-time": ["monotonic-clock"], + "html": [ + "webappapis/microtask-queuing/queue-microtask-exceptions.any", + "webappapis/microtask-queuing/queue-microtask.any" + ], + "user-timing": [ + "clear_all_marks", + "clear_all_measures", + "clear_non_existent_mark", + "clear_non_existent_measure", + "clear_one_mark", + "clear_one_measure", + "entry_type", + "mark-entry-constructor", + "mark-errors", + "mark-measure-return-objects", + "mark.any", + { + "name": "measure_syntax_err", + "expectFail": [ + // TODO(lucacasonato): re-enable when #9009 is fixed. + "self.performance.measure(\"measure\", \"mark\"), where \"mark\" is a non-existent mark, throws a SyntaxError exception.", + "self.performance.measure(\"measure\", \"mark\", \"existing_mark\"), where \"mark\" is a non-existent mark, throws a SyntaxError exception.", + "self.performance.measure(\"measure\", \"existing_mark\", \"mark\"), where \"mark\" is a non-existent mark, throws a SyntaxError exception.", + "self.performance.measure(\"measure\", \"mark\", \"mark\"), where \"mark\" is a non-existent mark, throws a SyntaxError exception." + ] + }, + "measure-l3", + { + "name": "structured-serialize-detail", + "expectFail": [ + // TODO(lucacasonato): re-enable when we use real structured clone. + "Mark: Throw an exception when the detail property cannot be structured-serialized.", + "Measure: Throw an exception when the detail property cannot be structured-serialized." + ] + }, + "user_timing_exists" ] } diff --git a/runtime/js/40_performance.js b/runtime/js/40_performance.js index 0a63dc704d..b9c8732704 100644 --- a/runtime/js/40_performance.js +++ b/runtime/js/40_performance.js @@ -99,6 +99,8 @@ } class PerformanceMark extends PerformanceEntry { + [Symbol.toStringTag] = "PerformanceMark"; + #detail = null; get detail() { @@ -111,8 +113,12 @@ constructor( name, - { detail = null, startTime = now() } = {}, + options = {}, ) { + if (typeof options !== "object") { + throw new TypeError("Invalid options"); + } + const { detail = null, startTime = now() } = options; super(name, "mark", startTime, 0, illegalConstructorKey); if (startTime < 0) { throw new TypeError("startTime cannot be negative"); @@ -140,6 +146,8 @@ } class PerformanceMeasure extends PerformanceEntry { + [Symbol.toStringTag] = "PerformanceMeasure"; + #detail = null; get detail() { diff --git a/test_util/wpt b/test_util/wpt index b6f4d8ca80..835839463c 160000 --- a/test_util/wpt +++ b/test_util/wpt @@ -1 +1 @@ -Subproject commit b6f4d8ca80c396728754871433e61340da413022 +Subproject commit 835839463c5270731a6a57885caff34cac7725e5