content/media/test/test_mixed_principals.html

Fri, 16 Jan 2015 04:50:19 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 04:50:19 +0100
branch
TOR_BUG_9701
changeset 13
44a2da4a2ab2
permissions
-rw-r--r--

Replace accessor implementation with direct member state manipulation, by
request https://trac.torproject.org/projects/tor/ticket/9701#comment:32

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <!--
michael@0 4 https://bugzilla.mozilla.org/show_bug.cgi?id=489415
michael@0 5 -->
michael@0 6 <head>
michael@0 7 <title>Test for Bug 489415</title>
michael@0 8 <script type="application/javascript" src="/MochiKit/MochiKit.js"></script>
michael@0 9 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
michael@0 11 <script type="text/javascript" src="manifest.js"></script>
michael@0 12 </head>
michael@0 13 <body>
michael@0 14 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=489415">Mozilla Bug 489415</a>
michael@0 15 <p id="display"></p>
michael@0 16
michael@0 17 <video id="v1" autoplay onended="loaded('v1')"></video>
michael@0 18 <video id="v2" autoplay onended="loaded('v2')"></video>
michael@0 19
michael@0 20 <pre id="test">
michael@0 21 <script type="text/javascript">
michael@0 22 SimpleTest.waitForExplicitFinish();
michael@0 23
michael@0 24 var v1 = document.getElementById("v1");
michael@0 25 var v2 = document.getElementById("v2");
michael@0 26
michael@0 27 var resource = getPlayableVideo(gSeekTests);
michael@0 28
michael@0 29 if (resource != null) {
michael@0 30 var count = 0;
michael@0 31
michael@0 32 function loaded(id) {
michael@0 33 var c = document.createElement("canvas");
michael@0 34 var ctx = c.getContext("2d");
michael@0 35 var v = document.getElementById(id);
michael@0 36 ctx.drawImage(v, 0, 0);
michael@0 37 try {
michael@0 38 c.toDataURL();
michael@0 39 ok(false, "Failed to throw exception in toDataURL for " + id);
michael@0 40 } catch (ex) {
michael@0 41 ok(true, "Threw exception in toDataURL for " + id);
michael@0 42 }
michael@0 43 if (++count == 2) {
michael@0 44 SimpleTest.finish();
michael@0 45 }
michael@0 46 }
michael@0 47
michael@0 48 // Generate a random key. The first load with that key will return
michael@0 49 // data, the second and subsequent loads with that key will return a redirect
michael@0 50 // to a different origin ('localhost:8888' will be redirected to 'example.org',
michael@0 51 // and 'example.org' will be redirected to 'localhost:8888'). We rely on the
michael@0 52 // fact that Ogg will do a seek to the end of the resource, triggering a new
michael@0 53 // load with the same key which will return a same-origin resource.
michael@0 54 // Loading data from two different origins should be detected by the media
michael@0 55 // cache and result in a null principal so that the canvas usage above fails.
michael@0 56 var key = Math.floor(Math.random()*100000000);
michael@0 57
michael@0 58 // In v1, try loading from same-origin first and then getting redirected to
michael@0 59 // another origin.
michael@0 60 v1.src = "http://mochi.test:8888/tests/content/media/test/dynamic_redirect.sjs?key=v1_" + key + "&res=" + resource.name;
michael@0 61 v1.load();
michael@0 62
michael@0 63 // In v2, try loading cross-origin first and then getting redirected to
michael@0 64 // our origin.
michael@0 65 v2.src = "http://example.org/tests/content/media/test/dynamic_redirect.sjs?key=v2_" + key + "&res=" + resource.name;
michael@0 66 v2.load();
michael@0 67
michael@0 68 } else {
michael@0 69 todo(false, "No types supported");
michael@0 70 }
michael@0 71 </script>
michael@0 72 </pre>
michael@0 73
michael@0 74 </body>
michael@0 75 </html>

mercurial