mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-21 17:25:36 +00:00
8663662eb8
Automatic update from web-platform-tests ResourceTiming: remove setTimeout lints Change-Id: I868a3dbb41a44ad36f948d1649b041b148b43759 Reviewed-on: https://chromium-review.googlesource.com/c/1487800 Reviewed-by: Yoav Weiss <yoavweiss@chromium.org> Commit-Queue: Nicolás Peña Moreno <npm@chromium.org> Cr-Commit-Position: refs/heads/master@{#636029} -- wpt-commits: ba4199a373672ac3e1981ef7a6351269f9d9c78c wpt-pr: 15553
52 lines
1.7 KiB
HTML
52 lines
1.7 KiB
HTML
<!DOCTYPE HTML>
|
|
<meta charset=utf-8>
|
|
<meta name="timeout" content="long">
|
|
<title>One resource when reusing data</title>
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
<body>
|
|
<script>
|
|
async_test(t => {
|
|
var img_entries = 0;
|
|
var observed = 0;
|
|
var img_url = "resources/blue.png";
|
|
var observer = new PerformanceObserver(
|
|
function (entryList, obs) {
|
|
var entries = entryList.getEntriesByType("resource");
|
|
for (var i = 0; i < entries.length; ++i) {
|
|
// Ignore any entries for the test harness files if present.
|
|
if (/testharness(report)?\.js/.test(entries[i].name)) {
|
|
continue;
|
|
}
|
|
|
|
++observed;
|
|
if (entries[i].name.indexOf(img_url) != -1)
|
|
++img_entries;
|
|
}
|
|
});
|
|
observer.observe({entryTypes: ["resource"]});
|
|
window.onload = function() {
|
|
// A timeout is needed as PerformanceObserver is not guaranteed to run before onload triggered.
|
|
t.step_timeout(function() {
|
|
assert_equals(observed, 1);
|
|
assert_equals(img_entries, 1);
|
|
t.done();
|
|
}, 0);
|
|
};
|
|
// Images are added dynamically to make sure the observer is registered before their download finishes.
|
|
var img1 = document.createElement("img");
|
|
img1.src = img_url;
|
|
document.body.appendChild(img1);
|
|
var img2 = document.createElement("img");
|
|
img2.src = img_url;
|
|
document.body.appendChild(img2);
|
|
}, "A single resource used in two elements produces a single entry.");
|
|
</script>
|
|
<h1>One resource when reusing data</h1>
|
|
<p>
|
|
If the user agent is to reuse the data from another existing or completed fetch initiated from the current document, abort the remaining steps.
|
|
</p>
|
|
<div id="log"></div>
|
|
</body>
|
|
|