Skip to content

Commit

Permalink
Bug 1689388 [wpt PR 27367] - Updates for TAO-null-opaque-origin.sub.h…
Browse files Browse the repository at this point in the history
…tml, a=testonly

Automatic update from web-platform-tests
Updates for TAO-null-opaque-origin.sub.html

We want to normalize and update our WPT tests for ResourceTiming. This
change uses
- 'promise_test' instead of 'async_test'
- 'fetch_tests_from_window' instead of hand-rolled 'PostMessage' calls
as well as some other small cleanups.

Bug: 1171767
Change-Id: Id71c0eef898ffb4982785f01edd2a4df9b1bfbba
GitHubIssue: w3c/resource-timing#254
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2656419
Commit-Queue: Tom McKee <[email protected]>
Reviewed-by: Yoav Weiss <[email protected]>
Cr-Commit-Position: refs/heads/master@{#848574}

--

wpt-commits: 1f6bc471fb537e733703cce3283fbb4d7f47547b
wpt-pr: 27367
  • Loading branch information
tommckee1 authored and moz-wptsync-bot committed Feb 2, 2021
1 parent 5c87e53 commit 31ad885
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 43 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Resource Timing TAO - "null" and opaque origin</title>
<link rel="author" title="Google" href="http://www.google.com/" />
<link rel="help" href="https://www.w3.org/TR/resource-timing-2/#timing-allow-origin"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/get-host-info.sub.js"></script>
</head>
<body>
<h1>Description</h1>
<p>This test validates that, for a cross origin resource, the timing allow
check algorithm will succeed when the value of Timing-Allow-Origin is null and
the origin is an opaque origin.</p>
<div id="log"></div>
<iframe id="frameContext"></iframe>
<script>
const origin = get_host_info()["ORIGIN"];
const frame_content = `data:text/html;utf8,<body>
<script src="${origin}/resources/testharness.js"></` + `script>
<script>
const url = "${origin}/resource-timing/resources/TAOResponse.py?tao=null";
promise_test(() => { return new Promise((resolve, reject) => {
const run_test = entryList => {
const entry = entryList.getEntries()[0];
const sum = entry.redirectStart + entry.redirectEnd +
entry.domainLookupStart + entry.domainLookupEnd +
entry.connectStart + entry.connectEnd +
entry.secureConnectionStart + entry.requestStart +
entry.responseStart + entry.transferSize +
entry.encodedBodySize + entry.decodedBodySize;
assert_not_equals(sum, 0, "Timings must be non-zero");
};
const observer = new PerformanceObserver(list => {
try {
run_test(list);
resolve();
} catch(e) {
reject(e);
}
});
observer.observe({ entryTypes: ["resource"] });
fetch(url);
})}, "An opaque origin should be authorized to see resource timings when" +
" the TAO header is the string 'null'");
</` + `script></body>`;

frameContext.style = "display:none"
frameContext.src = frame_content;
fetch_tests_from_window(frameContext.contentWindow);
</script>
</body>
</html>

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def main(request, response):
# null, fail unless it's an opaque origin
response.headers.set(b'Timing-Allow-Origin', b'null')
elif tao == b'Null':
# case-insentive null, fail
# case-insensitive null, fail
response.headers.set(b'Timing-Allow-Origin', b'Null')
elif tao == b'origin':
# case-sensitive match for origin, pass
Expand Down

0 comments on commit 31ad885

Please sign in to comment.