зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1379345 - Transmit permissions for view-source URIs, r=ehsan
This commit is contained in:
Родитель
3f20e1f6cd
Коммит
4f71ca4422
|
@ -5135,7 +5135,17 @@ ContentParent::AboutToLoadHttpFtpWyciwygDocumentForChild(nsIChannel* aChannel)
|
|||
MOZ_ASSERT(aChannel);
|
||||
|
||||
nsresult rv;
|
||||
if (!aChannel->IsDocument()) {
|
||||
bool isDocument = aChannel->IsDocument();
|
||||
if (!isDocument) {
|
||||
// We may be looking at a nsIHttpChannel which has isMainDocumentChannel set
|
||||
// (e.g. the internal http channel for a view-source: load.).
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aChannel);
|
||||
if (httpChannel) {
|
||||
rv = httpChannel->GetIsMainDocumentChannel(&isDocument);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
}
|
||||
if (!isDocument) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -5155,9 +5165,7 @@ ContentParent::AboutToLoadHttpFtpWyciwygDocumentForChild(nsIChannel* aChannel)
|
|||
|
||||
nsLoadFlags newLoadFlags;
|
||||
aChannel->GetLoadFlags(&newLoadFlags);
|
||||
bool isDocument = false;
|
||||
aChannel->GetIsDocument(&isDocument);
|
||||
if (newLoadFlags & nsIRequest::LOAD_DOCUMENT_NEEDS_COOKIE && isDocument) {
|
||||
if (newLoadFlags & nsIRequest::LOAD_DOCUMENT_NEEDS_COOKIE) {
|
||||
UpdateCookieStatus(aChannel);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,3 +7,4 @@
|
|||
# nsPermissionManager::PermissionKey::CreateFromPrincipal. Because of this, it
|
||||
# is only run in e10s opt builds.
|
||||
skip-if = debug || !e10s
|
||||
[browser_permmgr_viewsrc.js]
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
add_task(async function() {
|
||||
// Add a permission for example.com, start a new content process, and make
|
||||
// sure that the permission has been sent down.
|
||||
Services.perms.add(Services.io.newURI("http://example.com"),
|
||||
"viewsourceTestingPerm",
|
||||
Services.perms.ALLOW_ACTION);
|
||||
|
||||
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser,
|
||||
"view-source:http://example.com",
|
||||
/* waitForLoad */ true,
|
||||
/* waitForStateStop */ false,
|
||||
/* forceNewProcess */ true);
|
||||
await ContentTask.spawn(tab.linkedBrowser, null, async function() {
|
||||
is(Services.perms.testPermission(Services.io.newURI("http://example.com"),
|
||||
"viewsourceTestingPerm"),
|
||||
Services.perms.ALLOW_ACTION);
|
||||
});
|
||||
await BrowserTestUtils.removeTab(tab);
|
||||
});
|
|
@ -150,6 +150,7 @@ struct HttpChannelOpenArgs
|
|||
TimeStamp dispatchFetchEventEnd;
|
||||
TimeStamp handleFetchEventStart;
|
||||
TimeStamp handleFetchEventEnd;
|
||||
bool forceMainDocumentChannel;
|
||||
};
|
||||
|
||||
struct HttpChannelConnectArgs
|
||||
|
|
|
@ -438,7 +438,6 @@ HttpBaseChannel::SetLoadFlags(nsLoadFlags aLoadFlags)
|
|||
}
|
||||
|
||||
mLoadFlags = aLoadFlags;
|
||||
mForceMainDocumentChannel = (aLoadFlags & LOAD_DOCUMENT_URI);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -2171,7 +2170,7 @@ NS_IMETHODIMP
|
|||
HttpBaseChannel::GetIsMainDocumentChannel(bool* aValue)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aValue);
|
||||
*aValue = mForceMainDocumentChannel || (mLoadFlags & LOAD_DOCUMENT_URI);
|
||||
*aValue = IsNavigation();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -2963,7 +2962,7 @@ HttpBaseChannel::GetURIPrincipal()
|
|||
bool
|
||||
HttpBaseChannel::IsNavigation()
|
||||
{
|
||||
return mForceMainDocumentChannel;
|
||||
return mForceMainDocumentChannel || (mLoadFlags & LOAD_DOCUMENT_URI);
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -2613,6 +2613,8 @@ HttpChannelChild::ContinueAsyncOpen()
|
|||
openArgs.handleFetchEventStart() = mHandleFetchEventStart;
|
||||
openArgs.handleFetchEventEnd() = mHandleFetchEventEnd;
|
||||
|
||||
openArgs.forceMainDocumentChannel() = mForceMainDocumentChannel;
|
||||
|
||||
// This must happen before the constructor message is sent. Otherwise messages
|
||||
// from the parent could arrive quickly and be delivered to the wrong event
|
||||
// target.
|
||||
|
|
|
@ -149,7 +149,8 @@ HttpChannelParent::Init(const HttpChannelCreationArgs& aArgs)
|
|||
a.dispatchFetchEventStart(),
|
||||
a.dispatchFetchEventEnd(),
|
||||
a.handleFetchEventStart(),
|
||||
a.handleFetchEventEnd());
|
||||
a.handleFetchEventEnd(),
|
||||
a.forceMainDocumentChannel());
|
||||
}
|
||||
case HttpChannelCreationArgs::THttpChannelConnectArgs:
|
||||
{
|
||||
|
@ -478,7 +479,8 @@ HttpChannelParent::DoAsyncOpen( const URIParams& aURI,
|
|||
const TimeStamp& aDispatchFetchEventStart,
|
||||
const TimeStamp& aDispatchFetchEventEnd,
|
||||
const TimeStamp& aHandleFetchEventStart,
|
||||
const TimeStamp& aHandleFetchEventEnd)
|
||||
const TimeStamp& aHandleFetchEventEnd,
|
||||
const bool& aForceMainDocumentChannel)
|
||||
{
|
||||
nsCOMPtr<nsIURI> uri = DeserializeURI(aURI);
|
||||
if (!uri) {
|
||||
|
@ -555,6 +557,10 @@ HttpChannelParent::DoAsyncOpen( const URIParams& aURI,
|
|||
if (aLoadFlags != nsIRequest::LOAD_NORMAL)
|
||||
httpChannel->SetLoadFlags(aLoadFlags);
|
||||
|
||||
if (aForceMainDocumentChannel) {
|
||||
httpChannel->SetIsMainDocumentChannel(true);
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < requestHeaders.Length(); i++) {
|
||||
if (requestHeaders[i].mEmpty) {
|
||||
httpChannel->SetEmptyRequestHeader(requestHeaders[i].mHeader);
|
||||
|
|
|
@ -172,7 +172,8 @@ protected:
|
|||
const TimeStamp& aDispatchFetchEventStart,
|
||||
const TimeStamp& aDispatchFetchEventEnd,
|
||||
const TimeStamp& aHandleFetchEventStart,
|
||||
const TimeStamp& aHandleFetchEventEnd);
|
||||
const TimeStamp& aHandleFetchEventEnd,
|
||||
const bool& aForceMainDocumentChannel);
|
||||
|
||||
virtual mozilla::ipc::IPCResult RecvSetPriority(const int16_t& priority) override;
|
||||
virtual mozilla::ipc::IPCResult RecvSetClassOfService(const uint32_t& cos) override;
|
||||
|
|
Загрузка…
Ссылка в новой задаче