Title: [240824] trunk
Revision
240824
Author
commit-qu...@webkit.org
Date
2019-01-31 15:26:29 -0800 (Thu, 31 Jan 2019)

Log Message

Web Inspector: Timeline time range selection sometimes shows 0.000, should be just 0
https://bugs.webkit.org/show_bug.cgi?id=194108
<rdar://problem/47714273>

Patch by Joseph Pecoraro <pecor...@apple.com> on 2019-01-31
Reviewed by Devin Rousso.

Source/WebInspectorUI:

* UserInterface/Base/Utilities.js:
Check under epsilon for the zero case.

LayoutTests:

* inspector/unit-tests/number-utilities-expected.txt:
* inspector/unit-tests/number-utilities.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (240823 => 240824)


--- trunk/LayoutTests/ChangeLog	2019-01-31 23:20:08 UTC (rev 240823)
+++ trunk/LayoutTests/ChangeLog	2019-01-31 23:26:29 UTC (rev 240824)
@@ -1,3 +1,14 @@
+2019-01-31  Joseph Pecoraro  <pecor...@apple.com>
+
+        Web Inspector: Timeline time range selection sometimes shows 0.000, should be just 0
+        https://bugs.webkit.org/show_bug.cgi?id=194108
+        <rdar://problem/47714273>
+
+        Reviewed by Devin Rousso.
+
+        * inspector/unit-tests/number-utilities-expected.txt:
+        * inspector/unit-tests/number-utilities.html:
+
 2019-01-31  Chris Dumez  <cdu...@apple.com>
 
         [ MacOS ] Layout Test performance-api/performance-observer-callback-after-gc.html is flaky

Modified: trunk/LayoutTests/inspector/unit-tests/number-utilities-expected.txt (240823 => 240824)


--- trunk/LayoutTests/inspector/unit-tests/number-utilities-expected.txt	2019-01-31 23:20:08 UTC (rev 240823)
+++ trunk/LayoutTests/inspector/unit-tests/number-utilities-expected.txt	2019-01-31 23:26:29 UTC (rev 240824)
@@ -26,6 +26,7 @@
 PASS: normal resolution of greater than 1hr but sub 1 day should be hrs
 PASS: normal resolution of greater than 1 day should be days
 PASS: normal resolution of greater than 1 day should be days
+PASS: normal resolution of super small value should be ms with no decimals
 PASS: high resolution of 0ms should be ms with no decimals
 PASS: high resolution of sub 1ms should be ms with decimals
 PASS: high resolution of sub 10ms should be ms with decimals
@@ -35,6 +36,7 @@
 PASS: high resolution of greater than 1s should be seconds with decimals
 PASS: high resolution of greater than 1s should be seconds with decimals
 PASS: high resolution greater than 1s should be seconds with decimals
+PASS: high resolution of super small value should be ms with no decimals
 
 -- Running test case: Number.bytesToString
 PASS: normal resolution of sub 1k should be bytes

Modified: trunk/LayoutTests/inspector/unit-tests/number-utilities.html (240823 => 240824)


--- trunk/LayoutTests/inspector/unit-tests/number-utilities.html	2019-01-31 23:20:08 UTC (rev 240823)
+++ trunk/LayoutTests/inspector/unit-tests/number-utilities.html	2019-01-31 23:26:29 UTC (rev 240824)
@@ -5,6 +5,9 @@
 <script>
 function test()
 {
+    // This is the floating point precision error value from: `0.3 - 0.2 - 0.1`
+    const superSmallValue = -2.7755575615628914e-17;
+
     let suite = InspectorTest.createSyncSuite("NumberUtilities");
 
     suite.addTestCase({
@@ -44,6 +47,7 @@
             InspectorTest.expectEqual(Number.secondsToString(12345, false), "3.4hrs", "normal resolution of greater than 1hr but sub 1 day should be hrs");
             InspectorTest.expectEqual(Number.secondsToString(123456, false), "1.4 days", "normal resolution of greater than 1 day should be days");
             InspectorTest.expectEqual(Number.secondsToString(1234567, false), "14.3 days", "normal resolution of greater than 1 day should be days");
+            InspectorTest.expectEqual(Number.secondsToString(superSmallValue, false), "0ms", "normal resolution of super small value should be ms with no decimals");
 
             // High resolution.
             InspectorTest.expectEqual(Number.secondsToString(0, true), "0ms", "high resolution of 0ms should be ms with no decimals");
@@ -55,6 +59,7 @@
             InspectorTest.expectEqual(Number.secondsToString(30.123456, true), "30.12s", "high resolution of greater than 1s should be seconds with decimals");
             InspectorTest.expectEqual(Number.secondsToString(60.123456, true), "60.12s", "high resolution of greater than 1s should be seconds with decimals");
             InspectorTest.expectEqual(Number.secondsToString(100.123456, true), "100.12s", "high resolution greater than 1s should be seconds with decimals");
+            InspectorTest.expectEqual(Number.secondsToString(superSmallValue, true), "0ms", "high resolution of super small value should be ms with no decimals");
 
             return true;
         }

Modified: trunk/Source/WebInspectorUI/ChangeLog (240823 => 240824)


--- trunk/Source/WebInspectorUI/ChangeLog	2019-01-31 23:20:08 UTC (rev 240823)
+++ trunk/Source/WebInspectorUI/ChangeLog	2019-01-31 23:26:29 UTC (rev 240824)
@@ -1,3 +1,14 @@
+2019-01-31  Joseph Pecoraro  <pecor...@apple.com>
+
+        Web Inspector: Timeline time range selection sometimes shows 0.000, should be just 0
+        https://bugs.webkit.org/show_bug.cgi?id=194108
+        <rdar://problem/47714273>
+
+        Reviewed by Devin Rousso.
+
+        * UserInterface/Base/Utilities.js:
+        Check under epsilon for the zero case.
+
 2019-01-31  Matt Baker  <mattba...@apple.com>
 
         REGRESSION(r?): Web Inspector: Clicking on text doesn't move text caret when editing innerHTML/tagName/attribute

Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Utilities.js (240823 => 240824)


--- trunk/Source/WebInspectorUI/UserInterface/Base/Utilities.js	2019-01-31 23:20:08 UTC (rev 240823)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Utilities.js	2019-01-31 23:26:29 UTC (rev 240824)
@@ -1156,12 +1156,12 @@
 {
     value(seconds, higherResolution)
     {
+        const epsilon = 0.0001;
+
         let ms = seconds * 1000;
-        if (!ms)
+        if (ms < epsilon)
             return WI.UIString("%.0fms").format(0);
 
-        const epsilon = 0.0001;
-
         if (Math.abs(ms) < (10 + epsilon)) {
             if (higherResolution)
                 return WI.UIString("%.3fms").format(ms);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to