Back out df17cff05b54 (bug 927196) for test bustage

CLOSED TREE
This commit is contained in:
Phil Ringnalda 2013-10-25 18:28:13 -07:00
parent 93488f1541
commit d1973e4b00
9 changed files with 11 additions and 81 deletions

View File

@ -391,7 +391,7 @@ nsXMLHttpRequest::InitParameters(bool aAnon, bool aSystem)
// Chrome is always allowed access, so do the permission check only
// for non-chrome pages.
if (!IsSystemXHR() && aSystem) {
if (!IsSystemXHR()) {
nsCOMPtr<nsIDocument> doc = window->GetExtantDoc();
if (!doc) {
return;

View File

@ -198,11 +198,6 @@ public:
return nullptr;
}
if (!aParams.mMozAnon && aParams.mMozSystem) {
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
return nullptr;
}
nsRefPtr<nsXMLHttpRequest> req = new nsXMLHttpRequest();
req->Construct(principal->GetPrincipal(), global);
req->InitParameters(aParams.mMozAnon, aParams.mMozSystem);

View File

@ -520,7 +520,6 @@ support-files =
[test_bug895974.html]
[test_bug902847.html]
[test_bug907892.html]
[test_bug927196.html]
[test_caretPositionFromPoint.html]
[test_classList.html]
[test_copypaste.html]

View File

@ -465,7 +465,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=338583
function doTest5_c(test_id)
{
// credentials using the auth cache and cookies
var xhr = new XMLHttpRequest({mozAnon: true, mozSystem: true});
var xhr = new XMLHttpRequest({mozAnon: false, mozSystem: true});
xhr.withCredentials = true;
// also, test mixed mode UI
xhr.open("GET", "https://example.com/tests/content/base/test/file_restrictedEventSource.sjs?test=user1_xhr", true, "user 1", "password 1");
@ -494,7 +494,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=338583
function doTest5_d(test_id)
{
var xhr = new XMLHttpRequest({mozAnon: true, mozSystem: true});
var xhr = new XMLHttpRequest({mozAnon: false, mozSystem: true});
xhr.withCredentials = true;
xhr.open("GET", "https://example.com/tests/content/base/test/file_restrictedEventSource.sjs?test=user2_xhr", true, "user 2", "password 2");
xhr.send();
@ -522,7 +522,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=338583
function doTest5_e(test_id)
{
// credentials using the auth cache and cookies
var xhr = new XMLHttpRequest({mozAnon: true, mozSystem: true});
var xhr = new XMLHttpRequest({mozAnon: false, mozSystem: true});
xhr.withCredentials = true;
xhr.open("GET", "http://example.org/tests/content/base/test/file_restrictedEventSource.sjs?test=user1_xhr", true, "user 1", "password 1");
xhr.send();
@ -550,7 +550,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=338583
function doTest5_f(test_id)
{
var xhr = new XMLHttpRequest({mozAnon: true, mozSystem: true});
var xhr = new XMLHttpRequest({mozAnon: false, mozSystem: true});
xhr.withCredentials = true;
xhr.open("GET", "http://example.org/tests/content/base/test/file_restrictedEventSource.sjs?test=user2_xhr", true, "user 2", "password 2");
xhr.send();

View File

@ -22,7 +22,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=426308
const SJS_URL = "http://example.org:80/tests/content/base/test/bug426308-redirect.sjs";
function startTest() {
var req = new XMLHttpRequest({mozAnon: true, mozSystem: true});
var req = new XMLHttpRequest({mozAnon: false, mozSystem: true});
req.open("GET", SJS_URL + "?" + window.location.href, false);
req.send(null);

View File

@ -51,7 +51,7 @@ function createDoc() {
function xhrDoc(idx) {
return function() {
// Defy same-origin restrictions!
var xhr = new XMLHttpRequest({mozAnon: true, mozSystem: true});
var xhr = new XMLHttpRequest({mozAnon: false, mozSystem: true});
xhr.open("GET", docSources[idx], false);
xhr.send();
return xhr.responseXML;

View File

@ -19,7 +19,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=804395
<script type="application/javascript">
function test200() {
var xhr = new XMLHttpRequest({mozAnon: true, mozSystem: true});
var xhr = new XMLHttpRequest({mozAnon: false, mozSystem: true});
xhr.open('GET', 'jar:http://example.org/tests/content/base/test/file_bug804395.jar!/foo.bar', true);
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
@ -31,7 +31,7 @@ function test200() {
}
function test404() {
var xhr = new XMLHttpRequest({mozAnon: true, mozSystem: true});
var xhr = new XMLHttpRequest({mozAnon: false, mozSystem: true});
xhr.open('GET', 'jar:http://example.org/tests/content/base/test/file_bug804395.jar!/foo.do_not_exist', true);
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
@ -43,7 +43,7 @@ function test404() {
}
function test0() {
var xhr = new XMLHttpRequest({mozAnon: true, mozSystem: true});
var xhr = new XMLHttpRequest({mozAnon: false, mozSystem: true});
xhr.open('GET', 'jar:http://example.org/tests/content/base/test/file_bug804395.jar!/foo.bar', true);
ok(xhr.status == 0, "Not Sent request must have status 0");
runTests();

View File

@ -1,64 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=426308
-->
<head>
<title>Test for Bug 426308</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=927196">Mozilla Bug 927196</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
/** Test for Bug 927196 **/
function startTest() {
try {
req = new XMLHttpRequest({mozSystem: true});
ok(false, "Should not be reached");
} catch(e) {
is(e.name, "SecurityError", "XMLHttpRequest should not be mozSystem");
}
req = new XMLHttpRequest({mozAnon: true});
is(req.mozAnon, true, "XMLHttpRequest should be mozAnon");
is(req.mozSystem, false, "XMLHttpRequest should not be mozSystem");
req = new XMLHttpRequest({mozAnon: true, mozSystem: true});
is(req.mozAnon, true, "XMLHttpRequest should be mozAnon");
is(req.mozSystem, true, "XMLHttpRequest should be mozSystem");
try {
req = new XMLHttpRequest({mozAnon: false, mozSystem: true});
ok(false, "Should not be reached");
} catch(e) {
is(e.name, "SecurityError", "XMLHttpRequest should throw SecurityError");
}
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
var req = new XMLHttpRequest({mozAnon: true});
is(req.mozAnon, true, "XMLHttpRequest should be mozAnon");
is(req.mozSystem, false, "XMLHttpRequest should not be mozSystem");
req = new XMLHttpRequest({mozAnon: true, mozSystem: true});
is(req.mozAnon, false, "XMLHttpRequest should be mozAnon");
is(req.mozSystem, false, "XMLHttpRequest should not be mozSystem");
addLoadEvent(function() {
SpecialPowers.pushPermissions([{'type': 'systemXHR', 'allow': true, 'context': document}], startTest);
});
</script>
</pre>
</body>
</html>

View File

@ -70,7 +70,7 @@ function startTest() {
}
// Try setting headers in privileged context
request = new XMLHttpRequest({mozAnon: true, mozSystem: true});
request = new XMLHttpRequest({mozAnon: false, mozSystem: true});
request.open("GET", window.location.href);
for (i = 0; i < headers.length; i++)
request.setRequestHeader(headers[i], "test" + i);