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