Bug 918734 - Throw invalid state errors when XHRs fail their CheckInnerWindowCorrectness() checks, to match the XHR spec. r=khuey

--HG--
extra : rebase_source : c8f7a5b05bc318464ffb9b3cae23ae7cb8a247ea
This commit is contained in:
Thomas Wisniewski 2016-07-18 01:38:03 -04:00
Родитель 340717ad42
Коммит 5b4240186c
2 изменённых файлов: 11 добавлений и 12 удалений

Просмотреть файл

@ -1426,8 +1426,7 @@ XMLHttpRequestMainThread::Open(const nsACString& inMethod, const nsACString& url
if (!doc) {
// This could be because we're no longer current or because we're in some
// non-window context...
nsresult rv = CheckInnerWindowCorrectness();
if (NS_WARN_IF(NS_FAILED(rv))) {
if (NS_WARN_IF(NS_FAILED(CheckInnerWindowCorrectness()))) {
return NS_ERROR_DOM_INVALID_STATE_ERR;
}
}
@ -1448,8 +1447,10 @@ XMLHttpRequestMainThread::Open(const nsACString& inMethod, const nsACString& url
}
return rv;
}
rv = CheckInnerWindowCorrectness();
NS_ENSURE_SUCCESS(rv, rv);
if (NS_WARN_IF(NS_FAILED(CheckInnerWindowCorrectness()))) {
return NS_ERROR_DOM_INVALID_STATE_ERR;
}
// XXXbz this is wrong: we should only be looking at whether
// user/password were passed, not at the values! See bug 759624.
@ -1900,8 +1901,9 @@ XMLHttpRequestMainThread::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
} else {
// If we're no longer current, just kill the load, though it really should
// have been killed already.
nsresult rv = CheckInnerWindowCorrectness();
NS_ENSURE_SUCCESS(rv, rv);
if (NS_WARN_IF(NS_FAILED(CheckInnerWindowCorrectness()))) {
return NS_ERROR_DOM_INVALID_STATE_ERR;
}
}
// Create an empty document from it.
@ -2446,7 +2448,9 @@ XMLHttpRequestMainThread::Send(nsIVariant* aVariant, const Nullable<RequestBody>
PopulateNetworkInterfaceId();
nsresult rv = CheckInnerWindowCorrectness();
NS_ENSURE_SUCCESS(rv, rv);
if (NS_FAILED(rv)) {
return NS_ERROR_DOM_INVALID_STATE_ERR;
}
if (mState != State::opened || // Step 1
mFlagSend || // Step 2

Просмотреть файл

@ -1,5 +0,0 @@
[open-url-multi-window-3.htm]
type: testharness
[XMLHttpRequest: open() resolving URLs (multi-Window; 3; evil)]
expected: FAIL