content/media/test/test_mixed_principals.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/media/test/test_mixed_principals.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,75 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=489415
     1.8 +-->
     1.9 +<head>
    1.10 +  <title>Test for Bug 489415</title>
    1.11 +  <script type="application/javascript" src="/MochiKit/MochiKit.js"></script>
    1.12 +  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.13 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    1.14 +  <script type="text/javascript" src="manifest.js"></script>
    1.15 +</head>
    1.16 +<body>
    1.17 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=489415">Mozilla Bug 489415</a>
    1.18 +<p id="display"></p>
    1.19 +
    1.20 +<video id="v1" autoplay onended="loaded('v1')"></video>
    1.21 +<video id="v2" autoplay onended="loaded('v2')"></video>
    1.22 +
    1.23 +<pre id="test">
    1.24 +<script type="text/javascript">
    1.25 +SimpleTest.waitForExplicitFinish();
    1.26 +
    1.27 +var v1 = document.getElementById("v1");
    1.28 +var v2 = document.getElementById("v2");
    1.29 +
    1.30 +var resource = getPlayableVideo(gSeekTests);
    1.31 +
    1.32 +if (resource != null) {
    1.33 +  var count = 0;
    1.34 +
    1.35 +  function loaded(id) {
    1.36 +    var c = document.createElement("canvas");
    1.37 +    var ctx = c.getContext("2d");
    1.38 +    var v = document.getElementById(id);
    1.39 +    ctx.drawImage(v, 0, 0);
    1.40 +    try {
    1.41 +      c.toDataURL();
    1.42 +      ok(false, "Failed to throw exception in toDataURL for " + id);
    1.43 +    } catch (ex) {
    1.44 +      ok(true, "Threw exception in toDataURL for " + id);
    1.45 +    }
    1.46 +    if (++count == 2) {
    1.47 +      SimpleTest.finish();
    1.48 +    }
    1.49 +  }
    1.50 +
    1.51 +  // Generate a random key. The first load with that key will return
    1.52 +  // data, the second and subsequent loads with that key will return a redirect
    1.53 +  // to a different origin ('localhost:8888' will be redirected to 'example.org',
    1.54 +  // and 'example.org' will be redirected to 'localhost:8888'). We rely on the
    1.55 +  // fact that Ogg will do a seek to the end of the resource, triggering a new
    1.56 +  // load with the same key which will return a same-origin resource.
    1.57 +  // Loading data from two different origins should be detected by the media
    1.58 +  // cache and result in a null principal so that the canvas usage above fails.
    1.59 +  var key = Math.floor(Math.random()*100000000);
    1.60 +
    1.61 +  // In v1, try loading from same-origin first and then getting redirected to
    1.62 +  // another origin.
    1.63 +  v1.src = "http://mochi.test:8888/tests/content/media/test/dynamic_redirect.sjs?key=v1_" + key + "&res=" + resource.name;
    1.64 +  v1.load();
    1.65 +
    1.66 +  // In v2, try loading cross-origin first and then getting redirected to
    1.67 +  // our origin.
    1.68 +  v2.src = "http://example.org/tests/content/media/test/dynamic_redirect.sjs?key=v2_" + key + "&res=" + resource.name;
    1.69 +  v2.load();
    1.70 +  
    1.71 +} else {
    1.72 +  todo(false, "No types supported");
    1.73 +}
    1.74 +</script>
    1.75 +</pre>
    1.76 +
    1.77 +</body>
    1.78 +</html>

mercurial