content/base/test/csp/test_CSP_bug802872.html

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 <!DOCTYPE HTML>
     2 <html>
     3 <head>
     4   <title>Bug 802872</title>
     5   <!-- Including SimpleTest.js so we can use waitForExplicitFinish !-->
     6   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     7   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
     8 </head>
     9 <body>
    10   <p id="display"></p>
    11   <div id="content" style="display: none"></div>
    12   <iframe style="width:100%;" id='eventframe'></iframe>
    14 <script class="testbody" type="text/javascript">
    16 SimpleTest.waitForExplicitFinish();
    18 var finishedTests = 0;
    19 var numberOfTests = 2;
    21 var checkExplicitFinish = function () {
    22   finishedTests++;
    23   if (finishedTests == numberOfTests) {
    24      SimpleTest.finish();
    25   }
    26 }
    28 SpecialPowers.pushPrefEnv(
    29   {'set':[["security.csp.speccompliant", true]]},
    30   function () {
    31     // add event listeners for CSP-permitted EventSrc callbacks
    32     addEventListener('allowedEventSrcCallbackOK', function (e) {
    33       ok(true, "OK: CSP allows EventSource for whitelisted domain!");
    34       checkExplicitFinish();
    35     }, false);
    36     addEventListener('allowedEventSrcCallbackFailed', function (e) {
    37       ok(false, "Error: CSP blocks EventSource for whitelisted domain!");
    38       checkExplicitFinish();
    39     }, false);
    41     // add event listeners for CSP-blocked EventSrc callbacks
    42     addEventListener('blockedEventSrcCallbackOK', function (e) {
    43       ok(false, "Error: CSP allows EventSource to not whitelisted domain!");
    44       checkExplicitFinish();
    45     }, false);
    46     addEventListener('blockedEventSrcCallbackFailed', function (e) {
    47       ok(true, "OK: CSP blocks EventSource for not whitelisted domain!");
    48       checkExplicitFinish();
    49     }, false);
    51     // load it
    52     document.getElementById('eventframe').src = 'file_CSP_bug802872.html';
    53   }
    54 );
    56 </script>
    57 </body>
    58 </html>

mercurial