content/media/test/test_readyState.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>Media test: readyState</title>
     5   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     6   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
     7 </head>
     8 <body>
     9 <video id='v1'></video><audio id='a1'></audio>
    10 <pre id="test">
    11 <script class="testbody" type="text/javascript">
    12 "use strict";
    13 var v1 = document.getElementById('v1');
    14 var a1 = document.getElementById('a1');
    15 var passed = "truthy";
    17 is(v1.readyState, 0);
    18 is(a1.readyState, 0);
    20 try {
    21   v1.readyState = 0;
    22 } catch (e) {
    23   passed = !passed;
    24 }
    25 try {
    26   a1.readyState = 0;
    27 } catch (e) {
    28   passed = !passed;
    29 }
    30 ok(passed === true,
    31    "Setting readyState throws in strict mode (readonly attribute)");
    32 </script>
    34 <script class="testbody" type="text/javascript">
    35 var v1 = document.getElementById('v1');
    36 var a1 = document.getElementById('a1');
    37 var passed = false;
    39 is(v1.readyState, 0);
    40 is(a1.readyState, 0);
    42 try {
    43   v1.readyState = 1;
    44   a1.readyState = 1;
    45   passed = v1.readyState === 0 && a1.readyState === 0;
    46 } catch(e) { }
    47 ok(passed, "Should not be able to set readyState (readonly attribute)");
    48 </script>
    49 </pre>
    50 </body>
    51 </html>

mercurial