Skip to content

Commit

Permalink
[ResourceTiming] Update TAO-crossorigin-port.sub.html with new style
Browse files Browse the repository at this point in the history
This change rewrites (and renames) the above test to conform to the new
style we're introducing to Resource Timing Web Platform Tests. See
wpt/resource-timing/CodingingConventions.md for what the new style
prescribes.

Bug: 1171767
Change-Id: I84df93ab1165ab1e315dc406144791be3b1a5b28
GithubIssue: w3c/resource-timing#254
  • Loading branch information
tommckee1 authored and chromium-wpt-export-bot committed May 10, 2021
1 parent 55d0964 commit 1d7328a
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 25 deletions.
25 changes: 0 additions & 25 deletions resource-timing/TAO-crossorigin-port.sub.html

This file was deleted.

35 changes: 35 additions & 0 deletions resource-timing/TAO-port-mismatch-means-crossorigin.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>TAO - port mismatch must fail the check</title>
<link rel="author" title="Google" href="http://www.google.com/" />
<link rel="help" href="https://www.w3.org/TR/resource-timing-2/#sec-timing-allow-origin"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="resources/entry-invariants.js"></script>
<script>

const {ORIGINAL_HOST, HTTP_PORT2} = get_host_info();

// The main page is being requested on the default port (HTTP_PORT), while the
// subresource will be requested on a separate port (HTTP_PORT2). The response
// will have a Timing-Allow-Origin header value with the second port so this
// page's origin should not be a match.
const url = `${location.protocol}//${ORIGINAL_HOST}:${HTTP_PORT2}` +
`/resource-timing/resources/TAOResponse.py?` +
`tao=origin_port_${HTTP_PORT2}`;
attribute_test(
fetch, url, invariants.assert_tao_failure_resource,
"Make sure that the port matters for the TAO check");

</script>
</head>
<body>
<h1>Description</h1>
<p>This test validates that for a cross origin resource with different ports,
the timing allow check algorithm will fail when the value of
Timing-Allow-Origin value has the right host but the wrong port in it.</p>
</body>
</html>
25 changes: 25 additions & 0 deletions resource-timing/resources/entry-invariants.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,32 @@ const invariants = {

assert_equals(entry.fetchStart, entry.startTime,
"fetchStart must equal startTime");
},

assert_tao_failure_resource: entry => {
assert_equals(entry.entryType, "resource", "entryType must always be 'resource'");

assert_positive_(entry, [
"startTime",
"duration",
]);

assert_zeroed_(entry, [
"redirectStart",
"redirectEnd",
"domainLookupStart",
"domainLookupEnd",
"connectStart",
"connectEnd",
"secureConnectionStart",
"requestStart",
"responseStart",
"transferSize",
"encodedBodySize",
"decodedBodySize",
]);
}

};

// Given a resource-loader, a path (a relative path or absolute URL), and a
Expand Down

0 comments on commit 1d7328a

Please sign in to comment.