зеркало из https://github.com/mozilla/gecko-dev.git
Bug 814050. XMLHttpRequest.withCredentials header should throw on main thread too, in some cases. r=peterv
This commit is contained in:
Родитель
6c53c87fec
Коммит
0ec259a019
|
@ -3420,13 +3420,13 @@ nsXMLHttpRequest::WithCredentials()
|
|||
NS_IMETHODIMP
|
||||
nsXMLHttpRequest::SetWithCredentials(bool aWithCredentials)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
ErrorResult rv;
|
||||
SetWithCredentials(aWithCredentials, rv);
|
||||
return rv;
|
||||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
void
|
||||
nsXMLHttpRequest::SetWithCredentials(bool aWithCredentials, nsresult& aRv)
|
||||
nsXMLHttpRequest::SetWithCredentials(bool aWithCredentials, ErrorResult& aRv)
|
||||
{
|
||||
// Return error if we're already processing a request
|
||||
if (XML_HTTP_REQUEST_SENT & mState) {
|
||||
|
@ -3438,7 +3438,7 @@ nsXMLHttpRequest::SetWithCredentials(bool aWithCredentials, nsresult& aRv)
|
|||
if (HasOrHasHadOwner() &&
|
||||
!(mState & (XML_HTTP_REQUEST_UNSENT | XML_HTTP_REQUEST_ASYNC))) {
|
||||
LogMessage("WithCredentialsSyncXHRWarning", GetOwner());
|
||||
aRv = NS_ERROR_DOM_INVALID_ACCESS_ERR;
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -262,7 +262,7 @@ public:
|
|||
}
|
||||
void SetTimeout(uint32_t aTimeout, ErrorResult& aRv);
|
||||
bool WithCredentials();
|
||||
void SetWithCredentials(bool aWithCredentials, nsresult& aRv);
|
||||
void SetWithCredentials(bool aWithCredentials, ErrorResult& aRv);
|
||||
nsXMLHttpRequestUpload* Upload();
|
||||
|
||||
private:
|
||||
|
|
|
@ -598,6 +598,7 @@ MOCHITEST_FILES_B = \
|
|||
test_xhr_send_readystate.html \
|
||||
test_bug813919.html \
|
||||
test_bug814576.html \
|
||||
test_xhr_withCredentials.html \
|
||||
$(NULL)
|
||||
|
||||
# OOP tests don't work on Windows (bug 763081) or native-fennec
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=814050
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 814050</title>
|
||||
<script type="application/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=814050">Mozilla Bug 814050</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 814050 **/
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", "", false);
|
||||
try {
|
||||
xhr.withCredentials = true;
|
||||
ok(false, "Should throw on withCredentials sets for sync XHR");
|
||||
} catch (e) {
|
||||
ok(true, "Should throw on withCredentials sets for sync XHR");
|
||||
}
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", "", true);
|
||||
xhr.withCredentials = true;
|
||||
ok(true, "Should not throw on withCredentials sets for async XHR");
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -81,7 +81,7 @@ interface XMLHttpRequest : XMLHttpRequestEventTarget {
|
|||
[SetterThrows]
|
||||
attribute unsigned long timeout;
|
||||
|
||||
[SetterThrows=Workers]
|
||||
[SetterThrows]
|
||||
attribute boolean withCredentials;
|
||||
|
||||
[Throws=Workers]
|
||||
|
|
Загрузка…
Ссылка в новой задаче