- Revision
- 212806
- Author
- [email protected]
- Date
- 2017-02-21 21:43:50 -0800 (Tue, 21 Feb 2017)
Log Message
[User Timing] Throw a SyntaxError for performance.measure if mark name is not found
https://bugs.webkit.org/show_bug.cgi?id=168707
Patch by Joseph Pecoraro <[email protected]> on 2017-02-21
Reviewed by Ryosuke Niwa.
Source/WebCore:
Test: performance-api/performance-measure-name.html
* page/PerformanceUserTiming.cpp:
(WebCore::UserTiming::findExistingMarkStartTime):
Instead of returning zero, throw a SyntaxError. This is more in line
with User Timing Level 1 and behavior in Window. This is an issue with
the Level 2 spec: https://github.com/w3c/user-timing/issues/21
LayoutTests:
* performance-api/performance-measure-name-expected.txt: Added.
* performance-api/performance-measure-name.html: Added.
* performance-api/resources/measure-name.js: Added.
Test to cover SyntaxError for missing measure start/end mark names.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (212805 => 212806)
--- trunk/LayoutTests/ChangeLog 2017-02-22 05:08:54 UTC (rev 212805)
+++ trunk/LayoutTests/ChangeLog 2017-02-22 05:43:50 UTC (rev 212806)
@@ -1,3 +1,15 @@
+2017-02-21 Joseph Pecoraro <[email protected]>
+
+ [User Timing] Throw a SyntaxError for performance.measure if mark name is not found
+ https://bugs.webkit.org/show_bug.cgi?id=168707
+
+ Reviewed by Ryosuke Niwa.
+
+ * performance-api/performance-measure-name-expected.txt: Added.
+ * performance-api/performance-measure-name.html: Added.
+ * performance-api/resources/measure-name.js: Added.
+ Test to cover SyntaxError for missing measure start/end mark names.
+
2017-02-21 John Wilander <[email protected]>
Unreviewed, marking a set of test cases as skipped while we investigate.
Added: trunk/LayoutTests/performance-api/performance-measure-name-expected.txt (0 => 212806)
--- trunk/LayoutTests/performance-api/performance-measure-name-expected.txt (rev 0)
+++ trunk/LayoutTests/performance-api/performance-measure-name-expected.txt 2017-02-22 05:43:50 UTC (rev 212806)
@@ -0,0 +1,23 @@
+Tests performance.measure startName/endName must exist.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS performance.mark("existing-mark-name") did not throw exception.
+PASS performance.measure("measure-name", "x") threw exception SyntaxError (DOM Exception 12): The string did not match the expected pattern..
+PASS performance.measure("measure-name", "existing-mark-name", "x") threw exception SyntaxError (DOM Exception 12): The string did not match the expected pattern..
+PASS performance.mark("x") did not throw exception.
+PASS performance.measure("measure-name", "x") did not throw exception.
+PASS performance.measure("measure-name", "existing-mark-name", "x") did not throw exception.
+
+Starting worker: resources/measure-name.js
+PASS [Worker] performance.mark("existing-mark-name") did not throw exception.
+PASS [Worker] performance.measure("measure-name", "x") threw exception SyntaxError (DOM Exception 12): No mark named 'x' exists.
+PASS [Worker] performance.measure("measure-name", "existing-mark-name", "x") threw exception SyntaxError (DOM Exception 12): No mark named 'x' exists.
+PASS [Worker] performance.mark("x") did not throw exception.
+PASS [Worker] performance.measure("measure-name", "x") did not throw exception.
+PASS [Worker] performance.measure("measure-name", "existing-mark-name", "x") did not throw exception.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/performance-api/performance-measure-name.html (0 => 212806)
--- trunk/LayoutTests/performance-api/performance-measure-name.html (rev 0)
+++ trunk/LayoutTests/performance-api/performance-measure-name.html 2017-02-22 05:43:50 UTC (rev 212806)
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script src=""
+<script>
+debug("");
+let worker = startWorker("resources/measure-name.js");
+</script>
+<script src=""
+</body>
+</html>
Added: trunk/LayoutTests/performance-api/resources/measure-name.js (0 => 212806)
--- trunk/LayoutTests/performance-api/resources/measure-name.js (rev 0)
+++ trunk/LayoutTests/performance-api/resources/measure-name.js 2017-02-22 05:43:50 UTC (rev 212806)
@@ -0,0 +1,20 @@
+if (self.importScripts)
+ importScripts("../../resources/js-test-pre.js");
+
+self.jsTestIsAsync = true;
+
+if (self.window)
+ description("Tests performance.measure startName/endName must exist.");
+
+shouldNotThrow(`performance.mark("existing-mark-name")`);
+
+shouldThrow(`performance.measure("measure-name", "x")`);
+shouldThrow(`performance.measure("measure-name", "existing-mark-name", "x")`);
+
+shouldNotThrow(`performance.mark("x")`);
+
+shouldNotThrow(`performance.measure("measure-name", "x")`);
+shouldNotThrow(`performance.measure("measure-name", "existing-mark-name", "x")`);
+
+if (self.importScripts)
+ finishJSTest();
Modified: trunk/Source/WebCore/ChangeLog (212805 => 212806)
--- trunk/Source/WebCore/ChangeLog 2017-02-22 05:08:54 UTC (rev 212805)
+++ trunk/Source/WebCore/ChangeLog 2017-02-22 05:43:50 UTC (rev 212806)
@@ -1,3 +1,18 @@
+2017-02-21 Joseph Pecoraro <[email protected]>
+
+ [User Timing] Throw a SyntaxError for performance.measure if mark name is not found
+ https://bugs.webkit.org/show_bug.cgi?id=168707
+
+ Reviewed by Ryosuke Niwa.
+
+ Test: performance-api/performance-measure-name.html
+
+ * page/PerformanceUserTiming.cpp:
+ (WebCore::UserTiming::findExistingMarkStartTime):
+ Instead of returning zero, throw a SyntaxError. This is more in line
+ with User Timing Level 1 and behavior in Window. This is an issue with
+ the Level 2 spec: https://github.com/w3c/user-timing/issues/21
+
2017-02-21 Ryan Haddad <[email protected]>
Unreviewed attempt to fix the Windows build.
Modified: trunk/Source/WebCore/page/PerformanceUserTiming.cpp (212805 => 212806)
--- trunk/Source/WebCore/page/PerformanceUserTiming.cpp 2017-02-22 05:08:54 UTC (rev 212805)
+++ trunk/Source/WebCore/page/PerformanceUserTiming.cpp 2017-02-22 05:43:50 UTC (rev 212806)
@@ -123,7 +123,7 @@
PerformanceTiming* timing = m_performance.timing();
if (!timing)
- return 0.0;
+ return Exception { SYNTAX_ERR, makeString("No mark named '", markName, "' exists") };
if (auto function = restrictedMarkFunction(markName)) {
double value = static_cast<double>(((*timing).*(function))());