content/media/test/test_standalone.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: standalone video documents</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   <script type="text/javascript" src="manifest.js"></script>
     8 </head>
     9 <body onload="doTest()">
    11 <pre id="test">
    12 <script class="testbody" type="text/javascript">
    14 var iframes = [];
    16 for (var i=0; i<gSmallTests.length; ++i) {
    17   var test = gSmallTests[i];
    19   // We can't play WAV files in stand alone documents, so just don't
    20   // run the test on non-video content types.
    21   var tag = getMajorMimeType(test.type);
    22   if (tag != "video" || !document.createElement("video").canPlayType(test.type))
    23     continue;
    25   var f = document.createElement("iframe");
    26   f.src = test.name;
    27   f._test = test;
    28   f.id = "frame" + i;
    29   iframes.push(f);
    30   document.body.appendChild(f);
    31 }
    34 function filename(uri) {
    35   return uri.substr(uri.lastIndexOf("/")+1);
    36 }
    38 function doTest()
    39 {
    40   for (var i=0; i<iframes.length; ++i) {
    41     var f = document.getElementById(iframes[i].id);
    42     var v = f.contentDocument.body.firstChild;
    43     is(v.tagName.toLowerCase(), "video", "Is video element");
    44     var src = filename(v.currentSrc);
    45     is(src, iframes[i]._test.name, "Name ("+src+") should match ("+iframes[i]._test.name+")");
    46     is(v.controls, true, "Controls set (" + src + ")");
    47     is(v.autoplay, true, "Autoplay set (" + src + ")");
    48   }
    49   SimpleTest.finish();
    50 }
    52 if (iframes.length == 0) {
    53   todo(false, "No types supported");
    54 } else {
    55   SimpleTest.waitForExplicitFinish();
    56 }
    58 </script>
    59 </pre>
    60 </body>
    61 </html>

mercurial