Bug 1564795 [wpt PR 17676] - Do not expose element, event, and layout-shift entries via getEntries, a=testonly

Automatic update from web-platform-tests
Do not expose element, event, and layout-shift entries via getEntries

Currently, Performance's getEntriesByType, getEntriesByName, and
getEntries methods include buffered entries of types 'element', 'event',
and 'layout-shift'. We do not want to expose these to the performance
timeline now that the buffered flag is shipped. This CL removes them
from those methods and fixes/adds web_tests that check those methods.

Bug: 581518, 823744, 883483, 972830
Change-Id: I0d74794bcc205cded6684472cc56836e253856cf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1689073
Reviewed-by: Steve Kobes <skobes@chromium.org>
Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#675032}

--

wpt-commits: c13852e02350b4e86a8c348885933f9e9b83e807
wpt-pr: 17676
This commit is contained in:
Nicolás Peña Moreno 2019-07-19 19:45:15 +00:00 коммит произвёл James Graham
Родитель f980eb93c5
Коммит d91292efd5
3 изменённых файлов: 55 добавлений и 25 удалений

Просмотреть файл

@ -0,0 +1,31 @@
<!DOCTYPE HTML>
<meta charset=utf-8>
<title>Element Timing: 'element' entries are not accessible via performance timeline</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/element-timing-helpers.js"></script>
<script>
let img;
async_test(function (t) {
if (!window.PerformanceElementTiming) {
assert_unreached("PerformanceElementTiming is not implemented");
}
const beforeRender = performance.now();
new PerformanceObserver(
t.step_func_done(function(entryList) {
assert_equals(entryList.getEntries().length, 1);
const entry = entryList.getEntries()[0];
assert_equals(entry.entryType, 'element');
assert_equals(entry.name, 'image-paint');
const entriesByName = performance.getEntriesByName('image-paint', 'element');
const entriesByType = performance.getEntriesByType('element');
const allEntries = performance.getEntries();
assert_equals(entriesByName.length, 0, 'Element Timing entry should not be retrievable by getEntriesByName');
assert_equals(entriesByType.length, 0, 'Element Timing entry should not be retrievable by getEntriesByType');
assert_equals(allEntries.filter(e => e.entryType === 'element').length, 0, 'Element Timing entry should not be retrievable by getEntries');
})
).observe({type: 'element', buffered: true});
}, 'Element Timing entries are not accessible via performance.getEntries*');
</script>
<img src='resources/square100.png' elementtiming='my_image' id='my_id'/>

Просмотреть файл

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<meta charset=utf-8>
<title>Event Timing: make sure event-timing entries are retrievable by existing perf APIs.</title>
<title>Event Timing: make sure 'event' entries are not retrievable by performance.getEntries* APIs.</title>
<meta name="timeout" content="long">
<button id='button'>Generate a 'click' event</button>
<script src=/resources/testharness.js></script>
@ -10,17 +10,15 @@
<script src=/resources/testdriver-vendor.js></script>
<script src=resources/event-timing-test-utils.js></script>
<img src=resources/slow-image.py>
<script>
function validateEntries() {
const entriesByName = performance.getEntriesByName('mousedown', 'event');
const entriesByType = performance.getEntriesByType('event');
const allEntries = performance.getEntries();
assert_equals(entriesByName.length, 1, 'event-timing entry should be retrievable by getEntriesByName');
const e = entriesByName[0];
assert_true(entriesByType.includes(e), 'event-timing entry should be retrievable by getEntries');
assert_true(allEntries.includes(e), 'event-timing entry should be retrievable by getEntriesByType');
assert_equals(entriesByName.length, 0, 'Event Timing entry should not be retrievable by getEntriesByName');
assert_equals(entriesByType.length, 0, 'Event Timing entry should not be retrievable by getEntriesByType');
assert_equals(allEntries.filter(e => e.entryType === 'event').length, 0, 'Event Timing entry should not be retrievable by getEntries');
}
/* Timeline:
@ -32,12 +30,15 @@
Validate entries
*/
async_test(function(t) {
clickAndBlockMain('button');
on_event(window, 'load', e => {
if (!window.PerformanceEventTiming) {
assert_unreached('PerformanceEventTiming is not implemented');
}
new PerformanceObserver(t.step_func_done(() => {
validateEntries();
t.done();
});
}, "Event Timing: make sure event-timing entries are retrievable by existing perf APIs.");
})).observe({entryTypes: ['event']});
clickAndBlockMain('button');
}, "Event Timing: make sure event-timing entries are not retrievable by performance.getEntries*.");
</script>
</html>

Просмотреть файл

@ -1,6 +1,6 @@
<!DOCTYPE HTML>
<meta charset=utf-8>
<title>Layout Instability: query layout shift value via the performance timeline</title>
<title>Layout Instability entries are not available via the performance timeline</title>
<body>
<style>
#myDiv { position: relative; width: 300px; height: 100px; }
@ -13,18 +13,10 @@
<script>
async_test(function (t) {
const startTime = performance.now();
// Modify the position of the div.
document.getElementById('myDiv').style = "top: 60px";
function testBufferedEntry() {
if (performance.getEntriesByType('layout-shift').length === 0) {
t.step_timeout(testBufferedEntry, 0);
return;
}
new PerformanceObserver(list => {
const endTime = performance.now();
assert_equals(performance.getEntriesByType('layout-shift').length, 1);
assert_equals(performance.getEntries().filter(
entry => entry.entryType === 'layout-shift').length, 1);
const entry = performance.getEntriesByType('layout-shift')[0];
assert_equals(list.getEntries().length, 1);
const entry = list.getEntries()[0];
assert_equals(entry.entryType, "layout-shift");
assert_equals(entry.name, "");
assert_greater_than_equal(entry.startTime, startTime)
@ -36,10 +28,16 @@
// 300 * (100 + 60) * (60 / maxDimension) / viewport size.
assert_equals(entry.value, 300 * (100 + 60) * (60 / maxDimension) /
(document.documentElement.clientWidth * document.documentElement.clientHeight));
// The entry should not be available via getEntries* methods.
assert_equals(performance.getEntriesByType('layout-shift').length, 0, 'getEntriesByType should have no layout-shift entries');
assert_equals(performance.getEntriesByName('', 'layout-shift').length, 0, 'getEntriesByName should have no layout-shift entries');
assert_equals(performance.getEntries().filter(e => e.entryType === 'layout-shift').length, 0, 'getEntries should have no layout-shift entries');
t.done();
}
t.step(testBufferedEntry);
}, 'Layout shift before onload is buffered into the performance timeline.');
}).observe({type: 'layout-shift'});
// Modify the position of the div.
document.getElementById('myDiv').style = "top: 60px";
}, 'Layout shift before onload is not buffered into the performance timeline.');
</script>
</body>