Commit 760800d7 authored by sunjian's avatar sunjian Committed by Commit bot

Move nav timing 2's wpt tests into w3c/webperf/approved directory

BUG=80267

Review-Url: https://codereview.chromium.org/2624553002
Cr-Commit-Position: refs/heads/master@{#443084}
parent 66e610ba
This is a testharness.js-based test.
PASS PerformanceNavigationTiming interface: existence and properties of interface object
PASS PerformanceNavigationTiming interface object length
PASS PerformanceNavigationTiming interface object name
FAIL PerformanceNavigationTiming interface: existence and properties of interface prototype object assert_equals: class string of PerformanceNavigationTiming.prototype expected "[object PerformanceNavigationTimingPrototype]" but got "[object PerformanceNavigationTiming]"
PASS PerformanceNavigationTiming interface: existence and properties of interface prototype object's "constructor" property
PASS PerformanceNavigationTiming interface: attribute unloadEventStart
PASS PerformanceNavigationTiming interface: attribute unloadEventEnd
PASS PerformanceNavigationTiming interface: attribute domInteractive
PASS PerformanceNavigationTiming interface: attribute domContentLoadedEventStart
PASS PerformanceNavigationTiming interface: attribute domContentLoadedEventEnd
PASS PerformanceNavigationTiming interface: attribute domComplete
PASS PerformanceNavigationTiming interface: attribute loadEventStart
PASS PerformanceNavigationTiming interface: attribute loadEventEnd
PASS PerformanceNavigationTiming interface: attribute type
PASS PerformanceNavigationTiming interface: attribute redirectCount
Harness: the test ran to completion.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Navigation Timing 2 IDL tests</title>
<link rel="author" title="Google" href="http://www.google.com/" />
<link rel="help" href="http://www.w3.org/TR/navigation-timing-2/#sec-PerformanceNavigationTiming"/>
<script src="/w3c/resources/testharness.js"></script>
<script src="/w3c/resources/testharnessreport.js"></script>
<script src="/w3c/resources/WebIDLParser.js"></script>
<script src="/w3c/resources/idlharness.js"></script>
</head>
<body>
<pre id='untested_idl' style='display:none'>
interface PerformanceResourceTiming : PerformanceEntry {
readonly attribute DOMString initiatorType;
readonly attribute DOMHighResTimeStamp workerStart;
readonly attribute DOMHighResTimeStamp redirectStart;
readonly attribute DOMHighResTimeStamp redirectEnd;
readonly attribute DOMHighResTimeStamp fetchStart;
readonly attribute DOMHighResTimeStamp domainLookupStart;
readonly attribute DOMHighResTimeStamp domainLookupEnd;
readonly attribute DOMHighResTimeStamp connectStart;
readonly attribute DOMHighResTimeStamp connectEnd;
readonly attribute DOMHighResTimeStamp secureConnectionStart;
readonly attribute DOMHighResTimeStamp requestStart;
readonly attribute DOMHighResTimeStamp responseStart;
readonly attribute DOMHighResTimeStamp responseEnd;
[MeasureAs=PerformanceResourceTimingSizes] readonly attribute unsigned long long transferSize;
[MeasureAs=PerformanceResourceTimingSizes] readonly attribute unsigned long long encodedBodySize;
[MeasureAs=PerformanceResourceTimingSizes] readonly attribute unsigned long long decodedBodySize;
};
</pre>
<pre id='idl'>
enum NavigationType {
"navigate",
"reload",
"back_forward",
"prerender"
};
interface PerformanceNavigationTiming : PerformanceResourceTiming {
readonly attribute DOMHighResTimeStamp unloadEventStart;
readonly attribute DOMHighResTimeStamp unloadEventEnd;
readonly attribute DOMHighResTimeStamp domInteractive;
readonly attribute DOMHighResTimeStamp domContentLoadedEventStart;
readonly attribute DOMHighResTimeStamp domContentLoadedEventEnd;
readonly attribute DOMHighResTimeStamp domComplete;
readonly attribute DOMHighResTimeStamp loadEventStart;
readonly attribute DOMHighResTimeStamp loadEventEnd;
readonly attribute NavigationType type;
readonly attribute unsigned short redirectCount;
};
</pre>
<script>
function test_idl() {
var idl_array = new IdlArray();
idl_array.add_untested_idls(document.getElementById("untested_idl").textContent);
idl_array.add_idls(document.getElementById("idl").textContent);
idl_array.test();
}
test_idl();
</script>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Navigation Timing 2 WPT</title>
<link rel="author" title="Google" href="http://www.google.com/" />
<link rel="help" href="http://www.w3.org/TR/navigation-timing-2/#sec-PerformanceNavigationTiming"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>Description</h1>
<p>This test validates that PerformanceObserver can observe nav timing 2 instance and that the expected attributes in nav timing 2 instance exist (but does not validate that the values are correct).</p>
<script>
var navTiming2Attributes = [
'connectEnd',
'connectStart',
'decodedBodySize',
'domComplete',
'domContentLoadedEventEnd',
'domContentLoadedEventStart',
'domInteractive',
'domainLookupEnd',
'domainLookupStart',
'duration',
'encodedBodySize',
'entryType',
'fetchStart',
'initiatorType',
'loadEventEnd',
'loadEventStart',
'name',
'redirectCount',
'redirectEnd',
'redirectStart',
'requestStart',
'responseEnd',
'responseStart',
'secureConnectionStart',
'transferSize',
'type',
'unloadEventEnd',
'unloadEventStart',
'workerStart'
];
async_test(function (t) {
var observer = new PerformanceObserver(
t.step_func(function (entryList) {
var entries = entryList.getEntries();
assert_equals(entries.length, 1,
"There should be only one navigation timing instance.");
for (var i = 0; i < navTiming2Attributes.length; i++) {
assert_true(navTiming2Attributes[i] in entries[0],
"Expected attribute: " + navTiming2Attributes[i] + ".");
}
observer.disconnect();
t.done();
})
);
observer.observe({entryTypes: ["navigation"]});
}, "Performance navigation timing entries are observable.");
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Navigation Timing 2 WPT</title>
<link rel="author" title="Google" href="http://www.google.com/" />
<link rel="help" href="http://www.w3.org/TR/navigation-timing-2/#sec-PerformanceNavigationTiming"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>Description</h1>
<p>This test validates that the values of nav timing 2 instance's timing-related attributes are in certain order and the others are of expected values.</p>
<script>
var navTiming2EventOrder1 = [
'startTime',
'redirectStart',
//'unloadEventStart',
'redirectEnd',
//'unloadEventEnd',
'fetchStart',
'domainLookupStart',
'domainLookupEnd',
'connectStart',
//'secureConnectionStart',
'connectEnd',
'requestStart',
'responseStart',
'responseEnd',
'domInteractive',
'domContentLoadedEventStart',
'domContentLoadedEventEnd',
'domComplete',
'loadEventStart',
'loadEventEnd'
];
var navTiming2EventOrder2 = [
'redirectStart',
'unloadEventStart',
'redirectEnd',
'unloadEventEnd',
'fetchStart'
];
var navTiming2EventOrder3 = [
'connectStart',
'secureConnectionStart',
'connectEnd'
];
function verifyTimingEventOrder(eventOrder, timingEntry) {
for (var i = 0; i < eventOrder.length - 1; i++) {
assert_true(timingEntry[eventOrder[i]] <= timingEntry[eventOrder[i + 1]],
"Expected " + eventOrder[i] + " to be no greater than " + eventOrder[i + 1] + ".");
}
}
async_test(function (t) {
var observer = new PerformanceObserver(
t.step_func(function (entryList) {
var entries = entryList.getEntries();
assert_equals(entries[0].entryType, "navigation",
"Expected entryType to be: navigation.");
assert_equals(entries[0].name, "document",
"Expected name to be: document.");
assert_equals(entries[0].startTime, 0,
"Expected startTime to be: 0.");
assert_equals(entries[0].duration, entries[0].loadEventEnd,
"Expected duration to be equal to loadEventEnd.");
assert_equals(entries[0].initiatorType, "",
"Expected initiatorType to be an empty string.");
// This test may fail when response is from cach. Disable or clean cach before
// running this test.
assert_true(entries[0].transferSize > entries[0].encodedBodySize,
"Expected transferSize to be greater than encodedBodySize in uncached navigation.");
assert_equals(entries[0].encodedBodySize, 0);
assert_equals(entries[0].decodedBodySize, 0);
verifyTimingEventOrder(entries[0], navTiming2EventOrder1);
// When unloadEvent happens
if (entries[0]["unloadEventStart"] != 0) {
verifyTimingEventOrder(entries[0], navTiming2EventOrder2);
}
// When a secure transport is used
if (entries[0]["secureConnectionStart"] != 0) {
verifyTimingEventOrder(entries[0], navTiming2EventOrder3);
}
observer.disconnect();
t.done();
})
);
observer.observe({entryTypes: ["navigation"]});
}, "Performance navigation timing instance's value is reasonable.");
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Navigation Timing 2 WPT</title>
<link rel="author" title="Google" href="http://www.google.com/" />
<link rel="help" href="http://www.w3.org/TR/navigation-timing-2/#sec-PerformanceNavigationTiming"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
var navTiming2Attributes = [
'connectEnd',
'connectStart',
'decodedBodySize',
'domComplete',
'domContentLoadedEventEnd',
'domContentLoadedEventStart',
'domInteractive',
'domainLookupEnd',
'domainLookupStart',
'duration',
'encodedBodySize',
'entryType',
'fetchStart',
'initiatorType',
'loadEventEnd',
'loadEventStart',
'name',
'redirectCount',
'redirectEnd',
'redirectStart',
'requestStart',
'responseEnd',
'responseStart',
'secureConnectionStart',
'transferSize',
'type',
'unloadEventEnd',
'unloadEventStart',
'workerStart'
];
var originalTiming = {};
var didOpen = false;
function onload_test()
{
if (!didOpen) {
setTimeout(testTimingWithDocumentOpen, 0);
didOpen = true;
}
}
function testTimingWithDocumentOpen()
{
var subcontentWindow = document.getElementById("frameContext").contentWindow;
var timing = subcontentWindow.performance.getEntriesByType("navigation")[0];
for (i in navTiming2Attributes) {
originalTiming[navTiming2Attributes[i]] = timing[navTiming2Attributes[i]];
}
var subdocument = subcontentWindow.document;
subdocument.open();
subdocument.write('<!DOCTYPE HTML>');
subdocument.write('<html>');
subdocument.write('<head>');
subdocument.write('<meta charset="utf-8" />');
subdocument.write('<title><Green Test Page</title>');
subdocument.write('</head>');
subdocument.write('<body style="background-color:#00FF00;">');
subdocument.write('</body>');
subdocument.write('</html>');
subdocument.close();
setTimeout(function() {
var timing = subcontentWindow.performance.getEntriesByType("navigation")[0];
for (var i in navTiming2Attributes) {
assert_equals(originalTiming[navTiming2Attributes[i]], timing[navTiming2Attributes[i]],
navTiming2Attributes[i] + " is the same after document open.");
}
done();
}, 0);
}
</script>
</head>
<body>
<h1>Description</h1>
<p>This test validates window.performance.getEntriesByType("navigation") remains constant when a
document is replaced using document.open.</p>
<p>This page should be loaded with a yellow frame below. It then replaces the
document in that frame with a green document.</p>
<p>The test passes if all of the checks to performance.getEntriesByType("navigation") are correct and
the frame below ends with a green background.</p>
<iframe id="frameContext" onload="onload_test();" src="/w3c/webperf/resources/blank_page_yellow.htm" style="width: 250px; height: 250px;"></iframe>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Navigation Timing 2 WPT</title>
<link rel="author" title="Google" href="http://www.google.com/" />
<link rel="help" href="http://www.w3.org/TR/navigation-timing-2/#sec-PerformanceNavigationTiming"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>Description</h1>
<p>This test validates that nav timing 2 instance can be accessed by three different accessors once available: window.performance.getEntries()/getEntriesByType("navigation")/getEntriesByName("document")</p>
<script>
var navTiming2Attributes = [
'connectEnd',
'connectStart',
'decodedBodySize',
'domComplete',
'domContentLoadedEventEnd',
'domContentLoadedEventStart',
'domInteractive',
'domainLookupEnd',
'domainLookupStart',
'duration',
'encodedBodySize',
'entryType',
'fetchStart',
'initiatorType',
'loadEventEnd',
'loadEventStart',
'name',
'redirectCount',
'redirectEnd',
'redirectStart',
'requestStart',
'responseEnd',
'responseStart',
'secureConnectionStart',
'transferSize',
'type',
'unloadEventEnd',
'unloadEventStart',
'workerStart'
];
async_test(function (t) {
var observer = new PerformanceObserver(
t.step_func(function (entryList) {
var instance1 = performance.getEntries()[0];
var instance2 = performance.getEntriesByType("navigation")[0];
var instance3 = performance.getEntriesByName("document")[0];
assert_equals(performance.getEntriesByType("navigation").length, 1, "Expected there is only one navigation timing instance.");
assert_equals(performance.getEntriesByName("document").length, 1, "Expected there is only one navigation timing instance.");
for (var i = 0; i < navTiming2Attributes.length; i++) {
assert_equals(instance1[navTiming2Attributes[i]], instance2[navTiming2Attributes[i]]);
}
for (var i = 0; i < navTiming2Attributes.length; i++) {
assert_equals(instance1[navTiming2Attributes[i]], instance3[navTiming2Attributes[i]]);
}
observer.disconnect();
t.done();
})
);
observer.observe({entryTypes: ["navigation"]});
}, "Performance navigation timing entries are accessible through three different accessors.");
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" >
<title>Navigation Timing 2 WPT</title>
<link rel="author" title="Google" href="http://www.google.com/" />
<link rel="help" href="http://www.w3.org/TR/navigation-timing/#sec-navigation-timing-interface"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>Description</h1>
<p>This test validates that all of the window.performance.getEntriesByType("navigation") attributes remain unchanged after an in document navigation (URL fragment change).</p>
<script>
var navTiming2Attributes = [
'connectEnd',
'connectStart',
'decodedBodySize',
'domComplete',
'domContentLoadedEventEnd',
'domContentLoadedEventStart',
'domInteractive',
'domainLookupEnd',
'domainLookupStart',
'duration',
'encodedBodySize',
'entryType',
'fetchStart',
'initiatorType',
'loadEventEnd',
'loadEventStart',
'name',
'redirectCount',
'redirectEnd',
'redirectStart',
'requestStart',
'responseEnd',
'responseStart',
'secureConnectionStart',
'transferSize',
'type',
'unloadEventEnd',
'unloadEventStart',
'workerStart'
];
var initial_timing = {};
function check_timing_not_changed()
{
var timing = window.performance.getEntriesByType("navigation")[0];
for (var i = 0; i < navTiming2Attributes.length; ++i)
{
var property = navTiming2Attributes[i];
assert_equals(timing[property], initial_timing[property],
property + " is the same after in document navigation.");
}
done();
}
function save_timing_after_load()
{
var timing = window.performance.getEntriesByType("navigation")[0];
for (var i = 0; i < navTiming2Attributes.length; ++i)
{
var property = navTiming2Attributes[i];
initial_timing[property] = timing[property];
}
window.location.href = "#1";
setTimeout("check_timing_not_changed()", 0);
}
function load_handler()
{
window.removeEventListener("load", load_handler);
setTimeout("save_timing_after_load()", 0);
}
window.addEventListener("load", load_handler, false);
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Navigation Timing 2 WPT</title>
<link rel="author" title="Google" href="http://www.google.com/" />
<link rel="help" href="http://www.w3.org/TR/navigation-timing/#sec-navigation-timing-interface"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
function onload_test()
{
// do this with a timeout to see the visuals of the navigations.
setTimeout("nav_frame();", 100);
}
var step = 1;
function nav_frame()
{
var navigation_frame = document.getElementById("frameContext").contentWindow;
switch (step)
{
case 1:
{
navigation_frame.location.href = '/w3c/webperf/resources/blank_page_green_with_onunload.htm';
step++;
break;
}
case 2:
{
assert_equals(navigation_frame.performance.getEntriesByType("navigation")[0].type,
"navigate",
'Expected navigation type to be navigate.');
navigation_frame.history.back();
step++;
break;
}
case 3:
{
assert_equals(navigation_frame.performance.getEntriesByType("navigation")[0].type,
"back_forward",
'Expected navigation type to be back_forward.');
step++;
navigation_frame.history.forward();
break;
}
case 4:
{
assert_equals(navigation_frame.performance.getEntriesByType("navigation")[0].type,
"back_forward",
'Expected navigation type to be back_forward.');
done();
step++;
break;
}
default:
break;
}
}
</script>
</head>
<body>
<h1>
Description</h1>
<p>
This test validates the value of window.performance.getEntriesByType("navigation")[0].type with a forward
and back navigation.</p>
<p>This page should be loaded with a yellow background frame below. It should turn green for a starting
navigation, back to yellow for a back navigation and then back to green again for a forward navigation.</p>
<p>Along the navigation timeline the window.performance.getEntriesByType("navigation")[0].type is checked for back_forward.</p>
<p>This test passes if all of the checks to the window.performance.getEntriesByType("navigation")[0].type are correct throughout the navigation
scenario and the frame below ends with a green background. Otherwise, this test fails.</p>
<iframe id="frameContext" onload="onload_test();" src="/w3c/webperf/resources/blank_page_yellow_with_onunload.htm" style="width: 250px; height: 250px;"></iframe>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Navigation Timing 2 WPT</title>
<link rel="author" title="Google" href="http://www.google.com/" />
<link rel="help" href="http://www.w3.org/TR/navigation-timing/#sec-navigation-timing-interface"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
async_test(function (t) {
var observer = new PerformanceObserver(
t.step_func(function (entryList) {
assert_equals(entryList.getEntries()[0].type, "navigate", "Expected navigation type to be navigate.");
observer.disconnect();
t.done();
})
);
observer.observe({entryTypes: ["navigation"]});
}, "Navigation type to be navigate.");
</script>
</head>
<body>
<h1>
Description</h1>
<p>
This test validates the value of window.performance.getEntriesByType("navigation")[0].type to be navigate.</p>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Navigation Timing 2 WPT</title>
<link rel="author" title="Google" href="http://www.google.com/" />
<link rel="help" href="http://www.w3.org/TR/navigation-timing-2/#sec-PerformanceNavigationTiming"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
var reload_frame;
function onload_test()
{
reload_frame = document.getElementById("frameContext");
reload_frame.onload = function() {
setTimeout(do_test, 0);
}
setTimeout("reload_the_frame();", 100);
}
function reload_the_frame()
{
reload_frame.contentWindow.location.reload(true);
}
function do_test()
{
var newNavTiming = document.getElementById("frameContext").contentWindow.performance.getEntriesByType("navigation")[0];
assert_equals(newNavTiming.type, "reload", "Expected navigation type to be reload.");
assert_true(newNavTiming.unloadEventStart > 0, "Expected unloadEventStart to be greater than 0.");
assert_true(newNavTiming.unloadEventEnd > 0, "Expected unloadEventEnd to be greater than 0.");
done();
}
</script>
</head>
<body onload="onload_test();">
<h1>Description</h1>
<p>This test validates the value of window.performance.getEntriesByType("navigation")[0].(type/unloadEventEnd/unloadEventStart) with a reloaded navigation.</p>
<p>This page should be loaded with a green background frame below. The frame will be automatically reloaded
and then verified that
<ul>
<li>The window.performance.getEntriesByType("navigation").type = "reload" after reload</li>
<li>The window.performance.getEntriesByType("navigation").unloadEventStart > 0 after reload</li>
<li>The window.performance.getEntriesByType("navigation").unloadEventEnd > 0 after reload</li>
</ul>
</p>
<iframe id="frameContext" src="/w3c/webperf/resources/blank_page_green.html" style="width: 250px; height: 250px;"></iframe>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Navigation Timing 2 WPT</title>
<link rel="author" title="Google" href="http://www.google.com/" />
<link rel="help" href="http://www.w3.org/TR/navigation-timing/#sec-navigation-timing-interface"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
function onload_test()
{
var iframe_performance = document.getElementById("frameContext").contentWindow.performance;
assert_equals(iframe_performance.getEntriesByType("navigation").length, 0, "Expected there is no navigation timing instance");
done();
}
</script>
</head>
<body>
<h1>Description</h1>
<p>This test validates there does not exist a navigation timing instance when opening internal pages like about:blank.</p>
<iframe id="frameContext" onload="onload_test();" src="about:blank" style="width: 250px; height: 250px;"></iframe>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Navigation Timing 2 WPT</title>
<link rel="author" title="Google" href="http://www.google.com/" />
<link rel="help" href="http://www.w3.org/TR/navigation-timing/#sec-navigation-timing-interface"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>Description</h1>
<p>This test validates there does not exist a navigation timing instance when opening a data uri. This data uri is equivalent to nav2_data_uri.html.</p>
<script>
async_test(function(t) {
var gotEvent = false;
window.addEventListener("message", t.step_func(function() {
assert_unreached("A navigation timing instance existed");
}));
window.addEventListener("load", t.step_func(function() {
t.step_timeout(function() { t.done(); }, 2000);
}));
}, "Navigation timing instance existence");
</script>
<iframe src="data:text/html;charset=utf-8,%3C%21DOCTYPE%20html%3E%0D%0A%3Ctitle%3Edata%20URL%20source%20for%20navigation-timing%2Fnav2_test_open_data_uri.html%3C%2Ftitle%3E%0D%0A%3C%21--%20NB%3A%20this%20file%20isn%27t%20actually%20used%20any%20where%21%20--%3E%0D%0A%3Clink%20rel%3D%22author%22%20title%3D%22Google%22%20href%3D%22http%3A%2F%2Fwww.google.com%2F%22%20%2F%3E%0D%0A%3Cscript%3E%0D%0Avar%20observer%20%3D%20new%20PerformanceObserver%28%0D%0A%20%20%20%20function%20%28entryList%29%20%7B%0D%0A%20%20%20%20%20%20%20%20parent.postMessage%28%22observed%22%2C%20%22%2A%22%29%3B%0D%0A%20%20%20%20%20%20%20%20observer.disconnect%28%29%3B%0D%0A%20%20%20%20%7D%29%3B%0D%0Aobserver.observe%28%7BentryTypes%3A%20%5B%22navigation%22%5D%7D%29%3B%0D%0A%3C%2Fscript%3E%0D%0A"></iframe>
<!-- NB: see nav2_data_uri.html for the source of that data URI -->
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Navigation Timing 2 WPT</title>
<link rel="author" title="Google" href="http://www.google.com/" />
<link rel="help" href="http://www.w3.org/TR/navigation-timing-2/#sec-PerformanceNavigationTiming"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>Description</h1>
<p>This test validates that the value of the window.performance.getEntriesByType("navigation")[0].redirectCount attribute, as well as the window.performance.getEntriesByType("navigation")[0].redirectStart and redirectEnd attributes on a non-redirected navigation.</p>
<script>
async_test(function (t) {
var observer = new PerformanceObserver(
t.step_func(function (entryList) {
var navTiming = performance.getEntriesByType("navigation")[0];
assert_equals(navTiming.redirectCount, 0, "Expected redirectCount to be 0.");
assert_equals(navTiming.redirectStart, 0, "Expected redirectStart to be 0.");
assert_equals(navTiming.redirectEnd, 0, "Expected redirectEnd to be 0.");
observer.disconnect();
t.done();
})
);
observer.observe({entryTypes: ["navigation"]});
}, "Naivation without redirects.");
</script>
</body>
</html>
\ No newline at end of file
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
<title>Navigation Timing 2 WPT</title>
<link rel="author" title="Google" href="http://www.google.com/" />
<link rel="help" href="http://www.w3.org/TR/navigation-timing-2/#sec-PerformanceNavigationTiming"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
function verifyTimingEventOrder(eventOrder, timingEntry) {
for (var i = 0; i < eventOrder.length - 1; i++) {
assert_true(timingEntry[eventOrder[i]] < timingEntry[eventOrder[i + 1]],
"Expected " + eventOrder[i] + " to be no greater than " + eventOrder[i + 1] + ".");
}
}
function onload_test()
{
var frame_performance = document.getElementById("frameContext").contentWindow.performance;
assert_equals(frame_performance.getEntriesByType("navigation")[0].type,
"navigate",
"Expected navigation type to be navigate.");
assert_equals(frame_performance.getEntriesByType("navigation")[0].redirectCount, 1, "Expected redirectCount to be 1.");
var timgingEvents = [
'startTime',
'redirectStart',
'redirectEnd',
];
verifyTimingEventOrder(timgingEvents, frame_performance.getEntriesByType("navigation")[0]);
done();
}
</script>
</head>
<body>
<h1>Description</h1>
<p>This test validates the values of the window.performance.redirectCount and the
window.performance.timing.redirectStart/End times for a same-origin server side redirect navigation.</p>
<iframe id="frameContext" onload="onload_test();" src="/w3c/webperf/resources/redirect.php?location=/w3c/webperf/resources/blank_page_green.htm" style="width: 250px; height: 250px;"></iframe>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Navigation Timing 2 WPT</title>
<link rel="author" title="Google" href="http://www.google.com/" />
<link rel="help" href="http://www.w3.org/TR/navigation-timing-2/#sec-PerformanceNavigationTiming"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
function onload_test()
{
var performanceNamespace = document.getElementById("frameContext").contentWindow.performance;
assert_equals(performanceNamespace.getEntriesByType("navigation")[0].type,
"navigate",
"Expected navigation type to be navigate.");
assert_equals(performanceNamespace.getEntriesByType("navigation")[0].redirectCount, 0,
"Expected redirectCount to be 0.");
assert_equals(performanceNamespace.getEntriesByType("navigation")[0].redirectStart, 0,
"Expected redirectStart to be 0.");
assert_equals(performanceNamespace.getEntriesByType("navigation")[0].redirectEnd, 0,
"Expected redirectEnd to be 0.");
done();
}
</script>
</head>
<body>
<h1>Description</h1>
<p>This test validates the values of the window.performance.getEntriesByType("navigation")[0].redirectCount and the
window.performance.getEntriesByType("navigation")[0].redirectStart/End times for a cross-origin server side redirect navigation.</p>
<iframe id="frameContext" src="" style="width: 250px; height: 250px;"></iframe>
<script>
// combine the page origin and redirect origin into the IFRAME's src URL
var pageOrigin = '127.0.0.1:8000';
var redirectOrigin = 'localhost:8000';
var destUrl = 'http://' + redirectOrigin + '/w3c/webperf/resources/redirect.php';
destUrl += '?location=http://' + pageOrigin + '/w3c/webperf/resources/blank_page_green.htm';
var frameContext = document.getElementById("frameContext");
frameContext.onload = onload_test;
frameContext.src = destUrl;
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Navigation Timing 2 WPT</title>
<link rel="author" title="Google" href="http://www.google.com/" />
<link rel="help" href="http://www.w3.org/TR/navigation-timing-2/#sec-PerformanceNavigationTiming"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
function verifyTimingEventOrder(eventOrder, timingEntry) {
for (var i = 0; i < eventOrder.length - 1; i++) {
assert_true(timingEntry[eventOrder[i]] < timingEntry[eventOrder[i + 1]],
"Expected " + eventOrder[i] + " to be no greater than " + eventOrder[i + 1] + ".");
}
}
function onload_test()
{
var frame_performance = document.getElementById("frameContext").contentWindow.performance;
assert_equals(frame_performance.getEntriesByType("navigation")[0].type,
"navigate",
"Expected navigation type to be navigate.");
assert_equals(frame_performance.getEntriesByType("navigation")[0].redirectCount, 1, "Expected redirectCount to be 1.");
var timgingEvents = [
'startTime',
'redirectStart',
'redirectEnd',
];
verifyTimingEventOrder(timgingEvents, frame_performance.getEntriesByType("navigation")[0]);
done();
}
</script>
</head>
<body>
<h1>Description</h1>
<p>This test validates the values of the window.performance.getEntriesByType("navigation")[0].redirectCount and the
window.performance.getEntriesByType("navigation")[0].redirectStart/End times for a cross-origin server side redirect navigation when the redirect chooses to opt-in.</p>
<iframe id="frameContext" src="" style="width: 250px; height: 250px;"></iframe>
<script>
// combine the page origin and redirect origin into the IFRAME's src URL
// combine the page origin and redirect origin into the IFRAME's src URL
var pageOrigin = '127.0.0.1:8000';
var redirectOrigin = 'localhost:8000';
var destUrl = 'http://' + redirectOrigin + '/w3c/webperf/resources/redirect-opt-in.php';
destUrl += '?location=http://' + pageOrigin + '/w3c/webperf/resources/blank_page_green.htm';
var frameContext = document.getElementById("frameContext");
frameContext.onload = onload_test;
frameContext.src = destUrl;
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Navigation Timing 2 WPT</title>
<link rel="author" title="Google" href="http://www.google.com/" />
<link rel="help" href="http://www.w3.org/TR/navigation-timing-2/#sec-PerformanceNavigationTiming"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>Description</h1>
<p>This test validates that each window has a unique nav timing 2 instance.</p>
<iframe id="frameContext" src="resources/blank_page_green.html" style="display:none;";></iframe>
<script>
var navTiming2Attributes = [
'connectEnd',
'connectStart',
'decodedBodySize',
'domComplete',
'domContentLoadedEventEnd',
'domContentLoadedEventStart',
'domInteractive',
'domainLookupEnd',
'domainLookupStart',
'duration',
'encodedBodySize',
'entryType',
'fetchStart',
'initiatorType',
'loadEventEnd',
'loadEventStart',
'name',
'redirectCount',
'redirectEnd',
'redirectStart',
'requestStart',
'responseEnd',
'responseStart',
'secureConnectionStart',
'transferSize',
'type',
'unloadEventEnd',
'unloadEventStart',
'workerStart'
];
function not_same_instance(instance1, instance2, attributes) {
for (var i in attributes) {
if (instance1[attributes[i]] != instance2[attributes[i]])
return true;
}
return false;
}
async_test(function (t) {
var observer = new PerformanceObserver(
t.step_func(function (entryList) {
assert_equals(entryList.getEntriesByType("navigation").length, 1, "Only one nav timing instance exists.");
assert_equals(document.getElementById("frameContext").contentWindow.performance.getEntriesByType("navigation").length, 1,
"Only one nav timing instance exists.");
var main_frame_instance = entryList.getEntriesByType("navigation")[0];
var iframe_instance = document.getElementById("frameContext").contentWindow.performance.getEntriesByType("navigation")[0];
assert_true(not_same_instance(main_frame_instance, iframe_instance, navTiming2Attributes),
"Two nav timing instances are not the same instance.");
observer.disconnect();
t.done();
})
);
observer.observe({entryTypes: ["navigation"]});
}, "Each window has a unique nav timing 2 instance.");
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Navigation Timing 2 WPT</title>
<link rel="author" title="Google" href="http://www.google.com/" />
<link rel="help" href="http://www.w3.org/TR/navigation-timing/#sec-navigation-timing-interface"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
function onload_test()
{
var frame = document.getElementById("frameContext");
assert_equals(frame.contentWindow.performance.getEntriesByType("navigation")[0].type,
"navigate",
"Expected navigation type to be navigate.");
assert_equals(frame.contentWindow.performance.getEntriesByType("navigation")[0].unloadEventStart, 0,
"Expected unloadEventStart to be 0.");
assert_equals(frame.contentWindow.performance.getEntriesByType("navigation")[0].unloadEventEnd, 0,
"Expected unloadEventEnd to be 0.");
done();
}
</script>
</head>
<body>
<h1>Description</h1>
<p>This test validates the unload event times are 0 when there is no previous document.</p>
<iframe id="frameContext" onload="onload_test();" src="/w3c/webperf/resources/blank_page_green.htm" style="width: 250px; height: 250px;"></iframe>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Navigation Timing 2 WPT</title>
<link rel="author" title="Google" href="http://www.google.com/" />
<link rel="help" href="http://www.w3.org/TR/navigation-timing-2/#sec-PerformanceNavigationTiming"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
function onload_test()
{
var reload_frame = document.getElementById("frameContext");
reload_frame.onload = do_test;
reload_frame.contentWindow.location.href = "/w3c/webperf/resources/blank_page_green.htm";
}
function do_test()
{
var newNavTiming = document.getElementById("frameContext").contentWindow.performance.getEntriesByType("navigation")[0];
assert_equals(newNavTiming.type, "navigate", "Expected navigation type to be navigate.");
assert_equals(newNavTiming.unloadEventStart, 0, "Expected unloadEventStart to be 0.");
assert_equals(newNavTiming.unloadEventEnd, 0, "Expected unloadEventEnd to be 0.");
done();
}
</script>
</head>
<body>
<h1>Description</h1>
<p>This test validates the value of window.performance.getEntriesByType("navigation")[0].(type/unloadEventEnd/unloadEventStart) with a navigation on top of a cross-origin document.</p>
<p>This page should be loaded with a green background frame below. The frame will be automatically reloaded
and then verified that
<ul>
<li>The window.performance.getEntriesByType("navigation").type = "navigate"</li>
<li>The window.performance.getEntriesByType("navigation").unloadEventStart = 0</li>
<li>The window.performance.getEntriesByType("navigation").unloadEventEnd = 0</li>
</ul>
</p>
<iframe id="frameContext" onload="onload_test();" src="127.0.0.1:8000" style="width: 250px; height: 250px;"></iframe>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Navigation Timing 2 WPT</title>
<link rel="author" title="Google" href="http://www.google.com/" />
<link rel="help" href="http://www.w3.org/TR/navigation-timing-2/#sec-PerformanceNavigationTiming"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
var reload_frame;
function onload_test()
{
reload_frame = document.getElementById("frameContext");
reload_frame.onload = do_test;
setTimeout("reload_the_frame();", 100);
}
function reload_the_frame()
{
var pageOrigin = '127.0.0.1:8000';
var redirectOrigin = 'localhost:8000';
var destUrl = 'http://' + redirectOrigin + '/w3c/webperf/resources/redirect.php';
destUrl += '?location=http://' + pageOrigin + '/w3c/webperf/resources/blank_page_yellow.htm';
reload_frame.contentWindow.location.href = destUrl;
}
function do_test()
{
var newNavTiming = document.getElementById("frameContext").contentWindow.performance.getEntriesByType("navigation")[0];
assert_equals(newNavTiming.type, "navigate", "Expected navigation type to be navigate.");
assert_equals(newNavTiming.unloadEventStart, 0, "Expected unloadEventStart to be 0.");
assert_equals(newNavTiming.unloadEventEnd, 0, "Expected unloadEventEnd to be 0.");
done();
}
</script>
</head>
<body>
<h1>Description</h1>
<p>This test validates the value of window.performance.getEntriesByType("navigation")[0].(type/unloadEventEnd/unloadEventStart) with a reloaded navigation.</p>
<p>This page should be loaded with a green background frame below. The frame will be automatically reloaded
and then verified that
<ul>
<li>The window.performance.getEntriesByType("navigation").type = "navigate"</li>
<li>The window.performance.getEntriesByType("navigation").unloadEventStart == 0</li>
<li>The window.performance.getEntriesByType("navigation").unloadEventEnd == 0</li>
</ul>
</p>
<iframe id="frameContext" onload="onload_test();" src="/w3c/webperf/resources/blank_page_green.htm" style="width: 250px; height: 250px;"></iframe>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Navigation Timing 2 WPT</title>
<link rel="author" title="Google" href="http://www.google.com/" />
<link rel="help" href="http://www.w3.org/TR/navigation-timing-2/#sec-PerformanceNavigationTiming"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
function onload_test()
{
var reload_frame = document.getElementById("frameContext");
reload_frame.onload = do_test;
reload_frame.contentWindow.location.reload(true);
}
function do_test()
{
var newNavTiming = document.getElementById("frameContext").contentWindow.performance.getEntriesByType("navigation")[0];
assert_true(newNavTiming.unloadEventStart > 0, "Expected unloadEventStart to be greater than 0.");
assert_true(newNavTiming.unloadEventEnd > 0, "Expected unloadEventEnd to be greater than 0.");
done();
}
</script>
</head>
<body>
<h1>Description</h1>
<p>This test validates the value of window.performance.getEntriesByType("navigation")[0].(type/unloadEventEnd/unloadEventStart) with a reloaded navigation.</p>
<p>This page should be loaded with a green background frame below. The frame will be automatically reloaded
and then verified that
<ul>
<li>The window.performance.getEntriesByType("navigation").unloadEventStart > 0 after reload</li>
<li>The window.performance.getEntriesByType("navigation").unloadEventEnd > 0 after reload</li>
</ul>
</p>
<iframe id="frameContext" onload="onload_test();" src="/w3c/webperf/resources/blank_page_green.htm" style="width: 250px; height: 250px;"></iframe>
</body>
</html>
<?php
$code = ctype_digit($_GET["code"]) ? $_GET["code"] : "302";
$location = $_GET["location"] ? $_GET["location"] : $_SERVER["SCRIPT_NAME"] . "?followed";
header("HTTP/1.1 $code");
header("Location: $location");
header("Timing-Allow-Origin: *");
exit;
?>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment