Title: [242209] trunk
Revision
242209
Author
[email protected]
Date
2019-02-28 11:09:32 -0800 (Thu, 28 Feb 2019)

Log Message

Fix Resource Timing buffer edge cases for WPT
https://bugs.webkit.org/show_bug.cgi?id=193213

Patch by Charles Vazac <[email protected]> on 2019-02-28
Reviewed by Youenn Fablet.

LayoutTests/imported/w3c:

* web-platform-tests/resource-timing/buffer-full-add-after-full-event.html:
* web-platform-tests/resource-timing/buffer-full-add-entries-during-callback-that-drop-expected.txt:
* web-platform-tests/resource-timing/buffer-full-add-then-clear-expected.txt:
* web-platform-tests/resource-timing/buffer-full-then-increased-expected.txt:

Source/WebCore:

Test coverage by LayoutTests/imported/w3c/web-platform-tests/resource-timing/buffer*.html

* page/Performance.cpp:
(WebCore::Performance::resourceTimingBufferFullTimerFired): Only dispatch the
resourcetimingbufferfull event if the buffer is still full (as it may have been cleared or
expanded). Also, avoid infinite loops if we aren't able to decrease the number of entries in
the secondary buffer.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/http/tests/performance/performance-resource-timing-resourcetimingbufferfull-shrinking-buffer-crash-expected.txt (242208 => 242209)


--- trunk/LayoutTests/http/tests/performance/performance-resource-timing-resourcetimingbufferfull-shrinking-buffer-crash-expected.txt	2019-02-28 18:51:55 UTC (rev 242208)
+++ trunk/LayoutTests/http/tests/performance/performance-resource-timing-resourcetimingbufferfull-shrinking-buffer-crash-expected.txt	2019-02-28 19:09:32 UTC (rev 242209)
@@ -19,12 +19,10 @@
 PASS resourcesAfterShrinkingBuffer = performance.getEntriesByType("resource"); resourcesAfterShrinkingBuffer.length is 2
 PASS resourcesAfterShrinkingBuffer[0] is originalResources[0]
 PASS resourcesAfterShrinkingBuffer[1] is originalResources[1]
-
-Inside resourcetimingbufferfull 2
 PASS performance.clearResourceTimings(); performance.getEntriesByType("resource").length is 0
 
 After resourcetimingbufferfull
-PASS resourcetimingbufferfullEventCount is 2
+PASS resourcetimingbufferfullEventCount is 1
 PASS resourcesAfterClearing = performance.getEntriesByType("resource"); resourcesAfterClearing.length is 1
 PASS resourcesAfterClearing[0].initiatorType is "fetch"
 PASS new URL(resourcesAfterClearing[0].name).search is "?resource=2"

Modified: trunk/LayoutTests/http/tests/performance/performance-resource-timing-resourcetimingbufferfull-shrinking-buffer-crash.html (242208 => 242209)


--- trunk/LayoutTests/http/tests/performance/performance-resource-timing-resourcetimingbufferfull-shrinking-buffer-crash.html	2019-02-28 18:51:55 UTC (rev 242208)
+++ trunk/LayoutTests/http/tests/performance/performance-resource-timing-resourcetimingbufferfull-shrinking-buffer-crash.html	2019-02-28 19:09:32 UTC (rev 242209)
@@ -42,12 +42,11 @@
         shouldBe('resourcesAfterShrinkingBuffer = performance.getEntriesByType("resource"); resourcesAfterShrinkingBuffer.length', '2');
         shouldBe('resourcesAfterShrinkingBuffer[0]', 'originalResources[0]');
         shouldBe('resourcesAfterShrinkingBuffer[1]', 'originalResources[1]');
-    } else if (resourcetimingbufferfullEventCount == 2) {
         shouldBe('performance.clearResourceTimings(); performance.getEntriesByType("resource").length', '0');
         setTimeout(() => {
             debug('');
             debug('After resourcetimingbufferfull');
-            shouldBe('resourcetimingbufferfullEventCount', '2');
+            shouldBe('resourcetimingbufferfullEventCount', '1');
             shouldBe('resourcesAfterClearing = performance.getEntriesByType("resource"); resourcesAfterClearing.length', '1');
             shouldBeEqualToString('resourcesAfterClearing[0].initiatorType', 'fetch');
             shouldBeEqualToString('new URL(resourcesAfterClearing[0].name).search', '?resource=2');

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (242208 => 242209)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2019-02-28 18:51:55 UTC (rev 242208)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2019-02-28 19:09:32 UTC (rev 242209)
@@ -1,3 +1,15 @@
+2019-02-28  Charles Vazac  <[email protected]>
+
+        Fix Resource Timing buffer edge cases for WPT
+        https://bugs.webkit.org/show_bug.cgi?id=193213
+
+        Reviewed by Youenn Fablet.
+
+        * web-platform-tests/resource-timing/buffer-full-add-after-full-event.html:
+        * web-platform-tests/resource-timing/buffer-full-add-entries-during-callback-that-drop-expected.txt:
+        * web-platform-tests/resource-timing/buffer-full-add-then-clear-expected.txt:
+        * web-platform-tests/resource-timing/buffer-full-then-increased-expected.txt:
+
 2019-02-26  Youenn Fablet  <[email protected]>
 
         Move service worker response validation from the service worker client to the service worker itself

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/resource-timing/buffer-full-add-entries-during-callback-that-drop-expected.txt (0 => 242209)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/resource-timing/buffer-full-add-entries-during-callback-that-drop-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/resource-timing/buffer-full-add-entries-during-callback-that-drop-expected.txt	2019-02-28 19:09:32 UTC (rev 242209)
@@ -0,0 +1,3 @@
+
+PASS Test that entries synchronously added to the buffer during the callback are dropped 
+

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/resource-timing/buffer-full-add-then-clear-expected.txt (242208 => 242209)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/resource-timing/buffer-full-add-then-clear-expected.txt	2019-02-28 18:51:55 UTC (rev 242208)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/resource-timing/buffer-full-add-then-clear-expected.txt	2019-02-28 19:09:32 UTC (rev 242209)
@@ -1,6 +1,3 @@
-CONSOLE MESSAGE: line 2659: Error: assert_unreached: resourcetimingbufferfull should not fire Reached unreachable code
 
-Harness Error (FAIL), message = Error: assert_unreached: resourcetimingbufferfull should not fire Reached unreachable code
+PASS Test that if the buffer is cleared after entries were added to the secondary buffer, those entries make it into the primary one 
 
-FAIL Test that if the buffer is cleared after entries were added to the secondary buffer, those entries make it into the primary one assert_equals: the last 3 resources should be in the buffer, since the first one was cleared expected 3 but got 0
-

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/resource-timing/buffer-full-then-increased-expected.txt (242208 => 242209)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/resource-timing/buffer-full-then-increased-expected.txt	2019-02-28 18:51:55 UTC (rev 242208)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/resource-timing/buffer-full-then-increased-expected.txt	2019-02-28 19:09:32 UTC (rev 242209)
@@ -1,6 +1,3 @@
-CONSOLE MESSAGE: line 2659: Error: assert_unreached: resourcetimingbufferfull should not fire Reached unreachable code
 
-Harness Error (FAIL), message = Error: assert_unreached: resourcetimingbufferfull should not fire Reached unreachable code
+PASS Test that overflowing the buffer and immediately increasing its limit does not trigger the resourcetimingbufferfull event 
 
-FAIL Test that overflowing the buffer and immediately increasing its limit does not trigger the resourcetimingbufferfull event assert_equals: All resources should be in the buffer, since its size was increased expected 3 but got 1
-

Modified: trunk/Source/WebCore/ChangeLog (242208 => 242209)


--- trunk/Source/WebCore/ChangeLog	2019-02-28 18:51:55 UTC (rev 242208)
+++ trunk/Source/WebCore/ChangeLog	2019-02-28 19:09:32 UTC (rev 242209)
@@ -1,3 +1,18 @@
+2019-02-28  Charles Vazac  <[email protected]>
+
+        Fix Resource Timing buffer edge cases for WPT
+        https://bugs.webkit.org/show_bug.cgi?id=193213
+
+        Reviewed by Youenn Fablet.
+
+        Test coverage by LayoutTests/imported/w3c/web-platform-tests/resource-timing/buffer*.html
+
+        * page/Performance.cpp:
+        (WebCore::Performance::resourceTimingBufferFullTimerFired): Only dispatch the
+        resourcetimingbufferfull event if the buffer is still full (as it may have been cleared or
+        expanded). Also, avoid infinite loops if we aren't able to decrease the number of entries in
+        the secondary buffer.
+
 2019-02-28  Takashi Komori  <[email protected]>
 
         [Curl] HTTP Body is missing with redirection.

Modified: trunk/Source/WebCore/page/Performance.cpp (242208 => 242209)


--- trunk/Source/WebCore/page/Performance.cpp	2019-02-28 18:51:55 UTC (rev 242208)
+++ trunk/Source/WebCore/page/Performance.cpp	2019-02-28 19:09:32 UTC (rev 242209)
@@ -214,11 +214,15 @@
     ASSERT(scriptExecutionContext());
 
     while (!m_backupResourceTimingBuffer.isEmpty()) {
+        auto beforeCount = m_backupResourceTimingBuffer.size();
+
         auto backupBuffer = WTFMove(m_backupResourceTimingBuffer);
         ASSERT(m_backupResourceTimingBuffer.isEmpty());
 
-        m_resourceTimingBufferFullFlag = true;
-        dispatchEvent(Event::create(eventNames().resourcetimingbufferfullEvent, Event::CanBubble::No, Event::IsCancelable::No));
+        if (isResourceTimingBufferFull()) {
+            m_resourceTimingBufferFullFlag = true;
+            dispatchEvent(Event::create(eventNames().resourcetimingbufferfullEvent, Event::CanBubble::No, Event::IsCancelable::No));
+        }
 
         if (m_resourceTimingBufferFullFlag) {
             for (auto& entry : backupBuffer)
@@ -241,6 +245,13 @@
             } else
                 m_backupResourceTimingBuffer.append(entry.copyRef());
         }
+
+        auto afterCount = m_backupResourceTimingBuffer.size();
+
+        if (beforeCount <= afterCount) {
+            m_backupResourceTimingBuffer.clear();
+            break;
+        }
     }
     m_waitingForBackupBufferToBeProcessed = false;
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to