|
1 // Script to populate the test frames in the frame ancestors mochitest. |
|
2 // |
|
3 function setupFrames() { |
|
4 |
|
5 var $ = function(v) { return document.getElementById(v); } |
|
6 var base = { |
|
7 self: '/tests/content/base/test/csp/file_CSP_frameancestors.sjs', |
|
8 a: 'http://mochi.test:8888/tests/content/base/test/csp/file_CSP_frameancestors.sjs', |
|
9 b: 'http://example.com/tests/content/base/test/csp/file_CSP_frameancestors.sjs' |
|
10 }; |
|
11 |
|
12 var host = { a: 'http://mochi.test:8888', b: 'http://example.com:80' }; |
|
13 |
|
14 var innerframeuri = null; |
|
15 var elt = null; |
|
16 |
|
17 elt = $('aa_allow'); |
|
18 elt.src = base.a + "?testid=aa_allow&internalframe=aa_a&csp=" + |
|
19 escape("allow 'none'; frame-ancestors " + host.a + "; script-src 'self'"); |
|
20 |
|
21 elt = $('aa_block'); |
|
22 elt.src = base.a + "?testid=aa_block&internalframe=aa_b&csp=" + |
|
23 escape("allow 'none'; frame-ancestors 'none'; script-src 'self'"); |
|
24 |
|
25 elt = $('ab_allow'); |
|
26 elt.src = base.b + "?testid=ab_allow&internalframe=ab_a&csp=" + |
|
27 escape("allow 'none'; frame-ancestors " + host.a + "; script-src 'self'"); |
|
28 |
|
29 elt = $('ab_block'); |
|
30 elt.src = base.b + "?testid=ab_block&internalframe=ab_b&csp=" + |
|
31 escape("allow 'none'; frame-ancestors 'none'; script-src 'self'"); |
|
32 |
|
33 /* .... two-level framing */ |
|
34 elt = $('aba_allow'); |
|
35 innerframeuri = base.a + "?testid=aba_allow&double=1&internalframe=aba_a&csp=" + |
|
36 escape("allow 'none'; frame-ancestors " + host.a + " " + host.b + "; script-src 'self'"); |
|
37 elt.src = base.b + "?externalframe=" + escape('<iframe src="' + innerframeuri + '"></iframe>'); |
|
38 |
|
39 elt = $('aba_block'); |
|
40 innerframeuri = base.a + "?testid=aba_allow&double=1&internalframe=aba_b&csp=" + |
|
41 escape("allow 'none'; frame-ancestors " + host.a + "; script-src 'self'"); |
|
42 elt.src = base.b + "?externalframe=" + escape('<iframe src="' + innerframeuri + '"></iframe>'); |
|
43 |
|
44 elt = $('aba2_block'); |
|
45 innerframeuri = base.a + "?testid=aba_allow&double=1&internalframe=aba2_b&csp=" + |
|
46 escape("allow 'none'; frame-ancestors " + host.b + "; script-src 'self'"); |
|
47 elt.src = base.b + "?externalframe=" + escape('<iframe src="' + innerframeuri + '"></iframe>'); |
|
48 |
|
49 elt = $('abb_allow'); |
|
50 innerframeuri = base.b + "?testid=abb_allow&double=1&internalframe=abb_a&csp=" + |
|
51 escape("allow 'none'; frame-ancestors " + host.a + " " + host.b + "; script-src 'self'"); |
|
52 elt.src = base.b + "?externalframe=" + escape('<iframe src="' + innerframeuri + '"></iframe>'); |
|
53 |
|
54 elt = $('abb_block'); |
|
55 innerframeuri = base.b + "?testid=abb_allow&double=1&internalframe=abb_b&csp=" + |
|
56 escape("allow 'none'; frame-ancestors " + host.a + "; script-src 'self'"); |
|
57 elt.src = base.b + "?externalframe=" + escape('<iframe src="' + innerframeuri + '"></iframe>'); |
|
58 |
|
59 elt = $('abb2_block'); |
|
60 innerframeuri = base.b + "?testid=abb_allow&double=1&internalframe=abb2_b&csp=" + |
|
61 escape("allow 'none'; frame-ancestors " + host.b + "; script-src 'self'"); |
|
62 elt.src = base.b + "?externalframe=" + escape('<iframe src="' + innerframeuri + '"></iframe>'); |
|
63 } |
|
64 |
|
65 window.addEventListener('load', setupFrames, false); |