Backed out changeset d40e649ff250

This commit is contained in:
Kyle Huey 2011-10-31 11:39:46 -04:00
parent da627d5039
commit f289751612
2 changed files with 3 additions and 24 deletions

View File

@ -112,8 +112,7 @@ interface nsIContentPolicy : nsISupports
const unsigned long TYPE_PING = 10;
/**
* Indicates an XMLHttpRequest. Also used for document.load, EventSource, and
* WebSockets.
* Indicates an XMLHttpRequest. Also used for document.load and for EventSource.
*/
const unsigned long TYPE_XMLHTTPREQUEST = 11;
const unsigned long TYPE_DATAREQUEST = 11; // alias

View File

@ -76,8 +76,6 @@
#include "mozilla/Preferences.h"
#include "nsDOMLists.h"
#include "xpcpublic.h"
#include "nsContentPolicyUtils.h"
#include "nsContentErrors.h"
using namespace mozilla;
@ -1277,9 +1275,6 @@ nsWebSocket::Init(nsIPrincipal* aPrincipal,
rv = ParseURL(PromiseFlatString(aURL));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocument> originDoc =
nsContentUtils::GetDocumentFromScriptContext(mScriptContext);
// Don't allow https:// to open ws://
if (!mSecure &&
!Preferences::GetBool("network.websocket.allowInsecureFromHTTPS",
@ -1287,6 +1282,8 @@ nsWebSocket::Init(nsIPrincipal* aPrincipal,
// Confirmed we are opening plain ws:// and want to prevent this from a
// secure context (e.g. https). Check the security context of the document
// associated with this script, which is the same as associated with mOwner.
nsCOMPtr<nsIDocument> originDoc =
nsContentUtils::GetDocumentFromScriptContext(mScriptContext);
if (originDoc && originDoc->GetSecurityInfo())
return NS_ERROR_DOM_SECURITY_ERR;
}
@ -1304,23 +1301,6 @@ nsWebSocket::Init(nsIPrincipal* aPrincipal,
AppendUTF16toUTF8(protocolArray[index], mRequestedProtocolList);
}
// Check content policy.
PRInt16 shouldLoad = nsIContentPolicy::ACCEPT;
rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_DATAREQUEST,
mURI,
mPrincipal,
originDoc,
EmptyCString(),
nsnull,
&shouldLoad,
nsContentUtils::GetContentPolicy(),
nsContentUtils::GetSecurityManager());
NS_ENSURE_SUCCESS(rv, rv);
if (NS_CP_REJECTED(shouldLoad)) {
// Disallowed by content policy.
return NS_ERROR_CONTENT_BLOCKED;
}
// the constructor should throw a SYNTAX_ERROR only if it fails to parse the
// url parameter, so we don't care about the EstablishConnection result.
EstablishConnection();