Update web-platform-tests to revision e2eb25aaa6dd3c512b172588f3400f9c25a410c3

This commit is contained in:
WPT Sync Bot 2019-02-11 20:38:59 -05:00
parent 3d4a416c6b
commit 8b66216ed2
484 changed files with 1945 additions and 1089 deletions

View file

@ -10,19 +10,32 @@ function getAbsoluteURL(url)
return new URL(url, location.href).href;
}
function verifyNumberOfDownloads(url, number)
{
var numDownloads = 0;
performance.getEntriesByName(getAbsoluteURL(url)).forEach(entry => {
if (entry.transferSize > 0) {
numDownloads++;
}
});
assert_equals(numDownloads, number, url);
}
function verifyNumberOfResourceTimingEntries(url, number)
{
var numEntries = performance.getEntriesByName(getAbsoluteURL(url)).length;
assert_equals(numEntries, number, url);
}
// Verifies that the resource is loaded, but not downloaded from network
// more than once. This can be used to verify that a preloaded resource is
// not downloaded again when used.
function verifyLoadedAndNoDoubleDownload(url) {
var entries = performance.getEntriesByName(getAbsoluteURL(url));
// UA may create separate RT entries for preload and normal load,
// so we just check (entries.length > 0).
assert_greater_than(entries.length, 0, url + ' should be loaded');
var numDownloads = 0;
entries.forEach(entry => {
// transferSize is zero if the resource is loaded from cache.
if (entry.transferSize > 0) {
numDownloads++;
}
});
// numDownloads can be zero if the resource was already cached before running
// the test (for example, when the test is running repeatedly without
// clearing cache between runs).
assert_less_than_equal(
numDownloads, 1,
url + ' should be downloaded from network at most once');
}