content/media/test/test_bug874897.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.

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <!--
michael@0 4 https://bugzilla.mozilla.org/show_bug.cgi?id=874897
michael@0 5 -->
michael@0 6
michael@0 7 <head>
michael@0 8 <title>Test for Bug 874897</title>
michael@0 9 <script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
michael@0 10 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 11 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
michael@0 12 <script type="text/javascript" src="manifest.js"></script>
michael@0 13 </head>
michael@0 14 <body>
michael@0 15 <script class="testbody" type="text/javascript">
michael@0 16
michael@0 17 var manager = new MediaTestManager;
michael@0 18
michael@0 19 function loadeddata(e) {
michael@0 20 var v = e.target;
michael@0 21 ok(v.readyState >= v.HAVE_CURRENT_DATA,
michael@0 22 "readyState must be >= HAVE_CURRENT_DATA for " + v._name);
michael@0 23
michael@0 24 var canvas = document.createElement("canvas");
michael@0 25 canvas.width = 210;
michael@0 26 canvas.height = 120;
michael@0 27 document.body.appendChild(canvas);
michael@0 28 var ctx = canvas.getContext("2d");
michael@0 29 try {
michael@0 30 ctx.drawImage(v, 0, 0, v.videoWidth, v.videoHeight, 0, 0, canvas.width, canvas.height);
michael@0 31 ok(true, "Shouldn't throw exception while drawing to canvas from video for " + v._name);
michael@0 32 } catch (ex) {
michael@0 33 ok(false, "Shouldn't throw exception while drawing to canvas from video for " + v._name);
michael@0 34 }
michael@0 35
michael@0 36 v._finished = true;
michael@0 37 v.parentNode.removeChild(v);
michael@0 38 manager.finished(v.token);
michael@0 39 }
michael@0 40
michael@0 41 function startTest(test, token) {
michael@0 42 var type = getMajorMimeType(test.type);
michael@0 43 if (type != "video")
michael@0 44 return;
michael@0 45
michael@0 46 var v = document.createElement('video');
michael@0 47 v.token = token;
michael@0 48 manager.started(token);
michael@0 49 v.src = test.name;
michael@0 50 v._name = test.name;
michael@0 51 v._finished = false;
michael@0 52 v.autoplay = true;
michael@0 53 v.style.display = "none";
michael@0 54 v.addEventListener("loadeddata", loadeddata, false);
michael@0 55 document.body.appendChild(v);
michael@0 56 }
michael@0 57
michael@0 58 SimpleTest.waitForExplicitFinish();
michael@0 59 SpecialPowers.pushPrefEnv({"set": [["media.cache_size", 40000]]}, beginTest);
michael@0 60 function beginTest() {
michael@0 61 manager.runTests(gAspectRatioTests, startTest);
michael@0 62 }
michael@0 63
michael@0 64 </script>
michael@0 65 </pre>
michael@0 66
michael@0 67 </body>
michael@0 68 </html>

mercurial