File: TAO-port-mismatch-means-crossorigin.html

package info (click to toggle)
firefox 144.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,637,504 kB
  • sloc: cpp: 7,576,692; javascript: 6,430,831; ansic: 3,748,119; python: 1,398,978; xml: 628,810; asm: 438,679; java: 186,194; sh: 63,212; makefile: 19,159; objc: 13,086; perl: 12,986; yacc: 4,583; cs: 3,846; pascal: 3,448; lex: 1,720; ruby: 1,003; exp: 762; php: 436; lisp: 258; awk: 247; sql: 66; sed: 53; csh: 10
file content (46 lines) | stat: -rw-r--r-- 2,007 bytes parent folder | download | duplicates (29)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<!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, PORT, PORT2} = get_host_info();

// The main page is being requested on the default port (PORT), while the
// subresource will be requested on a separate port (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 port_mismatch_url = `${location.protocol}//${ORIGINAL_HOST}:${PORT2}` +
                          `/resource-timing/resources/TAOResponse.py?` +
                          `tao=origin_port_${PORT2}`;
attribute_test(
  fetch, port_mismatch_url, invariants.assert_tao_failure_resource,
  "A port mismatch must fail the TAO check");

// The same URL as above except the Timing-Allow-Origin header will have the
// same port as this page's origin. Therefore, this page's origin will match
// the Timing-Allow-Origin header's value. Therefore, the subresource's timings
// must be exposed.
const port_match_url = `${location.protocol}//${ORIGINAL_HOST}:${PORT2}` +
                       `/resource-timing/resources/TAOResponse.py?` +
                       `tao=origin_port_${PORT}`;
attribute_test(
  fetch, port_match_url, invariants.assert_tao_pass_no_redirect_http,
  "An identical port must pass 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>