content/media/test/test_mediarecorder_avoid_recursion.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 <html>
michael@0 2 <head>
michael@0 3 <title>MediaRecorder infinite recursion with requestData() calls in "dataavailable" event</title>
michael@0 4 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 5 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
michael@0 6 <script type="text/javascript" src="manifest.js"></script>
michael@0 7 </head>
michael@0 8 <body>
michael@0 9 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=897776">Mozill
michael@0 10 a Bug 897776</a>
michael@0 11 <pre id="test">
michael@0 12 <script class="testbody" type="text/javascript">
michael@0 13 function startTest() {
michael@0 14 navigator.mozGetUserMedia({audio: true, fake: true}, function(stream) {
michael@0 15 var mediaRecorder = new MediaRecorder(stream);
michael@0 16 var count = 0;
michael@0 17 mediaRecorder.start();
michael@0 18 info("mediaRecorder start");
michael@0 19 mediaRecorder.ondataavailable = function (e) {
michael@0 20 ++count;
michael@0 21 info("got ondataavailable data size = " + e.data.size);
michael@0 22 // no more requestData() to prevent busy main thread from starving
michael@0 23 // the encoding thread
michael@0 24 if (count == 30) {
michael@0 25 info("stream.stop");
michael@0 26 stream.stop();
michael@0 27 } else if (count < 30 && mediaRecorder.state == 'recording') {
michael@0 28 info("requestData again");
michael@0 29 mediaRecorder.requestData();
michael@0 30 }
michael@0 31 }
michael@0 32 mediaRecorder.requestData();
michael@0 33 info("mediaRecorder requestData");
michael@0 34 mediaRecorder.onstop = function () {
michael@0 35 ok(true, "requestData within ondataavailable successfully avoided infinite recursion");
michael@0 36 SimpleTest.finish();
michael@0 37 }
michael@0 38 }, function(err) {
michael@0 39 ok(false, 'Unexpected error fired with: ' + err);
michael@0 40 SimpleTest.finish();
michael@0 41 });
michael@0 42 }
michael@0 43
michael@0 44 SimpleTest.waitForExplicitFinish();
michael@0 45 startTest();
michael@0 46
michael@0 47 </script>
michael@0 48 </pre>
michael@0 49 </body>
michael@0 50 </html>
michael@0 51

mercurial