forked from web-platform-tests/wpt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test added for navigation timing bits dependent on DocumentLoadTiming (…
…web-platform-tests#41795) - Test to observe the navigation timing entries dependent on Document Load Timing for a detached iframe. These entries return 0 after the iframe is detached. Change-Id: Ia8207153f07edc197593682394aa66606acd365f Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4835569 Reviewed-by: Yoav Weiss <[email protected]> Commit-Queue: Ansh mishra <[email protected]> Cr-Commit-Position: refs/heads/main@{#1200908} Co-authored-by: ANSH MISHRA <[email protected]>
- Loading branch information
1 parent
abe2f14
commit da07204
Showing
1 changed file
with
85 additions
and
0 deletions.
There are no files selected for viewing
85 changes: 85 additions & 0 deletions
85
navigation-timing/test-timing-attributes-dependent-on-document-load.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>Navigation Timing 2 WPT</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script> | ||
setup({ single_test: true }); | ||
var reload_frame; | ||
|
||
// Array of navigation timing entries dependent on Document Load Timing. | ||
var navTimingAttributes = [ | ||
'fetchStart', | ||
'loadEventEnd', | ||
'loadEventStart', | ||
'redirectCount', | ||
'redirectEnd', | ||
'redirectStart', | ||
'responseEnd', | ||
'unloadEventEnd', | ||
'unloadEventStart', | ||
]; | ||
|
||
// Function to run the test when the page loads. | ||
function onload_test() { | ||
reload_frame = document.getElementById("frameContext"); | ||
reload_frame.onload = function() { | ||
step_timeout(do_test, 0); | ||
} | ||
step_timeout(reload_the_frame, 0); | ||
} | ||
|
||
/* | ||
Function to reload the iframe and observe values for navigation timing entries: | ||
redirectStart, redirectEnd and redirectCount dependent on Document Load Timing. | ||
*/ | ||
function reload_the_frame() { | ||
reload_frame.contentWindow.location.href = | ||
"/common/redirect.py?location=/navigation-timing/resources/blank-page-green.html"; | ||
} | ||
|
||
/* | ||
Function to obtain navigation timing entries and, | ||
check if the values are greater than 0. | ||
*/ | ||
function do_test() { | ||
var nav_frame = document.getElementById("frameContext").contentWindow; | ||
var pnt1 = nav_frame.performance.getEntriesByType("navigation")[0]; | ||
for (i in navTimingAttributes) { | ||
assert_greater_than(pnt1[navTimingAttributes[i]], 0, | ||
`Expected navigation timing entries: ${navTimingAttributes[i]} greater than 0`); | ||
} | ||
step_timeout(remove, 0); | ||
done(); // Avoids scripting errors | ||
} | ||
|
||
/* | ||
Function to remove the iframe from the parent body and, | ||
check if the navigation timing entries of detached iframe are 0. | ||
*/ | ||
function remove() { | ||
var nav_frame = document.getElementById("frameContext").contentWindow; | ||
var pnt1 = nav_frame.performance.getEntriesByType("navigation")[0]; | ||
document.body.removeChild(document.getElementById("frameContext")); | ||
for (i in navTimingAttributes) { | ||
assert_equals(pnt1[navTimingAttributes[i]], 0, | ||
`${navTimingAttributes[i]} dependent on Document Load Timing: returns 0`); | ||
} | ||
} | ||
</script> | ||
</head> | ||
<body onload="onload_test();"> | ||
<h1>Description</h1> | ||
<p>This test observes values of navigation timing entries,</p> | ||
<p>dependent on Document Load Timing for a detached iframe.</p> | ||
<br /> | ||
<p>This page should be loaded with a green background frame below,</p> | ||
<p>which disappears after the iframe is detached.</p> | ||
<br /> | ||
<iframe id="frameContext" | ||
src="/navigation-timing/resources/blank-page-green.html" | ||
style="width: 250px; height: 250px;"></iframe> | ||
</body> | ||
</html> |