content/base/test/csp/file_CSP_frameancestors_main.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 // Script to populate the test frames in the frame ancestors mochitest.
     2 //
     3 function setupFrames() {
     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   };
    12   var host = { a: 'http://mochi.test:8888', b: 'http://example.com:80' };
    14   var innerframeuri = null;
    15   var elt = null;
    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'");
    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'");
    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'");
    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'");
    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>');
    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>');
    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>');
    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>');
    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>');
    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 }
    65 window.addEventListener('load', setupFrames, false);

mercurial