зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1509611 [wpt PR 14219] - Revert "Align resource timing buffer full processing to spec PR 168", a=testonly
Automatic update from web-platform-tests Revert "Align resource timing buffer full processing to spec PR 168" This reverts commit 579d65014c9d6cc248ec1de47013bf6c20c72158. Reason for revert: Findit (https://goo.gl/kROfz5) identified CL at revision 610667 as the culprit for flakes in the build cycles as shown on: https://findit-for-me.appspot.com/waterfall/flake/flake-culprit?key=ag9zfmZpbmRpdC1mb3ItbWVyQwsSDEZsYWtlQ3VscHJpdCIxY2hyb21pdW0vNTc5ZDY1MDE0YzlkNmNjMjQ4ZWMxZGU0NzAxM2JmNmMyMGM3MjE1OAw Sample Failed Build: https://ci.chromium.org/buildbot/chromium.webkit/WebKit%20Linux%20Trusty%20Leak/26746 Sample Failed Step: webkit_layout_tests Sample Flaky Test: external/wpt/resource-timing/buffer-full-store-and-clear-during-callback.html Original change's description: > Align resource timing buffer full processing to spec PR 168 > > This change implements the processing model from PR 168[1], when > it comes to setResourceTimingBufferSize(), clearResourceTimings() > and the firing of the resourcetimingbufferfull event. > > [1] https://github.com/w3c/resource-timing/pull/168 > > Change-Id: I3a57196f10e0b4cf2bae5662b0e075673a0c2d80 > Reviewed-on: https://chromium-review.googlesource.com/c/1345269 > Commit-Queue: Yoav Weiss <yoavweiss@chromium.org> > Commit-Queue: Yoav Weiss <yoav@yoav.ws> > Reviewed-by: Nicolás Peña Moreno <npm@chromium.org> > Cr-Commit-Position: refs/heads/master@{#610667} Change-Id: I0840bd9b763030b6e200e8f9a94c73c7982044a0 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: 908181 Reviewed-on: https://chromium-review.googlesource.com/c/1349498 Cr-Commit-Position: refs/heads/master@{#610683} -- wpt-commits: 40e50ecff750feff8e62dc98a72e9bca3a8c94cf wpt-pr: 14219
This commit is contained in:
Родитель
9d00062db3
Коммит
de664d14cf
|
@ -1,89 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<link rel="help" href="https://w3c.github.io/resource-timing/#dom-performance-setresourcetimingbuffersize">
|
||||
<title>This test validates that setResourceTimingBufferFull behaves appropriately when set to the current buffer level.</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
let eventFired = false;
|
||||
function loadRandomResource() {
|
||||
return fetch(window.location.href + "?" + Math.random());
|
||||
}
|
||||
|
||||
setup(function() {
|
||||
// Get the browser into a consistent state.
|
||||
performance.clearResourceTimings();
|
||||
performance.setResourceTimingBufferSize(3);
|
||||
});
|
||||
|
||||
let gatherEntries = new Promise(function(resolve, reject) {
|
||||
// Gather up 3 Resource Entries to kick off the rest of test behavior.
|
||||
let resources = 0;
|
||||
let observer = new PerformanceObserver(function(list) {
|
||||
resources += list.getEntriesByType("resource").length;
|
||||
if (resources !== 3)
|
||||
return;
|
||||
observer.disconnect();
|
||||
resolve();
|
||||
});
|
||||
observer.observe({entryTypes: ["resource"]});
|
||||
for (let i = 0; i < 3; ++i)
|
||||
loadRandomResource();
|
||||
});
|
||||
|
||||
let setBufferSize = new Promise(function(resolve, reject) {
|
||||
performance.onresourcetimingbufferfull = function() {
|
||||
eventFired = true;
|
||||
performance.clearResourceTimings();
|
||||
};
|
||||
resolve();
|
||||
});
|
||||
|
||||
promise_test(function() {
|
||||
return gatherEntries;
|
||||
}, "Reset the entries number");
|
||||
promise_test(function() {
|
||||
return setBufferSize;
|
||||
}, "Set the buffer size");
|
||||
promise_test(function() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
loadRandomResource().then(resolve);
|
||||
});
|
||||
}, "Overflow the buffer");
|
||||
/*
|
||||
promise_test(function() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
let waitForIt = function() {
|
||||
if (eventFired) {
|
||||
eventFired = false;
|
||||
resolve();
|
||||
}
|
||||
}
|
||||
step_timeout(waitForIt, 0);
|
||||
});
|
||||
}, "Wait for event");
|
||||
*/
|
||||
promise_test(function() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
performance.clearResourceTimings();
|
||||
loadRandomResource().then(function() {
|
||||
resolve();
|
||||
})});
|
||||
}, "Clear and add another entry to the buffer");
|
||||
promise_test(function() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
let waitForIt = function() {
|
||||
if (performance.getEntriesByType("resource").length) {
|
||||
resolve();
|
||||
} else {
|
||||
reject("After buffer full, entry never added to primary");
|
||||
}
|
||||
}
|
||||
step_timeout(waitForIt, 0);
|
||||
});
|
||||
}, "Wait for entry to be added");
|
||||
</script>
|
|
@ -1,53 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head onload>
|
||||
<meta charset="utf-8" />
|
||||
<title>This test validates that synchronously adding entries in onresourcetimingbufferfull callback results in these entries being properly handled.</title>
|
||||
<link rel="author" title="Intel" href="http://www.intel.com/" />
|
||||
<link rel="help" href="http://www.w3.org/TR/resource-timing/#performanceresourcetiming"/>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/append.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
promise_test(()=>{
|
||||
return new Promise((resolve, reject)=>{
|
||||
const resource_timing_buffer_size = 1;
|
||||
performance.clearResourceTimings();
|
||||
var add_entry = function() {
|
||||
performance.setResourceTimingBufferSize(resource_timing_buffer_size + 1);
|
||||
// The sync attribute is added to the secondary buffer, so will be last one there and eventually dropped.
|
||||
xhrScript("resources/empty.js?xhr");
|
||||
resolve();
|
||||
}
|
||||
performance.addEventListener('resourcetimingbufferfull', add_entry);
|
||||
performance.setResourceTimingBufferSize(resource_timing_buffer_size);
|
||||
// Scripts appended in JS to ensure setResourceTimingBufferSize is called before.
|
||||
// This resource gets buffered in the resource timing entry buffer.
|
||||
appendScript('resources/empty.js');
|
||||
// This resource overflows the entry buffer, and goes into the secondary buffer.
|
||||
appendScript('resources/empty_script.js');
|
||||
});
|
||||
}, "Prepare test");
|
||||
promise_test(function() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
let waitForIt = function() {
|
||||
resolve();
|
||||
}
|
||||
step_timeout(waitForIt, 0);
|
||||
});
|
||||
}, "Wait for next task");
|
||||
promise_test(()=>{
|
||||
return new Promise((resolve, reject)=>{
|
||||
let entries = performance.getEntriesByType('resource');
|
||||
assert_equals(entries.length, 2,
|
||||
'Both entries should be stored in resource timing buffer since its increases size once it overflows.');
|
||||
assert_true(entries[0].name.includes('empty.js'), "empty.js is in the entries buffer");
|
||||
assert_true(entries[1].name.includes('empty_script.js'), "empty_script.js is in the entries buffer");
|
||||
resolve();
|
||||
});
|
||||
}, "Test");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -1,38 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head onload>
|
||||
<meta charset="utf-8" />
|
||||
<title>This test validates that synchronously adding entries in onresourcetimingbufferfull callback results in these entries being properly handled.</title>
|
||||
<link rel="author" title="Intel" href="http://www.intel.com/" />
|
||||
<link rel="help" href="http://www.w3.org/TR/resource-timing/#performanceresourcetiming"/>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/append.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
const resource_timing_buffer_size = 1;
|
||||
const t = async_test("Verify that adding entries to the resource timing buffer during resourcetimingbufferfull call works");
|
||||
performance.clearResourceTimings();
|
||||
var add_entry = function() {
|
||||
performance.setResourceTimingBufferSize(resource_timing_buffer_size + 2);
|
||||
xhrScript("resources/empty.js?xhr");
|
||||
}
|
||||
performance.addEventListener('resourcetimingbufferfull', add_entry);
|
||||
performance.setResourceTimingBufferSize(resource_timing_buffer_size);
|
||||
// Scripts appended in JS to ensure setResourceTimingBufferSize is called before.
|
||||
// This resource gets buffered in the resource timing entry buffer.
|
||||
appendScript('resources/empty.js');
|
||||
// This resource overflows the entry buffer, and goes into the secondary buffer.
|
||||
appendScript('resources/empty_script.js');
|
||||
window.onload = t.step_func_done(()=>{
|
||||
let entries = performance.getEntriesByType('resource');
|
||||
assert_equals(entries.length, 3,
|
||||
'All entries should be stored in resource timing buffer since its increases size once it overflows.');
|
||||
assert_true(entries[0].name.includes('empty.js'), "empty.js is in the entries buffer");
|
||||
assert_true(entries[1].name.includes('empty_script.js'), "empty_script.js is in the entries buffer");
|
||||
assert_true(entries[2].name.includes('empty.js?xhr'), "empty.js?xhr is in the entries buffer");
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -1,41 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head onload>
|
||||
<meta charset="utf-8" />
|
||||
<title>This test validates that synchronously adding entries in onresourcetimingbufferfull callback results in these entries being properly handled.</title>
|
||||
<link rel="author" title="Intel" href="http://www.intel.com/" />
|
||||
<link rel="help" href="http://www.w3.org/TR/resource-timing/#performanceresourcetiming"/>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/append.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
const resource_timing_buffer_size = 1;
|
||||
const t = async_test("Verify that adding entries and then clearing the resource timing buffer results in entries added in the right order");
|
||||
performance.clearResourceTimings();
|
||||
performance.addEventListener('resourcetimingbufferfull', t.unreached_func("resourcetimingbufferfull should not fire"));
|
||||
performance.setResourceTimingBufferSize(resource_timing_buffer_size);
|
||||
// Scripts appended in JS to ensure setResourceTimingBufferSize is called before.
|
||||
// This resource gets buffered in the resource timing entry buffer.
|
||||
xhrScript('resources/empty.js?xhr');
|
||||
// These resources overflow the entry buffer, and goes into the secondary buffer.
|
||||
xhrScript('resources/empty.js?xhr2');
|
||||
xhrScript('resources/empty.js?xhr3');
|
||||
performance.clearResourceTimings();
|
||||
performance.setResourceTimingBufferSize(3);
|
||||
xhrScript('resources/empty.js?xhr4');
|
||||
let entriesAfterAddition = performance.getEntriesByType('resource');
|
||||
window.onload = t.step_timeout(()=>{
|
||||
let entries = performance.getEntriesByType('resource');
|
||||
assert_equals(entries.length, 3,
|
||||
'the last 3 resources should be in the buffer, since the first one was cleared');
|
||||
assert_true(entries[0].name.includes('empty.js?xhr2'), "empty.js?xhr2 is in the entries buffer");
|
||||
assert_true(entries[1].name.includes('empty.js?xhr3'), "empty.js?xhr3 is in the entries buffer");
|
||||
assert_true(entries[2].name.includes('empty.js?xhr4'), "empty.js?xhr4 is in the entries buffer");
|
||||
assert_equals(entriesAfterAddition.length, 0, "No entries should have been added to the primary buffer before the task to 'fire a buffer full event'.");
|
||||
t.done();
|
||||
}, 0);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -1,37 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head onload>
|
||||
<meta charset="utf-8" />
|
||||
<title>This test validates that decreasing the buffer size in onresourcetimingbufferfull callback does not result in extra entries being dropped.</title>
|
||||
<link rel="author" title="Intel" href="http://www.intel.com/" />
|
||||
<link rel="help" href="http://www.w3.org/TR/resource-timing/#performanceresourcetiming"/>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/append.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
const resource_timing_buffer_size = 2;
|
||||
const t = async_test("Verify that reducing the size of the resource timing buffer during resourcetimingbufferfull call works");
|
||||
performance.clearResourceTimings();
|
||||
let resize = function() {
|
||||
performance.setResourceTimingBufferSize(resource_timing_buffer_size - 1);
|
||||
}
|
||||
performance.addEventListener('resourcetimingbufferfull', resize);
|
||||
performance.setResourceTimingBufferSize(resource_timing_buffer_size);
|
||||
// Scripts appended in JS to ensure setResourceTimingBufferSize is called before.
|
||||
// This resource gets buffered in the resource timing entry buffer.
|
||||
xhrScript('resources/empty.js');
|
||||
xhrScript('resources/empty.js?second');
|
||||
// This resource overflows the entry buffer, and goes into the secondary buffer.
|
||||
xhrScript('resources/empty_script.js');
|
||||
window.onload = t.step_func_done(()=>{
|
||||
let entries = performance.getEntriesByType('resource');
|
||||
assert_equals(entries.length, 2,
|
||||
'Both entries should be stored in resource timing buffer since it decreased its limit only after it overflowed.');
|
||||
assert_true(entries[0].name.includes('empty.js'), "empty.js is in the entries buffer");
|
||||
assert_true(entries[1].name.includes('empty.js?second'), "empty.js?second is in the entries buffer");
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -1,36 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head onload>
|
||||
<meta charset="utf-8" />
|
||||
<title>This test validates increasing the buffer size in onresourcetimingbufferfull callback of resource timing.</title>
|
||||
<link rel="author" title="Intel" href="http://www.intel.com/" />
|
||||
<link rel="help" href="http://www.w3.org/TR/resource-timing/#performanceresourcetiming"/>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/append.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
const resource_timing_buffer_size = 1;
|
||||
const t = async_test("Verify that increasing the resource timing buffer during resourcetimingbufferfull call works");
|
||||
performance.clearResourceTimings();
|
||||
var increase = function() {
|
||||
performance.setResourceTimingBufferSize(resource_timing_buffer_size * 2);
|
||||
}
|
||||
performance.addEventListener('resourcetimingbufferfull', increase);
|
||||
performance.setResourceTimingBufferSize(resource_timing_buffer_size);
|
||||
// Scripts appended in JS to ensure setResourceTimingBufferSize is called before.
|
||||
// This resource gets buffered in the resource timing entry buffer.
|
||||
appendScript('resources/empty.js');
|
||||
// This resource overflows the entry buffer, and goes into the secondary buffer.
|
||||
appendScript('resources/empty_script.js');
|
||||
window.onload = t.step_func_done(()=>{
|
||||
let entries = performance.getEntriesByType('resource');
|
||||
assert_equals(entries.length, 2,
|
||||
'Both entries should be stored in resource timing buffer since its increases size once it overflows.');
|
||||
assert_true(entries[0].name.includes('empty.js'), "empty.js is in the entries buffer");
|
||||
assert_true(entries[1].name.includes('empty_script.js'), "empty_script.js is in the entries buffer");
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -1,45 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head onload>
|
||||
<meta charset="utf-8" />
|
||||
<title>This test validates the buffer doesn't contain more entries than it should inside onresourcetimingbufferfull callback.</title>
|
||||
<link rel="author" title="Intel" href="http://www.intel.com/" />
|
||||
<link rel="help" href="http://www.w3.org/TR/resource-timing/#performanceresourcetiming"/>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/append.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
const t = async_test("Verify that inspecting the resource timing buffer during resourcetimingbufferfull call doesn't exceed the limit.");
|
||||
let resource_timing_buffer_size = 2;
|
||||
performance.clearResourceTimings();
|
||||
var resize = function() {
|
||||
assert_equals(performance.getEntriesByType("resource").length, resource_timing_buffer_size, "resource timing buffer in resourcetimingbufferfull is the size of the limit");
|
||||
++resource_timing_buffer_size;
|
||||
performance.setResourceTimingBufferSize(resource_timing_buffer_size);
|
||||
xhrScript("resources/empty.js?xhr");
|
||||
assert_equals(performance.getEntriesByType("resource").length, resource_timing_buffer_size - 1, "A sync request was not added to the primary buffer just yet, because it is full");
|
||||
++resource_timing_buffer_size;
|
||||
performance.setResourceTimingBufferSize(resource_timing_buffer_size);
|
||||
}
|
||||
performance.addEventListener('resourcetimingbufferfull', t.step_func(resize));
|
||||
performance.setResourceTimingBufferSize(resource_timing_buffer_size);
|
||||
// Scripts appended in JS to ensure setResourceTimingBufferSize is called before.
|
||||
// These resources gets buffered in the resource timing entry buffer.
|
||||
appendScript('resources/empty.js');
|
||||
appendScript('resources/empty.js?second');
|
||||
// This resource overflows the entry buffer, and goes into the secondary buffer.
|
||||
appendScript('resources/empty_script.js');
|
||||
window.onload = t.step_func_done(()=>{
|
||||
let entries = performance.getEntriesByType('resource');
|
||||
assert_equals(entries.length, resource_timing_buffer_size,
|
||||
'All 4 entries should be stored in resource timing buffer.');
|
||||
assert_true(entries[0].name.includes('empty.js'), "empty.js is in the entries buffer");
|
||||
assert_true(entries[1].name.includes('empty.js?second'), "empty.js?second is in the entries buffer");
|
||||
assert_true(entries[2].name.includes('empty_script.js'), "empty_script.js is in the entries buffer");
|
||||
assert_true(entries[3].name.includes('empty.js?xhr'), "empty.js?xhr is in the entries buffer");
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -1,88 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<link rel="help" href="https://w3c.github.io/resource-timing/#dom-performance-setresourcetimingbuffersize">
|
||||
<title>This test validates that setResourceTimingBufferFull behaves appropriately when set to the current buffer level.</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
let eventFired = false;
|
||||
function loadRandomResource() {
|
||||
return fetch(window.location.href + "?" + Math.random());
|
||||
}
|
||||
|
||||
setup(function() {
|
||||
// Get the browser into a consistent state.
|
||||
performance.clearResourceTimings();
|
||||
performance.setResourceTimingBufferSize(100);
|
||||
|
||||
window.result = "";
|
||||
|
||||
});
|
||||
|
||||
let gatherEntries = new Promise(function(resolve, reject) {
|
||||
// Gather up 3 Resource Entries to kick off the rest of test behavior.
|
||||
let resources = 0;
|
||||
let observer = new PerformanceObserver(function(list) {
|
||||
resources += list.getEntriesByType("resource").length;
|
||||
if (resources !== 3)
|
||||
return;
|
||||
observer.disconnect();
|
||||
resolve();
|
||||
});
|
||||
observer.observe({entryTypes: ["resource"]});
|
||||
for (let i = 0; i < 3; ++i)
|
||||
loadRandomResource();
|
||||
});
|
||||
|
||||
let setBufferSize = new Promise(function(resolve, reject) {
|
||||
performance.onresourcetimingbufferfull = function() {
|
||||
eventFired = true;
|
||||
window.result += "Event Fired with " + performance.getEntriesByType("resource").length + " entries. ";
|
||||
performance.clearResourceTimings();
|
||||
};
|
||||
window.result += "before setLimit(3). ";
|
||||
performance.setResourceTimingBufferSize(3);
|
||||
window.result += "after setLimit(3). ";
|
||||
resolve();
|
||||
});
|
||||
|
||||
promise_test(function() {
|
||||
return gatherEntries;
|
||||
}, "Reset the entries number");
|
||||
promise_test(function() {
|
||||
return setBufferSize;
|
||||
}, "Set the buffer size");
|
||||
promise_test(function() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
loadRandomResource().then(function() {
|
||||
window.result += "after loading 4th resource. ";
|
||||
resolve();
|
||||
})});
|
||||
}, "Overflow the buffer");
|
||||
promise_test(function() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
let waitForIt = function() {
|
||||
if (eventFired) {
|
||||
resolve();
|
||||
}
|
||||
}
|
||||
step_timeout(waitForIt, 0);
|
||||
});
|
||||
}, "Wait for event");
|
||||
promise_test(function() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
if (window.result != "before setLimit(3). after setLimit(3). after loading 4th resource. Event Fired with 3 entries. ") {
|
||||
reject("Non matching value: " + window.result);
|
||||
}
|
||||
let entries = performance.getEntriesByType("resource");
|
||||
if (entries.length != 1) {
|
||||
reject("Number of entries in resource timing buffer is unexpected: " + entries.length);
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
}, "Check result");
|
||||
</script>
|
|
@ -1,42 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head onload>
|
||||
<meta charset="utf-8" />
|
||||
<title>This test validates the behavior of read and clear operation in onresourcetimingbufferfull callback of resource timing.</title>
|
||||
<link rel="author" title="Intel" href="http://www.intel.com/" />
|
||||
<link rel="help" href="http://www.w3.org/TR/resource-timing/#performanceresourcetiming"/>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/append.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
const t = async_test("Verify that clearing the resource timing buffer and storing the entries during resourcetimingbufferfull call works");
|
||||
const resource_timing_buffer_size = 1;
|
||||
performance.clearResourceTimings();
|
||||
let global_buffer = [];
|
||||
let store_and_clear = function() {
|
||||
const entryList = performance.getEntriesByType('resource');
|
||||
entryList.forEach(function (entry) {
|
||||
global_buffer.push(entry);
|
||||
});
|
||||
performance.clearResourceTimings();
|
||||
}
|
||||
performance.addEventListener('resourcetimingbufferfull', store_and_clear);
|
||||
performance.setResourceTimingBufferSize(resource_timing_buffer_size);
|
||||
// Scripts appended in JS to ensure setResourceTimingBufferSize is called before.
|
||||
// This resource gets buffered in the resource timing entry buffer.
|
||||
appendScript('resources/empty.js');
|
||||
// This resource overflows the entry buffer, and goes into the secondary buffer.
|
||||
appendScript('resources/empty_script.js');
|
||||
window.onload = t.step_func_done(()=>{
|
||||
let entries = performance.getEntriesByType('resource');
|
||||
assert_equals(entries.length, 1,
|
||||
"Only the last entry should be stored in resource timing buffer since it's cleared once it overflows.");
|
||||
assert_equals(global_buffer.length, 1, '1 resource timing entry should be moved to global buffer.');
|
||||
assert_true(global_buffer[0].name.includes('empty.js'), "empty.js is in the global buffer");
|
||||
assert_true(entries[0].name.includes('empty_script.js'), "empty_script.js is in the entries buffer");
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -1,37 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head onload>
|
||||
<meta charset="utf-8" />
|
||||
<title>This test validates that synchronously adding entries in onresourcetimingbufferfull callback results in these entries being properly handled.</title>
|
||||
<link rel="author" title="Intel" href="http://www.intel.com/" />
|
||||
<link rel="help" href="http://www.w3.org/TR/resource-timing/#performanceresourcetiming"/>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/append.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
const resource_timing_buffer_size = 1;
|
||||
const t = async_test("Verify that adding entries and then increasing the size of the resource timing buffer results in entries added in the right order");
|
||||
performance.clearResourceTimings();
|
||||
performance.addEventListener('resourcetimingbufferfull', t.unreached_func("resourcetimingbufferfull should not fire"));
|
||||
performance.setResourceTimingBufferSize(resource_timing_buffer_size);
|
||||
// Scripts appended in JS to ensure setResourceTimingBufferSize is called before.
|
||||
// This resource gets buffered in the resource timing entry buffer.
|
||||
xhrScript('resources/empty.js?xhr');
|
||||
// These resources overflow the entry buffer, and goes into the secondary buffer.
|
||||
xhrScript('resources/empty.js?xhr2');
|
||||
xhrScript('resources/empty.js?xhr3');
|
||||
performance.setResourceTimingBufferSize(3);
|
||||
window.onload = t.step_timeout(()=>{
|
||||
let entries = performance.getEntriesByType('resource');
|
||||
assert_equals(entries.length, 3,
|
||||
'All resources should be in the buffer, since its size was increased');
|
||||
assert_true(entries[0].name.includes('empty.js?xhr'), "empty.js?xhr2 is in the entries buffer");
|
||||
assert_true(entries[1].name.includes('empty.js?xhr2'), "empty.js?xhr3 is in the entries buffer");
|
||||
assert_true(entries[2].name.includes('empty.js?xhr3'), "empty.js?xhr3 is in the entries buffer");
|
||||
t.done();
|
||||
}, 0);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -9,29 +9,33 @@
|
|||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/webperftestharness.js"></script>
|
||||
<script src="resources/webperftestharnessextension.js"></script>
|
||||
<script src="resources/append.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<body onload=onload_test()>
|
||||
<script>
|
||||
const context = new PerformanceContext(performance);
|
||||
const t = async_test("Verify that resourcetimingbufferfull is properly invoked");
|
||||
performance.clearResourceTimings();
|
||||
let bufferSize = 2;
|
||||
const bufferSize = 5;
|
||||
context.setResourceTimingBufferSize(bufferSize);
|
||||
let bufferFullCount = 0;
|
||||
function buffer_full_callback(e) {
|
||||
assert_equals(e.bubbles, false, "Event bubbles attribute is false");
|
||||
function buffer_full_callback() {
|
||||
bufferFullCount++;
|
||||
}
|
||||
context.registerResourceTimingBufferFullCallback(t.step_func(buffer_full_callback));
|
||||
context.registerResourceTimingBufferFullCallback(buffer_full_callback);
|
||||
// Scripts appended in JS to ensure setResourceTimingBufferSize is called before.
|
||||
function appendScript(src) {
|
||||
const script = document.createElement('script');
|
||||
script.type = 'text/javascript';
|
||||
script.src = src;
|
||||
document.body.appendChild(script);
|
||||
}
|
||||
appendScript('resources/empty.js');
|
||||
appendScript('resources/empty_script.js');
|
||||
appendScript('resources/resource_timing_test0.js');
|
||||
window.onload = t.step_func_done(()=>{
|
||||
assert_equals(context.getEntriesByType('resource').length, bufferSize, 'There should only be |bufferSize| resource entries.');
|
||||
assert_equals(bufferFullCount, 1, 'onresourcetimingbufferfull should have been invoked once.');
|
||||
});
|
||||
setup({ explicit_done: true });
|
||||
function onload_test() {
|
||||
test_equals(context.getEntriesByType('resource').length, bufferSize, 'There should only be |bufferSize| resource entries.');
|
||||
test_equals(bufferFullCount, 1, 'onresourcetimingbufferfull should have been invoked once buffer is full.');
|
||||
done();
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,56 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head onload>
|
||||
<meta charset="utf-8" />
|
||||
<title>This test validates the behavior of read and clear operation in onresourcetimingbufferfull callback of resource timing.</title>
|
||||
<link rel="author" title="Intel" href="http://www.intel.com/" />
|
||||
<link rel="help" href="http://www.w3.org/TR/resource-timing/#performanceresourcetiming"/>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/webperftestharness.js"></script>
|
||||
<script src="resources/webperftestharnessextension.js"></script>
|
||||
</head>
|
||||
<body onload=onload_test()>
|
||||
<script>
|
||||
const context = new PerformanceContext(performance);
|
||||
const resource_timing_buffer_size = 1;
|
||||
let global_buffer = [];
|
||||
function store_and_clear() {
|
||||
const entryList = context.getEntriesByType('resource');
|
||||
entryList.forEach(function (entry) {
|
||||
global_buffer.push(entry);
|
||||
});
|
||||
context.clearResourceTimings();
|
||||
}
|
||||
context.registerResourceTimingBufferFullCallback(store_and_clear);
|
||||
context.setResourceTimingBufferSize(resource_timing_buffer_size);
|
||||
// Scripts appended in JS to ensure setResourceTimingBufferSize is called before.
|
||||
function appendScript(src) {
|
||||
const script = document.createElement('script');
|
||||
script.type = 'text/javascript';
|
||||
script.src = src;
|
||||
document.body.appendChild(script);
|
||||
}
|
||||
appendScript('resources/empty.js');
|
||||
appendScript('resources/empty_script.js');
|
||||
appendScript('resources/resource_timing_test0.js');
|
||||
setup({ explicit_done: true });
|
||||
function onload_test() {
|
||||
test_equals(context.getEntriesByType('resource').length, 0, 'No entry should be stored in resource timing buffer since its cleared once an item arrived.');
|
||||
// The entry for empty.js must not be in the global buffer, but all others should be.
|
||||
test_equals(global_buffer.length, 6, '6 resource timing entries should be moved to global buffer.');
|
||||
const index = window.location.pathname.lastIndexOf('resource-timing');
|
||||
const pathname = window.location.pathname.substring(0, index);
|
||||
let expected_entries = {};
|
||||
expected_entries[pathname + 'resources/testharness.js'] = 'script';
|
||||
expected_entries[pathname + 'resources/testharnessreport.js'] = 'script';
|
||||
expected_entries[pathname + 'resource-timing/resources/webperftestharness.js'] = 'script';
|
||||
expected_entries[pathname + 'resource-timing/resources/webperftestharnessextension.js'] = 'script';
|
||||
expected_entries[pathname + 'resource-timing/resources/empty_script.js'] = 'script';
|
||||
expected_entries[pathname + 'resource-timing/resources/resource_timing_test0.js'] = 'script';
|
||||
test_resource_entries(global_buffer, expected_entries);
|
||||
done();
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -1,12 +0,0 @@
|
|||
function appendScript(src) {
|
||||
const script = document.createElement('script');
|
||||
script.type = 'text/javascript';
|
||||
script.src = src;
|
||||
document.body.appendChild(script);
|
||||
}
|
||||
|
||||
function xhrScript(src) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", src, false);
|
||||
xhr.send(null);
|
||||
}
|
|
@ -44,13 +44,19 @@ promise_test(function(test) {
|
|||
assert_greater_than(entry.startTime, 0);
|
||||
assert_greater_than(entry.responseEnd, entry.startTime);
|
||||
}
|
||||
return new Promise(function(resolve) {
|
||||
return Promise.race([
|
||||
new Promise(function(resolve) {
|
||||
performance.onresourcetimingbufferfull = _ => {
|
||||
resolve('bufferfull');
|
||||
}
|
||||
performance.setResourceTimingBufferSize(expectedResources.length);
|
||||
fetch('dummy.txt');
|
||||
});
|
||||
}),
|
||||
|
||||
// Race the bufferfull event against another fetch. We should get the
|
||||
// event before this completes. This allows us to detect a failure
|
||||
// to dispatch the event without timing out the entire test.
|
||||
fetch('dummy.txt').then(resp => resp.text())
|
||||
]);
|
||||
})
|
||||
.then(function(result) {
|
||||
assert_equals(result, 'bufferfull');
|
||||
|
|
Загрузка…
Ссылка в новой задаче