From 4372ffbfa4b69dcdc2e2a48bce4b06f334fc999d Mon Sep 17 00:00:00 2001 From: Christoph Kerschbaumer Date: Tue, 2 Feb 2016 20:35:15 -0800 Subject: [PATCH] Bug 1195173 - Convert ExtensionProtocolHandler to use channel->Open2() (r=maglione) --- netwerk/protocol/res/ExtensionProtocolHandler.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/netwerk/protocol/res/ExtensionProtocolHandler.cpp b/netwerk/protocol/res/ExtensionProtocolHandler.cpp index 83214e3acfc..da297d1de99 100644 --- a/netwerk/protocol/res/ExtensionProtocolHandler.cpp +++ b/netwerk/protocol/res/ExtensionProtocolHandler.cpp @@ -104,8 +104,9 @@ ExtensionProtocolHandler::SubstituteChannel(nsIURI* aURI, const char* kToType = "text/css"; nsCOMPtr inputStream; - if (aLoadInfo && aLoadInfo->GetSecurityMode()) { - // Certain security checks require an async channel. + if (aLoadInfo && + aLoadInfo->GetSecurityMode() == nsILoadInfo::SEC_REQUIRE_CORS_DATA_INHERITS) { + // If the channel needs to enforce CORS, we need to open the channel async. nsCOMPtr outputStream; rv = NS_NewPipe(getter_AddRefs(inputStream), getter_AddRefs(outputStream), @@ -128,11 +129,14 @@ ExtensionProtocolHandler::SubstituteChannel(nsIURI* aURI, rv = (*result)->AsyncOpen2(converter); } else { - // Stylesheet loads for extension content scripts require a sync channel, - // but fortunately do not invoke security checks. + // Stylesheet loads for extension content scripts require a sync channel. nsCOMPtr sourceStream; - rv = (*result)->Open(getter_AddRefs(sourceStream)); + if (aLoadInfo && aLoadInfo->GetEnforceSecurity()) { + rv = (*result)->Open2(getter_AddRefs(sourceStream)); + } else { + rv = (*result)->Open(getter_AddRefs(sourceStream)); + } NS_ENSURE_SUCCESS(rv, rv); rv = convService->Convert(sourceStream, kFromType, kToType,