Title: [270355] trunk
Revision
270355
Author
[email protected]
Date
2020-12-02 11:07:32 -0800 (Wed, 02 Dec 2020)

Log Message

Fix crash with performance.measure() with negative duration
https://bugs.webkit.org/show_bug.cgi?id=219418

Patch by Julian Gonzalez <[email protected]> on 2020-12-02
Reviewed by Alex Christensen.

Source/WebCore:

In PerformanceUserTiming::measure(), the wrong variable is used
to look up the exception to return if an invalid duration
value is provided.

Updated user-timing-apis test to catch this crash.

* page/PerformanceUserTiming.cpp:
(WebCore::PerformanceUserTiming::measure):

LayoutTests:

Add a test to verify that an Exception is thrown when
passing a negative duration to performance.measure(),
instead of a crash occurring.

* performance-api/resources/user-timing-api.js:
* performance-api/user-timing-apis-expected.txt:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (270354 => 270355)


--- trunk/LayoutTests/ChangeLog	2020-12-02 19:05:10 UTC (rev 270354)
+++ trunk/LayoutTests/ChangeLog	2020-12-02 19:07:32 UTC (rev 270355)
@@ -1,3 +1,17 @@
+2020-12-02  Julian Gonzalez  <[email protected]>
+
+        Fix crash with performance.measure() with negative duration
+        https://bugs.webkit.org/show_bug.cgi?id=219418
+
+        Reviewed by Alex Christensen.
+
+        Add a test to verify that an Exception is thrown when
+        passing a negative duration to performance.measure(),
+        instead of a crash occurring.
+
+        * performance-api/resources/user-timing-api.js:
+        * performance-api/user-timing-apis-expected.txt:
+
 2020-12-02  James Darpinian  <[email protected]>
 
         Update ANGLE 2020-11-12

Modified: trunk/LayoutTests/performance-api/resources/user-timing-api.js (270354 => 270355)


--- trunk/LayoutTests/performance-api/resources/user-timing-api.js	2020-12-02 19:05:10 UTC (rev 270354)
+++ trunk/LayoutTests/performance-api/resources/user-timing-api.js	2020-12-02 19:07:32 UTC (rev 270355)
@@ -23,6 +23,7 @@
 shouldNotThrow(`performance.mark("mark_name")`);
 shouldThrow(`performance.measure()`);
 shouldNotThrow(`performance.measure("measure_name")`);
+shouldThrow(`performance.measure("measure_name", { start: 0, duration: -1 })`);
 shouldNotThrow(`performance.clearMarks()`);
 shouldNotThrow(`performance.clearMarks("mark_name")`);
 shouldNotThrow(`performance.clearMeasures()`);

Modified: trunk/LayoutTests/performance-api/user-timing-apis-expected.txt (270354 => 270355)


--- trunk/LayoutTests/performance-api/user-timing-apis-expected.txt	2020-12-02 19:05:10 UTC (rev 270354)
+++ trunk/LayoutTests/performance-api/user-timing-apis-expected.txt	2020-12-02 19:07:32 UTC (rev 270355)
@@ -20,6 +20,7 @@
 PASS performance.mark("mark_name") did not throw exception.
 PASS performance.measure() threw exception TypeError: Not enough arguments.
 PASS performance.measure("measure_name") did not throw exception.
+PASS performance.measure("measure_name", { start: 0, duration: -1 }) threw exception TypeError: Type error.
 PASS performance.clearMarks() did not throw exception.
 PASS performance.clearMarks("mark_name") did not throw exception.
 PASS performance.clearMeasures() did not throw exception.
@@ -43,6 +44,7 @@
 PASS [Worker] performance.mark("mark_name") did not throw exception.
 PASS [Worker] performance.measure() threw exception TypeError: Not enough arguments.
 PASS [Worker] performance.measure("measure_name") did not throw exception.
+PASS [Worker] performance.measure("measure_name", { start: 0, duration: -1 }) threw exception TypeError: Type error.
 PASS [Worker] performance.clearMarks() did not throw exception.
 PASS [Worker] performance.clearMarks("mark_name") did not throw exception.
 PASS [Worker] performance.clearMeasures() did not throw exception.

Modified: trunk/Source/WebCore/ChangeLog (270354 => 270355)


--- trunk/Source/WebCore/ChangeLog	2020-12-02 19:05:10 UTC (rev 270354)
+++ trunk/Source/WebCore/ChangeLog	2020-12-02 19:07:32 UTC (rev 270355)
@@ -1,3 +1,19 @@
+2020-12-02  Julian Gonzalez  <[email protected]>
+
+        Fix crash with performance.measure() with negative duration
+        https://bugs.webkit.org/show_bug.cgi?id=219418
+
+        Reviewed by Alex Christensen.
+
+        In PerformanceUserTiming::measure(), the wrong variable is used
+        to look up the exception to return if an invalid duration
+        value is provided.
+
+        Updated user-timing-apis test to catch this crash.
+
+        * page/PerformanceUserTiming.cpp:
+        (WebCore::PerformanceUserTiming::measure):
+
 2020-12-02  Andres Gonzalez  <[email protected]>
 
         Fix for accessibility layout tests involving ranges in isolated tree mode.

Modified: trunk/Source/WebCore/page/PerformanceUserTiming.cpp (270354 => 270355)


--- trunk/Source/WebCore/page/PerformanceUserTiming.cpp	2020-12-02 19:05:10 UTC (rev 270354)
+++ trunk/Source/WebCore/page/PerformanceUserTiming.cpp	2020-12-02 19:07:32 UTC (rev 270355)
@@ -211,7 +211,7 @@
             return start.releaseException();
         auto duration = convertMarkToTimestamp(*measureOptions.duration);
         if (duration.hasException())
-            return start.releaseException();
+            return duration.releaseException();
         endTime = start.returnValue() + duration.returnValue();
     } else
         endTime = m_performance.now();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to