diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /testing/web-platform/tests/navigation-timing | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/web-platform/tests/navigation-timing')
28 files changed, 1381 insertions, 0 deletions
diff --git a/testing/web-platform/tests/navigation-timing/OWNERS b/testing/web-platform/tests/navigation-timing/OWNERS new file mode 100644 index 000000000..7052a3f20 --- /dev/null +++ b/testing/web-platform/tests/navigation-timing/OWNERS @@ -0,0 +1,4 @@ +@plehegar +@igrigorik +@toddreifsteck +@yoavweiss diff --git a/testing/web-platform/tests/navigation-timing/idlharness.html b/testing/web-platform/tests/navigation-timing/idlharness.html new file mode 100644 index 000000000..65a8778f7 --- /dev/null +++ b/testing/web-platform/tests/navigation-timing/idlharness.html @@ -0,0 +1,120 @@ +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>Navigation Timing IDL tests</title> +<link rel="author" title="W3C" href="http://www.w3.org/" /> +<link rel="help" href="http://www.w3.org/TR/navigation-timing/#sec-navigation-timing-interface"/> +<link rel="help" href="http://www.w3.org/TR/navigation-timing/#sec-navigation-info-interface"/> +<link rel="help" href="http://www.w3.org/TR/navigation-timing/#sec-window.performance-attribute"/> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/resources/WebIDLParser.js"></script> +<script src="/resources/idlharness.js"></script> +</head> +<body> +<h1>Navigation Timing IDL tests</h1> +<div id="log"></div> + +<pre id='untested_idl' style='display:none'> + +[PrimaryGlobal] +interface Window { +}; + +callback interface EventListener { + void handleEvent(Event event); +}; + +interface Event { + // PhaseType + const unsigned short NONE = 0; + const unsigned short CAPTURING_PHASE = 1; + const unsigned short AT_TARGET = 2; + const unsigned short BUBBLING_PHASE = 3; + readonly attribute DOMString type; + readonly attribute EventTarget? target; + readonly attribute EventTarget? currentTarget; + readonly attribute unsigned short eventPhase; + readonly attribute boolean bubbles; + readonly attribute boolean cancelable; + readonly attribute DOMTimeStamp timeStamp; + void stopPropagation (); + void preventDefault (); + void initEvent (DOMString eventTypeArg, boolean bubblesArg, boolean cancelableArg); + // Introduced in DOM Level 3 + void stopImmediatePropagation (); + readonly attribute boolean defaultPrevented; + readonly attribute boolean isTrusted; +}; + +interface EventTarget { + // Modified in DOM Level 3 + void addEventListener (DOMString type, EventListener? listener, optional boolean useCapture = false); + void removeEventListener (DOMString type, EventListener? listener, optional boolean useCapture = false); + boolean dispatchEvent (Event event); +}; + +</pre> + +<pre id='idl'> +interface PerformanceTiming { + readonly attribute unsigned long long navigationStart; + readonly attribute unsigned long long unloadEventStart; + readonly attribute unsigned long long unloadEventEnd; + readonly attribute unsigned long long redirectStart; + readonly attribute unsigned long long redirectEnd; + readonly attribute unsigned long long fetchStart; + readonly attribute unsigned long long domainLookupStart; + readonly attribute unsigned long long domainLookupEnd; + readonly attribute unsigned long long connectStart; + readonly attribute unsigned long long connectEnd; + readonly attribute unsigned long long secureConnectionStart; + readonly attribute unsigned long long requestStart; + readonly attribute unsigned long long responseStart; + readonly attribute unsigned long long responseEnd; + readonly attribute unsigned long long domLoading; + readonly attribute unsigned long long domInteractive; + readonly attribute unsigned long long domContentLoadedEventStart; + readonly attribute unsigned long long domContentLoadedEventEnd; + readonly attribute unsigned long long domComplete; + readonly attribute unsigned long long loadEventStart; + readonly attribute unsigned long long loadEventEnd; +}; + +interface PerformanceNavigation { + const unsigned short TYPE_NAVIGATE = 0; + const unsigned short TYPE_RELOAD = 1; + const unsigned short TYPE_BACK_FORWARD = 2; + const unsigned short TYPE_RESERVED = 255; + readonly attribute unsigned short type; + readonly attribute unsigned short redirectCount; +}; + +interface Performance : EventTarget { + readonly attribute PerformanceTiming timing; + readonly attribute PerformanceNavigation navigation; +}; + +partial interface Window { + [Replaceable] readonly attribute Performance performance; +}; +</pre> + +<script> +(function() { + 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.add_objects({Window: ["window"], + Performance: ["window.performance"], + PerformanceNavigation: ["window.performance.navigation"], + PerformanceTiming: ["window.performance.timing"]}); + + idl_array.test(); +})(); +</script> +</body> +</html> diff --git a/testing/web-platform/tests/navigation-timing/resources/blank_page_green.html b/testing/web-platform/tests/navigation-timing/resources/blank_page_green.html new file mode 100644 index 000000000..b8a1947b7 --- /dev/null +++ b/testing/web-platform/tests/navigation-timing/resources/blank_page_green.html @@ -0,0 +1,10 @@ +<!DOCTYPE HTML> +<html> + <head> + <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> + <title>Green Test Page</title> + </head> + <body style="background-color:#00FF00;"> + <h1>Placeholder</h1> + </body> +</html> diff --git a/testing/web-platform/tests/navigation-timing/resources/blank_page_green_with_onunload.html b/testing/web-platform/tests/navigation-timing/resources/blank_page_green_with_onunload.html new file mode 100644 index 000000000..2f401747b --- /dev/null +++ b/testing/web-platform/tests/navigation-timing/resources/blank_page_green_with_onunload.html @@ -0,0 +1,11 @@ +<!DOCTYPE HTML> +<html> + <head> + <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> + <title>Green Test Page</title> + </head> + <!-- use onunload to ensure this does not trigger bfcache --> + <body style="background-color:#00FF00;" onunload="1;"> + <h1>Placeholder</h1> + </body> +</html> diff --git a/testing/web-platform/tests/navigation-timing/resources/blank_page_meta_redirect.html b/testing/web-platform/tests/navigation-timing/resources/blank_page_meta_redirect.html new file mode 100644 index 000000000..50d6e7057 --- /dev/null +++ b/testing/web-platform/tests/navigation-timing/resources/blank_page_meta_redirect.html @@ -0,0 +1,11 @@ +<!DOCTYPE HTML> +<html> + <head> + <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> + <meta http-equiv="refresh" content="1;URL='blank_page_green.html'" /> + <title>Redirect Placeholder</title> + </head> + <body style="background-color:#FFFF00";> + <h1>Placeholder</h1> + </body> +</html> diff --git a/testing/web-platform/tests/navigation-timing/resources/blank_page_unload.html b/testing/web-platform/tests/navigation-timing/resources/blank_page_unload.html new file mode 100644 index 000000000..bb2a27f16 --- /dev/null +++ b/testing/web-platform/tests/navigation-timing/resources/blank_page_unload.html @@ -0,0 +1,25 @@ +<!DOCTYPE HTML> +<html> + <head> + <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> + + <title>Yellow Test Page</title> + + <script type="text/javascript"> + function onbeforeunload_handler() + { + var temp = "onbeforeunload"; + } + + function onunload_handler() + { + var temp = "onunload"; + } + </script> + </head> + <body onbeforeunload="onbeforeunload_handler();" + onunload="onunload_handler();" + style="background-color:#FFFF00;"> + <h1>Unload</h1> + </body> +</html> diff --git a/testing/web-platform/tests/navigation-timing/resources/blank_page_yellow.html b/testing/web-platform/tests/navigation-timing/resources/blank_page_yellow.html new file mode 100644 index 000000000..4e5e1a000 --- /dev/null +++ b/testing/web-platform/tests/navigation-timing/resources/blank_page_yellow.html @@ -0,0 +1,10 @@ +<!DOCTYPE HTML> +<html> + <head> + <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> + <title>Yellow Test Page</title> + </head> + <body style="background-color:#FFFF00;"> + <h1>Placeholder</h1> + </body> +</html>
\ No newline at end of file diff --git a/testing/web-platform/tests/navigation-timing/resources/blank_page_yellow_with_onunload.html b/testing/web-platform/tests/navigation-timing/resources/blank_page_yellow_with_onunload.html new file mode 100644 index 000000000..771e0701d --- /dev/null +++ b/testing/web-platform/tests/navigation-timing/resources/blank_page_yellow_with_onunload.html @@ -0,0 +1,11 @@ +<!DOCTYPE HTML> +<html> + <head> + <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> + <title>Yellow Test Page</title> + </head> + <!-- use onunload to ensure this does not trigger bfcache --> + <body style="background-color:#FFFF00;" onunload="1;"> + <h1>Placeholder</h1> + </body> +</html>
\ No newline at end of file diff --git a/testing/web-platform/tests/navigation-timing/resources/webperftestharness.js b/testing/web-platform/tests/navigation-timing/resources/webperftestharness.js new file mode 100644 index 000000000..750946dde --- /dev/null +++ b/testing/web-platform/tests/navigation-timing/resources/webperftestharness.js @@ -0,0 +1,155 @@ +/* +Distributed under both the W3C Test Suite License [1] and the W3C +3-clause BSD License [2]. To contribute to a W3C Test Suite, see the +policies and contribution forms [3]. + +[1] http://www.w3.org/Consortium/Legal/2008/04-testsuite-license +[2] http://www.w3.org/Consortium/Legal/2008/03-bsd-license +[3] http://www.w3.org/2004/10/27-testcases + */ + +// +// Helper Functions for NavigationTiming W3C tests +// + +var performanceNamespace = window.performance; +var timingAttributes = [ + 'connectEnd', + 'connectStart', + 'domComplete', + 'domContentLoadedEventEnd', + 'domContentLoadedEventStart', + 'domInteractive', + 'domLoading', + 'domainLookupEnd', + 'domainLookupStart', + 'fetchStart', + 'loadEventEnd', + 'loadEventStart', + 'navigationStart', + 'redirectEnd', + 'redirectStart', + 'requestStart', + 'responseEnd', + 'responseStart', + 'unloadEventEnd', + 'unloadEventStart' +]; + +var namespace_check = false; + +// +// All test() functions in the WebPerf test suite should use wp_test() instead. +// +// wp_test() validates the window.performance namespace exists prior to running tests and +// immediately shows a single failure if it does not. +// + +function wp_test(func, msg, properties) +{ + // only run the namespace check once + if (!namespace_check) + { + namespace_check = true; + + if (performanceNamespace === undefined || performanceNamespace == null) + { + // show a single error that window.performance is undefined + test(function() { assert_true(performanceNamespace !== undefined && performanceNamespace != null, "window.performance is defined and not null"); }, "window.performance is defined and not null.", {author:"W3C http://www.w3.org/",help:"http://www.w3.org/TR/navigation-timing/#sec-window.performance-attribute",assert:"The window.performance attribute provides a hosting area for performance related attributes. "}); + } + } + + test(func, msg, properties); +} + +function test_namespace(child_name, skip_root) +{ + if (skip_root === undefined) { + var msg = 'window.performance is defined'; + wp_test(function () { assert_true(performanceNamespace !== undefined, msg); }, msg,{author:"W3C http://www.w3.org/",help:"http://www.w3.org/TR/navigation-timing/#sec-window.performance-attribute",assert:"The window.performance attribute provides a hosting area for performance related attributes. "}); + } + + if (child_name !== undefined) { + var msg2 = 'window.performance.' + child_name + ' is defined'; + wp_test(function() { assert_true(performanceNamespace[child_name] !== undefined, msg2); }, msg2,{author:"W3C http://www.w3.org/",help:"http://www.w3.org/TR/navigation-timing/#sec-window.performance-attribute",assert:"The window.performance attribute provides a hosting area for performance related attributes. "}); + } +} + +function test_attribute_exists(parent_name, attribute_name, properties) +{ + var msg = 'window.performance.' + parent_name + '.' + attribute_name + ' is defined.'; + wp_test(function() { assert_true(performanceNamespace[parent_name][attribute_name] !== undefined, msg); }, msg, properties); +} + +function test_enum(parent_name, enum_name, value, properties) +{ + var msg = 'window.performance.' + parent_name + '.' + enum_name + ' is defined.'; + wp_test(function() { assert_true(performanceNamespace[parent_name][enum_name] !== undefined, msg); }, msg, properties); + + msg = 'window.performance.' + parent_name + '.' + enum_name + ' = ' + value; + wp_test(function() { assert_equals(performanceNamespace[parent_name][enum_name], value, msg); }, msg, properties); +} + +function test_timing_order(attribute_name, greater_than_attribute, properties) +{ + // ensure it's not 0 first + var msg = "window.performance.timing." + attribute_name + " > 0"; + wp_test(function() { assert_true(performanceNamespace.timing[attribute_name] > 0, msg); }, msg, properties); + + // ensure it's in the right order + msg = "window.performance.timing." + attribute_name + " >= window.performance.timing." + greater_than_attribute; + wp_test(function() { assert_true(performanceNamespace.timing[attribute_name] >= performanceNamespace.timing[greater_than_attribute], msg); }, msg, properties); +} + +function test_timing_greater_than(attribute_name, greater_than, properties) +{ + var msg = "window.performance.timing." + attribute_name + " > " + greater_than; + test_greater_than(performanceNamespace.timing[attribute_name], greater_than, msg, properties); +} + +function test_timing_equals(attribute_name, equals, msg, properties) +{ + var test_msg = msg || "window.performance.timing." + attribute_name + " == " + equals; + test_equals(performanceNamespace.timing[attribute_name], equals, test_msg, properties); +} + +// +// Non-test related helper functions +// + +function sleep_milliseconds(n) +{ + var start = new Date().getTime(); + while (true) { + if ((new Date().getTime() - start) >= n) break; + } +} + +// +// Common helper functions +// + +function test_true(value, msg, properties) +{ + wp_test(function () { assert_true(value, msg); }, msg, properties); +} + +function test_equals(value, equals, msg, properties) +{ + wp_test(function () { assert_equals(value, equals, msg); }, msg, properties); +} + +function test_greater_than(value, greater_than, msg, properties) +{ + wp_test(function () { assert_true(value > greater_than, msg); }, msg, properties); +} + +function test_greater_or_equals(value, greater_than, msg, properties) +{ + wp_test(function () { assert_true(value >= greater_than, msg); }, msg, properties); +} + +function test_not_equals(value, notequals, msg, properties) +{ + wp_test(function() { assert_true(value !== notequals, msg); }, msg, properties); +} diff --git a/testing/web-platform/tests/navigation-timing/test_document_open.html b/testing/web-platform/tests/navigation-timing/test_document_open.html new file mode 100644 index 000000000..1fe75da4e --- /dev/null +++ b/testing/web-platform/tests/navigation-timing/test_document_open.html @@ -0,0 +1,82 @@ +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8" /> +<title>window.performance.timing for dynamically created documents</title> +<link rel="author" title="Microsoft" href="http://www.microsoft.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 src="resources/webperftestharness.js"></script> +<script> +setup({explicit_done: true}); + +// explicitly test the namespace before we start testing +test_namespace(); + +var originalTiming = {}; +var didOpen = false; + +function onload_test() { + if (!didOpen) { + setTimeout(testTimingWithDocumentOpen, 0); + didOpen = true; + } +} + +function testTimingWithDocumentOpen() { + var subcontentWindow = document.getElementById("frameContext").contentWindow; + + if (subcontentWindow.performance === undefined) + { + // avoid script errors + done(); + return; + } + + var timing = subcontentWindow.performance.timing; + for (i in timingAttributes) { + originalTiming[timingAttributes[i]] = timing[timingAttributes[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.timing; + for (var i in timingAttributes) { + test_equals(timing[timingAttributes[i]], + originalTiming[timingAttributes[i]], + timingAttributes[i] + " is the same after document open."); + } + done(); + }, 0); +} +</script> +</head> +<body> +<h1>Description</h1> +<p>This test validates window.performance.timing 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.timing are correct and +the frame below ends with a green background.</p> + +<div id="log"></div> +<br /> +<iframe id="frameContext" onload="onload_test();" src="resources/blank_page_yellow.html" style="width: 250px; height: 250px;"></iframe> +</body> +</html> diff --git a/testing/web-platform/tests/navigation-timing/test_document_readiness_exist.html b/testing/web-platform/tests/navigation-timing/test_document_readiness_exist.html new file mode 100644 index 000000000..58f5659a0 --- /dev/null +++ b/testing/web-platform/tests/navigation-timing/test_document_readiness_exist.html @@ -0,0 +1,49 @@ +<!DOCTYPE html> +<html> +<head> + <meta charset="utf-8" /> + <title>document.readyState values exist during a navigation</title> + <link rel="author" title="Microsoft" href="http://www.microsoft.com/" /> + <link rel="help" href="http://www.w3.org/TR/html5/dom.html#resource-metadata-management"/> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script> + setup({ explicit_done: true }); + var has_loading = (document.readyState == "loading"); + var has_interactive = (document.readyState == "interactive"); + var has_complete = (document.readyState == "complete"); + + document.onreadystatechange = function() + { + if (document.readyState == "loading") + { + has_loading = true; + } + if (document.readyState == "interactive") + { + has_interactive = true; + } + if (document.readyState = "complete") + { + has_complete = true; + } + }; + + function onload_test() + { + test(function () { assert_true(has_loading); }, "Document readiness has loading state."); + test(function () { assert_true(has_interactive); }, "Document readiness has interactive state."); + test(function () { assert_true(has_complete); }, "Document readiness has complete state."); + done(); + } + </script> + +</head> +<body onload="onload_test();"> + <h1>Description</h1> + <p>This test validates that the "loading", "interactive" and "complete" + document.readyState states are available during a navigation.</p> + <p>Refresh this page to guarantee all readyState phases.</p> + <div id="log"></div> +</body> +</html> diff --git a/testing/web-platform/tests/navigation-timing/test_navigate_within_document.html b/testing/web-platform/tests/navigation-timing/test_navigate_within_document.html new file mode 100644 index 000000000..e35d67df8 --- /dev/null +++ b/testing/web-platform/tests/navigation-timing/test_navigate_within_document.html @@ -0,0 +1,66 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8" > + <title>window.performance.timing in document navigation</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 src="resources/webperftestharness.js"></script> + </head> + <body> + <h1>Description</h1> + <p>This test validates that all of the window.performance.timing attributes remain unchanged after an in document navigation (URL fragment change).</p> + + <div id="log"></div> + <script> + setup({explicit_done: true}); + + // explicitly test the namespace before we start testing + test_namespace('timing'); + + var timing; + + function check_timing_not_changed() + { + for (var i = 0; i < timingAttributes.length; ++i) + { + var property = timingAttributes[i]; + test_equals(timing[property], initial_timing[property], + property + " is the same after in document navigation."); + } + done(); + } + + var initial_timing = {}; + function save_timing_after_load() + { + for (var i = 0; i < timingAttributes.length; ++i) + { + var property = timingAttributes[i]; + initial_timing[property] = timing[property]; + } + window.location.href = "#1"; + setTimeout("check_timing_not_changed()", 0); + } + + function load_handler() + { + if (performanceNamespace === undefined) + { + // avoid script errors + done(); + return; + } + + timing = performanceNamespace.timing; + + window.removeEventListener("load", load_handler); + setTimeout("save_timing_after_load()", 0); + } + + window.addEventListener("load", load_handler, false); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/navigation-timing/test_navigation_attributes_exist.html b/testing/web-platform/tests/navigation-timing/test_navigation_attributes_exist.html new file mode 100644 index 000000000..465409ea4 --- /dev/null +++ b/testing/web-platform/tests/navigation-timing/test_navigation_attributes_exist.html @@ -0,0 +1,25 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8"> + <title>window.performance.navigation attributes</title> + <link rel="author" title="Microsoft" href="http://www.microsoft.com/" /> + <link rel="help" href="http://www.w3.org/TR/navigation-timing/#sec-navigation-info-interface"/> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="resources/webperftestharness.js"></script> + </head> + <body> + <h1>Description</h1> + <p>This test validates that all of the window.performance.navigation attributes exist (but does not validate that their values are correct).</p> + + <div id="log"></div> + + <script> + test_namespace('navigation'); + + test_attribute_exists('navigation', 'type'); + test_attribute_exists('navigation', 'redirectCount'); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/navigation-timing/test_navigation_redirectCount_none.html b/testing/web-platform/tests/navigation-timing/test_navigation_redirectCount_none.html new file mode 100644 index 000000000..2046b32cd --- /dev/null +++ b/testing/web-platform/tests/navigation-timing/test_navigation_redirectCount_none.html @@ -0,0 +1,29 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8" /> + <title>window.performance.navigation.redirectCount on a non-redirected navigation</title> + <link rel="author" title="Microsoft" href="http://www.microsoft.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 src="resources/webperftestharness.js"></script> + </head> + <body> + <h1>Description</h1> + <p>This test validates that the value of the window.performance.navigation.redirectCount attribute, as well as the window.performance.timing.redirectStart and redirectEnd attributes on a non-redirected navigation.</p> + + <div id="log"></div> + + <script> + test_namespace('navigation'); + + if (performanceNamespace !== undefined) + { + test_equals(performanceNamespace.timing.redirectStart, 0, 'timing.redirectStart on an non-redirected navigation'); + test_equals(performanceNamespace.timing.redirectEnd, 0, 'timing.redirectEnd on an non-redirected navigation'); + test_equals(performanceNamespace.navigation.redirectCount, 0, 'navigation.redirectCount on an non-redirected navigation',{help:"http://www.w3.org/TR/navigation-timing/#sec-navigation-info-interface"}); + } + </script> + </body> +</html> diff --git a/testing/web-platform/tests/navigation-timing/test_navigation_type_backforward.html b/testing/web-platform/tests/navigation-timing/test_navigation_type_backforward.html new file mode 100644 index 000000000..9856b1ac7 --- /dev/null +++ b/testing/web-platform/tests/navigation-timing/test_navigation_type_backforward.html @@ -0,0 +1,95 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8" /> + <title>window.navigation.type for back and forward navigations</title> + <link rel="author" title="Microsoft" href="http://www.microsoft.com/" /> + <link rel="help" href="http://www.w3.org/TR/navigation-timing/#sec-navigation-info-interface"/> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="resources/webperftestharness.js"></script> + <script> + setup({explicit_done: true}); + + // explicitly test the namespace before we start testing + test_namespace('navigation'); + + function onload_test() + { + if (performanceNamespace === undefined) + { + // avoid script errors + done(); + return; + } + + // 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 = '/navigation-timing/resources/blank_page_green_with_onunload.html'; + step++; + break; + } + case 2: + { + test_equals(navigation_frame.performance.navigation.type, + performanceNamespace.navigation.TYPE_NAVIGATE, + 'window.performance.navigation.type == TYPE_NAVIGATE'); + navigation_frame.history.back(); + step++; + break; + } + case 3: + { + test_equals(navigation_frame.performance.navigation.type, + performanceNamespace.navigation.TYPE_BACK_FORWARD, + 'window.performance.navigation.type == TYPE_BACK_FORWARD after history.back()'); + step++; + navigation_frame.history.forward(); + break; + } + case 4: + { + test_equals(navigation_frame.performance.navigation.type, + performanceNamespace.navigation.TYPE_BACK_FORWARD, + 'window.performance.navigation.type == TYPE_BACK_FORWARD after history.forward()'); + done(); + step++; + break; + } + default: + break; + } + } + </script> + + </head> + <body> + <h1> + Description</h1> + <p> + This test validates the value of window.performance.navigation.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 frame.window.performance.type is checked for TYPE_BACK_FORWARD.</p> + + <p>This test passes if all of the checks to the navigation.type are correct throughout the navigation + scenario and the frame below ends with a green background. Otherwise, this test fails.</p> + + <div id="log"></div> + <br /> + <iframe id="frameContext" onload="onload_test();" src="resources/blank_page_yellow_with_onunload.html" style="width: 250px; height: 250px;"></iframe> + </body> +</html> diff --git a/testing/web-platform/tests/navigation-timing/test_navigation_type_enums.html b/testing/web-platform/tests/navigation-timing/test_navigation_type_enums.html new file mode 100644 index 000000000..8bf8e4f3d --- /dev/null +++ b/testing/web-platform/tests/navigation-timing/test_navigation_type_enums.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8" /> + <title>window.performance.navigation enums</title> + <link rel="author" title="Microsoft" href="http://www.microsoft.com/" /> + <link rel="help" href="http://www.w3.org/TR/navigation-timing/#sec-navigation-info-interface"/> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="resources/webperftestharness.js"></script> + </head> + <body> + <h1>Description</h1> + <p>This test validates that the TYPE_* enumerations of window.performance.navigation exist and their values are correct.</p> + + <div id="log"></div> + + <script> + test_namespace('navigation'); + + test_enum('navigation', 'TYPE_NAVIGATE', 0); + test_enum('navigation', 'TYPE_RELOAD', 1); + test_enum('navigation', 'TYPE_BACK_FORWARD', 2); + test_enum('navigation', 'TYPE_RESERVED', 255); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/navigation-timing/test_navigation_type_reload.html b/testing/web-platform/tests/navigation-timing/test_navigation_type_reload.html new file mode 100644 index 000000000..c10c3bdb9 --- /dev/null +++ b/testing/web-platform/tests/navigation-timing/test_navigation_type_reload.html @@ -0,0 +1,108 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8" /> + <title>window.performance.navigation.type with a reloaded navigation</title> + <link rel="author" title="Microsoft" href="http://www.microsoft.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 src="resources/webperftestharness.js"></script> + <script> + setup({explicit_done: true}); + + // explicitly test the namespace before we start testing + test_namespace('navigation'); + var reload_frame; + var startingTime; + + function deepCopy(p, c) + { + var c = c || {}; + for (var i in p) + { + if (typeof p[i] === 'object') + { + c[i] = (p[i].constructor === Array) ? [] : {}; + deepCopy(p[i], c[i]); + } else c[i] = p[i]; + } + return c; + } + + + function onload_test() + { + reload_frame = document.getElementById("frameContext"); + reload_frame.onload = function() { + /* Need to make sure we don't examine loadEventEnd + until after the load event has finished firing */ + setTimeout(do_test, 0); + } + setTimeout("reload_the_frame();", 100); + } + + function reload_the_frame() + { + //Before reloading, save the current timing + startingTime = deepCopy(reload_frame.contentWindow.performance.timing); + reload_frame.contentWindow.location.reload(true); + } + + function do_test() + { + reload_frame.onload = null; + if (performanceNamespace) + { + //Verify that the navigation type has updated to reload + test_equals(reload_frame.contentWindow.performance.navigation.type, + performanceNamespace.navigation.TYPE_RELOAD, + 'window.performance.navigation.type == TYPE_RELOAD'); + + //Verify that the timing data has been updated into the future + var reloadTime = reload_frame.contentWindow.performance.timing; + for (attribute in timingAttributes) + { + var time = timingAttributes[attribute]; + if (reloadTime[time] === 0) + { + test_equals(reloadTime[time], + startingTime[time], + "Reload " + time + "(" + reloadTime[time] + ")" + + " == " + + "Original " + time + "(" + startingTime[time] + ")"); + } + else + { + test_greater_than(reloadTime[time], + startingTime[time], + "Reload " + time + + " > " + + "Original " + time); + } + } + } + + done(); + } + </script> + </head> + <body onload="onload_test();"> + <h1>Description</h1> + <p>This test validates the value of window.performance.navigation.type and the values of + window.performance.timing.* 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.navigation.type = TYPE_RELOAD</li> + <li>All of the widow.performance.timing.* values after reload are > all of the window.performance.timing.* values + prior to reload.</li> + </ul> + </p> + + <div id="log"></div> + <br /> + <iframe id="frameContext" src="resources/blank_page_green.html" style="width: 250px; height: 250px;"></iframe> + </body> +</html> diff --git a/testing/web-platform/tests/navigation-timing/test_no_previous_document.html b/testing/web-platform/tests/navigation-timing/test_no_previous_document.html new file mode 100644 index 000000000..26600bba7 --- /dev/null +++ b/testing/web-platform/tests/navigation-timing/test_no_previous_document.html @@ -0,0 +1,40 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8" /> + <title>window.performance.timing attributes on an initial navigation</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 src="resources/webperftestharness.js"></script> + + <script> + setup({explicit_done: true}); + + var frame; + function onload_test() + { + frame = document.getElementById("frameContext"); + test_namespace('navigation'); + if (performanceNamespace) + { + test_true(frame.contentWindow.performance.navigation.type == performanceNamespace.navigation.TYPE_NAVIGATE, + 'timing.navigation.type is TYPE_NAVIGATE',{help:"http://www.w3.org/TR/navigation-timing/#sec-navigation-info-interface"}); + + test_equals(frame.contentWindow.performance.timing.unloadEventStart, 0, 'timing.unloadEventStart == 0 on navigation with no previous document'); + test_equals(frame.contentWindow.performance.timing.unloadEventEnd, 0, 'timing.unloadEventEnd == 0 navigation with no previous document'); + } + done(); + } + </script> + + </head> + <body onload="onload_test();"> + <h1>Description</h1> + <p>This test validates the unload event times are 0 when there is no previous document.</p> + + <div id="log"></div><br /> + <iframe id="frameContext" src="resources/blank_page_green.html" style="width: 250px; height: 250px;"></iframe> + </body> +</html> diff --git a/testing/web-platform/tests/navigation-timing/test_performance_attributes_exist.html b/testing/web-platform/tests/navigation-timing/test_performance_attributes_exist.html new file mode 100644 index 000000000..662ab0a73 --- /dev/null +++ b/testing/web-platform/tests/navigation-timing/test_performance_attributes_exist.html @@ -0,0 +1,22 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8" /> + <title>window.performance attributes</title> + <link rel="author" title="Microsoft" href="http://www.microsoft.com/" /> + <link rel="help" href="http://www.w3.org/TR/navigation-timing/#sec-window.performance-attribute"/> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="resources/webperftestharness.js"></script> + </head> + <body> + <h1>Description</h1> + <p>This test validates that the navigation and timing attributes exist for window.performance + (but does not validate that their values are correct).</p> + <div id="log"></div> + <script> + test_namespace('navigation'); + test_namespace('timing', true); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/navigation-timing/test_performance_attributes_exist_in_object.html b/testing/web-platform/tests/navigation-timing/test_performance_attributes_exist_in_object.html new file mode 100644 index 000000000..0464758c6 --- /dev/null +++ b/testing/web-platform/tests/navigation-timing/test_performance_attributes_exist_in_object.html @@ -0,0 +1,28 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8" /> + <title>window.performance attribute exists in an object</title> + <link rel="author" title="Google" href="http://www.google.com/" /> + <link rel="help" href="http://www.w3.org/TR/navigation-timing/#sec-window.performance-attribute"/> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="resources/webperftestharness.js"></script> + <script> + function onload_test() { + var objWindow = + document.getElementById("objectContext").contentDocument.defaultView; + performanceNamespace = objWindow.performance; + test_namespace('timing'); + test_namespace('navigation', true); + } + </script> + </head> + <body> + <h1>Description</h1> + <p>This test validates that the window.performance object exists in an + object element (but does not validate that their values are correct).</p> + <object id="objectContext" onload="onload_test();" data="resources/blank_page_green.html"></object> + <div id="log"></div> + </body> +</html> diff --git a/testing/web-platform/tests/navigation-timing/test_readwrite.html b/testing/web-platform/tests/navigation-timing/test_readwrite.html new file mode 100644 index 000000000..3d2a96f18 --- /dev/null +++ b/testing/web-platform/tests/navigation-timing/test_readwrite.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8" /> + <title>window.performance is read/write</title> + <link rel="author" title="Microsoft" href="http://www.microsoft.com/" /> + <link rel="help" href="http://www.w3.org/TR/navigation-timing/#sec-window.performance-attribute"/> + <meta name="assert" content="The window.performance attribute provides a hosting area for performance related attributes. "/> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="resources/webperftestharness.js"></script> + </head> + <body> + <h1>Description</h1> + <p>This test validates that the window.performance object is read/write.</p> + <div id="log"></div> + <script> + test_namespace(); + + window.performance = 'foo'; + test_equals(window.performance, 'foo', 'window.performance is read/write'); + + var performance = 'bar'; + test_equals(performance, 'bar', 'var performance is read/write'); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/navigation-timing/test_timing_attributes_exist.html b/testing/web-platform/tests/navigation-timing/test_timing_attributes_exist.html new file mode 100644 index 000000000..f3dea6838 --- /dev/null +++ b/testing/web-platform/tests/navigation-timing/test_timing_attributes_exist.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8" /> + <title>window.performance.timing attributes</title> + <link rel="author" title="Microsoft" href="http://www.microsoft.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 src="resources/webperftestharness.js"></script> + </head> + <body> + <h1>Description</h1> + <p>This test validates that all of the window.performance.timing attributes exist (but does not validate that their values are correct).</p> + + <div id="log"></div> + + <script> + test_namespace('timing'); + + for (var i = 0; i < timingAttributes.length; ++i) + { + test_attribute_exists('timing', timingAttributes[i]); + } + </script> + </body> +</html> diff --git a/testing/web-platform/tests/navigation-timing/test_timing_attributes_order.html b/testing/web-platform/tests/navigation-timing/test_timing_attributes_order.html new file mode 100644 index 000000000..b607404b8 --- /dev/null +++ b/testing/web-platform/tests/navigation-timing/test_timing_attributes_order.html @@ -0,0 +1,109 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8" /> + <title>window.performance.timing attribute ordering on a simple navigation</title> + <link rel="author" title="Microsoft" href="http://www.microsoft.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 src="resources/webperftestharness.js"></script> + <script> + setup({explicit_done: true}); + + test_namespace('timing'); + + var step = 1; + function onload_test() + { + if (step === 1 && window.performance === undefined) + { + // avoid script errors + done(); + return; + } + + var navigation_frame = document.getElementById("frameContext").contentWindow; + performanceNamespace = navigation_frame.performance; + switch (step) + { + case 1: + { + navigation_frame.location.href = '/navigation-timing/resources/blank_page_green.html'; + step++; + break; + } + case 2: + { + test_namespace('navigation', true); + + // + // Tests + // + test_equals(performanceNamespace.navigation.type, + performanceNamespace.navigation.TYPE_NAVIGATE, + 'window.performance.navigation.type == TYPE_NAVIGATE',{help:"http://www.w3.org/TR/navigation-timing/#sec-navigation-info-interface"}); + + // navigiation must be non-0 + test_timing_greater_than('navigationStart', 0); + + // must be no redirection for this test case + test_timing_equals('redirectStart', 0); + test_timing_equals('redirectEnd', 0); + + // validate attribute ordering + test_timing_order('fetchStart', 'navigationStart'); + test_timing_order('domainLookupStart', 'fetchStart'); + test_timing_order('domainLookupEnd', 'domainLookupStart'); + test_timing_order('connectStart', 'domainLookupEnd'); + test_timing_order('connectEnd', 'connectStart'); + test_timing_order('requestStart', 'connectEnd'); + test_timing_order('responseStart', 'requestStart'); + test_timing_order('responseEnd', 'responseStart'); + test_timing_order('domLoading', 'fetchStart'); + test_timing_order('domInteractive', 'responseEnd'); + test_timing_order('domContentLoadedEventStart', 'domInteractive'); + test_timing_order('domContentLoadedEventEnd', 'domContentLoadedEventStart'); + test_timing_order('domComplete', 'domContentLoadedEventEnd'); + test_timing_order('loadEventStart', 'domContentLoadedEventEnd'); + test_timing_order('loadEventEnd', 'loadEventStart'); + + // setup requires the frame to have a previous page with an onunload event handler. + test_timing_order('unloadEventStart', 'navigationStart'); + test_timing_order('unloadEventEnd', 'unloadEventStart'); + + step++; + done(); + break; + } + default: + break; + } + } + </script> + </head> + <body> + <h1>Description</h1> + <p>This test validates the ordering of the window.performance.timing attributes.</p> + + <p>This page should be loaded with a yellow background frame below which contains an unload event + handler.</p> + + <p>After the page loads, the frame is navigated to a new blank page with a green background. At this point, the navigation timeline is verified</p> + + <p>This test passes if all of the checks to the frame.window.performance.timing attributes are + correct throughout the navigation scenario and the frame below ends with a green background. + Otherwise, this test fails.</p> + + <h1>Setup</h1> + + <div id="log"></div> + <br /> + <iframe id="frameContext" + onload="/* Need to make sure we don't examine loadEventEnd + until after the load event has finished firing */ + setTimeout(onload_test, 0);" + src="resources/blank_page_unload.html" + style="width: 250px; height: 250px;"></iframe> + </body> +</html> diff --git a/testing/web-platform/tests/navigation-timing/test_timing_client_redirect.html b/testing/web-platform/tests/navigation-timing/test_timing_client_redirect.html new file mode 100644 index 000000000..0cb7a2676 --- /dev/null +++ b/testing/web-platform/tests/navigation-timing/test_timing_client_redirect.html @@ -0,0 +1,54 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8" /> + <title>window.performance.timing.redirect attributes on a client redirect navigation</title> + <link rel="author" title="Microsoft" href="http://www.microsoft.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 src="resources/webperftestharness.js"></script> + <script> + setup({explicit_done: true}); + + test_namespace('navigation'); + test_namespace('timing', true); + + var redirect_frame; + function onload_test() + { + if (performanceNamespace === undefined) + { + // avoid script errors + done(); + return; + } + + redirect_frame = document.getElementById("frameContext"); + redirect_frame.onload = do_test; + } + + function do_test() + { + redirect_frame.onload = ""; + test_true(redirect_frame.contentWindow.performance.navigation.type == performanceNamespace.navigation.TYPE_NAVIGATE, + 'timing.navigation.type is TYPE_NAVIGATE',{help:"http://www.w3.org/TR/navigation-timing/#sec-navigation-info-interface"}); + + test_equals(redirect_frame.contentWindow.performance.navigation.redirectCount, 0, 'navigation.redirectCount == 0 on an client redirected navigation',{help:"http://www.w3.org/TR/navigation-timing/#sec-navigation-info-interface"}); + test_equals(redirect_frame.contentWindow.performance.timing.redirectStart, 0, 'timing.redirectStart == 0 on an client redirected navigation'); + test_equals(redirect_frame.contentWindow.performance.timing.redirectEnd, 0, 'timing.redirectEnd == 0 on an client redirected navigation'); + + done(); + } + </script> + + </head> + <body onload="onload_test();"> + <h1>Description</h1> + <p>This test validates the values of the window.navigation.redirectCount and the + window.performance.timing.redirectStart/End times on a client side redirect.</p> + + <div id="log"></div><br /> + <iframe id="frameContext" src="resources/blank_page_meta_redirect.html" style="width: 250px; height: 250px;"></iframe> + </body> +</html> diff --git a/testing/web-platform/tests/navigation-timing/test_timing_reload.html b/testing/web-platform/tests/navigation-timing/test_timing_reload.html new file mode 100644 index 000000000..57d2dcebe --- /dev/null +++ b/testing/web-platform/tests/navigation-timing/test_timing_reload.html @@ -0,0 +1,90 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8" /> + <title>window.performance.timing attributes after a reloaded navigation</title> + <link rel="author" title="Microsoft" href="http://www.microsoft.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 src="resources/webperftestharness.js"></script> + <script> + setup({explicit_done: true}); + + // explicitly test the namespace before we start testing + test_namespace('navigation'); + + var reload_frame; + var initial_timing; + + function onload_test() + { + reload_frame = document.getElementById("frameContext"); + + if (reload_frame.contentWindow.performance === undefined) + { + // avoid script errors + done(); + return; + } + + reload_frame.onload = do_test; + + // save frame's initial timings + initial_timing = {}; + var timing = reload_frame.contentWindow.performance.timing; + + for (var i = 0; i < timingAttributes.length; ++i) + { + var property = timingAttributes[i]; + initial_timing[property] = timing[property]; + } + + setTimeout("reload_the_frame();", 100); + } + + function reload_the_frame() + { + reload_frame.contentWindow.location.reload(true); + } + + function do_test() + { + reload_frame.onload = ""; + + // ensure the frame reloaded + test_equals(reload_frame.contentWindow.performance.navigation.type, + performanceNamespace.navigation.TYPE_RELOAD, + "window.performance.navigation.type == TYPE_RELOAD", {help:"http://www.w3.org/TR/navigation-timing/#sec-navigation-info-interface"}); + + // ensure reload timings changed + var timing = reload_frame.contentWindow.performance.timing; + for (var i = 0; i < timingAttributes.length; ++i) + { + var property = timingAttributes[i]; + + // ignore any timings that were zero initially + if (initial_timing[property] !== 0) + { + test_not_equals(timing[property], initial_timing[property], + property + " is different after the reload."); + } + } + + done(); + } + </script> + </head> + <body onload="onload_test();"> + <h1>Description</h1> + <p>This test validates that the window.performance.timing attributes change when a page is reloaded.</p> + + <p>This page should be loaded with a green background frame below. The frame will be automatically reloaded + and then verified that the window.performance.timing attributes have been updated to the new reloaded navigation timings.</p> + + <div id="log"></div> + <br /> + <iframe id="frameContext" src="resources/blank_page_green.html" style="width: 250px; height: 250px;"></iframe> + + </body> +</html> diff --git a/testing/web-platform/tests/navigation-timing/test_timing_server_redirect.html b/testing/web-platform/tests/navigation-timing/test_timing_server_redirect.html new file mode 100644 index 000000000..22137be74 --- /dev/null +++ b/testing/web-platform/tests/navigation-timing/test_timing_server_redirect.html @@ -0,0 +1,47 @@ +<!DOCTYPE HTML> +<html> + <head> + <meta charset="utf-8" /> + <title>window.performance.timing.redirect attributes on a same-origin server redirected navigation</title> + <link rel="author" title="Microsoft" href="http://www.microsoft.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 src="resources/webperftestharness.js"></script> + + <script> + function onload_test() + { + test_namespace('navigation'); + if (performanceNamespace === undefined) + { + // avoid script errors + done(); + return; + } + + performanceNamespace = document.getElementById("frameContext").contentWindow.performance; + test_equals(performanceNamespace.navigation.type, + performanceNamespace.navigation.TYPE_NAVIGATE, + 'timing.navigation.type is TYPE_NAVIGATE'); + test_equals(performanceNamespace.navigation.redirectCount, 1, 'navigation.redirectCount == 1 on an server redirected navigation'); + + test_timing_greater_than('navigationStart', 0); + + test_timing_order('redirectStart', 'navigationStart'); + test_timing_order('redirectEnd', 'redirectStart'); + test_timing_order('fetchStart', 'redirectEnd'); + } + </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> + + <div id="log"></div> + <br /> + <iframe id="frameContext" onload="onload_test();" src="/common/redirect.py?location=/navigation-timing/resources/blank_page_green.html" style="width: 250px; height: 250px;"></iframe> + </body> +</html> diff --git a/testing/web-platform/tests/navigation-timing/test_timing_xserver_redirect.html b/testing/web-platform/tests/navigation-timing/test_timing_xserver_redirect.html new file mode 100644 index 000000000..ef00526b0 --- /dev/null +++ b/testing/web-platform/tests/navigation-timing/test_timing_xserver_redirect.html @@ -0,0 +1,70 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8" /> + <title>window.performance.timing.redirect attributes on a cross-origin server redirected navigation</title> + <link rel="author" title="Microsoft" href="http://www.microsoft.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 src="resources/webperftestharness.js"></script> + <script src="/common/utils.js"></script> + <script> + setup({explicit_done: true}); + + // + // Test configuration + // + + var subdomain = "www"; + + // + // Tests + // + function onload_test() + { + test_namespace('navigation'); + if (performanceNamespace === undefined) + { + // avoid script errors + done(); + return; + } + + performanceNamespace = document.getElementById("frameContext").contentWindow.performance; + test_equals(performanceNamespace.navigation.type, + performanceNamespace.navigation.TYPE_NAVIGATE, + 'timing.navigation.type is TYPE_NAVIGATE',{help:"http://www.w3.org/TR/navigation-timing/#sec-navigation-info-interface"}); + test_equals(performanceNamespace.navigation.redirectCount, 0, 'navigation.redirectCount == 0 on a cross-origin server redirected navigation', {help:"http://www.w3.org/TR/navigation-timing/#sec-navigation-info-interface"}); + + test_timing_greater_than('navigationStart', 0); + + test_equals(performanceNamespace.timing.redirectStart, 0, 'timing.redirectStart == 0 on a server redirected navigation from another domain'); + test_equals(performanceNamespace.timing.redirectEnd, 0, 'timing.redirectEnd == 0 on a server redirected navigation from another domain'); + + 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 cross-origin server side redirect navigation.</p> + + <div id="log"></div> + <br /> + <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 destUrl = make_absolute_url({subdomain: subdomain, + path: "/common/redirect.py", + query: "location=" + make_absolute_url( + {path: "/navigation-timing/resources/blank_page_green.html"}) + }); + var frameContext = document.getElementById("frameContext"); + frameContext.onload = onload_test; + frameContext.src = destUrl; + </script> + </body> +</html> diff --git a/testing/web-platform/tests/navigation-timing/test_unique_performance_objects.html b/testing/web-platform/tests/navigation-timing/test_unique_performance_objects.html new file mode 100644 index 000000000..aa41196d0 --- /dev/null +++ b/testing/web-platform/tests/navigation-timing/test_unique_performance_objects.html @@ -0,0 +1,29 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8" /> + <title>Each window object has a unique performance object</title> + <link rel="author" title="Microsoft" href="http://www.microsoft.com/" /> + <link rel="help" href="http://www.w3.org/TR/navigation-timing/#sec-window.performance-attribute" /> + <meta name="assert" content="Each browsing context must have a unique window.performance.timing attribute."/> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="resources/webperftestharness.js"></script> + </head> + <body> + <h1>Description</h1> + <p>This test validates that each window has a unique window.performance object.</p> + <iframe id="frameContext" src="resources/blank_page_green.html" style="display:none;";></iframe> + <div id="log"></div> + <script> + test_namespace('timing'); + + if (performanceNamespace !== undefined) + { + test_not_equals(performanceNamespace.timing, + document.getElementById("frameContext").contentWindow.performance.timing, + "Different window objects have unique performance objects"); + } + </script> + </body> +</html> |