зеркало из https://github.com/mozilla/gecko-dev.git
Merge m-c to autoland
This commit is contained in:
Коммит
b063c8b962
|
@ -2613,7 +2613,7 @@ XMLHttpRequestMainThread::InitiateFetch(nsIInputStream* aUploadStream,
|
|||
|
||||
// Per spec, we throw on sync errors, but not async.
|
||||
if (mFlagSynchronous) {
|
||||
return NS_ERROR_DOM_NETWORK_ERR;
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2874,7 +2874,7 @@ XMLHttpRequestMainThread::SendInternal(const RequestBodyBase* aBody)
|
|||
if (!mChannel) {
|
||||
// Per spec, silently fail on async request failures; throw for sync.
|
||||
if (mFlagSynchronous) {
|
||||
return NS_ERROR_DOM_NETWORK_ERR;
|
||||
return NS_ERROR_FAILURE;
|
||||
} else {
|
||||
// Defer the actual sending of async events just in case listeners
|
||||
// are attached after the send() method is called.
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
[send-after-setting-document-domain.htm]
|
||||
type: testharness
|
||||
expected: ERROR
|
||||
[loading documents from the origin document.domain was set to should throw]
|
||||
expected: FAIL
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
[send-authentication-basic-cors-not-enabled.htm]
|
||||
type: testharness
|
||||
[XMLHttpRequest: send() - "Basic" authenticated CORS requests with user name and password passed to open() (asserts failure)]
|
||||
expected: FAIL
|
||||
|
|
@ -1,4 +1,17 @@
|
|||
[send-non-same-origin.sub.htm]
|
||||
type: testharness
|
||||
[XMLHttpRequest: send() - non same-origin (mailto:test@example.org)]
|
||||
expected: FAIL
|
||||
|
||||
[XMLHttpRequest: send() - non same-origin (tel:+31600000000)]
|
||||
expected: FAIL
|
||||
|
||||
[XMLHttpRequest: send() - non same-origin (http://www2.web-platform.test:8000/)]
|
||||
expected: FAIL
|
||||
|
||||
[XMLHttpRequest: send() - non same-origin (javascript:alert('FAIL'))]
|
||||
expected: FAIL
|
||||
|
||||
[XMLHttpRequest: send() - non same-origin (folder.txt)]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
[send-redirect-bogus-sync.htm]
|
||||
type: testharness
|
||||
[XMLHttpRequest: send() - Redirects (bogus Location header; sync) (301: foobar://abcd)]
|
||||
expected: FAIL
|
||||
|
||||
[XMLHttpRequest: send() - Redirects (bogus Location header; sync) (302: http://z)]
|
||||
expected: FAIL
|
||||
|
||||
[XMLHttpRequest: send() - Redirects (bogus Location header; sync) (302: mailto:someone@example.org)]
|
||||
expected: FAIL
|
||||
|
||||
[XMLHttpRequest: send() - Redirects (bogus Location header; sync) (303: http://z)]
|
||||
expected: FAIL
|
||||
|
||||
[XMLHttpRequest: send() - Redirects (bogus Location header; sync) (303: tel:1234567890)]
|
||||
expected: FAIL
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
[send-redirect-infinite-sync.htm]
|
||||
type: testharness
|
||||
[XMLHttpRequest: send() - Redirects (infinite loop; sync) (301)]
|
||||
expected: FAIL
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
[xmlhttprequest-network-error-sync.htm]
|
||||
type: testharness
|
||||
[XMLHttpRequest: members during network errors (sync)]
|
||||
expected: FAIL
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>XMLHttpRequest: send() with document.domain set: loading documents from original origin after setting document.domain</title>
|
||||
<script src="send-after-setting-document-domain-window-helper.js"></script>
|
||||
<link rel="help" href="https://xhr.spec.whatwg.org/#the-open()-method" data-tested-assertations="following::ol[1]/li[2]/ol[1]/li[3]" />
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
run_test(function() {
|
||||
document.domain = document.domain; // this is not a noop, it does actually change the security context
|
||||
var client = new XMLHttpRequest();
|
||||
client.open("GET", "status.py?content=hello", false);
|
||||
client.send(null);
|
||||
assert_equals(client.responseText, "hello");
|
||||
document.domain = document.domain.replace(/^\w+\./, "");
|
||||
client.open("GET", "status.py?content=hello2", false);
|
||||
client.send(null);
|
||||
assert_equals(client.responseText, "hello2");
|
||||
}, "loading documents from original origin after setting document.domain");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -1,20 +0,0 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>XMLHttpRequest: send() with document.domain set: loading documents from the origin document.domain was set to should throw</title>
|
||||
<script src="send-after-setting-document-domain-window-helper.js"></script>
|
||||
<link rel="help" href="https://xhr.spec.whatwg.org/#the-open()-method" data-tested-assertations="following::ol[1]/li[2]/ol[1]/li[3]" />
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
run_test(function() {
|
||||
document.domain = document.domain.replace(/^\w+\./, "");
|
||||
var client = new XMLHttpRequest();
|
||||
client.open("GET", location.protocol + "//" + document.domain + location.pathname.replace(/[^\/]*$/, "") + "status.py?content=hello3", false);
|
||||
assert_throws("NetworkError", function() {
|
||||
client.send(null);
|
||||
});
|
||||
}, "loading documents from the origin document.domain was set to should throw");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -1,29 +0,0 @@
|
|||
function assert_equals(value, expected) {
|
||||
if (value != expected) {
|
||||
throw "Got wrong value.\nExpected '" + expected + "',\ngot '" + value + "'";
|
||||
}
|
||||
}
|
||||
|
||||
function assert_throws(expected_exc, func) {
|
||||
try {
|
||||
func.call(this);
|
||||
} catch(e) {
|
||||
var actual = e.name || e.type;
|
||||
if (actual != expected_exc) {
|
||||
throw "Got wrong exception.\nExpected '" + expected_exc + "',\ngot '" + actual + "'.";
|
||||
}
|
||||
return;
|
||||
}
|
||||
throw "Expected exception, but none was thrown";
|
||||
}
|
||||
|
||||
function run_test(test, name) {
|
||||
var result = {passed: true, message: null, name: name};
|
||||
try {
|
||||
test();
|
||||
} catch(e) {
|
||||
result.passed = false;
|
||||
result.message = e + "";
|
||||
}
|
||||
opener.postMessage(result, "*");
|
||||
}
|
|
@ -4,36 +4,35 @@
|
|||
<title>XMLHttpRequest: send() with document.domain set</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<!-- The spec doesn't seem to explicitly cover this case (as of June 2013) -->
|
||||
<link rel="help" href="https://xhr.spec.whatwg.org/#the-open()-method" data-tested-assertations="following::ol[1]/li[2]/ol[1]/li[3]" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
var test_base_url = location.protocol+'//www2.'+location.host+"/XMLHttpRequest/resources/",
|
||||
test_windows = [
|
||||
window.open(test_base_url + "send-after-setting-document-domain-window-1.htm"),
|
||||
window.open(test_base_url + "send-after-setting-document-domain-window-2.htm"),
|
||||
],
|
||||
num_tests_left = test_windows.length;
|
||||
// first make sure we actually run off a domain with at least three parts, in order to be able to shorten it..
|
||||
if (location.hostname.split(/\./).length < 3) {
|
||||
location.href = location.protocol+'//www2.'+location.host+location.pathname
|
||||
}
|
||||
|
||||
async_test(function(wrapper_test) {
|
||||
window.addEventListener("message", function(evt) {
|
||||
// run a shadow test that just forwards the results
|
||||
async_test(function(test) {
|
||||
assert_true(evt.data.passed, evt.data.message);
|
||||
test.done();
|
||||
}, evt.data.name);
|
||||
|
||||
// after last result comes in, close all test
|
||||
// windows and complete the wrapper test.
|
||||
if (--num_tests_left == 0) {
|
||||
for (var i=0; i<test_windows.length; ++i) {
|
||||
test_windows[i].close();
|
||||
}
|
||||
wrapper_test.done();
|
||||
}
|
||||
}, false);
|
||||
}, "All tests ran");
|
||||
test(function() {
|
||||
document.domain = document.domain // this is not a noop, it does actually change the security context
|
||||
var client = new XMLHttpRequest()
|
||||
client.open("GET", "resources/status.py?content=hello", false)
|
||||
client.send(null)
|
||||
assert_equals(client.responseText, "hello")
|
||||
document.domain = document.domain.replace(/^\w+\./, '')
|
||||
client.open("GET", "resources/status.py?content=hello2", false)
|
||||
client.send(null)
|
||||
assert_equals(client.responseText, "hello2")
|
||||
}, "loading documents from original origin after setting document.domain")
|
||||
// try to load a document from the origin document.domain was set to
|
||||
test(function () {
|
||||
var client = new XMLHttpRequest()
|
||||
client.open("GET", location.protocol + '//' + document.domain + location.pathname.replace(/[^\/]*$/, '') + "resources/status.py?content=hello3", false)
|
||||
// AFAIK this should throw
|
||||
assert_throws('NetworkError', function(){client.send(null)})
|
||||
}, "loading documents from the origin document.domain was set to should throw")
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Загрузка…
Ссылка в новой задаче