Commit 7ae79f68 authored by Liquan (Max) Gu's avatar Liquan (Max) Gu Committed by Commit Bot

Long tasks: replace settimeout with step_timeout in test and fix the test

Replace settimeout with set_timeout in the test longtask-in-parentiframe.html,
according to testharness-api.
The original test fails because the long task is fired before the observer is
created, so this CL fixes it by delaying the long task until the iframe is
loaded.

Bug: 745031
Change-Id: I89e0f0fab5ef0458c773f90ded428fc1a483913c
Reviewed-on: https://chromium-review.googlesource.com/579593Reviewed-by: default avatarShubhie Panicker <panicker@chromium.org>
Commit-Queue: Liquan Gu <maxlg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#490831}
parent 9e4c1de0
......@@ -160,7 +160,6 @@ SET TIMEOUT: eventsource/eventsource-close.htm
SET TIMEOUT: eventsource/eventsource-request-cancellation.htm
SET TIMEOUT: html/*
SET TIMEOUT: IndexedDB/*
SET TIMEOUT: longtask-timing/longtask-in-parentiframe.html
SET TIMEOUT: infrastructure/*
SET TIMEOUT: media-source/mediasource-util.js
SET TIMEOUT: media-source/URL-createObjectURL-revoke.html
......
......@@ -7,21 +7,25 @@
<script src="/resources/testharnessreport.js"></script>
<script>
async_test(t => {
var t = async_test(t => {
window.addEventListener("message", t.step_func(e => {
assert_equals(e.data, "longtask+same-origin-ancestor+frame");
assert_equals(e.data, "longtask+same-origin-ancestor+script");
t.done();
}));
}, "Performance longtask entries in parent are observable in child iframe");
</script>
}, "Performance longtask entries in parent are observable in child iframe");
<iframe src="resources/subframe-observing-longtask.html" id="child-iframe-id" name="child-iframe-name"></iframe>
var iframe = document.createElement('iframe');
iframe.onload = function() {
t.step_timeout(function(){
var begin = window.performance.now();
while (window.performance.now() < begin + 51);
}, 50);
}
iframe.id = 'child-iframe-id';
iframe.name = 'child-iframe-name';
document.body.appendChild(iframe);
iframe.src = 'resources/subframe-observing-longtask.html';
<script>
setTimeout(function(){
var begin = window.performance.now();
while (window.performance.now() < begin + 51);
}, 50);
</script>
</body>
\ No newline at end of file
</body>
......@@ -7,12 +7,15 @@
<script>
var observer = new PerformanceObserver(function(entryList) {
for (i = 0; i < entryList.getEntries().length; i++) {
var longtask = entryList.getEntries()[i];
// Ignore long task generated within here, as part of making this iframe.
if (longtask.name == "same-origin-self")
return;
// TODO(panicker): include frameId etc.
var entryContents = longtask.entryType + '+' + longtask.name + '+' + longtask.attribution[0].name;
var longtask = entryList.getEntries()[i];
// Ignore long task generated within here, as part of making this iframe.
// Ignore multiple-contexts and unknown because they cause longtask-in-parentiframe test to be flaky.
if (longtask.name == "same-origin-self" ||
longtask.name == "multiple-contexts" || longtask.name == "unknown")
return;
// TODO(panicker): include frameId etc.
var entryContents = longtask.entryType + '+' + longtask.name + '+' +
longtask.attribution[0].name;
top.postMessage(entryContents, '*');
}
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment