blob: 3231d69ae9ca2cce17cda917f3cd071867f0c8a8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
<!DOCTYPE html>
<meta charset="utf-8" />
<title>
Resource timing attributes are consistent for the same-origin subresources.
</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../resources/test-helpers.js"></script>
<body>
<script>
setup(() => {
assert_true(HTMLScriptElement.supports("webbundle"));
});
promise_test(async (t) => {
const bundle_url =
"https://{{domains[]}}:{{ports[https][0]}}/web-bundle/resources/wbn/dynamic1.wbn?pipe=trickle(d0.5)";
const script_url =
"https://{{domains[]}}:{{ports[https][0]}}/web-bundle/resources/wbn/dynamic/resource1.js";
const element = createWebBundleElement(
"../resources/wbn/dynamic1.wbn?pipe=trickle(d0.5)",
/*resources=*/ [script_url]
);
document.body.appendChild(element);
var script_entries = 0;
var web_bundle_entries = 0;
var web_bundle_entry, script_entry;
const promise = new Promise((resolve) => {
new PerformanceObserver(
t.step_func((entryList) => {
var entries = entryList.getEntriesByType("resource");
for (var i = 0; i < entries.length; ++i) {
if (entries[i].name === script_url) {
script_entry = entries[i];
script_entries++;
}
if (entries[i].name === bundle_url) {
web_bundle_entry = entries[i];
web_bundle_entries++;
}
}
if (web_bundle_entries > 0 && script_entries > 0) {
// Check timestamps.
assert_greater_than_equal(
script_entry.responseStart,
script_entry.requestStart + 500
);
assert_greater_than_equal(
script_entry.responseStart,
web_bundle_entry.responseStart
);
assert_greater_than_equal(
script_entry.responseEnd,
script_entry.responseStart
);
assert_greater_than_equal(
script_entry.requestStart,
script_entry.connectEnd
);
assert_greater_than_equal(
script_entry.responseEnd,
script_entry.responseStart
);
// Check sizes.
assert_greater_than(script_entry.encodedBodySize, 0);
assert_equals(
script_entry.transferSize,
script_entry.encodedBodySize + 300
);
assert_equals(
script_entry.encodedBodySize,
script_entry.decodedBodySize
);
resolve();
}
})
).observe({ entryTypes: ["resource"] });
});
const script = document.createElement("script");
script.type = "module";
script.src = script_url;
document.body.appendChild(script);
return promise;
}, "Timestamp attributes filled in resource timing entries should be consistent.");
</script>
</body>
|