Bug 1523562 [wpt PR 14845] - [resource-timing] Modify is_secure_context_ based on resource, a=testonly

Automatic update from web-platform-tests
[resource-timing] Modify is_secure_context_ based on resource

This is a followup on [1], which fixes the case where the document's
protocol and the resource's protocol are not the same, and adds tests
to that effect.

[1]https://chromium-review.googlesource.com/c/chromium/src/+/1396129

Change-Id: I7e0fda2e1275cb38359bf5781994f1b273248e4d
Reviewed-on: https://chromium-review.googlesource.com/c/1409446
Commit-Queue: Yoav Weiss <yoavweiss@chromium.org>
Reviewed-by: Nicolás Peña Moreno <npm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#623889}

--

wpt-commits: 4851d0827f2dc5762d257473e2d917bf4fc7ba69
wpt-pr: 14845
This commit is contained in:
Yoav Weiss 2019-02-01 11:40:11 +00:00 коммит произвёл James Graham
Родитель d5d417a074
Коммит 647cc9caa1
7 изменённых файлов: 158 добавлений и 3 удалений

Просмотреть файл

@ -41,7 +41,7 @@ function onload_test() {
test_equals(entry.fetchStart, entry.connectStart, 'connectStart and fetchStart should be the same');
test_equals(entry.fetchStart, entry.connectEnd, 'connectEnd and fetchStart should be the same');
if(!window.isSecureConnection) {
test_equals(entry.secureConnectionStart, 0, 'secureConnectStart should be zero');
test_equals(entry.secureConnectionStart, 0, 'secureConnectionStart should be zero');
}
test_equals(entry.fetchStart, entry.domainLookupStart, 'domainLookupStart and fetchStart should be the same')
test_equals(entry.fetchStart, entry.domainLookupEnd, 'domainLookupEnd and fetchStart should be the same')

Просмотреть файл

@ -40,7 +40,7 @@ function onload_test() {
const entry = entries[1];
test_equals(entry.fetchStart, entry.connectStart, 'connectStart and fetchStart should be the same');
test_equals(entry.fetchStart, entry.connectEnd, 'connectEnd and fetchStart should be the same');
test_equals(entry.fetchStart, entry.secureConnectionStart, 'secureConnectStart and fetchStart should be the same');
test_equals(entry.fetchStart, entry.secureConnectionStart, 'secureConnectionStart and fetchStart should be the same');
test_equals(entry.fetchStart, entry.domainLookupStart, 'domainLookupStart and fetchStart should be the same')
test_equals(entry.fetchStart, entry.domainLookupEnd, 'domainLookupEnd and fetchStart should be the same')
}

Просмотреть файл

@ -0,0 +1,55 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Resource Timing connection reuse</title>
<link rel="author" title="Google" href="http://www.google.com/" />
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/webperftestharness.js"></script>
<script src="resources/webperftestharnessextension.js"></script>
<script>
setup({explicit_done: true});
let iframe;
let d;
let body;
// Explicitly test the namespace before we start testing.
test_namespace('getEntriesByType');
function setup_iframe() {
iframe = document.getElementById('frameContext');
d = iframe.contentWindow.document;
iframe.addEventListener('load', onload_test, false);
}
function onload_test() {
const entries = iframe.contentWindow.performance.getEntriesByType('resource');
// When a persistent connection is used, follow-on resources should be included as PerformanceResourceTiming objects.
test_equals(entries.length, 2, 'There should be 2 PerformanceEntries');
if (entries.length >= 2) {
// When a persistent connection is used, for the resource that reuses the socket, connectStart and connectEnd should have the same value as fetchStart.
const entry = entries[1];
test_equals(entry.fetchStart, entry.connectStart, 'connectStart and fetchStart should be the same');
test_equals(entry.fetchStart, entry.connectEnd, 'connectEnd and fetchStart should be the same');
// secureConnectionStart is the same as fetchStart since the subresource is fetched over https
test_equals(entry.fetchStart, entry.secureConnectionStart, 'secureConnectionStart and fetchStart should be the same');
test_equals(entry.fetchStart, entry.domainLookupStart, 'domainLookupStart and fetchStart should be the same')
test_equals(entry.fetchStart, entry.domainLookupEnd, 'domainLookupEnd and fetchStart should be the same')
}
done();
}
window.setup_iframe = setup_iframe;
</script>
</head>
<body>
<h1>Description</h1>
<p>This test validates that connectStart and connectEnd are the same when a connection is reused (e.g. when a persistent connection is used).</p>
<div id="log"></div>
<iframe id="frameContext" src="resources/fake_responses_https.sub.html"></iframe>
</body>
</html>

Просмотреть файл

@ -0,0 +1,55 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Resource Timing connection reuse</title>
<link rel="author" title="Google" href="http://www.google.com/" />
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/webperftestharness.js"></script>
<script src="resources/webperftestharnessextension.js"></script>
<script>
setup({explicit_done: true});
let iframe;
let d;
let body;
// Explicitly test the namespace before we start testing.
test_namespace('getEntriesByType');
function setup_iframe() {
iframe = document.getElementById('frameContext');
d = iframe.contentWindow.document;
iframe.addEventListener('load', onload_test, false);
}
function onload_test() {
const entries = iframe.contentWindow.performance.getEntriesByType('resource');
// When a persistent connection is used, follow-on resources should be included as PerformanceResourceTiming objects.
test_equals(entries.length, 2, 'There should be 2 PerformanceEntries');
if (entries.length >= 2) {
// When a persistent connection is used, for the resource that reuses the socket, connectStart and connectEnd should have the same value as fetchStart.
const entry = entries[1];
test_equals(entry.fetchStart, entry.connectStart, 'connectStart and fetchStart should be the same');
test_equals(entry.fetchStart, entry.connectEnd, 'connectEnd and fetchStart should be the same');
// secureConnectionStart is the same as fetchStart since the subresource is eventually redirected to https.
test_equals(entry.fetchStart, entry.secureConnectionStart, 'secureConnectionStart and fetchStart should be the same');
test_equals(entry.fetchStart, entry.domainLookupStart, 'domainLookupStart and fetchStart should be the same')
test_equals(entry.fetchStart, entry.domainLookupEnd, 'domainLookupEnd and fetchStart should be the same')
}
done();
}
window.setup_iframe = setup_iframe;
</script>
</head>
<body>
<h1>Description</h1>
<p>This test validates that connectStart and connectEnd are the same when a connection is reused (e.g. when a persistent connection is used).</p>
<div id="log"></div>
<iframe id="frameContext" src="resources/fake_responses_https_redirect.sub.html"></iframe>
</body>
</html>

Просмотреть файл

@ -2,13 +2,20 @@
def main(request, response):
tag = request.GET.first("tag", None)
redirect = request.GET.first("redirect", None)
match = request.headers.get("If-None-Match", None)
date = request.GET.first("date", "")
modified = request.headers.get("If-Modified-Since", None)
response.headers.set("Access-Control-Allow-Origin", "*");
response.headers.set("Timing-Allow-Origin", "*");
if tag:
response.headers.set("ETag", '"%s"' % tag)
elif date:
response.headers.set("Last-Modified", date)
if redirect:
response.headers.set("Location", redirect)
response.status = (302, "Moved")
return ""
if ((match is not None and match == tag) or
(modified is not None and modified == date)):
@ -16,4 +23,4 @@ def main(request, response):
return ""
else:
response.headers.set("Content-Type", "text/plain")
return "MAYBE NOT"
return "MAYBE NOT"

Просмотреть файл

@ -0,0 +1,18 @@
<body>
<script>
function request() {
var client = new XMLHttpRequest,
baseurl = "https://{{hosts[][www]}}:{{ports[https][0]}}{{location[pathname]}}",
url = new URL("fake_responses.py", baseurl).href;
client.open("GET", url, false)
client.send(null)
client.open("GET", url, false)
client.send(null)
}
if(window.parent.setup_iframe) {
window.parent.setup_iframe();
request();
}
</script>
</body>

Просмотреть файл

@ -0,0 +1,20 @@
<body>
<script>
function request() {
var client = new XMLHttpRequest,
baseurl = "http://{{hosts[][www]}}:{{ports[http][0]}}{{location[pathname]}}",
subresource = "fake_responses.py",
redirecturl = new URL(subresource, "https://{{hosts[][www]}}:{{ports[https][0]}}{{location[pathname]}}").href,
url = new URL(subresource + "?redirect=" + redirecturl, baseurl).href;
client.open("GET", url, false)
client.send(null)
client.open("GET", url, false)
client.send(null)
}
if(window.parent.setup_iframe) {
window.parent.setup_iframe();
request();
}
</script>
</body>