Tue, 06 Jan 2015 21:39:09 +0100
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>Test interactions of src and srcObject</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()">
10 <audio id="a"></audio>
11 <pre id="test">
12 <script class="testbody" type="text/javascript">
13 SimpleTest.waitForExplicitFinish();
15 var a = document.getElementById('a');
16 a.src = getPlayableAudio(gSmallTests).name;
18 var b = new Audio();
20 function doTest() {
21 var newSrc = a.src + "?2";
22 b.src = newSrc;
23 is(b.mozSrcObject, null, "Initial srcObject is null");
24 var stream = a.mozCaptureStream();
25 b.mozSrcObject = stream;
26 is(b.mozSrcObject, stream, "Stream set correctly");
27 try {
28 b.mozSrcObject = "invalid";
29 ok(false, "Setting mozSrcObject to an invalid value should throw.");
30 } catch (e) {
31 ok(e instanceof TypeError, "Exception should be a TypeError");
32 }
33 is(b.mozSrcObject, stream, "Stream not set to invalid value");
34 is(b.src, newSrc, "src attribute not affected by setting srcObject");
35 var step = 0;
36 b.addEventListener("loadedmetadata", function() {
37 if (step == 0) {
38 is(b.currentSrc, "", "currentSrc set to empty string while playing srcObject");
39 b.mozSrcObject = null;
40 is(b.mozSrcObject, null, "Stream set to null");
41 // The resource selection algorithm will run again and choose b.src
42 } else if (step == 1) {
43 is(b.currentSrc, b.src, "currentSrc set to src now that srcObject is null");
44 SimpleTest.finish();
45 }
46 ++step;
47 });
48 }
49 </script>
50 </pre>
51 </body>
52 </html>