Skip to content
Permalink
Browse files
Fix Resource Timing buffer edge cases for WPT
https://bugs.webkit.org/show_bug.cgi?id=193213

Patch by Charles Vazac <cvazac@akamai.com> 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.

Canonical link: https://commits.webkit.org/209500@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242209 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Charles Vazac authored and webkit-commit-queue committed Feb 28, 2019
1 parent 993a928 commit 8f457f9749bb6ca4b57d9eb1e6c6138cd422cab1
Showing 8 changed files with 47 additions and 15 deletions.
@@ -19,12 +19,10 @@ performance.setResourceTimingBufferSize(1)
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"
@@ -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');
@@ -1,3 +1,15 @@
2019-02-28 Charles Vazac <cvazac@akamai.com>

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 <youenn@apple.com>

Move service worker response validation from the service worker client to the service worker itself
@@ -0,0 +1,3 @@

PASS Test that entries synchronously added to the buffer during the callback are dropped

@@ -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

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
PASS Test that if the buffer is cleared after entries were added to the secondary buffer, those entries make it into the primary one

@@ -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

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
PASS Test that overflowing the buffer and immediately increasing its limit does not trigger the resourcetimingbufferfull event

@@ -1,3 +1,18 @@
2019-02-28 Charles Vazac <cvazac@akamai.com>

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 <Takashi.Komori@sony.com>

[Curl] HTTP Body is missing with redirection.
@@ -214,11 +214,15 @@ void Performance::resourceTimingBufferFullTimerFired()
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 @@ void Performance::resourceTimingBufferFullTimerFired()
} else
m_backupResourceTimingBuffer.append(entry.copyRef());
}

auto afterCount = m_backupResourceTimingBuffer.size();

if (beforeCount <= afterCount) {
m_backupResourceTimingBuffer.clear();
break;
}
}
m_waitingForBackupBufferToBeProcessed = false;
}

0 comments on commit 8f457f9

Please sign in to comment.