зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1204269 - Use the worker private in order to determine the origin of the entry settings object for workers; r=smaug
This commit is contained in:
Родитель
c49ce9299f
Коммит
93ed1d9a46
|
@ -1546,29 +1546,35 @@ WebSocketImpl::Init(JSContext* aCx,
|
|||
!Preferences::GetBool("network.websocket.allowInsecureFromHTTPS",
|
||||
false)) {
|
||||
// Confirmed we are opening plain ws:// and want to prevent this from a
|
||||
// secure context (e.g. https). Check the principal's uri to determine if
|
||||
// we were loaded from https.
|
||||
// secure context (e.g. https).
|
||||
nsCOMPtr<nsIPrincipal> principal;
|
||||
nsCOMPtr<nsIURI> originURI;
|
||||
if (mWorkerPrivate) {
|
||||
// For workers, retrieve the URI from the WorkerPrivate
|
||||
principal = mWorkerPrivate->GetPrincipal();
|
||||
} else {
|
||||
// Check the principal's uri to determine if we were loaded from https.
|
||||
nsCOMPtr<nsIGlobalObject> globalObject(GetEntryGlobal());
|
||||
if (globalObject) {
|
||||
nsCOMPtr<nsIPrincipal> principal(globalObject->PrincipalOrNull());
|
||||
principal = globalObject->PrincipalOrNull();
|
||||
}
|
||||
}
|
||||
|
||||
if (principal) {
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
principal->GetURI(getter_AddRefs(uri));
|
||||
if (uri) {
|
||||
principal->GetURI(getter_AddRefs(originURI));
|
||||
}
|
||||
if (originURI) {
|
||||
bool originIsHttps = false;
|
||||
aRv = uri->SchemeIs("https", &originIsHttps);
|
||||
aRv = originURI->SchemeIs("https", &originIsHttps);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (originIsHttps) {
|
||||
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Assign the sub protocol list and scan it for illegal values
|
||||
for (uint32_t index = 0; index < aProtocolArray.Length(); ++index) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче