mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 909993 - Add WebIDL for TextTrackCue and fix link in VTTCue.webidl. r=rillian r=bz (24a78498b) - Bug 1044102 - Part 4 - update W3C web platform tests. r=smaug (1379beb25) - Bug 1159830 - Autophone - webappstartup should not use console.log to output WEBAPP STARTUP COMPLETE. r=snorp, r=froydnj (f85a43beb) - Bug 1152574: Fix console service discarding to run when it is actually safe to do so (off of inner-window-destroyed). Also add a backstop at xpcom-shutdown to discard any cycle collected messages before it is too late. r=froydnj (01f6f8708) - Bug 1152574 - Do not report aborted XHR requests in web console (r=sicking) (814b8868d) - Bug 1186589 - Ensure CORS preflight requests are never intercepted. r=sicking (f0484fbe5) - namespace (6dc7db16d) - namespace (585e04c34) - Bug 1179505 - Make LoadInfo arguments optional in ipdl (r=bent,sicking) (c9d2efa2a) - fix old misspatch (3950e6fae) - Bug 1219027. Fix unbinding transformfeedback when deleting it. r=djg I believe this was the original intention of the code. This fixes deletion conformance tests. (3878dade7) - Bug 1175803 - Store redirect chain within loadInfo - part 1 (r=sicking,mayhemer) (5b0ea460a) - Bug 1143922 - Add AsyncOpen2 to nsIChannel and perform security checks when opening a channel - loadinfo changes (r=sicking,tanvi,sworkman) (46ab73d45) - Bug 1175803 - Store redirect chain within loadInfo - part 2 (r=sicking,mayhemer) (6181a439c) - Bug 1180964 - Provide a C++ friendly version of LoadInfo on nsIChanne version of LoadInfo on nsIChanne (563a98940) - Bug 1175803 - Store redirect chain within loadInfo - part 3 e10s (r=mrbkap,mayhemer) (7bf552870)
This commit is contained in:
@@ -42,7 +42,6 @@
|
||||
#include "WindowNamedPropertiesHandler.h"
|
||||
#include "nsFrameSelection.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIConsoleService.h"
|
||||
|
||||
// Helper Classes
|
||||
#include "nsJSUtils.h"
|
||||
@@ -1551,12 +1550,6 @@ nsGlobalWindow::FreeInnerObjects(bool aForDocumentOpen)
|
||||
{
|
||||
NS_ASSERTION(IsInnerWindow(), "Don't free inner objects on an outer window");
|
||||
|
||||
// Prune messages related to this window in the console cache
|
||||
nsCOMPtr<nsIConsoleService> console(do_GetService("@mozilla.org/consoleservice;1"));
|
||||
if (console) {
|
||||
console->ClearMessagesForWindowID(mWindowID);
|
||||
}
|
||||
|
||||
// Make sure that this is called before we null out the document and
|
||||
// other members that the window destroyed observers could
|
||||
// re-create.
|
||||
|
||||
@@ -42,7 +42,7 @@ WebGL2Context::DeleteTransformFeedback(WebGLTransformFeedback* tf)
|
||||
return;
|
||||
|
||||
if (mBoundTransformFeedback == tf)
|
||||
BindTransformFeedback(LOCAL_GL_TRANSFORM_FEEDBACK, tf);
|
||||
BindTransformFeedback(LOCAL_GL_TRANSFORM_FEEDBACK, nullptr);
|
||||
|
||||
tf->RequestDelete();
|
||||
}
|
||||
|
||||
@@ -4206,13 +4206,14 @@ ContentParent::GetConsoleService()
|
||||
return mConsoleService.get();
|
||||
}
|
||||
|
||||
// XXXkhuey everything about this is terrible.
|
||||
// Get the ConsoleService by CID rather than ContractID, so that we
|
||||
// can cast the returned pointer to an nsConsoleService (rather than
|
||||
// just an nsIConsoleService). This allows us to call the non-idl function
|
||||
// nsConsoleService::LogMessageWithMode.
|
||||
NS_DEFINE_CID(consoleServiceCID, NS_CONSOLESERVICE_CID);
|
||||
nsCOMPtr<nsConsoleService> consoleService(do_GetService(consoleServiceCID));
|
||||
mConsoleService = consoleService;
|
||||
nsCOMPtr<nsIConsoleService> consoleService(do_GetService(consoleServiceCID));
|
||||
mConsoleService = static_cast<nsConsoleService*>(consoleService.get());
|
||||
return mConsoleService.get();
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ BlockMixedActiveContent = Blocked loading mixed active content "%1$S"
|
||||
# CORS
|
||||
# LOCALIZATION NOTE: Do not translate "Access-Control-Allow-Origin", Access-Control-Allow-Credentials, Access-Control-Allow-Methods, Access-Control-Allow-Headers
|
||||
CORSDisabled=Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at %1$S. (Reason: CORS disabled).
|
||||
CORSRequestFailed=Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at %1$S. (Reason: CORS request failed).
|
||||
CORSRequestNotHttp=Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at %1$S. (Reason: CORS request not http).
|
||||
CORSMissingAllowOrigin=Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at %1$S. (Reason: CORS header 'Access-Control-Allow-Origin' missing).
|
||||
CORSAllowOriginNotMatchingOrigin=Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at %1$S. (Reason: CORS header 'Access-Control-Allow-Origin' does not match '%2$S').
|
||||
|
||||
@@ -45,11 +45,13 @@ SpecialPowers.pushPrefEnv({"set": [["media.webvtt.regions.enabled", true]]},
|
||||
is(cueList.length, 6, "Cue list length should be 6.");
|
||||
|
||||
// Check that the typedef of TextTrackCue works in Gecko.
|
||||
is(window.TextTrackCue, undefined, "TextTrackCue should be undefined.");
|
||||
isnot(window.TextTrackCue, undefined, "TextTrackCue should be defined.");
|
||||
isnot(window.VTTCue, undefined, "VTTCue should be defined.");
|
||||
|
||||
// Check if first cue was parsed correctly.
|
||||
var cue = cueList[0];
|
||||
ok(cue instanceof TextTrackCue, "Cue should be an instanceof TextTrackCue.");
|
||||
ok(cue instanceof VTTCue, "Cue should be an instanceof VTTCue.");
|
||||
is(cue.id, "1", "Cue's ID should be 1.");
|
||||
is(cue.startTime, 0.5, "Cue's start time should be 0.5.");
|
||||
is(cue.endTime, 0.7, "Cue's end time should be 0.7.");
|
||||
|
||||
@@ -537,14 +537,8 @@ nsCORSListenerProxy::CheckRequestApproved(nsIRequest* aRequest)
|
||||
// Check if the request failed
|
||||
nsresult status;
|
||||
nsresult rv = aRequest->GetStatus(&status);
|
||||
if (NS_FAILED(rv)) {
|
||||
LogBlockedRequest(aRequest, "CORSRequestFailed", nullptr);
|
||||
return rv;
|
||||
}
|
||||
if (NS_FAILED(status)) {
|
||||
LogBlockedRequest(aRequest, "CORSRequestFailed", nullptr);
|
||||
return status;
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_SUCCESS(status, status);
|
||||
|
||||
// Test that things worked on a HTTP level
|
||||
nsCOMPtr<nsIHttpChannel> http = do_QueryInterface(aRequest);
|
||||
@@ -1312,6 +1306,12 @@ NS_StartCORSPreflight(nsIChannel* aRequestChannel,
|
||||
|
||||
rv = preHttp->SetRequestMethod(NS_LITERAL_CSTRING("OPTIONS"));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Preflight requests should never be intercepted by service workers.
|
||||
nsCOMPtr<nsIHttpChannelInternal> preInternal = do_QueryInterface(preflightChannel);
|
||||
if (preInternal) {
|
||||
preInternal->ForceNoIntercept();
|
||||
}
|
||||
|
||||
// Set up listener which will start the original channel
|
||||
nsCOMPtr<nsIStreamListener> preflightListener =
|
||||
|
||||
@@ -1277,6 +1277,8 @@ var interfaceNamesInGlobalScope =
|
||||
"TextMetrics",
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
"TextTrack",
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
"TextTrackCue",
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
"TextTrackCueList",
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* The origin of this IDL file is
|
||||
* https://html.spec.whatwg.org/#texttrackcue
|
||||
*/
|
||||
|
||||
[Pref="media.webvtt.enabled"]
|
||||
interface TextTrackCue : EventTarget {
|
||||
readonly attribute TextTrack? track;
|
||||
|
||||
attribute DOMString id;
|
||||
attribute double startTime;
|
||||
attribute double endTime;
|
||||
attribute boolean pauseOnExit;
|
||||
|
||||
attribute EventHandler onenter;
|
||||
attribute EventHandler onexit;
|
||||
};
|
||||
@@ -4,7 +4,7 @@
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* The origin of this IDL file is
|
||||
* http://www.whatwg.org/specs/web-apps/current-work/#texttrackcue
|
||||
* http://dev.w3.org/html5/webvtt/#the-vttcue-interface
|
||||
*/
|
||||
|
||||
enum AutoKeyword { "auto" };
|
||||
@@ -25,13 +25,7 @@ enum DirectionSetting {
|
||||
|
||||
[Constructor(double startTime, double endTime, DOMString text),
|
||||
Pref="media.webvtt.enabled"]
|
||||
interface VTTCue : EventTarget {
|
||||
readonly attribute TextTrack? track;
|
||||
|
||||
attribute DOMString id;
|
||||
attribute double startTime;
|
||||
attribute double endTime;
|
||||
attribute boolean pauseOnExit;
|
||||
interface VTTCue : TextTrackCue {
|
||||
[Pref="media.webvtt.regions.enabled"]
|
||||
attribute VTTRegion? region;
|
||||
attribute DirectionSetting vertical;
|
||||
@@ -48,10 +42,6 @@ interface VTTCue : EventTarget {
|
||||
attribute AlignSetting align;
|
||||
attribute DOMString text;
|
||||
DocumentFragment getCueAsHTML();
|
||||
|
||||
attribute EventHandler onenter;
|
||||
|
||||
attribute EventHandler onexit;
|
||||
};
|
||||
|
||||
// Mozilla extensions.
|
||||
|
||||
@@ -524,6 +524,7 @@ WEBIDL_FILES = [
|
||||
'TextDecoder.webidl',
|
||||
'TextEncoder.webidl',
|
||||
'TextTrack.webidl',
|
||||
'TextTrackCue.webidl',
|
||||
'TextTrackCueList.webidl',
|
||||
'TextTrackList.webidl',
|
||||
'ThreadSafeChromeUtils.webidl',
|
||||
|
||||
@@ -140,6 +140,12 @@ fetchXHR('http://example.com/tests/dom/security/test/cors/file_CrossSiteXHR_serv
|
||||
finish();
|
||||
});
|
||||
|
||||
// Test that CORS preflight requests cannot be intercepted
|
||||
fetchXHR('http://example.com/tests/dom/security/test/cors/file_CrossSiteXHR_server.sjs?status=200&allowOrigin=*', null, function(xhr) {
|
||||
my_ok(xhr.status == 0, "cross origin load with incorrect headers should be a failure");
|
||||
finish();
|
||||
}, [["X-Unsafe", "unsafe"]]);
|
||||
|
||||
// Test that when the page fetches a url the controlling SW forces a redirect to
|
||||
// another location. This other location fetch should also be intercepted by
|
||||
// the SW.
|
||||
|
||||
@@ -7,6 +7,16 @@ onfetch = function(ev) {
|
||||
));
|
||||
}
|
||||
|
||||
else if (ev.request.url.includes('file_CrossSiteXHR_server.sjs')) {
|
||||
// N.B. this response would break the rules of CORS if it were allowed, but
|
||||
// this test relies upon the preflight request not being intercepted and
|
||||
// thus this response should not be used.
|
||||
if (ev.request.method == 'OPTIONS') {
|
||||
ev.respondWith(new Response('', {headers: {'Access-Control-Allow-Origin': '*',
|
||||
'Access-Control-Allow-Headers': 'X-Unsafe'}}))
|
||||
}
|
||||
}
|
||||
|
||||
else if (ev.request.url.includes("synthesized-404.txt")) {
|
||||
ev.respondWith(Promise.resolve(
|
||||
new Response("synthesized response body", { status: 404 })
|
||||
|
||||
@@ -16,8 +16,15 @@
|
||||
#include "nsNullPrincipal.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsString.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace net {
|
||||
class OptionalLoadInfoArgs;
|
||||
}
|
||||
|
||||
using namespace mozilla::net;
|
||||
|
||||
namespace ipc {
|
||||
|
||||
already_AddRefed<nsIPrincipal>
|
||||
@@ -220,66 +227,90 @@ PrincipalToPrincipalInfo(nsIPrincipal* aPrincipal,
|
||||
|
||||
nsresult
|
||||
LoadInfoToLoadInfoArgs(nsILoadInfo *aLoadInfo,
|
||||
mozilla::net::LoadInfoArgs* aLoadInfoArgs)
|
||||
OptionalLoadInfoArgs* aOptionalLoadInfoArgs)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (aLoadInfo) {
|
||||
rv = PrincipalToPrincipalInfo(aLoadInfo->LoadingPrincipal(),
|
||||
&aLoadInfoArgs->requestingPrincipalInfo());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = PrincipalToPrincipalInfo(aLoadInfo->TriggeringPrincipal(),
|
||||
&aLoadInfoArgs->triggeringPrincipalInfo());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
aLoadInfoArgs->securityFlags() = aLoadInfo->GetSecurityFlags();
|
||||
aLoadInfoArgs->contentPolicyType() = aLoadInfo->InternalContentPolicyType();
|
||||
aLoadInfoArgs->upgradeInsecureRequests() = aLoadInfo->GetUpgradeInsecureRequests();
|
||||
aLoadInfoArgs->innerWindowID() = aLoadInfo->GetInnerWindowID();
|
||||
aLoadInfoArgs->outerWindowID() = aLoadInfo->GetOuterWindowID();
|
||||
aLoadInfoArgs->parentOuterWindowID() = aLoadInfo->GetParentOuterWindowID();
|
||||
if (!aLoadInfo) {
|
||||
// if there is no loadInfo, then there is nothing to serialize
|
||||
*aOptionalLoadInfoArgs = void_t();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// use default values if no loadInfo is provided
|
||||
rv = PrincipalToPrincipalInfo(nsContentUtils::GetSystemPrincipal(),
|
||||
&aLoadInfoArgs->requestingPrincipalInfo());
|
||||
nsresult rv = NS_OK;
|
||||
PrincipalInfo requestingPrincipalInfo;
|
||||
rv = PrincipalToPrincipalInfo(aLoadInfo->LoadingPrincipal(),
|
||||
&requestingPrincipalInfo);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = PrincipalToPrincipalInfo(nsContentUtils::GetSystemPrincipal(),
|
||||
&aLoadInfoArgs->triggeringPrincipalInfo());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
aLoadInfoArgs->securityFlags() = nsILoadInfo::SEC_NORMAL;
|
||||
aLoadInfoArgs->contentPolicyType() = nsIContentPolicy::TYPE_OTHER;
|
||||
aLoadInfoArgs->upgradeInsecureRequests() = false;
|
||||
aLoadInfoArgs->innerWindowID() = 0;
|
||||
aLoadInfoArgs->outerWindowID() = 0;
|
||||
aLoadInfoArgs->parentOuterWindowID() = 0;
|
||||
|
||||
PrincipalInfo triggeringPrincipalInfo;
|
||||
rv = PrincipalToPrincipalInfo(aLoadInfo->TriggeringPrincipal(),
|
||||
&triggeringPrincipalInfo);
|
||||
|
||||
nsTArray<PrincipalInfo> redirectChain;
|
||||
for (const nsCOMPtr<nsIPrincipal>& principal : aLoadInfo->RedirectChain()) {
|
||||
rv = PrincipalToPrincipalInfo(principal, redirectChain.AppendElement());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
*aOptionalLoadInfoArgs =
|
||||
LoadInfoArgs(
|
||||
requestingPrincipalInfo,
|
||||
triggeringPrincipalInfo,
|
||||
aLoadInfo->GetSecurityFlags(),
|
||||
aLoadInfo->InternalContentPolicyType(),
|
||||
aLoadInfo->GetUpgradeInsecureRequests(),
|
||||
aLoadInfo->GetInnerWindowID(),
|
||||
aLoadInfo->GetOuterWindowID(),
|
||||
aLoadInfo->GetParentOuterWindowID(),
|
||||
aLoadInfo->GetEnforceSecurity(),
|
||||
aLoadInfo->GetInitialSecurityCheckDone(),
|
||||
redirectChain);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
LoadInfoArgsToLoadInfo(const mozilla::net::LoadInfoArgs& aLoadInfoArgs,
|
||||
LoadInfoArgsToLoadInfo(const OptionalLoadInfoArgs& aOptionalLoadInfoArgs,
|
||||
nsILoadInfo** outLoadInfo)
|
||||
{
|
||||
if (aOptionalLoadInfoArgs.type() == OptionalLoadInfoArgs::Tvoid_t) {
|
||||
*outLoadInfo = nullptr;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
const LoadInfoArgs& loadInfoArgs =
|
||||
aOptionalLoadInfoArgs.get_LoadInfoArgs();
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIPrincipal> requestingPrincipal =
|
||||
PrincipalInfoToPrincipal(aLoadInfoArgs.requestingPrincipalInfo(), &rv);
|
||||
PrincipalInfoToPrincipal(loadInfoArgs.requestingPrincipalInfo(), &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIPrincipal> triggeringPrincipal =
|
||||
PrincipalInfoToPrincipal(aLoadInfoArgs.triggeringPrincipalInfo(), &rv);
|
||||
PrincipalInfoToPrincipal(loadInfoArgs.triggeringPrincipalInfo(), &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsTArray<nsCOMPtr<nsIPrincipal>> redirectChain;
|
||||
for (const PrincipalInfo& principalInfo : loadInfoArgs.redirectChain()) {
|
||||
nsCOMPtr<nsIPrincipal> redirectedPrincipal =
|
||||
PrincipalInfoToPrincipal(principalInfo, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
redirectChain.AppendElement(redirectedPrincipal.forget());
|
||||
}
|
||||
|
||||
nsCOMPtr<nsILoadInfo> loadInfo =
|
||||
new mozilla::LoadInfo(requestingPrincipal,
|
||||
triggeringPrincipal,
|
||||
aLoadInfoArgs.securityFlags(),
|
||||
aLoadInfoArgs.contentPolicyType(),
|
||||
aLoadInfoArgs.upgradeInsecureRequests(),
|
||||
aLoadInfoArgs.innerWindowID(),
|
||||
aLoadInfoArgs.outerWindowID(),
|
||||
aLoadInfoArgs.parentOuterWindowID());
|
||||
loadInfoArgs.securityFlags(),
|
||||
loadInfoArgs.contentPolicyType(),
|
||||
loadInfoArgs.upgradeInsecureRequests(),
|
||||
loadInfoArgs.innerWindowID(),
|
||||
loadInfoArgs.outerWindowID(),
|
||||
loadInfoArgs.parentOuterWindowID(),
|
||||
loadInfoArgs.enforceSecurity(),
|
||||
loadInfoArgs.initialSecurityCheckDone(),
|
||||
redirectChain);
|
||||
|
||||
loadInfo.forget(outLoadInfo);
|
||||
return NS_OK;
|
||||
loadInfo.forget(outLoadInfo);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace ipc
|
||||
|
||||
@@ -35,12 +35,14 @@ struct ParamTraits<mozilla::OriginAttributes>
|
||||
}
|
||||
};
|
||||
|
||||
} // IPC namespace
|
||||
} // namespace IPC
|
||||
|
||||
namespace mozilla {
|
||||
namespace net {
|
||||
class LoadInfoArgs;
|
||||
}
|
||||
class OptionalLoadInfoArgs;
|
||||
} // namespace net
|
||||
|
||||
using namespace mozilla::net;
|
||||
|
||||
namespace ipc {
|
||||
|
||||
@@ -69,17 +71,15 @@ PrincipalToPrincipalInfo(nsIPrincipal* aPrincipal,
|
||||
*/
|
||||
nsresult
|
||||
LoadInfoToLoadInfoArgs(nsILoadInfo *aLoadInfo,
|
||||
mozilla::net::LoadInfoArgs* outLoadInfoArgs);
|
||||
OptionalLoadInfoArgs* outOptionalLoadInfoArgs);
|
||||
|
||||
/**
|
||||
* Convert LoadInfoArgs to a LoadInfo.
|
||||
*/
|
||||
nsresult
|
||||
LoadInfoArgsToLoadInfo(const mozilla::net::LoadInfoArgs& aLoadInfoArgs,
|
||||
LoadInfoArgsToLoadInfo(const OptionalLoadInfoArgs& aOptionalLoadInfoArgs,
|
||||
nsILoadInfo** outLoadInfo);
|
||||
|
||||
|
||||
|
||||
} // namespace ipc
|
||||
} // namespace mozilla
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "mozilla/LoadInfo.h"
|
||||
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/dom/ToJSValue.h"
|
||||
#include "nsFrameLoader.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIDocument.h"
|
||||
@@ -36,6 +37,8 @@ LoadInfo::LoadInfo(nsIPrincipal* aLoadingPrincipal,
|
||||
, mInnerWindowID(0)
|
||||
, mOuterWindowID(0)
|
||||
, mParentOuterWindowID(0)
|
||||
, mEnforceSecurity(false)
|
||||
, mInitialSecurityCheckDone(false)
|
||||
, mIsFromProcessingFrameAttributes(false)
|
||||
{
|
||||
MOZ_ASSERT(mLoadingPrincipal);
|
||||
@@ -88,7 +91,10 @@ LoadInfo::LoadInfo(nsIPrincipal* aLoadingPrincipal,
|
||||
bool aUpgradeInsecureRequests,
|
||||
uint64_t aInnerWindowID,
|
||||
uint64_t aOuterWindowID,
|
||||
uint64_t aParentOuterWindowID)
|
||||
uint64_t aParentOuterWindowID,
|
||||
bool aEnforceSecurity,
|
||||
bool aInitialSecurityCheckDone,
|
||||
nsTArray<nsCOMPtr<nsIPrincipal>>& aRedirectChain)
|
||||
: mLoadingPrincipal(aLoadingPrincipal)
|
||||
, mTriggeringPrincipal(aTriggeringPrincipal)
|
||||
, mSecurityFlags(aSecurityFlags)
|
||||
@@ -97,10 +103,14 @@ LoadInfo::LoadInfo(nsIPrincipal* aLoadingPrincipal,
|
||||
, mInnerWindowID(aInnerWindowID)
|
||||
, mOuterWindowID(aOuterWindowID)
|
||||
, mParentOuterWindowID(aParentOuterWindowID)
|
||||
, mEnforceSecurity(aEnforceSecurity)
|
||||
, mInitialSecurityCheckDone(aInitialSecurityCheckDone)
|
||||
, mIsFromProcessingFrameAttributes(false)
|
||||
{
|
||||
MOZ_ASSERT(mLoadingPrincipal);
|
||||
MOZ_ASSERT(mTriggeringPrincipal);
|
||||
|
||||
mRedirectChain.SwapElements(aRedirectChain);
|
||||
}
|
||||
|
||||
LoadInfo::~LoadInfo()
|
||||
@@ -168,6 +178,26 @@ LoadInfo::GetSecurityFlags(nsSecurityFlags* aResult)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LoadInfo::GetSecurityMode(uint32_t *aFlags)
|
||||
{
|
||||
*aFlags = (mSecurityFlags &
|
||||
(nsILoadInfo::SEC_REQUIRE_SAME_ORIGIN_DATA_INHERITS |
|
||||
nsILoadInfo::SEC_REQUIRE_SAME_ORIGIN_DATA_IS_BLOCKED |
|
||||
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_INHERITS |
|
||||
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL |
|
||||
nsILoadInfo::SEC_REQUIRE_CORS_DATA_INHERITS));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LoadInfo::GetRequireCorsWithCredentials(bool* aResult)
|
||||
{
|
||||
*aResult =
|
||||
(mSecurityFlags & nsILoadInfo::SEC_REQUIRE_CORS_WITH_CREDENTIALS);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LoadInfo::GetForceInheritPrincipal(bool* aInheritPrincipal)
|
||||
{
|
||||
@@ -183,6 +213,14 @@ LoadInfo::GetLoadingSandboxed(bool* aLoadingSandboxed)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LoadInfo::GetAboutBlankInherits(bool* aResult)
|
||||
{
|
||||
*aResult =
|
||||
(mSecurityFlags & nsILoadInfo::SEC_ABOUT_BLANK_INHERITS);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LoadInfo::GetExternalContentPolicyType(nsContentPolicyType* aResult)
|
||||
{
|
||||
@@ -252,4 +290,64 @@ LoadInfo::GetIsFromProcessingFrameAttributes(bool *aIsFromProcessingFrameAttribu
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LoadInfo::SetEnforceSecurity(bool aEnforceSecurity)
|
||||
{
|
||||
// Indicates whether the channel was openend using AsyncOpen2. Once set
|
||||
// to true, it must remain true throughout the lifetime of the channel.
|
||||
// Setting it to anything else than true will be discarded.
|
||||
MOZ_ASSERT(aEnforceSecurity, "aEnforceSecurity must be true");
|
||||
mEnforceSecurity = mEnforceSecurity || aEnforceSecurity;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LoadInfo::GetEnforceSecurity(bool* aResult)
|
||||
{
|
||||
*aResult = mEnforceSecurity;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LoadInfo::SetInitialSecurityCheckDone(bool aInitialSecurityCheckDone)
|
||||
{
|
||||
// Indicates whether the channel was ever evaluated by the
|
||||
// ContentSecurityManager. Once set to true, this flag must
|
||||
// remain true throughout the lifetime of the channel.
|
||||
// Setting it to anything else than true will be discarded.
|
||||
MOZ_ASSERT(aInitialSecurityCheckDone, "aInitialSecurityCheckDone must be true");
|
||||
mInitialSecurityCheckDone = mInitialSecurityCheckDone || aInitialSecurityCheckDone;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LoadInfo::GetInitialSecurityCheckDone(bool* aResult)
|
||||
{
|
||||
*aResult = mInitialSecurityCheckDone;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LoadInfo::AppendRedirectedPrincipal(nsIPrincipal* aPrincipal)
|
||||
{
|
||||
NS_ENSURE_ARG(aPrincipal);
|
||||
mRedirectChain.AppendElement(aPrincipal);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LoadInfo::GetRedirectChain(JSContext* aCx, JS::MutableHandle<JS::Value> aChain)
|
||||
{
|
||||
if (!ToJSValue(aCx, mRedirectChain, aChain)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
const nsTArray<nsCOMPtr<nsIPrincipal>>&
|
||||
LoadInfo::RedirectChain()
|
||||
{
|
||||
return mRedirectChain;
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
+26
-17
@@ -12,21 +12,22 @@
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsIWeakReferenceUtils.h" // for nsWeakPtr
|
||||
#include "nsIURI.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
class nsINode;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
namespace net {
|
||||
class LoadInfoArgs;
|
||||
}
|
||||
class OptionalLoadInfoArgs;
|
||||
} // namespace net
|
||||
|
||||
namespace ipc {
|
||||
// we have to forward declare that function so we can use it as a friend.
|
||||
nsresult
|
||||
LoadInfoArgsToLoadInfo(const mozilla::net::LoadInfoArgs& aLoadInfoArgs,
|
||||
LoadInfoArgsToLoadInfo(const mozilla::net::OptionalLoadInfoArgs& aLoadInfoArgs,
|
||||
nsILoadInfo** outLoadInfo);
|
||||
}
|
||||
} // namespace ipc
|
||||
|
||||
/**
|
||||
* Class that provides an nsILoadInfo implementation.
|
||||
@@ -57,6 +58,7 @@ private:
|
||||
// private constructor that is only allowed to be called from within
|
||||
// HttpChannelParent and FTPChannelParent declared as friends undeneath.
|
||||
// In e10s we can not serialize nsINode, hence we store the innerWindowID.
|
||||
// Please note that aRedirectChain uses swapElements.
|
||||
LoadInfo(nsIPrincipal* aLoadingPrincipal,
|
||||
nsIPrincipal* aTriggeringPrincipal,
|
||||
nsSecurityFlags aSecurityFlags,
|
||||
@@ -64,24 +66,31 @@ private:
|
||||
bool aUpgradeInsecureRequests,
|
||||
uint64_t aInnerWindowID,
|
||||
uint64_t aOuterWindowID,
|
||||
uint64_t aParentOuterWindowID);
|
||||
uint64_t aParentOuterWindowID,
|
||||
bool aEnforceSecurity,
|
||||
bool aInitialSecurityCheckDone,
|
||||
nsTArray<nsCOMPtr<nsIPrincipal>>& aRedirectChain);
|
||||
|
||||
friend nsresult
|
||||
mozilla::ipc::LoadInfoArgsToLoadInfo(const mozilla::net::LoadInfoArgs& aLoadInfoArgs,
|
||||
nsILoadInfo** outLoadInfo);
|
||||
mozilla::ipc::LoadInfoArgsToLoadInfo(
|
||||
const mozilla::net::OptionalLoadInfoArgs& aLoadInfoArgs,
|
||||
nsILoadInfo** outLoadInfo);
|
||||
|
||||
~LoadInfo();
|
||||
|
||||
nsCOMPtr<nsIPrincipal> mLoadingPrincipal;
|
||||
nsCOMPtr<nsIPrincipal> mTriggeringPrincipal;
|
||||
nsWeakPtr mLoadingContext;
|
||||
nsSecurityFlags mSecurityFlags;
|
||||
nsContentPolicyType mInternalContentPolicyType;
|
||||
nsCOMPtr<nsIURI> mBaseURI;
|
||||
bool mUpgradeInsecureRequests;
|
||||
uint64_t mInnerWindowID;
|
||||
uint64_t mOuterWindowID;
|
||||
uint64_t mParentOuterWindowID;
|
||||
nsCOMPtr<nsIPrincipal> mLoadingPrincipal;
|
||||
nsCOMPtr<nsIPrincipal> mTriggeringPrincipal;
|
||||
nsWeakPtr mLoadingContext;
|
||||
nsSecurityFlags mSecurityFlags;
|
||||
nsContentPolicyType mInternalContentPolicyType;
|
||||
nsCOMPtr<nsIURI> mBaseURI;
|
||||
bool mUpgradeInsecureRequests;
|
||||
uint64_t mInnerWindowID;
|
||||
uint64_t mOuterWindowID;
|
||||
uint64_t mParentOuterWindowID;
|
||||
bool mEnforceSecurity;
|
||||
bool mInitialSecurityCheckDone;
|
||||
nsTArray<nsCOMPtr<nsIPrincipal>> mRedirectChain;
|
||||
|
||||
// Is true if this load was triggered by processing the attributes of the
|
||||
// browsing context container.
|
||||
|
||||
@@ -85,7 +85,6 @@ XPIDL_SOURCES += [
|
||||
'nsIProxyInfo.idl',
|
||||
'nsIRandomGenerator.idl',
|
||||
'nsIRedirectChannelRegistrar.idl',
|
||||
'nsIRedirectHistory.idl',
|
||||
'nsIRedirectResultListener.idl',
|
||||
'nsIRequest.idl',
|
||||
'nsIRequestObserver.idl',
|
||||
|
||||
@@ -5,10 +5,12 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsBaseChannel.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsURLHelper.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsMimeTypes.h"
|
||||
#include "nsIContentSniffer.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsMimeTypes.h"
|
||||
#include "nsIHttpEventSink.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
@@ -168,8 +170,15 @@ nsBaseChannel::ContinueRedirect()
|
||||
|
||||
if (mOpenRedirectChannel) {
|
||||
nsresult rv = mRedirectChannel->AsyncOpen(mListener, mListenerContext);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
// Append the initial uri of the channel to the redirectChain
|
||||
// after the channel got openend successfully.
|
||||
if (mLoadInfo) {
|
||||
nsCOMPtr<nsIPrincipal> uriPrincipal;
|
||||
nsIScriptSecurityManager *sm = nsContentUtils::GetSecurityManager();
|
||||
sm->GetChannelURIPrincipal(this, getter_AddRefs(uriPrincipal));
|
||||
mLoadInfo->AppendRedirectedPrincipal(uriPrincipal);
|
||||
}
|
||||
}
|
||||
|
||||
mRedirectChannel = nullptr;
|
||||
|
||||
@@ -4,12 +4,16 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsIRequest.idl"
|
||||
#include "nsILoadInfo.idl"
|
||||
|
||||
interface nsIURI;
|
||||
interface nsIInterfaceRequestor;
|
||||
interface nsIInputStream;
|
||||
interface nsIStreamListener;
|
||||
interface nsILoadInfo;
|
||||
|
||||
%{C++
|
||||
#include "nsCOMPtr.h"
|
||||
%}
|
||||
|
||||
/**
|
||||
* The nsIChannel interface allows clients to construct "GET" requests for
|
||||
@@ -309,4 +313,15 @@ interface nsIChannel : nsIRequest
|
||||
* redirects and the like.
|
||||
*/
|
||||
attribute nsILoadInfo loadInfo;
|
||||
|
||||
%{ C++
|
||||
inline already_AddRefed<nsILoadInfo> GetLoadInfo()
|
||||
{
|
||||
nsCOMPtr<nsILoadInfo> result;
|
||||
mozilla::DebugOnly<nsresult> rv = GetLoadInfo(getter_AddRefs(result));
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv) || !result);
|
||||
return result.forget();
|
||||
}
|
||||
%}
|
||||
|
||||
};
|
||||
|
||||
@@ -12,12 +12,18 @@ interface nsINode;
|
||||
interface nsIPrincipal;
|
||||
interface nsIURI;
|
||||
|
||||
%{C++
|
||||
#include "nsTArray.h"
|
||||
%}
|
||||
|
||||
[ref] native const_nsIPrincipalArray(const nsTArray<nsCOMPtr<nsIPrincipal>>);
|
||||
|
||||
typedef unsigned long nsSecurityFlags;
|
||||
|
||||
/**
|
||||
* An nsILoadOwner represents per-load information about who started the load.
|
||||
*/
|
||||
[scriptable, builtinclass, uuid(6b7f8798-3c28-44fc-8b1a-cd613eb826c5)]
|
||||
[scriptable, builtinclass, uuid(cc51498e-f8f8-469d-85ba-6dcba17027e4)]
|
||||
interface nsILoadInfo : nsISupports
|
||||
{
|
||||
/**
|
||||
@@ -25,6 +31,64 @@ interface nsILoadInfo : nsISupports
|
||||
*/
|
||||
const unsigned long SEC_NORMAL = 0;
|
||||
|
||||
/**
|
||||
* The following five flags determine the security mode and hence what kind of
|
||||
* security checks should be performed throughout the lifetime of the channel.
|
||||
*
|
||||
* * SEC_REQUIRE_SAME_ORIGIN_DATA_INHERITS
|
||||
* * SEC_REQUIRE_SAME_ORIGIN_DATA_IS_BLOCKED
|
||||
* * SEC_ALLOW_CROSS_ORIGIN_DATA_INHERITS
|
||||
* * SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL
|
||||
* * SEC_REQUIRE_CORS_DATA_INHERITS
|
||||
*
|
||||
* Exactly one of these flags are required to be set in order to allow
|
||||
* the channel to perform the correct security checks (SOP, CORS, ...) and
|
||||
* return the correct result principal. If none or more than one of these
|
||||
* flags are set AsyncOpen2 will fail.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Enforce the same origin policy where data: loads inherit
|
||||
* the principal.
|
||||
*/
|
||||
const unsigned long SEC_REQUIRE_SAME_ORIGIN_DATA_INHERITS = (1<<0);
|
||||
|
||||
/*
|
||||
* Enforce the same origin policy but data: loads are blocked.
|
||||
*/
|
||||
const unsigned long SEC_REQUIRE_SAME_ORIGIN_DATA_IS_BLOCKED = (1<<1);
|
||||
|
||||
/**
|
||||
* Allow loads from other origins. Loads from data: will inherit
|
||||
* the principal of the origin that triggered the load.
|
||||
* Commonly used by plain <img>, <video>, <link rel=stylesheet> etc.
|
||||
*/
|
||||
const unsigned long SEC_ALLOW_CROSS_ORIGIN_DATA_INHERITS = (1<<2);
|
||||
|
||||
/**
|
||||
* Allow loads from other origins. Loads from data: will be allowed,
|
||||
* but the resulting resource will get a null principal.
|
||||
* Used in blink/webkit for <iframe>s. Likely also the mode
|
||||
* that should be used by most Chrome code.
|
||||
*/
|
||||
const unsigned long SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL = (1<<3);
|
||||
|
||||
/**
|
||||
* Allow loads from any origin, but require CORS for cross-origin
|
||||
* loads. Loads from data: are allowed and the result will inherit
|
||||
* the principal of the origin that triggered the load.
|
||||
* Commonly used by <img crossorigin>, <video crossorigin>,
|
||||
* XHR, fetch(), etc.
|
||||
*/
|
||||
const unsigned long SEC_REQUIRE_CORS_DATA_INHERITS = (1<<4);
|
||||
|
||||
/**
|
||||
* Use this flag in addition to SEC_REQUIRE_CORS_DATA_INHERITS
|
||||
* to make cross-origin CORS loads happen with credentials
|
||||
* (such as cookies and client side certs).
|
||||
*/
|
||||
const unsigned long SEC_REQUIRE_CORS_WITH_CREDENTIALS = (1<<5);
|
||||
|
||||
/**
|
||||
* Force inheriting of the Principal. The resulting resource will use the
|
||||
* principal of the document which is doing the load. Setting this flag
|
||||
@@ -40,7 +104,7 @@ interface nsILoadInfo : nsISupports
|
||||
*
|
||||
* This flag can not be used together with SEC_SANDBOXED.
|
||||
*/
|
||||
const unsigned long SEC_FORCE_INHERIT_PRINCIPAL = 0x01;
|
||||
const unsigned long SEC_FORCE_INHERIT_PRINCIPAL = (1<<6);
|
||||
|
||||
/**
|
||||
* Sandbox the load. The resulting resource will use a freshly created
|
||||
@@ -52,7 +116,12 @@ interface nsILoadInfo : nsISupports
|
||||
*
|
||||
* This flag can not be used together with SEC_FORCE_INHERIT_PRINCIPAL.
|
||||
*/
|
||||
const unsigned long SEC_SANDBOXED = 0x02;
|
||||
const unsigned long SEC_SANDBOXED = (1<<7);
|
||||
|
||||
/**
|
||||
* Inherit the Principal for about:blank.
|
||||
*/
|
||||
const unsigned long SEC_ABOUT_BLANK_INHERITS = (1<<8);
|
||||
|
||||
/**
|
||||
* The loadingPrincipal is the principal that is responsible for the load.
|
||||
@@ -137,6 +206,17 @@ interface nsILoadInfo : nsISupports
|
||||
}
|
||||
%}
|
||||
|
||||
/**
|
||||
* Allows to query only the security mode bits from above.
|
||||
*/
|
||||
[infallible] readonly attribute unsigned long securityMode;
|
||||
|
||||
/**
|
||||
* Determines whether credentials are sent with CORS requests.
|
||||
* Using this flag requires SEC_REQUIRE_CORS_DATA_INHERITS also to be set.
|
||||
*/
|
||||
[infallible] readonly attribute boolean requireCorsWithCredentials;
|
||||
|
||||
/**
|
||||
* If forceInheritPrincipal is true, the data coming from the channel should
|
||||
* use loadingPrincipal for its principal, even when the data is loaded over
|
||||
@@ -152,6 +232,12 @@ interface nsILoadInfo : nsISupports
|
||||
*/
|
||||
[infallible] readonly attribute boolean loadingSandboxed;
|
||||
|
||||
/**
|
||||
* If aboutBlankInherits is true, then about:blank should inherit
|
||||
* the principal.
|
||||
*/
|
||||
[infallible] readonly attribute boolean aboutBlankInherits;
|
||||
|
||||
/**
|
||||
* The external contentPolicyType of the channel, used for security checks
|
||||
* like Mixed Content Blocking and Content Security Policy.
|
||||
@@ -258,7 +344,82 @@ interface nsILoadInfo : nsISupports
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
return result;
|
||||
}
|
||||
%}
|
||||
%}
|
||||
|
||||
/**
|
||||
* Whenever a channel is openend by asyncOpen2() [or also open2()],
|
||||
* lets set this flag so that redirects of such channels are also
|
||||
* openend using asyncOpen2() [open2()].
|
||||
*
|
||||
* Please note, once the flag is set to true it must remain true
|
||||
* throughout the lifetime of the channel. Trying to set it
|
||||
* to anything else than true will be discareded.
|
||||
*
|
||||
*/
|
||||
attribute bool enforceSecurity;
|
||||
|
||||
%{ C++
|
||||
inline bool GetEnforceSecurity()
|
||||
{
|
||||
bool result;
|
||||
mozilla::DebugOnly<nsresult> rv = GetEnforceSecurity(&result);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
return result;
|
||||
}
|
||||
%}
|
||||
|
||||
/**
|
||||
* Whenever a channel is evaluated by the ContentSecurityManager
|
||||
* the first time, we set this flag to true to indicate that
|
||||
* subsequent calls of AsyncOpen2() do not have to enforce all
|
||||
* security checks again. E.g., after a redirect there is no
|
||||
* need to set up CORS again. We need this separate flag
|
||||
* because the redirectChain might also contain internal
|
||||
* redirects which might pollute the redirectChain so we can't
|
||||
* rely on the size of the redirectChain-array to query whether
|
||||
* a channel got redirected or not.
|
||||
*
|
||||
* Please note, once the flag is set to true it must remain true
|
||||
* throughout the lifetime of the channel. Trying to set it
|
||||
* to anything else than true will be discareded.
|
||||
*
|
||||
*/
|
||||
attribute bool initialSecurityCheckDone;
|
||||
|
||||
%{ C++
|
||||
inline bool GetInitialSecurityCheckDone()
|
||||
{
|
||||
bool result;
|
||||
mozilla::DebugOnly<nsresult> rv = GetInitialSecurityCheckDone(&result);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
return result;
|
||||
}
|
||||
%}
|
||||
|
||||
/**
|
||||
* Whenever a channel gets redirected, append the principal of the
|
||||
* channel [before the channels got redirected] to the loadinfo,
|
||||
* so that at every point this array lets us reason about all the
|
||||
* redirects this channel went through.
|
||||
*/
|
||||
void appendRedirectedPrincipal(in nsIPrincipal aPrincipal);
|
||||
|
||||
/**
|
||||
* An array of nsIPrincipal that store the redirects associated with this
|
||||
* channel. This array is filled whether or not the channel has ever been
|
||||
* opened. The last element of the array is associated with the most recent
|
||||
* channel.
|
||||
*/
|
||||
[implicit_jscontext]
|
||||
readonly attribute jsval redirectChain;
|
||||
|
||||
/**
|
||||
* A C++-friendly version of redirectChain.
|
||||
* Please note that this array has the same lifetime as the
|
||||
* loadInfo object - use with caution!
|
||||
*/
|
||||
[noscript, notxpcom, nostdcall, binaryname(RedirectChain)]
|
||||
const_nsIPrincipalArray binaryRedirectChain();
|
||||
|
||||
/**
|
||||
* This attribute will be true if this is a load triggered by
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
/**
|
||||
* Allows keeping track of channel redirects. Currently nsHttpChannel is the
|
||||
* only implementor.
|
||||
*/
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIArray;
|
||||
interface nsIPrincipal;
|
||||
|
||||
[scriptable, uuid(ab87eabf-d0c4-40a9-b4b2-a1191108d4c0)]
|
||||
interface nsIRedirectHistory : nsISupports
|
||||
{
|
||||
/**
|
||||
* An array of nsIPrincipal that store the redirects associated with this
|
||||
* channel. This array is filled whether or not the channel has ever been
|
||||
* opened. The last element of the array is associated with the most recent
|
||||
* channel.
|
||||
*/
|
||||
readonly attribute nsIArray redirects;
|
||||
};
|
||||
@@ -26,14 +26,26 @@ namespace net {
|
||||
|
||||
struct LoadInfoArgs
|
||||
{
|
||||
PrincipalInfo requestingPrincipalInfo;
|
||||
PrincipalInfo triggeringPrincipalInfo;
|
||||
uint32_t securityFlags;
|
||||
uint32_t contentPolicyType;
|
||||
bool upgradeInsecureRequests;
|
||||
uint64_t innerWindowID;
|
||||
uint64_t outerWindowID;
|
||||
uint64_t parentOuterWindowID;
|
||||
PrincipalInfo requestingPrincipalInfo;
|
||||
PrincipalInfo triggeringPrincipalInfo;
|
||||
uint32_t securityFlags;
|
||||
uint32_t contentPolicyType;
|
||||
bool upgradeInsecureRequests;
|
||||
uint64_t innerWindowID;
|
||||
uint64_t outerWindowID;
|
||||
uint64_t parentOuterWindowID;
|
||||
bool enforceSecurity;
|
||||
bool initialSecurityCheckDone;
|
||||
PrincipalInfo[] redirectChain;
|
||||
};
|
||||
|
||||
/**
|
||||
* Not every channel necessarily has a loadInfo attached.
|
||||
*/
|
||||
union OptionalLoadInfoArgs
|
||||
{
|
||||
void_t;
|
||||
LoadInfoArgs;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -77,7 +89,7 @@ struct HttpChannelOpenArgs
|
||||
bool allowSpdy;
|
||||
bool allowAltSvc;
|
||||
OptionalFileDescriptorSet fds;
|
||||
LoadInfoArgs loadInfo;
|
||||
OptionalLoadInfoArgs loadInfo;
|
||||
OptionalHttpResponseHead synthesizedResponseHead;
|
||||
uint32_t cacheKey;
|
||||
bool allowStaleCacheContent;
|
||||
@@ -106,7 +118,7 @@ struct FTPChannelOpenArgs
|
||||
uint64_t startPos;
|
||||
nsCString entityID;
|
||||
OptionalInputStreamParams uploadStream;
|
||||
LoadInfoArgs loadInfo;
|
||||
OptionalLoadInfoArgs loadInfo;
|
||||
};
|
||||
|
||||
struct FTPChannelConnectArgs
|
||||
|
||||
@@ -118,7 +118,7 @@ FTPChannelParent::DoAsyncOpen(const URIParams& aURI,
|
||||
const uint64_t& aStartPos,
|
||||
const nsCString& aEntityID,
|
||||
const OptionalInputStreamParams& aUploadStream,
|
||||
const LoadInfoArgs& aLoadInfoArgs)
|
||||
const OptionalLoadInfoArgs& aLoadInfoArgs)
|
||||
{
|
||||
nsCOMPtr<nsIURI> uri = DeserializeURI(aURI);
|
||||
if (!uri)
|
||||
|
||||
@@ -73,7 +73,7 @@ protected:
|
||||
bool DoAsyncOpen(const URIParams& aURI, const uint64_t& aStartPos,
|
||||
const nsCString& aEntityID,
|
||||
const OptionalInputStreamParams& aUploadStream,
|
||||
const LoadInfoArgs& aLoadInfoArgs);
|
||||
const OptionalLoadInfoArgs& aLoadInfoArgs);
|
||||
|
||||
// used to connect redirected-to channel in parent with just created
|
||||
// ChildChannel. Used during HTTP->FTP redirects.
|
||||
|
||||
@@ -189,7 +189,6 @@ NS_INTERFACE_MAP_BEGIN(HttpBaseChannel)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIHttpChannel)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIHttpChannelInternal)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIForcePendingChannel)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIRedirectHistory)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIUploadChannel)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIUploadChannel2)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupportsPriority)
|
||||
@@ -1965,13 +1964,6 @@ HttpBaseChannel::SetResponseTimeoutEnabled(bool aEnable)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpBaseChannel::AddRedirect(nsIPrincipal *aRedirect)
|
||||
{
|
||||
mRedirects.AppendObject(aRedirect);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpBaseChannel::ForcePending(bool aForcePending)
|
||||
{
|
||||
@@ -2138,24 +2130,6 @@ HttpBaseChannel::ShouldIntercept()
|
||||
return shouldIntercept;
|
||||
}
|
||||
|
||||
// nsIRedirectHistory
|
||||
NS_IMETHODIMP
|
||||
HttpBaseChannel::GetRedirects(nsIArray * *aRedirects)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIMutableArray> redirects =
|
||||
do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
for (int i = 0; i < mRedirects.Count(); ++i) {
|
||||
rv = redirects->AppendElement(mRedirects[i], false);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
*aRedirects = redirects;
|
||||
NS_IF_ADDREF(*aRedirects);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// nsHttpChannel::nsITraceableChannel
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -2423,28 +2397,6 @@ HttpBaseChannel::SetupReplacementChannel(nsIURI *newURI,
|
||||
"[this=%p] transferring chain of redirect cache-keys", this));
|
||||
httpInternal->SetCacheKeysRedirectChain(mRedirectedCachekeys.forget());
|
||||
}
|
||||
// Transfer existing redirect information. Add all of our existing
|
||||
// redirects to the new channel.
|
||||
for (int32_t i = 0; i < mRedirects.Count(); ++i) {
|
||||
if (LOG_ENABLED()) {
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
mRedirects[i]->GetURI(getter_AddRefs(uri));
|
||||
nsCString spec;
|
||||
if (uri) {
|
||||
uri->GetSpec(spec);
|
||||
}
|
||||
LOG(("HttpBaseChannel::SetupReplacementChannel adding redirect \'%s\' "
|
||||
"[this=%p]", spec.get(), this));
|
||||
}
|
||||
|
||||
httpInternal->AddRedirect(mRedirects[i]);
|
||||
}
|
||||
|
||||
// Add our own principal to the redirect information on the new channel. If
|
||||
// the redirect is vetoed, then newChannel->AsyncOpen won't be called.
|
||||
// However, the new channel's redirect chain will still be complete.
|
||||
nsCOMPtr<nsIPrincipal> principal = GetURIPrincipal();
|
||||
httpInternal->AddRedirect(principal);
|
||||
}
|
||||
|
||||
// transfer application cache information
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#include "nsHttpHandler.h"
|
||||
#include "nsIHttpChannelInternal.h"
|
||||
#include "nsIForcePendingChannel.h"
|
||||
#include "nsIRedirectHistory.h"
|
||||
#include "nsIUploadChannel.h"
|
||||
#include "nsIUploadChannel2.h"
|
||||
#include "nsIProgressEventSink.h"
|
||||
@@ -62,7 +61,6 @@ class HttpBaseChannel : public nsHashPropertyBag
|
||||
, public nsIEncodedChannel
|
||||
, public nsIHttpChannel
|
||||
, public nsIHttpChannelInternal
|
||||
, public nsIRedirectHistory
|
||||
, public nsIUploadChannel
|
||||
, public nsIUploadChannel2
|
||||
, public nsISupportsPriority
|
||||
@@ -82,7 +80,6 @@ public:
|
||||
NS_DECL_NSIUPLOADCHANNEL2
|
||||
NS_DECL_NSITRACEABLECHANNEL
|
||||
NS_DECL_NSITIMEDCHANNEL
|
||||
NS_DECL_NSIREDIRECTHISTORY
|
||||
|
||||
HttpBaseChannel();
|
||||
|
||||
@@ -188,7 +185,6 @@ public:
|
||||
NS_IMETHOD SetResponseTimeoutEnabled(bool aEnable) override;
|
||||
NS_IMETHOD GetNetworkInterfaceId(nsACString& aNetworkInterfaceId) override;
|
||||
NS_IMETHOD SetNetworkInterfaceId(const nsACString& aNetworkInterfaceId) override;
|
||||
NS_IMETHOD AddRedirect(nsIPrincipal *aRedirect) override;
|
||||
NS_IMETHOD ForcePending(bool aForcePending) override;
|
||||
NS_IMETHOD GetLastModifiedTime(PRTime* lastModifiedTime) override;
|
||||
NS_IMETHOD ForceNoIntercept() override;
|
||||
@@ -392,8 +388,6 @@ protected:
|
||||
|
||||
nsCOMPtr<nsIURI> mAPIRedirectToURI;
|
||||
nsAutoPtr<nsTArray<nsCString> > mRedirectedCachekeys;
|
||||
// Redirects added by previous channels.
|
||||
nsCOMArray<nsIPrincipal> mRedirects;
|
||||
|
||||
uint32_t mProxyResolveFlags;
|
||||
nsCOMPtr<nsIURI> mProxyURI;
|
||||
|
||||
@@ -1240,8 +1240,14 @@ HttpChannelChild::Redirect3Complete()
|
||||
if (mLoadGroup)
|
||||
mLoadGroup->RemoveRequest(this, nullptr, NS_BINDING_ABORTED);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
if (mLoadInfo) {
|
||||
mLoadInfo->AppendRedirectedPrincipal(GetURIPrincipal());
|
||||
}
|
||||
}
|
||||
else {
|
||||
NS_WARNING("CompleteRedirectSetup failed, HttpChannelChild already open?");
|
||||
}
|
||||
|
||||
// Release ref to new channel.
|
||||
mRedirectChannelChild = nullptr;
|
||||
|
||||
@@ -275,7 +275,7 @@ HttpChannelParent::DoAsyncOpen( const URIParams& aURI,
|
||||
const bool& allowSpdy,
|
||||
const bool& allowAltSvc,
|
||||
const OptionalFileDescriptorSet& aFds,
|
||||
const LoadInfoArgs& aLoadInfoArgs,
|
||||
const OptionalLoadInfoArgs& aLoadInfoArgs,
|
||||
const OptionalHttpResponseHead& aSynthesizedResponseHead,
|
||||
const uint32_t& aCacheKey,
|
||||
const bool& aAllowStaleCacheContent)
|
||||
|
||||
@@ -116,7 +116,7 @@ protected:
|
||||
const bool& allowSpdy,
|
||||
const bool& allowAltSvc,
|
||||
const OptionalFileDescriptorSet& aFds,
|
||||
const LoadInfoArgs& aLoadInfoArgs,
|
||||
const OptionalLoadInfoArgs& aLoadInfoArgs,
|
||||
const OptionalHttpResponseHead& aSynthesizedResponseHead,
|
||||
const uint32_t& aCacheKey,
|
||||
const bool& aAllowStaleCacheContent);
|
||||
|
||||
@@ -181,6 +181,11 @@ AutoRedirectVetoNotifier::ReportRedirectResult(bool succeeded)
|
||||
if (!mChannel)
|
||||
return;
|
||||
|
||||
// Append the initial uri of the channel to the redirectChain
|
||||
if (succeeded && mChannel->mLoadInfo) {
|
||||
mChannel->mLoadInfo->AppendRedirectedPrincipal(mChannel->GetURIPrincipal());
|
||||
}
|
||||
|
||||
mChannel->mRedirectChannel = nullptr;
|
||||
|
||||
nsCOMPtr<nsIRedirectResultListener> vetoHook;
|
||||
|
||||
@@ -25,7 +25,7 @@ interface nsIURI;
|
||||
* The callback interface for nsIHttpChannelInternal::HTTPUpgrade()
|
||||
*/
|
||||
|
||||
[scriptable, uuid(c025c35a-dda3-4a1d-9e6c-e02d7149ac79)]
|
||||
[scriptable, uuid(7b48d081-1dc1-4d08-b7a5-81491bf28c0e)]
|
||||
interface nsIHttpUpgradeListener : nsISupports
|
||||
{
|
||||
void onTransportAvailable(in nsISocketTransport aTransport,
|
||||
@@ -38,7 +38,7 @@ interface nsIHttpUpgradeListener : nsISupports
|
||||
* using any feature exposed by this interface, be aware that this interface
|
||||
* will change and you will be broken. You have been warned.
|
||||
*/
|
||||
[scriptable, uuid(26833ec7-4555-4f23-9281-3a12d4b76db1)]
|
||||
[scriptable, uuid(4c9e681e-efd8-4ed2-b57f-20d48c9b3c3b)]
|
||||
|
||||
interface nsIHttpChannelInternal : nsISupports
|
||||
{
|
||||
@@ -213,12 +213,6 @@ interface nsIHttpChannelInternal : nsISupports
|
||||
*/
|
||||
attribute boolean allowAltSvc;
|
||||
|
||||
/**
|
||||
* Add a new nsIPrincipal to the redirect chain. This is the only way to
|
||||
* write to nsIRedirectHistory.redirects.
|
||||
*/
|
||||
void addRedirect(in nsIPrincipal aPrincipal);
|
||||
|
||||
readonly attribute PRTime lastModifiedTime;
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,7 +33,7 @@ parent:
|
||||
bool aClientSetPingInterval,
|
||||
uint32_t aPingTimeout,
|
||||
bool aClientSetPingTimeout,
|
||||
LoadInfoArgs aLoadInfoArgs);
|
||||
OptionalLoadInfoArgs aLoadInfoArgs);
|
||||
Close(uint16_t code, nsCString reason);
|
||||
SendMsg(nsCString aMsg);
|
||||
SendBinaryMsg(nsCString aMsg);
|
||||
|
||||
@@ -483,7 +483,7 @@ WebSocketChannelChild::AsyncOpen(nsIURI *aURI,
|
||||
// Corresponding release in DeallocPWebSocket
|
||||
AddIPDLReference();
|
||||
|
||||
LoadInfoArgs loadInfoArgs;
|
||||
OptionalLoadInfoArgs loadInfoArgs;
|
||||
nsresult rv = LoadInfoToLoadInfoArgs(mLoadInfo, &loadInfoArgs);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ WebSocketChannelParent::RecvAsyncOpen(const URIParams& aURI,
|
||||
const bool& aClientSetPingInterval,
|
||||
const uint32_t& aPingTimeout,
|
||||
const bool& aClientSetPingTimeout,
|
||||
const LoadInfoArgs& aLoadInfoArgs)
|
||||
const OptionalLoadInfoArgs& aLoadInfoArgs)
|
||||
{
|
||||
LOG(("WebSocketChannelParent::RecvAsyncOpen() %p\n", this));
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ class WebSocketChannelParent : public PWebSocketParent,
|
||||
const bool& aClientSetPingInterval,
|
||||
const uint32_t& aPingTimeout,
|
||||
const bool& aClientSetPingTimeout,
|
||||
const LoadInfoArgs& aLoadInfoArgs) override;
|
||||
const OptionalLoadInfoArgs& aLoadInfoArgs) override;
|
||||
bool RecvClose(const uint16_t & code, const nsCString & reason) override;
|
||||
bool RecvSendMsg(const nsCString& aMsg) override;
|
||||
bool RecvSendBinaryMsg(const nsCString& aMsg) override;
|
||||
|
||||
@@ -34,10 +34,12 @@ function contentHandler(request, response)
|
||||
function finish_test(request, buffer)
|
||||
{
|
||||
do_check_eq(buffer, responseBody);
|
||||
let chan = request.QueryInterface(Ci.nsIRedirectHistory);
|
||||
do_check_eq(numRedirects - 1, chan.redirects.length);
|
||||
let chan = request.QueryInterface(Ci.nsIChannel);
|
||||
let redirectChain = chan.loadInfo.redirectChain;
|
||||
|
||||
do_check_eq(numRedirects - 1, redirectChain.length);
|
||||
for (let i = 0; i < numRedirects - 1; ++i) {
|
||||
let principal = chan.redirects.queryElementAt(i, Ci.nsIPrincipal);
|
||||
let principal = redirectChain[i];
|
||||
do_check_eq(URL + redirects[i], principal.URI.spec);
|
||||
}
|
||||
httpServer.stop(do_test_finished);
|
||||
|
||||
@@ -1201,39 +1201,6 @@
|
||||
[TextTrack interface: document.createElement("track").track must inherit property "oncuechange" with the proper type (10)]
|
||||
expected: PASS
|
||||
|
||||
[TextTrackCue interface: existence and properties of interface object]
|
||||
expected: FAIL
|
||||
|
||||
[TextTrackCue interface object length]
|
||||
expected: FAIL
|
||||
|
||||
[TextTrackCue interface: existence and properties of interface prototype object]
|
||||
expected: FAIL
|
||||
|
||||
[TextTrackCue interface: existence and properties of interface prototype object's "constructor" property]
|
||||
expected: FAIL
|
||||
|
||||
[TextTrackCue interface: attribute track]
|
||||
expected: FAIL
|
||||
|
||||
[TextTrackCue interface: attribute id]
|
||||
expected: FAIL
|
||||
|
||||
[TextTrackCue interface: attribute startTime]
|
||||
expected: FAIL
|
||||
|
||||
[TextTrackCue interface: attribute endTime]
|
||||
expected: FAIL
|
||||
|
||||
[TextTrackCue interface: attribute pauseOnExit]
|
||||
expected: FAIL
|
||||
|
||||
[TextTrackCue interface: attribute onenter]
|
||||
expected: FAIL
|
||||
|
||||
[TextTrackCue interface: attribute onexit]
|
||||
expected: FAIL
|
||||
|
||||
[TrackEvent must be primary interface of new TrackEvent("addtrack"; {track:document.createElement("track").track})]
|
||||
expected: FAIL
|
||||
|
||||
@@ -2194,9 +2161,6 @@
|
||||
[Window interface: window must inherit property "onstorage" with the proper type (112)]
|
||||
expected: FAIL
|
||||
|
||||
[Window interface: window must inherit property "createImageBitmap" with the proper type (122)]
|
||||
expected: FAIL
|
||||
|
||||
[Window interface: calling createImageBitmap(ImageBitmapSource,long,long,long,long) on window with too few arguments must throw TypeError]
|
||||
expected: FAIL
|
||||
|
||||
@@ -2359,24 +2323,6 @@
|
||||
[Navigator interface: window.navigator must inherit property "javaEnabled" with the proper type (20)]
|
||||
expected: FAIL
|
||||
|
||||
[ImageBitmap interface: existence and properties of interface object]
|
||||
expected: FAIL
|
||||
|
||||
[ImageBitmap interface object length]
|
||||
expected: FAIL
|
||||
|
||||
[ImageBitmap interface: existence and properties of interface prototype object]
|
||||
expected: FAIL
|
||||
|
||||
[ImageBitmap interface: existence and properties of interface prototype object's "constructor" property]
|
||||
expected: FAIL
|
||||
|
||||
[ImageBitmap interface: attribute width]
|
||||
expected: FAIL
|
||||
|
||||
[ImageBitmap interface: attribute height]
|
||||
expected: FAIL
|
||||
|
||||
[MessageEvent interface: operation initMessageEvent(DOMString,boolean,boolean,any,DOMString,DOMString,[object Object\],[object Object\],MessagePort)]
|
||||
expected: FAIL
|
||||
|
||||
|
||||
-3
@@ -3,6 +3,3 @@
|
||||
[source.media should not be supported]
|
||||
expected: FAIL
|
||||
|
||||
[TextTrackCue constructor should not be supported]
|
||||
expected: FAIL
|
||||
|
||||
|
||||
@@ -15,9 +15,6 @@
|
||||
[The CanvasProxy interface object should be exposed.]
|
||||
expected: FAIL
|
||||
|
||||
[The ImageBitmap interface object should be exposed.]
|
||||
expected: FAIL
|
||||
|
||||
[The CanvasRenderingContext2D interface object should be exposed.]
|
||||
expected: FAIL
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include "nsIFile.h"
|
||||
#include "nsIFileURL.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIRedirectHistory.h"
|
||||
#include "nsIDirectoryService.h"
|
||||
#include "nsAppDirectoryServiceDefs.h"
|
||||
#include "nsICategoryManager.h"
|
||||
@@ -1998,14 +1997,20 @@ nsExternalAppHandler::OnSaveComplete(nsIBackgroundFileSaver *aSaver,
|
||||
mSaver = nullptr;
|
||||
|
||||
// Save the redirect information.
|
||||
nsCOMPtr<nsIRedirectHistory> history = do_QueryInterface(mRequest);
|
||||
if (history) {
|
||||
(void)history->GetRedirects(getter_AddRefs(mRedirects));
|
||||
uint32_t length = 0;
|
||||
mRedirects->GetLength(&length);
|
||||
LOG(("nsExternalAppHandler: Got %u redirects\n", length));
|
||||
} else {
|
||||
LOG(("nsExternalAppHandler: No redirects\n"));
|
||||
nsCOMPtr<nsIChannel> channel = do_QueryInterface(mRequest);
|
||||
if (channel) {
|
||||
nsCOMPtr<nsILoadInfo> loadInfo = channel->GetLoadInfo();
|
||||
if (loadInfo) {
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIMutableArray> redirectChain =
|
||||
do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
LOG(("nsExternalAppHandler: Got %u redirects\n", loadInfo->RedirectChain().Length()));
|
||||
for (nsIPrincipal* principal : loadInfo->RedirectChain()) {
|
||||
redirectChain->AppendElement(principal, false);
|
||||
}
|
||||
mRedirects = redirectChain;
|
||||
}
|
||||
}
|
||||
|
||||
if (NS_FAILED(aStatus)) {
|
||||
@@ -2018,7 +2023,6 @@ nsExternalAppHandler::OnSaveComplete(nsIBackgroundFileSaver *aSaver,
|
||||
// for us, we'll fall back to using the prompt service if we absolutely
|
||||
// have to.
|
||||
if (!mTransfer) {
|
||||
nsCOMPtr<nsIChannel> channel = do_QueryInterface(mRequest);
|
||||
// We don't care if this fails.
|
||||
CreateFailedTransfer(channel && NS_UsePrivateBrowsing(channel));
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "nsPrintfCString.h"
|
||||
#include "nsProxyRelease.h"
|
||||
#include "nsIScriptError.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
|
||||
#include "mozilla/Preferences.h"
|
||||
|
||||
@@ -45,11 +46,15 @@ NS_IMPL_RELEASE(nsConsoleService)
|
||||
NS_IMPL_CLASSINFO(nsConsoleService, nullptr,
|
||||
nsIClassInfo::THREADSAFE | nsIClassInfo::SINGLETON,
|
||||
NS_CONSOLESERVICE_CID)
|
||||
NS_IMPL_QUERY_INTERFACE_CI(nsConsoleService, nsIConsoleService)
|
||||
NS_IMPL_CI_INTERFACE_GETTER(nsConsoleService, nsIConsoleService)
|
||||
NS_IMPL_QUERY_INTERFACE_CI(nsConsoleService, nsIConsoleService, nsIObserver)
|
||||
NS_IMPL_CI_INTERFACE_GETTER(nsConsoleService, nsIConsoleService, nsIObserver)
|
||||
|
||||
static bool sLoggingEnabled = true;
|
||||
static bool sLoggingBuffered = true;
|
||||
#if defined(ANDROID)
|
||||
static bool sLoggingLogcat = true;
|
||||
#endif // defined(ANDROID)
|
||||
|
||||
|
||||
nsConsoleService::nsConsoleService()
|
||||
: mMessages(nullptr)
|
||||
@@ -65,7 +70,7 @@ nsConsoleService::nsConsoleService()
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsConsoleService::ClearMessagesForWindowID(const uint64_t innerID)
|
||||
{
|
||||
MOZ_RELEASE_ASSERT(NS_IsMainThread());
|
||||
@@ -88,6 +93,7 @@ nsConsoleService::ClearMessagesForWindowID(const uint64_t innerID)
|
||||
|
||||
uint32_t j = i;
|
||||
// Now shift all the following messages
|
||||
// XXXkhuey this is not an efficient way to iterate through an array ...
|
||||
for (; j < mBufferSize - 1 && mMessages[j + 1]; j++) {
|
||||
mMessages[j] = mMessages[j + 1];
|
||||
}
|
||||
@@ -101,8 +107,6 @@ nsConsoleService::ClearMessagesForWindowID(const uint64_t innerID)
|
||||
// Ensure the next iteration handles the messages we just shifted down
|
||||
i--;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsConsoleService::~nsConsoleService()
|
||||
@@ -131,6 +135,15 @@ public:
|
||||
{
|
||||
Preferences::AddBoolVarCache(&sLoggingEnabled, "consoleservice.enabled", true);
|
||||
Preferences::AddBoolVarCache(&sLoggingBuffered, "consoleservice.buffered", true);
|
||||
#if defined(ANDROID)
|
||||
Preferences::AddBoolVarCache(&sLoggingLogcat, "consoleservice.logcat", true);
|
||||
#endif // defined(ANDROID)
|
||||
|
||||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
||||
MOZ_ASSERT(obs);
|
||||
obs->AddObserver(mConsole, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
|
||||
obs->AddObserver(mConsole, "inner-window-destroyed", false);
|
||||
|
||||
if (!sLoggingBuffered) {
|
||||
mConsole->Reset();
|
||||
}
|
||||
@@ -241,8 +254,8 @@ nsConsoleService::LogMessageWithMode(nsIConsoleMessage* aMessage,
|
||||
{
|
||||
MutexAutoLock lock(mLock);
|
||||
|
||||
#if defined(ANDROID) && !defined(RELEASE_BUILD)
|
||||
if (aOutputMode == OutputToLog) {
|
||||
#if defined(ANDROID)
|
||||
if (sLoggingLogcat && aOutputMode == OutputToLog) {
|
||||
nsCString msg;
|
||||
aMessage->ToString(msg);
|
||||
|
||||
@@ -479,3 +492,26 @@ nsConsoleService::Reset()
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsConsoleService::Observe(nsISupports* aSubject, const char* aTopic,
|
||||
const char16_t* aData)
|
||||
{
|
||||
if (!strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) {
|
||||
// Dump all our messages, in case any are cycle collected.
|
||||
Reset();
|
||||
// We could remove ourselves from the observer service, but it is about to
|
||||
// drop all observers anyways, so why bother.
|
||||
} else if (!strcmp(aTopic, "inner-window-destroyed")) {
|
||||
nsCOMPtr<nsISupportsPRUint64> supportsInt = do_QueryInterface(aSubject);
|
||||
MOZ_ASSERT(supportsInt);
|
||||
|
||||
uint64_t windowId;
|
||||
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(supportsInt->GetData(&windowId)));
|
||||
|
||||
ClearMessagesForWindowID(windowId);
|
||||
} else {
|
||||
MOZ_CRASH();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,8 @@
|
||||
|
||||
#include "nsIConsoleService.h"
|
||||
|
||||
class nsConsoleService final : public nsIConsoleService
|
||||
class nsConsoleService final : public nsIConsoleService,
|
||||
public nsIObserver
|
||||
{
|
||||
public:
|
||||
nsConsoleService();
|
||||
@@ -27,6 +28,7 @@ public:
|
||||
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
NS_DECL_NSICONSOLESERVICE
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
void SetIsDelivering()
|
||||
{
|
||||
@@ -60,6 +62,8 @@ public:
|
||||
private:
|
||||
~nsConsoleService();
|
||||
|
||||
void ClearMessagesForWindowID(const uint64_t innerID);
|
||||
|
||||
// Circular buffer of saved messages
|
||||
nsIConsoleMessage** mMessages;
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
interface nsIConsoleListener;
|
||||
interface nsIConsoleMessage;
|
||||
|
||||
[scriptable, uuid(2436031e-2167-4307-9f1c-a3f38b55a224)]
|
||||
[scriptable, uuid(0eb81d20-c37e-42d4-82a8-ca9ae96bdf52)]
|
||||
interface nsIConsoleService : nsISupports
|
||||
{
|
||||
void logMessage(in nsIConsoleMessage message);
|
||||
@@ -44,11 +44,6 @@ interface nsIConsoleService : nsISupports
|
||||
* Clear the message buffer (e.g. for privacy reasons).
|
||||
*/
|
||||
void reset();
|
||||
|
||||
/**
|
||||
* Clear the message buffer for a given inner window.
|
||||
*/
|
||||
void clearMessagesForWindowID(in uint64_t innerWindowID);
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user