From 5b4240186cd35b30eac0424ba53a569d405d3f6e Mon Sep 17 00:00:00 2001 From: Thomas Wisniewski Date: Mon, 18 Jul 2016 01:38:03 -0400 Subject: [PATCH] Bug 918734 - Throw invalid state errors when XHRs fail their CheckInnerWindowCorrectness() checks, to match the XHR spec. r=khuey --HG-- extra : rebase_source : c8f7a5b05bc318464ffb9b3cae23ae7cb8a247ea --- dom/xhr/XMLHttpRequestMainThread.cpp | 18 +++++++++++------- .../open-url-multi-window-3.htm.ini | 5 ----- 2 files changed, 11 insertions(+), 12 deletions(-) delete mode 100644 testing/web-platform/meta/XMLHttpRequest/open-url-multi-window-3.htm.ini diff --git a/dom/xhr/XMLHttpRequestMainThread.cpp b/dom/xhr/XMLHttpRequestMainThread.cpp index 837b19377662..8067da63e2d2 100644 --- a/dom/xhr/XMLHttpRequestMainThread.cpp +++ b/dom/xhr/XMLHttpRequestMainThread.cpp @@ -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 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 diff --git a/testing/web-platform/meta/XMLHttpRequest/open-url-multi-window-3.htm.ini b/testing/web-platform/meta/XMLHttpRequest/open-url-multi-window-3.htm.ini deleted file mode 100644 index 3ff53354ff20..000000000000 --- a/testing/web-platform/meta/XMLHttpRequest/open-url-multi-window-3.htm.ini +++ /dev/null @@ -1,5 +0,0 @@ -[open-url-multi-window-3.htm] - type: testharness - [XMLHttpRequest: open() resolving URLs (multi-Window; 3; evil)] - expected: FAIL -