diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/media/test/test_mixed_principals.html | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/media/test/test_mixed_principals.html')
-rw-r--r-- | dom/media/test/test_mixed_principals.html | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/dom/media/test/test_mixed_principals.html b/dom/media/test/test_mixed_principals.html new file mode 100644 index 000000000..d3f7ec257 --- /dev/null +++ b/dom/media/test/test_mixed_principals.html @@ -0,0 +1,94 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=489415 +--> +<head> + <title>Test for Bug 489415</title> + <script type="application/javascript" src="/MochiKit/MochiKit.js"></script> + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> + <script type="text/javascript" src="manifest.js"></script> +</head> +<body> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=489415">Mozilla Bug 489415</a> +<p id="display"></p> + +<video id="v1" preload="metadata" onended="onendedcb('v1')"></video> +<video id="v2" preload="metadata" onended="onendedcb('v2')"></video> + +<pre id="test"> +<script type="text/javascript"> +SimpleTest.waitForExplicitFinish(); + +var pushPrefs = (...p) => new Promise(r => SpecialPowers.pushPrefEnv({set: p}, r)); + +var v1 = document.getElementById("v1"); +var v2 = document.getElementById("v2"); +var count = 0; + +function onendedcb(id) { + var c = document.createElement("canvas"); + var ctx = c.getContext("2d"); + var v = document.getElementById(id); + ctx.drawImage(v, 0, 0); + try { + c.toDataURL(); + ok(false, "Failed to throw exception in toDataURL for " + id); + } catch (ex) { + ok(true, "Threw exception in toDataURL for " + id); + } + if (++count == 2) { + SimpleTest.finish(); + } +} + +function testMixedPrincipals(resource) { + // In some OS(XP) can not play mp4. Add this checking for the test failure. + if (!resource || !v1.canPlayType(resource.type)) { + todo(false, "No types supported"); + SimpleTest.finish(); + return; + } + // Make sure the media cache size(50MB) is large enough that the data could + // be download in MediaCache completely. + return pushPrefs(['media.cache_size', 50*1024]) + .then(() => { + + // Generate a random key. The first load with that key will return + // data, the second and subsequent loads with that key will return a redirect + // to a different origin ('localhost:8888' will be redirected to 'example.org', + // and 'example.org' will be redirected to 'localhost:8888'). We rely on the + // fact that Ogg will do a seek to the end of the resource, triggering a new + // load with the same key which will return a same-origin resource. + // Loading data from two different origins should be detected by the media + // cache and result in a null principal so that the canvas usage above fails. + var key = Math.floor(Math.random()*100000000); + + // In v1, try loading from same-origin first and then getting redirected to + // another origin. + v1.src = + "http://mochi.test:8888/tests/dom/media/test/dynamic_redirect.sjs?key=v1_" + + key + "&res=" + resource.name; + v1.onloadeddata = function () { + // To limit readahead, avoid racing with playback and "catching up" mode. + v1.play(); + } + + // In v2, try loading cross-origin first and then getting redirected to + // our origin. + v2.src = "http://example.org/tests/dom/media/test/dynamic_redirect.sjs?key=v2_" + key + "&res=" + resource.name; + v2.onloadeddata = function () { + // To limit readahead, avoid racing with playback and "catching up" mode. + v2.play(); + } + }); +} + +testMixedPrincipals({ name:"pixel_aspect_ratio.mp4", type:"video/mp4", duration:28}); + +</script> +</pre> + +</body> +</html> |