content/media/test/test_source_media.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 <head>
michael@0 4 <meta charset="utf-8">
michael@0 5 <title>Media test: media attribute for the source element.</title>
michael@0 6 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
michael@0 8 <script type="text/javascript" src="manifest.js"></script>
michael@0 9 <script type="text/javascript" src="../../html/content/test/reflect.js"></script>
michael@0 10 </head>
michael@0 11 <body>
michael@0 12 <pre id="test">
michael@0 13 <script type="text/javascript">
michael@0 14 var testCount = 0;
michael@0 15 function notifyFinished() {
michael@0 16 testCount++;
michael@0 17 if (testCount == 2) {
michael@0 18 SimpleTest.finish();
michael@0 19 }
michael@0 20 }
michael@0 21 SimpleTest.waitForExplicitFinish();
michael@0 22
michael@0 23 reflectString({
michael@0 24 element: document.createElement("source"),
michael@0 25 attribute: "media",
michael@0 26 });
michael@0 27
michael@0 28 var media = getPlayableVideo(gSmallTests);
michael@0 29
michael@0 30 if (media == null) {
michael@0 31 todo(false, "No media supported.");
michael@0 32 SimpleTest.finish();
michael@0 33 } else {
michael@0 34 var v = document.createElement('video');
michael@0 35 v.preload = "auto";
michael@0 36 v.innerHTML = "<source src=\"" + media.name + "?fail\" media=\"not all\">" +
michael@0 37 "<source src=\""+ media.name + "?pass\" media=\"all\">";
michael@0 38 var v2 = document.createElement("video");
michael@0 39 v2.preload = "auto";
michael@0 40 v2.innerHTML = "<source src=\""+ media.name +"?pass\">" +
michael@0 41 "<source src=\""+ media.name + "?fail\" media=\"all\">";
michael@0 42 document.body.appendChild(v);
michael@0 43 document.body.appendChild(v2);
michael@0 44
michael@0 45 v.addEventListener("loadedmetadata", function(e) {
michael@0 46 ok(/pass/.test(e.target.currentSrc),
michael@0 47 "The source has been chosen according to the media attribute.");
michael@0 48 notifyFinished();
michael@0 49 });
michael@0 50 v2.addEventListener("loadedmetadata", function(e) {
michael@0 51 ok(/pass/.test(e.target.currentSrc),
michael@0 52 "If no media attribute is specified, it defaults to \'all\'.")
michael@0 53 notifyFinished();
michael@0 54 });
michael@0 55 }
michael@0 56
michael@0 57 </script>
michael@0 58 </pre>
michael@0 59 </body>
michael@0 60 </html>

mercurial