2009-01-24 03:00:17 -08:00
|
|
|
<html>
|
|
|
|
<head>
|
2010-05-30 15:02:06 -07:00
|
|
|
<script type="text/javascript" src="manifest.js"></script>
|
2009-02-15 08:26:32 -08:00
|
|
|
</head>
|
|
|
|
<body onload="setTimeout(load, 0);" onunload="done()">
|
2009-01-24 03:00:17 -08:00
|
|
|
<script>
|
|
|
|
|
2009-06-25 21:23:15 -07:00
|
|
|
// Page URL: http://example.org/tests/content/media/test/file_access_controls.html
|
2009-01-24 03:00:17 -08:00
|
|
|
|
2010-05-30 15:02:06 -07:00
|
|
|
var gResource = getPlayableVideo(gSmallTests).name;
|
|
|
|
|
2009-01-24 03:00:17 -08:00
|
|
|
var gTests = [
|
|
|
|
{
|
2009-02-15 08:26:32 -08:00
|
|
|
// Test 0
|
2010-05-30 15:02:06 -07:00
|
|
|
url: "redirect.sjs?domain=example.com&file="+ gResource,
|
2009-01-24 03:00:17 -08:00
|
|
|
result: "error",
|
|
|
|
description: "Won't load when redirected to different domain",
|
|
|
|
},{
|
2009-02-15 08:26:32 -08:00
|
|
|
// Test 1
|
2010-05-30 15:02:06 -07:00
|
|
|
url: "redirect.sjs?domain=example.com&allowed&file=" + gResource,
|
2009-12-15 12:08:59 -08:00
|
|
|
result: "loadeddata",
|
2009-01-24 03:00:17 -08:00
|
|
|
description: "Can load when redirected to different domain with allow-origin",
|
|
|
|
},{
|
2009-02-15 08:26:32 -08:00
|
|
|
// Test 2
|
2010-05-30 15:02:06 -07:00
|
|
|
url: "redirect.sjs?domain=test1.example.org&file=" + gResource,
|
2009-01-24 03:00:17 -08:00
|
|
|
result: "error",
|
|
|
|
description: "Won't load when redirected to subdomain",
|
|
|
|
},{
|
2009-02-15 08:26:32 -08:00
|
|
|
// Test 3
|
2010-05-30 15:02:06 -07:00
|
|
|
url: "redirect.sjs?domain=test1.example.org&allowed&file=" + gResource,
|
2009-12-15 12:08:59 -08:00
|
|
|
result: "loadeddata",
|
2009-01-24 03:00:17 -08:00
|
|
|
description: "Can load when redirected to subdomain with allow-origin",
|
|
|
|
},{
|
2009-02-15 08:26:32 -08:00
|
|
|
// Test 4
|
2010-05-30 15:02:06 -07:00
|
|
|
url: "redirect.sjs?domain=example.org&file=" + gResource,
|
2009-12-15 12:08:59 -08:00
|
|
|
result: "loadeddata",
|
2009-01-24 03:00:17 -08:00
|
|
|
description: "Can load when redirected to same domain",
|
|
|
|
},{
|
2009-02-15 08:26:32 -08:00
|
|
|
// Test 5
|
2010-05-30 15:02:06 -07:00
|
|
|
url: "http://example.org/tests/content/media/test/" + gResource,
|
2009-12-15 12:08:59 -08:00
|
|
|
result: "loadeddata",
|
2009-01-24 03:00:17 -08:00
|
|
|
description: "Can load from same domain"
|
|
|
|
},{
|
2009-02-15 08:26:32 -08:00
|
|
|
// Test 6
|
2010-05-30 15:02:06 -07:00
|
|
|
url: "http://example.org:8000/tests/content/media/test/" + gResource,
|
2009-01-24 03:00:17 -08:00
|
|
|
result: "error",
|
2010-05-13 05:19:50 -07:00
|
|
|
description: "Won't load from different port on same domain"
|
2009-01-24 03:00:17 -08:00
|
|
|
},{
|
2009-02-15 08:26:32 -08:00
|
|
|
// Test 7
|
2010-05-30 15:02:06 -07:00
|
|
|
url: "http://example.org:8000/tests/content/media/test/allowed.sjs?" + gResource,
|
2009-12-15 12:08:59 -08:00
|
|
|
result: "loadeddata",
|
2009-01-24 03:00:17 -08:00
|
|
|
description: "Can load from different port on same domain with allow-origin",
|
|
|
|
},{
|
2009-02-15 08:26:32 -08:00
|
|
|
// Test 8
|
2010-05-30 15:02:06 -07:00
|
|
|
url: "http://example.com/tests/content/media/test/" + gResource,
|
2009-01-24 03:00:17 -08:00
|
|
|
result: "error",
|
|
|
|
description: "Won't load cross domain",
|
|
|
|
},{
|
2009-02-15 08:26:32 -08:00
|
|
|
// Test 9
|
2010-05-30 15:02:06 -07:00
|
|
|
url: "http://example.com/tests/content/media/test/allowed.sjs?" + gResource,
|
2009-12-15 12:08:59 -08:00
|
|
|
result: "loadeddata",
|
2009-01-24 03:00:17 -08:00
|
|
|
description: "Can load cross domain with allow-origin",
|
|
|
|
},{
|
2009-02-15 08:26:32 -08:00
|
|
|
// Test 10
|
2010-05-30 15:02:06 -07:00
|
|
|
url: "http://test1.example.org/tests/content/media/test/allowed.sjs?" + gResource,
|
2009-12-15 12:08:59 -08:00
|
|
|
result: "loadeddata",
|
2009-01-24 03:00:17 -08:00
|
|
|
description: "Can load from subdomain with allow-origin",
|
|
|
|
},{
|
2009-02-15 08:26:32 -08:00
|
|
|
// Test 11
|
2010-05-30 15:02:06 -07:00
|
|
|
url: "http://test1.example.org/tests/content/media/test/" + gResource,
|
2009-01-24 03:00:17 -08:00
|
|
|
result: "error",
|
|
|
|
description: "Won't load from subdomain",
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
var gTestNum = 0;
|
2009-02-15 08:26:32 -08:00
|
|
|
var gVideo = null;
|
2009-01-24 03:00:17 -08:00
|
|
|
var gTestedRemoved = false;
|
|
|
|
var gOldPref;
|
|
|
|
|
2009-12-15 12:08:59 -08:00
|
|
|
function eventHandler(event) {
|
2009-01-24 03:00:17 -08:00
|
|
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
2009-12-15 12:08:59 -08:00
|
|
|
//dump((gTestNum - 1) + ": " + event.type + "\n");
|
|
|
|
var video = event.target;
|
|
|
|
opener.is(event.type, video.expectedResult, video.testDescription +
|
|
|
|
(gTestedRemoved ? " (element not in document)" : " (element in document)"));
|
|
|
|
// Make sure any extra events cause an error
|
|
|
|
video.expectedResult = "<none>";
|
2009-01-24 03:00:17 -08:00
|
|
|
nextTest();
|
|
|
|
}
|
|
|
|
|
2009-02-15 08:26:32 -08:00
|
|
|
function createVideo() {
|
|
|
|
var v = document.createElement('video');
|
2009-12-15 12:08:59 -08:00
|
|
|
v.addEventListener('loadeddata', eventHandler, false);
|
|
|
|
v.addEventListener('error', eventHandler, false);
|
2009-02-15 08:26:32 -08:00
|
|
|
return v;
|
|
|
|
}
|
|
|
|
|
2009-01-24 03:00:17 -08:00
|
|
|
function load() {
|
|
|
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
|
|
|
opener.is(window.location.href,
|
2009-06-25 21:23:15 -07:00
|
|
|
"http://example.org/tests/content/media/test/file_access_controls.html",
|
2009-01-24 03:00:17 -08:00
|
|
|
"We must be on a example.org:80");
|
2009-02-15 08:26:32 -08:00
|
|
|
|
2009-01-24 03:00:17 -08:00
|
|
|
// Ensure access control check pref is on.
|
|
|
|
// media.enforce_same_site_origin
|
|
|
|
var prefService = Components.classes["@mozilla.org/preferences-service;1"]
|
|
|
|
.getService(Components.interfaces.nsIPrefService);
|
|
|
|
opener.ok(prefService!=null, "Get pref service");
|
|
|
|
var branch = prefService.getBranch("media.");
|
|
|
|
opener.ok(branch!=null, "Get media pref branch");
|
|
|
|
gOldPref = branch.getBoolPref("enforce_same_site_origin");
|
|
|
|
branch.setBoolPref("enforce_same_site_origin", true);
|
|
|
|
nextTest();
|
|
|
|
}
|
|
|
|
|
|
|
|
function nextTest() {
|
2009-02-15 08:26:32 -08:00
|
|
|
//dump("nextTest() called, gTestNum="+gTestNum+" gTestedRemoved="+gTestedRemoved+"\n");
|
2009-01-24 03:00:17 -08:00
|
|
|
if (gTestNum == gTests.length) {
|
2009-02-15 08:26:32 -08:00
|
|
|
//dump("gTestNum == gTests.length\n");
|
2009-01-24 03:00:17 -08:00
|
|
|
if (!gTestedRemoved) {
|
|
|
|
// Repeat all tests with element removed from doc, should get same result.
|
|
|
|
gTestedRemoved = true;
|
|
|
|
gTestNum = 0;
|
|
|
|
} else {
|
2009-02-15 08:26:32 -08:00
|
|
|
//dump("Exiting...\n");
|
2009-01-24 03:00:17 -08:00
|
|
|
// We're done, exit the test.
|
|
|
|
window.close();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2009-02-19 18:49:00 -08:00
|
|
|
|
|
|
|
if (gVideo && gVideo.parentNode)
|
|
|
|
gVideo.parentNode.removeChild(gVideo);
|
2010-08-26 19:11:46 -07:00
|
|
|
|
|
|
|
gVideo = null;
|
|
|
|
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
|
|
|
Components.utils.forceGC();
|
2009-02-15 08:26:32 -08:00
|
|
|
|
|
|
|
gVideo = createVideo();
|
2009-12-15 12:08:59 -08:00
|
|
|
gVideo.expectedResult = gTests[gTestNum].result;
|
|
|
|
gVideo.testDescription = gTests[gTestNum].description;
|
2009-02-15 08:26:32 -08:00
|
|
|
gVideo.src = gTests[gTestNum].url;
|
2009-12-15 12:08:59 -08:00
|
|
|
//dump("Starting test " + gTestNum + " at " + gVideo.src + " expecting:" + gVideo.expectedResult + "\n");
|
2009-02-15 08:26:32 -08:00
|
|
|
if (!gTestedRemoved) {
|
|
|
|
document.body.appendChild(gVideo);
|
|
|
|
// Will cause load() to be invoked.
|
|
|
|
} else {
|
|
|
|
gVideo.load();
|
|
|
|
}
|
2009-01-24 03:00:17 -08:00
|
|
|
gTestNum++;
|
|
|
|
}
|
|
|
|
|
|
|
|
function done() {
|
|
|
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
|
|
|
// Undo change to access control check pref.
|
|
|
|
var prefService = Components.classes["@mozilla.org/preferences-service;1"]
|
|
|
|
.getService(Components.interfaces.nsIPrefService);
|
|
|
|
var branch = prefService.getBranch("media.");
|
|
|
|
branch.setBoolPref("enforce_same_site_origin", gOldPref);
|
2010-08-26 19:11:46 -07:00
|
|
|
mediaTestCleanup();
|
2009-01-24 03:00:17 -08:00
|
|
|
opener.done();
|
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
|