Bug 1581220 [wpt PR 19053] - [resource-timing] Align TAO processing with CORS, a=testonly
authorYoav Weiss <yoavweiss@chromium.org>
Mon, 23 Sep 2019 12:24:03 +0000
changeset 494835 88ab455879f41c520b960c597231243fa38eaba9
parent 494834 be8f9407ca9a7242b13154bb99917cdd80417b73
child 494836 3506fb6955b86be99e249d4922e374753abc1da6
push id36615
push usercsabou@mozilla.com
push dateWed, 25 Sep 2019 09:50:53 +0000
treeherdermozilla-central@c31591e0b66f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1581220, 19053, 1803916, 698314
milestone71.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1581220 [wpt PR 19053] - [resource-timing] Align TAO processing with CORS, a=testonly Automatic update from web-platform-tests [resource-timing] Align TAO processing with CORS Implements https://github.com/w3c/resource-timing/pull/214 In order to some day be able to make TAO a subset of CORS, and in order to have a single mental model that developers can apply to both, this change makes sure that redirect chains that contained cross-origin requests require TAO on all following responses, even if they are same origin. Change-Id: I4c77ba5dbbe22c3de4dd05e4c7a8ac2c1526603b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1803916 Commit-Queue: Yoav Weiss <yoavweiss@chromium.org> Reviewed-by: Nicolás Peña Moreno <npm@chromium.org> Cr-Commit-Position: refs/heads/master@{#698314} -- wpt-commits: 5de667230a4470f3947bc2900acdfe36c1e3ce50 wpt-pr: 19053
testing/web-platform/tests/resource-timing/crossorigin-sandwich-TAO.sub.html
testing/web-platform/tests/resource-timing/crossorigin-sandwich-partial-TAO.sub.html
testing/web-platform/tests/resource-timing/resource_TAO_cross_origin_redirect_chain.html
testing/web-platform/tests/resource-timing/resources/blank-with-tao.html
testing/web-platform/tests/resource-timing/resources/blank-with-tao.html.headers
testing/web-platform/tests/resource-timing/resources/multi_redirect.py
--- a/testing/web-platform/tests/resource-timing/crossorigin-sandwich-TAO.sub.html
+++ b/testing/web-platform/tests/resource-timing/crossorigin-sandwich-TAO.sub.html
@@ -33,14 +33,15 @@
 </head>
 <body>
 <iframe id="frameContext" src="" style="width: 250px; height: 250px;"></iframe>
 <script>
     let destUrl = pageOrigin + '/resource-timing/resources/multi_redirect.py?';
     destUrl += 'page_origin=' + pageOrigin;
     destUrl += '&timing_allow=1';
     destUrl += '&cross_origin=' + crossOrigin;
+    destUrl += '&tao_steps=3';
     const frameContext = document.getElementById('frameContext');
     frameContext.onload = onload_test;
     frameContext.src = destUrl;
 </script>
 </body>
 </html>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/resource-timing/crossorigin-sandwich-partial-TAO.sub.html
@@ -0,0 +1,47 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<meta charset="utf-8" />
+<title>This test validates resource timing information for a same-origin=>cross-origin=>same-origin redirect chain with Timing-Allow-Origin.</title>
+<link rel="help" href="http://www.w3.org/TR/resource-timing/#performanceresourcetiming"/>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/common/get-host-info.sub.js"></script>
+<script src="resources/webperftestharness.js"></script>
+<script src="resources/webperftestharnessextension.js"></script>
+
+<script>
+    setup({explicit_done: true});
+    test_namespace('getEntriesByName');
+    const pageOrigin = get_host_info()['ORIGIN'];
+    const crossOrigin = get_host_info()['REMOTE_ORIGIN'];
+
+    function onload_test()
+    {
+        const entries = performance.getEntriesByName(document.getElementById('frameContext').src, 'resource');
+        test_equals(entries.length, 1, 'There should be one entry.');
+        const entry = entries[0];
+
+        test_equals(entry.redirectStart, 0, 'redirectStart == 0 in cross-origin redirect with Timing-Allow-Origin in some of the chain but not all of it.');
+        test_equals(entry.redirectEnd, 0, 'redirectEnd == 0 in cross-origin redirect with Timing-Allow-Origin in some of the chain but not all of it.');
+        test_greater_than(entry.fetchStart, 0, 'fetchStart > 0 in cross-origin redirect.');
+        test_equals(entry.fetchStart, entry.startTime, 'startTime == fetchStart in cross-origin redirect with Timing-Allow-Origin in some of the chain but not all of it.');
+        done();
+    }
+</script>
+
+</head>
+<body>
+<iframe id="frameContext" src="" style="width: 250px; height: 250px;"></iframe>
+<script>
+    let destUrl = pageOrigin + '/resource-timing/resources/multi_redirect.py?';
+    destUrl += 'page_origin=' + pageOrigin;
+    destUrl += '&timing_allow=1';
+    destUrl += '&cross_origin=' + crossOrigin;
+    destUrl += '&tao_steps=2';
+    const frameContext = document.getElementById('frameContext');
+    frameContext.onload = onload_test;
+    frameContext.src = destUrl;
+</script>
+</body>
+</html>
--- a/testing/web-platform/tests/resource-timing/resource_TAO_cross_origin_redirect_chain.html
+++ b/testing/web-platform/tests/resource-timing/resource_TAO_cross_origin_redirect_chain.html
@@ -32,15 +32,16 @@
 
 </head>
 <body>
 <iframe id="frameContext" src="" style="width: 250px; height: 250px;"></iframe>
 <script>
     let destUrl = get_host_info().HTTP_REMOTE_ORIGIN + '/resource-timing/resources/multi_redirect.py?';
     destUrl += 'page_origin=' + 'http://' + document.location.host;
     destUrl += '&cross_origin=' + get_host_info().HTTP_REMOTE_ORIGIN;
+    destUrl += '&tao_steps=3';
     destUrl += '&timing_allow=1';
     const frameContext = document.getElementById('frameContext');
     frameContext.onload = onload_test;
     frameContext.src = destUrl;
 </script>
 </body>
 </html>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/resource-timing/resources/blank-with-tao.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>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/resource-timing/resources/blank-with-tao.html.headers
@@ -0,0 +1,1 @@
+Timing-Allow-Origin: *
--- a/testing/web-platform/tests/resource-timing/resources/multi_redirect.py
+++ b/testing/web-platform/tests/resource-timing/resources/multi_redirect.py
@@ -11,34 +11,37 @@ def main(request, response):
         try:
             step = int(request.GET.first("step"))
         except ValueError:
             pass
 
     origin = request.url_parts.scheme + "://" + request.url_parts.hostname + ":" + str(request.url_parts.port)
     page_origin = request.GET.first("page_origin")
     cross_origin = request.GET.first("cross_origin")
+    tao_steps = 0
+    if "tao_steps" in request.GET:
+        tao_steps = int(request.GET.first("tao_steps"))
     timing_allow = "0"
     if "timing_allow" in request.GET:
         timing_allow = request.GET.first("timing_allow")
 
+    next_tao_steps = tao_steps - 1
     redirect_url_path = "/resource-timing/resources/multi_redirect.py?"
     redirect_url_path += "page_origin=" + page_origin
     redirect_url_path += "&cross_origin=" + cross_origin
     redirect_url_path += "&timing_allow=" + timing_allow
+    redirect_url_path += "&tao_steps=" + str(next_tao_steps)
     redirect_url_path += "&step="
+    if timing_allow != "0" and tao_steps > 0:
+        response.headers.set("timing-allow-origin", page_origin)
 
     if step == 1:
         # On the first request, redirect to a cross origin URL
         redirect_url = cross_origin + redirect_url_path + "2"
-        if timing_allow != "0" and origin != page_origin:
-            response.headers.set("timing-allow-origin", page_origin)
     elif step == 2:
         # On the second request, redirect to a same origin URL
         redirect_url = page_origin + redirect_url_path + "3"
-        if timing_allow != "0":
-            response.headers.set("timing-allow-origin", page_origin)
     else:
         # On the third request, redirect to a static response
-        redirect_url = page_origin + "/resource-timing/resources/blank_page_green.htm"
+        redirect_url = page_origin + "/resource-timing/resources/blank-with-tao.html"
 
     response.status = 302
     response.headers.set("Location", redirect_url)