summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/resource-timing/resources/frame-timing.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/resource-timing/resources/frame-timing.js
parentInitial commit. (diff)
downloadfirefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz
firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/resource-timing/resources/frame-timing.js')
-rw-r--r--testing/web-platform/tests/resource-timing/resources/frame-timing.js48
1 files changed, 48 insertions, 0 deletions
diff --git a/testing/web-platform/tests/resource-timing/resources/frame-timing.js b/testing/web-platform/tests/resource-timing/resources/frame-timing.js
new file mode 100644
index 0000000000..e0c364e9b2
--- /dev/null
+++ b/testing/web-platform/tests/resource-timing/resources/frame-timing.js
@@ -0,0 +1,48 @@
+function test_frame_timing_before_load_event(type) {
+ promise_test(async t => {
+ const {document, performance} = type === 'frame' ? window.parent : window;
+ const delay = 500;
+ const frame = document.createElement(type);
+ t.add_cleanup(() => frame.remove());
+ await new Promise(resolve => {
+ frame.addEventListener('load', resolve);
+ frame.src = `resources/iframe-with-delay.sub.html?delay=${delay}`;
+ (type === 'frame' ? document.querySelector('frameset') : document.body).appendChild(frame);
+ });
+
+ const entries = performance.getEntriesByName(frame.src);
+ const navigationEntry = frame.contentWindow.performance.getEntriesByType('navigation')[0];
+ assert_equals(entries.length, 1);
+ assert_equals(entries[0].initiatorType, type);
+ assert_greater_than(performance.now(), entries[0].responseEnd + delay);
+ const domContentLoadedEventAbsoluteTime = navigationEntry.domContentLoadedEventStart + frame.contentWindow.performance.timeOrigin;
+ const frameResponseEndAbsoluteTime = entries[0].responseEnd + performance.timeOrigin;
+ assert_greater_than(domContentLoadedEventAbsoluteTime, frameResponseEndAbsoluteTime);
+ }, `A ${type} should report its RT entry when the response is done and before it is completely loaded`);
+}
+
+
+function test_frame_timing_change_src(type) {
+ promise_test(async t => {
+ const {document, performance} = type === 'frame' ? window.parent : window;
+ const frame = document.createElement(type);
+ t.add_cleanup(() => frame.remove());
+ await new Promise(resolve => {
+ const done = () => {
+ resolve();
+ frame.removeEventListener('load', done);
+ }
+ frame.addEventListener('load', done);
+ frame.src = 'resources/green.html?1';
+ (type === 'frame' ? document.querySelector('frameset') : document.body).appendChild(frame);
+ });
+
+ await new Promise(resolve => {
+ frame.addEventListener('load', resolve);
+ frame.src = 'resources/green.html?2';
+ });
+
+ const entries = performance.getEntries().filter(e => e.name.includes('green.html'));
+ assert_equals(entries.length, 2);
+ }, `A ${type} should report separate RT entries if its src changed from the outside`);
+} \ No newline at end of file