Bug 633667: Per the spec, return NPRES_USER_BREAK when a plugin rejects an HTTP redirect, not NPRES_NETWORK_ERR. r=bsmedberg a=blocking2.0final+

This commit is contained in:
Josh Aas 2011-02-14 11:50:27 -05:00
parent ecb7086c9a
commit 2c810200dc
3 changed files with 10 additions and 4 deletions

View File

@ -161,6 +161,7 @@ mIsSuspended(PR_FALSE),
mIsPluginInitJSStream(mInst->mInPluginInitCall && mIsPluginInitJSStream(mInst->mInPluginInitCall &&
aURL && strncmp(aURL, "javascript:", aURL && strncmp(aURL, "javascript:",
sizeof("javascript:") - 1) == 0), sizeof("javascript:") - 1) == 0),
mRedirectDenied(PR_FALSE),
mResponseHeaderBuf(nsnull) mResponseHeaderBuf(nsnull)
{ {
memset(&mNPStream, 0, sizeof(mNPStream)); memset(&mNPStream, 0, sizeof(mNPStream));
@ -765,16 +766,19 @@ nsNPAPIPluginStreamListener::OnStopBinding(nsIPluginStreamInfo* pluginInfo,
if (!mInst || !mInst->CanFireNotifications()) if (!mInst || !mInst->CanFireNotifications())
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
// check if the stream is of seekable type and later its destruction // check if the stream is of seekable type and later its destruction
// see bug 91140 // see bug 91140
nsresult rv = NS_OK; nsresult rv = NS_OK;
NPReason reason = NS_FAILED(status) ? NPRES_NETWORK_ERR : NPRES_DONE; NPReason reason = NS_FAILED(status) ? NPRES_NETWORK_ERR : NPRES_DONE;
if (mRedirectDenied) {
reason = NPRES_USER_BREAK;
}
if (mStreamType != NP_SEEK || if (mStreamType != NP_SEEK ||
(NP_SEEK == mStreamType && NS_BINDING_ABORTED == status)) { (NP_SEEK == mStreamType && NS_BINDING_ABORTED == status)) {
rv = CleanUpStream(reason); rv = CleanUpStream(reason);
} }
return rv; return rv;
} }
@ -892,6 +896,7 @@ nsNPAPIPluginStreamListener::URLRedirectResponse(NPBool allow)
{ {
if (mHTTPRedirectCallback) { if (mHTTPRedirectCallback) {
mHTTPRedirectCallback->OnRedirectVerifyCallback(allow ? NS_OK : NS_ERROR_FAILURE); mHTTPRedirectCallback->OnRedirectVerifyCallback(allow ? NS_OK : NS_ERROR_FAILURE);
mRedirectDenied = allow ? PR_FALSE : PR_TRUE;
mHTTPRedirectCallback = nsnull; mHTTPRedirectCallback = nsnull;
} }
} }

View File

@ -150,6 +150,7 @@ protected:
PRPackedBool mCallNotify; PRPackedBool mCallNotify;
PRPackedBool mIsSuspended; PRPackedBool mIsSuspended;
PRPackedBool mIsPluginInitJSStream; PRPackedBool mIsPluginInitJSStream;
PRPackedBool mRedirectDenied;
nsCString mResponseHeaders; nsCString mResponseHeaders;
char* mResponseHeaderBuf; char* mResponseHeaderBuf;
nsCOMPtr<nsITimer> mDataPumpTimer; nsCOMPtr<nsITimer> mDataPumpTimer;

View File

@ -34,7 +34,7 @@
function test1() { function test1() {
expectedWriteURL = ""; expectedWriteURL = "";
expectedNotifyStatus = 1; expectedNotifyStatus = 2;
p.streamTest(redirectingURL, false, null, writeCallback, notifyCallback, redirectCallback, false); p.streamTest(redirectingURL, false, null, writeCallback, notifyCallback, redirectCallback, false);
} }