-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Resource Timing] Test XO redirection sandwich with and without TAO
- Loading branch information
Showing
2 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
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,47 @@ | ||
<!DOCTYPE HTML> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>This test validates resource timing information for a same-origin=>cross-origin=>same-origin redirect chain with Timing-Allow-Origin.</title> | ||
<link rel="author" title="Intel" href="http://www.intel.com/" /> | ||
<link rel="help" href="http://www.w3.org/TR/resource-timing/#performanceresourcetiming"/> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="resources/webperftestharness.js"></script> | ||
<script src="resources/webperftestharnessextension.js"></script> | ||
|
||
<script> | ||
setup({explicit_done: true}); | ||
test_namespace('getEntriesByName'); | ||
const pageOrigin = "{{host}}:{{ports[http][0]}}" | ||
const crossOrigin = "{{domains[www]}}:{{ports[http][0]}}" | ||
|
||
function onload_test() | ||
{ | ||
const context = new PerformanceContext(performance); | ||
const entries = context.getEntriesByName(document.getElementById('frameContext').src, 'resource'); | ||
test_equals(entries.length, 1, 'There should be one entry.'); | ||
const entry = entries[0]; | ||
|
||
test_greater_than(entry.redirectStart, 0, 'redirectStart > 0 in cross-origin redirect with Timing-Allow-Origin.'); | ||
test_greater_than(entry.redirectEnd, 0, 'redirectEnd > 0 in cross-origin redirect with Timing-Allow-Origin.'); | ||
test_greater_than(entry.fetchStart, 0, 'fetchStart > 0 in cross-origin redirect.'); | ||
test_greater_than(entry.fetchStart, entry.startTime, 'startTime < fetchStart in cross-origin redirect with Timing-Allow-Origin.'); | ||
done(); | ||
} | ||
</script> | ||
|
||
</head> | ||
<body> | ||
<iframe id="frameContext" src="" style="width: 250px; height: 250px;"></iframe> | ||
<script> | ||
let destUrl = 'http://' + pageOrigin + '/resource-timing/resources/multi_redirect.py?'; | ||
destUrl += 'page_origin=' + 'http://' + pageOrigin; | ||
destUrl += '&timing_allow=1'; | ||
destUrl += '&cross_origin=' + 'http://' + crossOrigin; | ||
const frameContext = document.getElementById('frameContext'); | ||
frameContext.onload = onload_test; | ||
frameContext.src = destUrl; | ||
</script> | ||
</body> | ||
</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,46 @@ | ||
<!DOCTYPE HTML> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>This test validates resource timing information for a same-origin=>cross-origin=>same-origin redirect chain with Timing-Allow-Origin.</title> | ||
<link rel="author" title="Intel" href="http://www.intel.com/" /> | ||
<link rel="help" href="http://www.w3.org/TR/resource-timing/#performanceresourcetiming"/> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="resources/webperftestharness.js"></script> | ||
<script src="resources/webperftestharnessextension.js"></script> | ||
|
||
<script> | ||
setup({explicit_done: true}); | ||
test_namespace('getEntriesByName'); | ||
const pageOrigin = "{{host}}:{{ports[http][0]}}" | ||
const crossOrigin = "{{domains[www]}}:{{ports[http][0]}}" | ||
|
||
function onload_test() | ||
{ | ||
const context = new PerformanceContext(performance); | ||
const entries = context.getEntriesByName(document.getElementById('frameContext').src, 'resource'); | ||
test_equals(entries.length, 1, 'There should be one entry.'); | ||
const entry = entries[0]; | ||
|
||
test_equals(entry.redirectStart, 0, 'redirectStart == 0 in cross-origin redirect with no Timing-Allow-Origin.'); | ||
test_equals(entry.redirectEnd, 0, 'redirectEnd == 0 in cross-origin redirect with no Timing-Allow-Origin.'); | ||
test_greater_than(entry.fetchStart, 0, 'fetchStart > 0 in cross-origin redirect.'); | ||
test_equals(entry.fetchStart, entry.startTime, 'startTime == fetchStart in cross-origin redirect with no Timing-Allow-Origin.'); | ||
done(); | ||
} | ||
</script> | ||
|
||
</head> | ||
<body> | ||
<iframe id="frameContext" src="" style="width: 250px; height: 250px;"></iframe> | ||
<script> | ||
let destUrl = 'http://' + pageOrigin + '/resource-timing/resources/multi_redirect.py?'; | ||
destUrl += 'page_origin=' + 'http://' + pageOrigin; | ||
destUrl += '&cross_origin=' + 'http://' + crossOrigin; | ||
const frameContext = document.getElementById('frameContext'); | ||
frameContext.onload = onload_test; | ||
frameContext.src = destUrl; | ||
</script> | ||
</body> | ||
</html> |