| <!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> |