Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 <!DOCTYPE HTML>
2 <html>
3 <meta charset="utf-8">
4 <head>
5 <title>Test MediaStreamAudioSourceNode doesn't get data from cross-origin media resources</title>
6 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
8 </head>
9 <body>
10 <pre id="test">
11 <script class="testbody" type="text/javascript">
12 SimpleTest.waitForExplicitFinish();
14 var audio = new Audio("http://example.org:80/tests/content/media/webaudio/test/small-shot.ogg");
15 var context = new AudioContext();
16 var node = context.createMediaStreamSource(audio.mozCaptureStreamUntilEnded());
17 var sp = context.createScriptProcessor(2048, 1);
18 node.connect(sp);
19 var nonzeroSampleCount = 0;
20 var complete = false;
21 var iterationCount = 0;
23 // This test ensures we receive at least expectedSampleCount nonzero samples
24 function processSamples(e) {
25 if (complete) {
26 return;
27 }
29 if (iterationCount == 0) {
30 // Don't start playing the audio until the AudioContext stuff is connected
31 // and running.
32 audio.play();
33 }
34 ++iterationCount;
36 var buf = e.inputBuffer.getChannelData(0);
37 var nonzeroSamplesThisBuffer = 0;
38 for (var i = 0; i < buf.length; ++i) {
39 if (buf[i] != 0) {
40 ++nonzeroSamplesThisBuffer;
41 }
42 }
43 is(nonzeroSamplesThisBuffer, 0,
44 "Checking all samples are zero");
45 if (iterationCount >= 20) {
46 SimpleTest.finish();
47 complete = true;
48 }
49 }
51 audio.oncanplaythrough = function() {
52 sp.onaudioprocess = processSamples;
53 };
54 </script>
55 </pre>
56 </body>
57 </html>