blob: 6965cbeb92c7c9bc337d6a5b8615bec059bb1ed6 (
plain)
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
47
48
49
50
51
52
53
54
55
56
|
<!DOCTYPE HTML>
<html>
<head>
<title>Bug 1542194 - Check blockedURI in violation reports after redirects</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<iframe id='testframe'></iframe>
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
let seenViolations = 0;
let expectedViolations = 3;
window.addEventListener("message", receiveMessage);
function receiveMessage(event) {
seenViolations++;
let blockedURI = event.data.blockedURI;
if (blockedURI.includes("test1")) {
is(blockedURI,
"http://example.com/tests/dom/security/test/csp/file_blocked_uri_in_violation_event_after_redirects.sjs?test1a",
"Test 1 should be the URI before redirect");
} else if (blockedURI.includes("test2")) {
is(blockedURI,
"http://test2.example.com",
"Test 2 should be the redirected pre-path URI");
} else if (blockedURI.includes("test3")) {
is(blockedURI,
"http://test3.example.com",
"Test 3 should be the redirected pre-path URI");
} else {
ok(false, "sanity: how can we end up here?");
}
if (seenViolations < expectedViolations) {
return;
}
window.removeEventListener("message", receiveMessage);
SimpleTest.finish();
}
let testframe = document.getElementById("testframe");
// This has to be same-origin with the test1 URL.
testframe.src = "http://example.com/tests/dom/security/test/csp/file_blocked_uri_in_violation_event_after_redirects.html";
</script>
</body>
</html>
|