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.

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

mercurial