Bug 1695730 [wpt PR 27843] - [ResourceTiming] Interrogate more attributes in Resource Timing WPT, a=testonly

Automatic update from web-platform-tests
[ResourceTiming] Interrogate more attributes in Resource Timing WPT

The Resource Timing spec enumerates the attributes for
PerformanceResourceTiming values as well as rules for what each
attribute must contain.

This changes adds tests to validate the computed attributes match
expectations from the spec.

Bug: 1171767
Change-Id: Ic5d284e7cb4a5d186a7cd8fefab342eac916e4fb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2727516
Reviewed-by: Yoav Weiss <yoavweiss@chromium.org>
Commit-Queue: Tom McKee <tommckee@chromium.org>
Cr-Commit-Position: refs/heads/master@{#859365}

--

wpt-commits: bd23e127fcc1456779eded21dda1c1dac66fc1d9
wpt-pr: 27843
This commit is contained in:
Tom McKee 2021-03-10 21:12:27 +00:00 коммит произвёл moz-wptsync-bot
Родитель 6d6a712143
Коммит 347bbde032
1 изменённых файлов: 61 добавлений и 2 удалений

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

@ -17,6 +17,35 @@ function load_image(path) {
});
}
function assert_ordered(entry, attributes) {
let before = attributes[0];
attributes.slice(1).forEach(after => {
assert_greater_than_equal(entry[after], entry[before],
`${after} should be greater than ${before}`);
before = after;
});
}
function assert_zeroed(entry, attributes) {
attributes.forEach(attribute => {
assert_equals(entry[attribute], 0, `${attribute} should be 0`);
});
}
function assert_not_negative(entry, attributes) {
attributes.forEach(attribute => {
assert_greater_than_equal(entry[attribute], 0,
`${attribute} should be greater than or equal to 0`);
});
}
function assert_positive(entry, attributes) {
attributes.forEach(attribute => {
assert_greater_than(entry[attribute], 0,
`${attribute} should be greater than 0`);
});
}
promise_test(async () => {
// Clean up entries from scripts includes.
performance.clearResourceTimings();
@ -25,8 +54,38 @@ promise_test(async () => {
if (entry_list.length != 1) {
throw new Error("There should be one entry for one resource");
}
assert_true(entry_list[0].name.includes('#hash=1'),
"There should be a hash in the resource name");
const entry = entry_list[0];
assert_true(entry.name.includes('#hash=1'),
"There should be a hash in the resource name");
assert_ordered(entry, [
"fetchStart",
"domainLookupStart",
"domainLookupEnd",
"connectStart",
"connectEnd",
"requestStart",
"responseStart",
"responseEnd",
]);
assert_zeroed(entry, [
"workerStart",
"secureConnectionStart",
"redirectStart",
"redirectEnd",
]);
assert_not_negative(entry, [
"duration",
]);
assert_positive(entry, [
"fetchStart",
"transferSize",
"encodedBodySize",
"decodedBodySize",
]);
}, "URL fragments should be present in the 'name' attribute");
</script>