content/html/content/test/file_fullscreen-denied.html

Thu, 15 Jan 2015 15:59:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:59:08 +0100
branch
TOR_BUG_9701
changeset 10
ac0c01689b40
permissions
-rw-r--r--

Implement a real Private Browsing Mode condition by changing the API/ABI;
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=545812
     6 Test DOM full-screen API.
     8 -->
     9 <head>
    10   <title>Test for Bug 545812</title>
    11   <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
    12   <script type="application/javascript" src="file_fullscreen-utils.js"></script>
    13   <style>
    14   body {
    15     background-color: black;
    16   }
    17   </style>
    18 </head>
    19 <body>
    21 <script type="application/javascript">
    23 /** Test for Bug 545812 **/
    25 function ok(condition, msg) {
    26   opener.ok(condition, "[denied] " + msg);
    27 }
    29 function is(a, b, msg) {
    30   opener.is(a, b, "[denied] " + msg);
    31 }
    33 var gotFullScreenChange = false;
    35 function begin() {
    36   document.addEventListener("mozfullscreenchange",
    37     function() {
    38       ok(false, "Should never receive a mozfullscreenchange event in the main window.");
    39       gotFullScreenChange = true;
    40     },
    41     false);
    43   // Request full-screen from a non trusted context (this script isn't a user
    44   // generated event!).
    45   SpecialPowers.setBoolPref("full-screen-api.allow-trusted-requests-only", true);
    46   addFullscreenErrorContinuation(
    47     function() {
    48       ok(!document.mozFullScreen, "Should not grant request in non-trusted context");
    49       // Test requesting full-screen mode in a long-running user-generated event handler.
    50       // The request in the key handler should not be granted.
    51       window.addEventListener("keypress", keyHandler, false);
    52       synthesizeKey("VK_A", {});
    53     });
    54   document.body.mozRequestFullScreen();
    55 }
    57 function keyHandler(event) {
    58   window.removeEventListener("keypress", keyHandler, false);
    60   // Busy loop until 2s has passed. We should then be past the 1 second threshold, and so
    61   // our request for full-screen mode should be rejected.
    62   var end = (new Date()).getTime() + 2000;
    63   while ((new Date()).getTime() < end) {
    64     ; // Wait...
    65   }
    66   addFullscreenErrorContinuation(
    67     function() {
    68       ok(!document.mozFullScreen, "Should not grant request in long-running event handler.");
    70       // Disable the requirement for trusted contexts only, so the tests are easier
    71       // to write.
    72       SpecialPowers.setBoolPref("full-screen-api.allow-trusted-requests-only", false);
    74       // Create an iframe without a allowfullscreen attribute, whose contents requests
    75       // full-screen. The request should be denied, and we should not receive a fullscreenchange
    76       // event in this document.
    77       var iframe = document.createElement("iframe");
    78       iframe.src = "file_fullscreen-denied-inner.html";
    79       document.body.appendChild(iframe);
    80     });
    81   document.body.mozRequestFullScreen();
    82 }
    84 function finish() {
    85   ok(!gotFullScreenChange, "Should not ever grant a fullscreen request in this doc.");
    86   opener.nextTest();
    87 }
    89 </script>
    90 </pre>
    91 <div id="full-screen-element"></div>
    92 </body>
    93 </html>

mercurial