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