blob: 2871028869e47966461d7e255c7eccb499628365 (
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
|
<!DOCTYPE HTML>
<html>
<head>
<title>Bug 1704473 - Remove head requirement for meta name=referrer</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<iframe id="frame_meta_in_head"></iframe>
<iframe id="frame_meta_notin_head"></iframe>
<script type="application/javascript">
SimpleTest.waitForExplicitFinish();
let testCounter = 0;
function checkTestsDone() {
testCounter++;
if(testCounter == 2) {
SimpleTest.finish();
}
}
var script = SpecialPowers.loadChromeScript(() => {
/* eslint-env mozilla/chrome-script */
let counter = 0;
Services.obs.addObserver(function onExamResp(subject) {
let channel = subject.QueryInterface(Ci.nsIHttpChannel);
if (!channel.URI.spec.startsWith("https://example.com") || counter >= 2) {
return;
}
let refererHeaderSet = false;
try {
channel.getRequestHeader("referer");
refererHeaderSet = true;
} catch (e) {
refererHeaderSet = false;
}
ok(!refererHeaderSet, "the referer header should not be set");
counter++;
sendAsyncMessage("checked-referer-header");
}, "http-on-stop-request");
});
script.addMessageListener("checked-referer-header", checkTestsDone);
let frame1 = document.getElementById("frame_meta_in_head");
frame1.src = "/tests/dom/security/test/general/file_meta_referrer_in_head.html";
let frame2 = document.getElementById("frame_meta_notin_head");
frame2.src = "/tests/dom/security/test/general/file_meta_referrer_notin_head.html";
</script>
</body>
</html>
|