dom/tests/mochitest/bugs/test_bug437361.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 <!--
     4 https://bugzilla.mozilla.org/show_bug.cgi?id=437361
     5 -->
     6 <head>
     7   <title>Test for Bug 437361</title>
     8   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     9   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    11   <script class="testbody" type="text/javascript">
    13   /** Test for Bug 437361 **/
    15   function testModalDialogBlockedCleanly() {
    16     is(true, SpecialPowers.getBoolPref("dom.disable_open_during_load"), "mozprefs sanity check");
    17     var rv = window.showModalDialog( // should be blocked without exception
    18       "data:text/html,<html><body onload='close(); returnValue = 1;' /></html>");
    19     is(rv, undefined, "Modal dialog opened unexpectedly.");
    20   }
    22   function testModalDialogAllowed() {
    23     is(false, SpecialPowers.getBoolPref("dom.disable_open_during_load"), "mozprefs sanity check");
    24     var rv = window.showModalDialog( // should not be blocked this time
    25       "data:text/html,<html><body onload='close(); returnValue = 1;' /></html>");
    26     is(rv, 1, "Problem with modal dialog returnValue.");
    27   }
    29   function testOtherExceptionsNotTrapped() {
    30     is(false, SpecialPowers.getBoolPref("dom.disable_open_during_load"), "mozprefs sanity check");
    31     window.showModalDialog('about:config'); // forbidden by SecurityCheckURL
    32   }
    34   function test(disableOpen, exceptionExpected, testFn, errorMsg) {
    35     var oldPrefVal = SpecialPowers.getBoolPref("dom.disable_open_during_load");
    36     try {
    37       SpecialPowers.setBoolPref("dom.disable_open_during_load", disableOpen);
    38       testFn();
    39       ok(!exceptionExpected, errorMsg);
    40     } catch (_) {
    41       ok(exceptionExpected, errorMsg);
    42     }
    43     finally {
    44       SpecialPowers.setBoolPref("dom.disable_open_during_load", oldPrefVal);
    45     }
    46   }
    48   test(true, false, testModalDialogBlockedCleanly,
    49        "Blocked showModalDialog caused an exception.");
    51   test(false, false, testModalDialogAllowed,
    52        "showModalDialog was blocked even though dom.disable_open_during_load was false.");
    54   test(false, true, testOtherExceptionsNotTrapped,
    55        "Incorrectly suppressed insecure showModalDialog exception.");
    57   </script>
    58 </head>
    59 <body>
    60 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=437361">Mozilla Bug 437361</a>
    61 <p id="display"></p>
    62 <div id="content" style="display: none"> 
    63 </div>
    64 <pre id="test">
    65 </pre>
    66 </body>
    67 </html>

mercurial