Backed out 4 changesets (bug 1532644) for causing wpt failures in /fetch/api/abort/general.any.serviceworker.html CLOSED TREE
Backed out changeset e18eed2287d2 (bug 1532644) Backed out changeset 49c1638654d6 (bug 1532644) Backed out changeset 2943c62bd7a2 (bug 1532644) Backed out changeset 0a736f3ff23c (bug 1532644)
This commit is contained in:
@@ -1071,7 +1071,7 @@ static WebIDLUtilityActorName UtilityActorNameToWebIDL(
|
|||||||
mozilla::UtilityActorName aType) {
|
mozilla::UtilityActorName aType) {
|
||||||
// Max is the value of the last enum, not the length, so add one.
|
// Max is the value of the last enum, not the length, so add one.
|
||||||
static_assert(WebIDLUtilityActorNameValues::Count ==
|
static_assert(WebIDLUtilityActorNameValues::Count ==
|
||||||
static_cast<size_t>(UtilityActorName::JSOracle) + 1,
|
static_cast<size_t>(UtilityActorName::MfMediaEngineCDM) + 1,
|
||||||
"In order for this static cast to be okay, "
|
"In order for this static cast to be okay, "
|
||||||
"UtilityActorName must match UtilityActorName exactly");
|
"UtilityActorName must match UtilityActorName exactly");
|
||||||
|
|
||||||
@@ -1083,7 +1083,6 @@ static WebIDLUtilityActorName UtilityActorNameToWebIDL(
|
|||||||
AudioDecoder_AppleMedia);
|
AudioDecoder_AppleMedia);
|
||||||
UTILITYACTORNAME_TO_WEBIDL_CASE(AudioDecoder_WMF, AudioDecoder_WMF);
|
UTILITYACTORNAME_TO_WEBIDL_CASE(AudioDecoder_WMF, AudioDecoder_WMF);
|
||||||
UTILITYACTORNAME_TO_WEBIDL_CASE(MfMediaEngineCDM, MfMediaEngineCDM);
|
UTILITYACTORNAME_TO_WEBIDL_CASE(MfMediaEngineCDM, MfMediaEngineCDM);
|
||||||
UTILITYACTORNAME_TO_WEBIDL_CASE(JSOracle, JSOracle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MOZ_ASSERT(false, "Unhandled case in WebIDLUtilityActorName");
|
MOZ_ASSERT(false, "Unhandled case in WebIDLUtilityActorName");
|
||||||
|
|||||||
@@ -727,7 +727,6 @@ enum WebIDLUtilityActorName {
|
|||||||
"audioDecoder_AppleMedia",
|
"audioDecoder_AppleMedia",
|
||||||
"audioDecoder_WMF",
|
"audioDecoder_WMF",
|
||||||
"mfMediaEngineCDM",
|
"mfMediaEngineCDM",
|
||||||
"jSOracle",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
dictionary UtilityActorsDictionary {
|
dictionary UtilityActorsDictionary {
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
||||||
/* vim: set ts=8 sts=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/. */
|
|
||||||
|
|
||||||
#include "mozilla/dom/JSOracleChild.h"
|
|
||||||
|
|
||||||
#include "mozilla/ClearOnShutdown.h"
|
|
||||||
#include "mozilla/dom/JSValidatorChild.h"
|
|
||||||
#include "mozilla/dom/PJSValidatorChild.h"
|
|
||||||
#include "mozilla/ipc/Endpoint.h"
|
|
||||||
|
|
||||||
using namespace mozilla::dom;
|
|
||||||
|
|
||||||
static mozilla::StaticRefPtr<JSOracleChild> sOracleSingletonChild;
|
|
||||||
|
|
||||||
JSOracleChild* JSOracleChild::GetSingleton() {
|
|
||||||
MOZ_ASSERT(NS_IsMainThread());
|
|
||||||
if (!sOracleSingletonChild) {
|
|
||||||
sOracleSingletonChild = new JSOracleChild();
|
|
||||||
ClearOnShutdown(&sOracleSingletonChild);
|
|
||||||
}
|
|
||||||
return sOracleSingletonChild;
|
|
||||||
}
|
|
||||||
|
|
||||||
already_AddRefed<PJSValidatorChild> JSOracleChild::AllocPJSValidatorChild() {
|
|
||||||
return MakeAndAddRef<JSValidatorChild>();
|
|
||||||
}
|
|
||||||
|
|
||||||
void JSOracleChild::Start(Endpoint<PJSOracleChild>&& aEndpoint) {
|
|
||||||
DebugOnly<bool> ok = std::move(aEndpoint).Bind(this);
|
|
||||||
MOZ_ASSERT(ok);
|
|
||||||
}
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
||||||
/* vim: set ts=8 sts=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/. */
|
|
||||||
|
|
||||||
#ifndef mozilla_dom_JSOracleChild
|
|
||||||
#define mozilla_dom_JSOracleChild
|
|
||||||
|
|
||||||
#include "mozilla/dom/PJSOracleChild.h"
|
|
||||||
|
|
||||||
namespace mozilla::ipc {
|
|
||||||
class UtilityProcessParent;
|
|
||||||
}
|
|
||||||
namespace mozilla::dom {
|
|
||||||
|
|
||||||
class PJSValidatorChild;
|
|
||||||
|
|
||||||
class JSOracleChild final : public PJSOracleChild {
|
|
||||||
public:
|
|
||||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(JSOracleChild, override);
|
|
||||||
|
|
||||||
already_AddRefed<PJSValidatorChild> AllocPJSValidatorChild();
|
|
||||||
|
|
||||||
void Start(Endpoint<PJSOracleChild>&& aEndpoint);
|
|
||||||
|
|
||||||
private:
|
|
||||||
~JSOracleChild() = default;
|
|
||||||
|
|
||||||
static JSOracleChild* GetSingleton();
|
|
||||||
};
|
|
||||||
} // namespace mozilla::dom
|
|
||||||
|
|
||||||
#endif // defined(mozilla_dom_JSOracleChild)
|
|
||||||
@@ -1,72 +0,0 @@
|
|||||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
||||||
/* vim: set ts=8 sts=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/. */
|
|
||||||
|
|
||||||
#include "mozilla/dom/JSOracleParent.h"
|
|
||||||
#include "mozilla/ClearOnShutdown.h"
|
|
||||||
#include "mozilla/RefPtr.h"
|
|
||||||
#include "mozilla/dom/PJSOracle.h"
|
|
||||||
#include "mozilla/ipc/Endpoint.h"
|
|
||||||
#include "mozilla/ipc/UtilityProcessManager.h"
|
|
||||||
|
|
||||||
using namespace mozilla;
|
|
||||||
using namespace mozilla::dom;
|
|
||||||
|
|
||||||
static StaticRefPtr<JSOracleParent> sOracleSingleton;
|
|
||||||
|
|
||||||
/* static */
|
|
||||||
void JSOracleParent::WithJSOracle(
|
|
||||||
const std::function<void(JSOracleParent* aParent)>& aCallback) {
|
|
||||||
GetSingleton()->StartJSOracle()->Then(
|
|
||||||
GetMainThreadSerialEventTarget(), __func__,
|
|
||||||
[aCallback](const JSOraclePromise::ResolveOrRejectValue& aResult) {
|
|
||||||
aCallback(aResult.IsReject() || !aResult.ResolveValue()
|
|
||||||
? nullptr
|
|
||||||
: GetSingleton());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void JSOracleParent::ActorDestroy(ActorDestroyReason aReason) {}
|
|
||||||
|
|
||||||
/* static */
|
|
||||||
JSOracleParent* JSOracleParent::GetSingleton() {
|
|
||||||
if (!sOracleSingleton) {
|
|
||||||
sOracleSingleton = new JSOracleParent();
|
|
||||||
ClearOnShutdown(&sOracleSingleton);
|
|
||||||
}
|
|
||||||
|
|
||||||
return sOracleSingleton;
|
|
||||||
}
|
|
||||||
|
|
||||||
RefPtr<JSOracleParent::JSOraclePromise> JSOracleParent::StartJSOracle() {
|
|
||||||
using namespace mozilla::ipc;
|
|
||||||
RefPtr<JSOracleParent> parent = JSOracleParent::GetSingleton();
|
|
||||||
return UtilityProcessManager::GetSingleton()->StartJSOracle(parent);
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult JSOracleParent::BindToUtilityProcess(
|
|
||||||
const RefPtr<mozilla::ipc::UtilityProcessParent>& aUtilityParent) {
|
|
||||||
Endpoint<PJSOracleParent> parentEnd;
|
|
||||||
Endpoint<PJSOracleChild> childEnd;
|
|
||||||
MOZ_ASSERT(aUtilityParent);
|
|
||||||
if (NS_FAILED(PJSOracle::CreateEndpoints(base::GetCurrentProcId(),
|
|
||||||
aUtilityParent->OtherPid(),
|
|
||||||
&parentEnd, &childEnd))) {
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!aUtilityParent->SendStartJSOracleService(std::move(childEnd))) {
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
Bind(std::move(parentEnd));
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
void JSOracleParent::Bind(Endpoint<PJSOracleParent>&& aEndpoint) {
|
|
||||||
DebugOnly<bool> ok = aEndpoint.Bind(this);
|
|
||||||
MOZ_ASSERT(ok);
|
|
||||||
}
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
||||||
/* vim: set ts=8 sts=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/. */
|
|
||||||
|
|
||||||
#ifndef mozilla_dom_JSOracleParent
|
|
||||||
#define mozilla_dom_JSOracleParent
|
|
||||||
|
|
||||||
#include "mozilla/MozPromise.h"
|
|
||||||
#include "mozilla/ProcInfo.h"
|
|
||||||
#include "mozilla/dom/PJSOracleParent.h"
|
|
||||||
|
|
||||||
namespace mozilla::ipc {
|
|
||||||
class UtilityProcessParent;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace mozilla::dom {
|
|
||||||
|
|
||||||
class JSOracleParent final : public PJSOracleParent {
|
|
||||||
public:
|
|
||||||
JSOracleParent() = default;
|
|
||||||
|
|
||||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(JSOracleParent, override);
|
|
||||||
|
|
||||||
static void WithJSOracle(
|
|
||||||
const std::function<void(JSOracleParent* aParent)>& aCallback);
|
|
||||||
|
|
||||||
UtilityActorName GetActorName() { return UtilityActorName::JSOracle; }
|
|
||||||
|
|
||||||
void ActorDestroy(ActorDestroyReason aReason) override;
|
|
||||||
|
|
||||||
nsresult BindToUtilityProcess(
|
|
||||||
const RefPtr<mozilla::ipc::UtilityProcessParent>& aUtilityParent);
|
|
||||||
|
|
||||||
void Bind(Endpoint<PJSOracleParent>&& aEndpoint);
|
|
||||||
|
|
||||||
private:
|
|
||||||
~JSOracleParent() = default;
|
|
||||||
|
|
||||||
static JSOracleParent* GetSingleton();
|
|
||||||
|
|
||||||
using JSOraclePromise = GenericNonExclusivePromise;
|
|
||||||
RefPtr<JSOraclePromise> StartJSOracle();
|
|
||||||
};
|
|
||||||
} // namespace mozilla::dom
|
|
||||||
|
|
||||||
#endif // defined(mozilla_dom_JSOracleParent)
|
|
||||||
@@ -1,81 +0,0 @@
|
|||||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
||||||
/* vim: set ts=8 sts=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/. */
|
|
||||||
|
|
||||||
#include "mozilla/dom/JSValidatorChild.h"
|
|
||||||
#include "mozilla/ipc/Endpoint.h"
|
|
||||||
|
|
||||||
using namespace mozilla::dom;
|
|
||||||
|
|
||||||
mozilla::ipc::IPCResult JSValidatorChild::RecvIsOpaqueResponseAllowed(
|
|
||||||
IsOpaqueResponseAllowedResolver&& aResolver) {
|
|
||||||
mResolver.emplace(aResolver);
|
|
||||||
|
|
||||||
return IPC_OK();
|
|
||||||
}
|
|
||||||
|
|
||||||
mozilla::ipc::IPCResult JSValidatorChild::RecvOnDataAvailable(Shmem&& aData) {
|
|
||||||
MOZ_ASSERT(mResolver);
|
|
||||||
|
|
||||||
if (!mSourceBytes.Append(Span(aData.get<char>(), aData.Size<char>()),
|
|
||||||
mozilla::fallible)) {
|
|
||||||
// To prevent an attacker from flood the validation process,
|
|
||||||
// we don't validate here.
|
|
||||||
Resolve(false);
|
|
||||||
}
|
|
||||||
DeallocShmem(aData);
|
|
||||||
|
|
||||||
return IPC_OK();
|
|
||||||
}
|
|
||||||
|
|
||||||
mozilla::ipc::IPCResult JSValidatorChild::RecvOnStopRequest(
|
|
||||||
const nsresult& aReason) {
|
|
||||||
if (!mResolver) {
|
|
||||||
return IPC_OK();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NS_FAILED(aReason)) {
|
|
||||||
Resolve(false);
|
|
||||||
} else {
|
|
||||||
Resolve(ShouldAllowJS());
|
|
||||||
}
|
|
||||||
|
|
||||||
return IPC_OK();
|
|
||||||
}
|
|
||||||
|
|
||||||
void JSValidatorChild::ActorDestroy(ActorDestroyReason aReason) {
|
|
||||||
if (mResolver) {
|
|
||||||
Resolve(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
void JSValidatorChild::Resolve(bool aAllow) {
|
|
||||||
MOZ_ASSERT(mResolver);
|
|
||||||
Maybe<Shmem> data = Nothing();
|
|
||||||
if (aAllow) {
|
|
||||||
if (!mSourceBytes.IsEmpty()) {
|
|
||||||
Shmem sharedData;
|
|
||||||
nsresult rv =
|
|
||||||
JSValidatorUtils::CopyCStringToShmem(this, mSourceBytes, sharedData);
|
|
||||||
if (NS_SUCCEEDED(rv)) {
|
|
||||||
data = Some(std::move(sharedData));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mResolver.ref()(
|
|
||||||
Tuple<const bool&, mozilla::Maybe<Shmem>&&>(aAllow, std::move(data)));
|
|
||||||
mResolver = Nothing();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool JSValidatorChild::ShouldAllowJS() const {
|
|
||||||
// mSourceBytes could be empty when
|
|
||||||
// 1. No OnDataAvailable calls
|
|
||||||
// 2. Failed to allocate shmem
|
|
||||||
//
|
|
||||||
// TODO(sefeng): THIS IS A VERY TEMPORARY SOLUTION
|
|
||||||
return !mSourceBytes.IsEmpty()
|
|
||||||
? !StringBeginsWith(NS_ConvertUTF8toUTF16(mSourceBytes), u"{"_ns)
|
|
||||||
: true;
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
||||||
/* vim: set ts=8 sts=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/. */
|
|
||||||
|
|
||||||
#ifndef mozilla_dom_JSValidatorChild
|
|
||||||
#define mozilla_dom_JSValidatorChild
|
|
||||||
|
|
||||||
#include "mozilla/ProcInfo.h"
|
|
||||||
#include "mozilla/dom/PJSValidatorChild.h"
|
|
||||||
#include "mozilla/dom/JSValidatorUtils.h"
|
|
||||||
|
|
||||||
namespace mozilla::dom {
|
|
||||||
class JSValidatorChild final : public PJSValidatorChild {
|
|
||||||
public:
|
|
||||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(JSValidatorChild, override);
|
|
||||||
|
|
||||||
mozilla::ipc::IPCResult RecvIsOpaqueResponseAllowed(
|
|
||||||
IsOpaqueResponseAllowedResolver&& aResolver);
|
|
||||||
|
|
||||||
mozilla::ipc::IPCResult RecvOnDataAvailable(Shmem&& aData);
|
|
||||||
|
|
||||||
mozilla::ipc::IPCResult RecvOnStopRequest(const nsresult& aReason);
|
|
||||||
|
|
||||||
void ActorDestroy(ActorDestroyReason aReason) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
virtual ~JSValidatorChild() = default;
|
|
||||||
|
|
||||||
void Resolve(bool aAllow);
|
|
||||||
bool ShouldAllowJS() const;
|
|
||||||
|
|
||||||
nsCString mSourceBytes;
|
|
||||||
Maybe<IsOpaqueResponseAllowedResolver> mResolver;
|
|
||||||
};
|
|
||||||
} // namespace mozilla::dom
|
|
||||||
|
|
||||||
#endif // defined(mozilla_dom_JSValidatorChild)
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
||||||
/* vim: set ts=8 sts=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/. */
|
|
||||||
|
|
||||||
#include "mozilla/net/OpaqueResponseUtils.h"
|
|
||||||
#include "mozilla/dom/JSValidatorParent.h"
|
|
||||||
#include "mozilla/dom/JSValidatorUtils.h"
|
|
||||||
#include "mozilla/dom/JSOracleParent.h"
|
|
||||||
#include "mozilla/RefPtr.h"
|
|
||||||
|
|
||||||
namespace mozilla::dom {
|
|
||||||
/* static */
|
|
||||||
already_AddRefed<JSValidatorParent> JSValidatorParent::Create() {
|
|
||||||
RefPtr<JSValidatorParent> validator = new JSValidatorParent();
|
|
||||||
JSOracleParent::WithJSOracle([validator](JSOracleParent* aParent) {
|
|
||||||
MOZ_ASSERT_IF(aParent, aParent->CanSend());
|
|
||||||
if (aParent) {
|
|
||||||
MOZ_ALWAYS_TRUE(aParent->SendPJSValidatorConstructor(validator));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return validator.forget();
|
|
||||||
}
|
|
||||||
|
|
||||||
void JSValidatorParent::IsOpaqueResponseAllowed(
|
|
||||||
const std::function<void(bool, Maybe<Shmem>)>& aCallback) {
|
|
||||||
JSOracleParent::WithJSOracle([=, self = RefPtr{this}](const auto* aParent) {
|
|
||||||
if (aParent) {
|
|
||||||
MOZ_DIAGNOSTIC_ASSERT(self->CanSend());
|
|
||||||
self->SendIsOpaqueResponseAllowed()->Then(
|
|
||||||
GetMainThreadSerialEventTarget(), __func__,
|
|
||||||
[aCallback](
|
|
||||||
const IsOpaqueResponseAllowedPromise::ResolveOrRejectValue&
|
|
||||||
aResult) {
|
|
||||||
if (aResult.IsResolve()) {
|
|
||||||
const Tuple<bool, Maybe<Shmem>>& result = aResult.ResolveValue();
|
|
||||||
aCallback(Get<0>(result), Get<1>(aResult.ResolveValue()));
|
|
||||||
} else {
|
|
||||||
aCallback(false, Nothing());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
aCallback(false, Nothing());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void JSValidatorParent::OnDataAvailable(const nsACString& aData) {
|
|
||||||
JSOracleParent::WithJSOracle(
|
|
||||||
[self = RefPtr{this}, data = nsCString{aData}](const auto* aParent) {
|
|
||||||
if (!aParent) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (self->CanSend()) {
|
|
||||||
Shmem sharedData;
|
|
||||||
nsresult rv =
|
|
||||||
JSValidatorUtils::CopyCStringToShmem(self, data, sharedData);
|
|
||||||
if (NS_FAILED(rv)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Unused << self->SendOnDataAvailable(std::move(sharedData));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void JSValidatorParent::OnStopRequest(nsresult aResult) {
|
|
||||||
JSOracleParent::WithJSOracle(
|
|
||||||
[self = RefPtr{this}, aResult](const auto* aParent) {
|
|
||||||
if (!aParent) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (self->CanSend()) {
|
|
||||||
Unused << self->SendOnStopRequest(aResult);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} // namespace mozilla::dom
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
||||||
/* vim: set ts=8 sts=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/. */
|
|
||||||
|
|
||||||
#ifndef mozilla_dom_JSValidatorParent
|
|
||||||
#define mozilla_dom_JSValidatorParent
|
|
||||||
|
|
||||||
#include "mozilla/MozPromise.h"
|
|
||||||
#include "mozilla/ProcInfo.h"
|
|
||||||
#include "mozilla/dom/PJSValidatorParent.h"
|
|
||||||
|
|
||||||
namespace mozilla::ipc {
|
|
||||||
class UtilityProcessParent;
|
|
||||||
class IProtocol;
|
|
||||||
} // namespace mozilla::ipc
|
|
||||||
|
|
||||||
namespace mozilla::dom {
|
|
||||||
|
|
||||||
class JSValidatorParent final : public PJSValidatorParent {
|
|
||||||
public:
|
|
||||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(JSValidatorParent, override);
|
|
||||||
|
|
||||||
static already_AddRefed<JSValidatorParent> Create();
|
|
||||||
|
|
||||||
void IsOpaqueResponseAllowed(
|
|
||||||
const std::function<void(bool, Maybe<mozilla::ipc::Shmem>)>& aCallback);
|
|
||||||
|
|
||||||
void OnDataAvailable(const nsACString& aData);
|
|
||||||
|
|
||||||
void OnStopRequest(nsresult aResult);
|
|
||||||
|
|
||||||
private:
|
|
||||||
virtual ~JSValidatorParent() = default;
|
|
||||||
};
|
|
||||||
} // namespace mozilla::dom
|
|
||||||
|
|
||||||
#endif // defined(mozilla_dom_JSValidatorParent)
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
||||||
/* vim: set ts=8 sts=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/. */
|
|
||||||
|
|
||||||
#include "mozilla/dom/JSValidatorUtils.h"
|
|
||||||
#include "mozilla/ipc/ProtocolUtils.h"
|
|
||||||
#include "mozilla/ipc/Shmem.h"
|
|
||||||
#include "nsStringFwd.h"
|
|
||||||
|
|
||||||
using namespace mozilla::ipc;
|
|
||||||
|
|
||||||
namespace mozilla::dom {
|
|
||||||
/* static */
|
|
||||||
nsresult JSValidatorUtils::CopyCStringToShmem(IProtocol* aActor,
|
|
||||||
const nsCString& aCString,
|
|
||||||
Shmem& aMem) {
|
|
||||||
if (!aActor->AllocShmem(aCString.Length(), &aMem)) {
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
}
|
|
||||||
memcpy(aMem.get<char>(), aCString.BeginReading(), aCString.Length());
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
} // namespace mozilla::dom
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
||||||
/* vim: set ts=8 sts=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/. */
|
|
||||||
|
|
||||||
#ifndef mozilla_dom_JSValidatorUtils
|
|
||||||
#define mozilla_dom_JSValidatorUtils
|
|
||||||
#include "ErrorList.h"
|
|
||||||
#include "nsStringFwd.h"
|
|
||||||
|
|
||||||
namespace mozilla::ipc {
|
|
||||||
class IProtocol;
|
|
||||||
class Shmem;
|
|
||||||
} // namespace mozilla::ipc
|
|
||||||
|
|
||||||
using namespace mozilla::ipc;
|
|
||||||
|
|
||||||
namespace mozilla::dom {
|
|
||||||
class JSValidatorUtils final {
|
|
||||||
public:
|
|
||||||
static nsresult CopyCStringToShmem(IProtocol* aActor,
|
|
||||||
const nsCString& aCString, Shmem& aMem);
|
|
||||||
};
|
|
||||||
}; // namespace mozilla::dom
|
|
||||||
#endif
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
/* -*- Mode: C++; 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/. */
|
|
||||||
|
|
||||||
include protocol PJSValidator;
|
|
||||||
|
|
||||||
namespace mozilla {
|
|
||||||
namespace dom {
|
|
||||||
|
|
||||||
// PJSOracle is a top-level actor which manages PJSValidator
|
|
||||||
async protocol PJSOracle {
|
|
||||||
manages PJSValidator;
|
|
||||||
|
|
||||||
child:
|
|
||||||
async PJSValidator();
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace dom
|
|
||||||
} // namespace mozilla
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
/* -*- Mode: C++; 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/. */
|
|
||||||
|
|
||||||
include protocol PJSOracle;
|
|
||||||
|
|
||||||
namespace mozilla {
|
|
||||||
namespace dom {
|
|
||||||
|
|
||||||
async protocol PJSValidator {
|
|
||||||
manager PJSOracle;
|
|
||||||
|
|
||||||
child:
|
|
||||||
async IsOpaqueResponseAllowed() returns(bool aAllowed, Shmem? aMem);
|
|
||||||
|
|
||||||
async OnDataAvailable(Shmem aData);
|
|
||||||
|
|
||||||
async OnStopRequest(nsresult aReason);
|
|
||||||
|
|
||||||
async __delete__();
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace dom
|
|
||||||
} // namespace mozilla
|
|
||||||
@@ -58,11 +58,6 @@ EXPORTS.mozilla.dom += [
|
|||||||
"FilePickerParent.h",
|
"FilePickerParent.h",
|
||||||
"InProcessChild.h",
|
"InProcessChild.h",
|
||||||
"InProcessParent.h",
|
"InProcessParent.h",
|
||||||
"JSOracleChild.h",
|
|
||||||
"JSOracleParent.h",
|
|
||||||
"JSValidatorChild.h",
|
|
||||||
"JSValidatorParent.h",
|
|
||||||
"JSValidatorUtils.h",
|
|
||||||
"LoginDetectionService.h",
|
"LoginDetectionService.h",
|
||||||
"MaybeDiscarded.h",
|
"MaybeDiscarded.h",
|
||||||
"MemoryReportRequest.h",
|
"MemoryReportRequest.h",
|
||||||
@@ -120,11 +115,6 @@ UNIFIED_SOURCES += [
|
|||||||
"DocShellMessageUtils.cpp",
|
"DocShellMessageUtils.cpp",
|
||||||
"FilePickerParent.cpp",
|
"FilePickerParent.cpp",
|
||||||
"InProcessImpl.cpp",
|
"InProcessImpl.cpp",
|
||||||
"JSOracleChild.cpp",
|
|
||||||
"JSOracleParent.cpp",
|
|
||||||
"JSValidatorChild.cpp",
|
|
||||||
"JSValidatorParent.cpp",
|
|
||||||
"JSValidatorUtils.cpp",
|
|
||||||
"LoginDetectionService.cpp",
|
"LoginDetectionService.cpp",
|
||||||
"MemMapSnapshot.cpp",
|
"MemMapSnapshot.cpp",
|
||||||
"MemoryReportRequest.cpp",
|
"MemoryReportRequest.cpp",
|
||||||
@@ -174,8 +164,6 @@ IPDL_SOURCES += [
|
|||||||
"PCycleCollectWithLogs.ipdl",
|
"PCycleCollectWithLogs.ipdl",
|
||||||
"PFilePicker.ipdl",
|
"PFilePicker.ipdl",
|
||||||
"PInProcess.ipdl",
|
"PInProcess.ipdl",
|
||||||
"PJSOracle.ipdl",
|
|
||||||
"PJSValidator.ipdl",
|
|
||||||
"PLoginReputation.ipdl",
|
"PLoginReputation.ipdl",
|
||||||
"PProcessHangMonitor.ipdl",
|
"PProcessHangMonitor.ipdl",
|
||||||
"PrefsTypes.ipdlh",
|
"PrefsTypes.ipdlh",
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ include PrefsTypes;
|
|||||||
|
|
||||||
include protocol PProfiler;
|
include protocol PProfiler;
|
||||||
include protocol PUtilityAudioDecoder;
|
include protocol PUtilityAudioDecoder;
|
||||||
include protocol PJSOracle;
|
|
||||||
|
|
||||||
#if defined(MOZ_SANDBOX) && defined(MOZ_DEBUG) && defined(ENABLE_TESTS)
|
#if defined(MOZ_SANDBOX) && defined(MOZ_DEBUG) && defined(ENABLE_TESTS)
|
||||||
include protocol PSandboxTesting;
|
include protocol PSandboxTesting;
|
||||||
@@ -83,8 +82,6 @@ child:
|
|||||||
|
|
||||||
async StartUtilityAudioDecoderService(Endpoint<PUtilityAudioDecoderParent> aEndpoint);
|
async StartUtilityAudioDecoderService(Endpoint<PUtilityAudioDecoderParent> aEndpoint);
|
||||||
|
|
||||||
async StartJSOracleService(Endpoint<PJSOracleChild> aEndpoint);
|
|
||||||
|
|
||||||
#if defined(MOZ_SANDBOX) && defined(MOZ_DEBUG) && defined(ENABLE_TESTS)
|
#if defined(MOZ_SANDBOX) && defined(MOZ_DEBUG) && defined(ENABLE_TESTS)
|
||||||
async InitSandboxTesting(Endpoint<PSandboxTestingChild> aEndpoint);
|
async InitSandboxTesting(Endpoint<PSandboxTestingChild> aEndpoint);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
#include "mozilla/ipc/UtilityProcessManager.h"
|
#include "mozilla/ipc/UtilityProcessManager.h"
|
||||||
#include "mozilla/ipc/UtilityProcessSandboxing.h"
|
#include "mozilla/ipc/UtilityProcessSandboxing.h"
|
||||||
#include "mozilla/dom/ContentParent.h"
|
#include "mozilla/dom/ContentParent.h"
|
||||||
#include "mozilla/dom/JSOracleChild.h"
|
|
||||||
#include "mozilla/dom/MemoryReportRequest.h"
|
#include "mozilla/dom/MemoryReportRequest.h"
|
||||||
#include "mozilla/ipc/CrashReporterClient.h"
|
#include "mozilla/ipc/CrashReporterClient.h"
|
||||||
#include "mozilla/ipc/Endpoint.h"
|
#include "mozilla/ipc/Endpoint.h"
|
||||||
@@ -238,17 +237,6 @@ UtilityProcessChild::RecvStartUtilityAudioDecoderService(
|
|||||||
return IPC_OK();
|
return IPC_OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
mozilla::ipc::IPCResult UtilityProcessChild::RecvStartJSOracleService(
|
|
||||||
Endpoint<PJSOracleChild>&& aEndpoint) {
|
|
||||||
mJSOracleInstance = new mozilla::dom::JSOracleChild();
|
|
||||||
if (!mJSOracleInstance) {
|
|
||||||
return IPC_FAIL(this, "Failing to create JSOracleParent");
|
|
||||||
}
|
|
||||||
|
|
||||||
mJSOracleInstance->Start(std::move(aEndpoint));
|
|
||||||
return IPC_OK();
|
|
||||||
}
|
|
||||||
|
|
||||||
void UtilityProcessChild::ActorDestroy(ActorDestroyReason aWhy) {
|
void UtilityProcessChild::ActorDestroy(ActorDestroyReason aWhy) {
|
||||||
if (AbnormalShutdown == aWhy) {
|
if (AbnormalShutdown == aWhy) {
|
||||||
NS_WARNING("Shutting down Utility process early due to a crash!");
|
NS_WARNING("Shutting down Utility process early due to a crash!");
|
||||||
|
|||||||
@@ -13,11 +13,6 @@
|
|||||||
|
|
||||||
#include "mozilla/PRemoteDecoderManagerParent.h"
|
#include "mozilla/PRemoteDecoderManagerParent.h"
|
||||||
#include "mozilla/ipc/AsyncBlockers.h"
|
#include "mozilla/ipc/AsyncBlockers.h"
|
||||||
#include "mozilla/dom/JSOracleChild.h"
|
|
||||||
|
|
||||||
namespace mozilla::dom {
|
|
||||||
class PJSOracleChild;
|
|
||||||
} // namespace mozilla::dom
|
|
||||||
|
|
||||||
namespace mozilla::ipc {
|
namespace mozilla::ipc {
|
||||||
|
|
||||||
@@ -60,9 +55,6 @@ class UtilityProcessChild final : public PUtilityProcessChild {
|
|||||||
mozilla::ipc::IPCResult RecvStartUtilityAudioDecoderService(
|
mozilla::ipc::IPCResult RecvStartUtilityAudioDecoderService(
|
||||||
Endpoint<PUtilityAudioDecoderParent>&& aEndpoint);
|
Endpoint<PUtilityAudioDecoderParent>&& aEndpoint);
|
||||||
|
|
||||||
mozilla::ipc::IPCResult RecvStartJSOracleService(
|
|
||||||
Endpoint<dom::PJSOracleChild>&& aEndpoint);
|
|
||||||
|
|
||||||
AsyncBlockers& AsyncShutdownService() { return mShutdownBlockers; }
|
AsyncBlockers& AsyncShutdownService() { return mShutdownBlockers; }
|
||||||
|
|
||||||
void ActorDestroy(ActorDestroyReason aWhy) override;
|
void ActorDestroy(ActorDestroyReason aWhy) override;
|
||||||
@@ -79,7 +71,6 @@ class UtilityProcessChild final : public PUtilityProcessChild {
|
|||||||
private:
|
private:
|
||||||
RefPtr<ChildProfilerController> mProfilerController;
|
RefPtr<ChildProfilerController> mProfilerController;
|
||||||
RefPtr<UtilityAudioDecoderParent> mUtilityAudioDecoderInstance{};
|
RefPtr<UtilityAudioDecoderParent> mUtilityAudioDecoderInstance{};
|
||||||
RefPtr<dom::JSOracleChild> mJSOracleInstance{};
|
|
||||||
AsyncBlockers mShutdownBlockers;
|
AsyncBlockers mShutdownBlockers;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
#include "UtilityProcessManager.h"
|
#include "UtilityProcessManager.h"
|
||||||
|
|
||||||
#include "JSOracleParent.h"
|
|
||||||
#include "mozilla/ipc/UtilityProcessHost.h"
|
#include "mozilla/ipc/UtilityProcessHost.h"
|
||||||
#include "mozilla/MemoryReportingProcess.h"
|
#include "mozilla/MemoryReportingProcess.h"
|
||||||
#include "mozilla/Preferences.h"
|
#include "mozilla/Preferences.h"
|
||||||
@@ -351,11 +350,6 @@ UtilityProcessManager::StartProcessForRemoteMediaDecoding(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<UtilityProcessManager::JSOraclePromise>
|
|
||||||
UtilityProcessManager::StartJSOracle(dom::JSOracleParent* aParent) {
|
|
||||||
return StartUtility(RefPtr{aParent}, SandboxingKind::GENERIC_UTILITY);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UtilityProcessManager::IsProcessLaunching(SandboxingKind aSandbox) {
|
bool UtilityProcessManager::IsProcessLaunching(SandboxingKind aSandbox) {
|
||||||
MOZ_ASSERT(NS_IsMainThread());
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
|
|
||||||
|
|||||||
@@ -18,10 +18,6 @@ namespace mozilla {
|
|||||||
|
|
||||||
class MemoryReportingProcess;
|
class MemoryReportingProcess;
|
||||||
|
|
||||||
namespace dom {
|
|
||||||
class JSOracleParent;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace ipc {
|
namespace ipc {
|
||||||
|
|
||||||
class UtilityProcessParent;
|
class UtilityProcessParent;
|
||||||
@@ -35,7 +31,6 @@ class UtilityProcessManager final : public UtilityProcessHost::Listener {
|
|||||||
public:
|
public:
|
||||||
using StartRemoteDecodingUtilityPromise =
|
using StartRemoteDecodingUtilityPromise =
|
||||||
MozPromise<Endpoint<PRemoteDecoderManagerChild>, nsresult, true>;
|
MozPromise<Endpoint<PRemoteDecoderManagerChild>, nsresult, true>;
|
||||||
using JSOraclePromise = GenericNonExclusivePromise;
|
|
||||||
|
|
||||||
static void Initialize();
|
static void Initialize();
|
||||||
static void Shutdown();
|
static void Shutdown();
|
||||||
@@ -54,8 +49,6 @@ class UtilityProcessManager final : public UtilityProcessHost::Listener {
|
|||||||
RefPtr<StartRemoteDecodingUtilityPromise> StartProcessForRemoteMediaDecoding(
|
RefPtr<StartRemoteDecodingUtilityPromise> StartProcessForRemoteMediaDecoding(
|
||||||
base::ProcessId aOtherProcess, SandboxingKind aSandbox);
|
base::ProcessId aOtherProcess, SandboxingKind aSandbox);
|
||||||
|
|
||||||
RefPtr<JSOraclePromise> StartJSOracle(mozilla::dom::JSOracleParent* aParent);
|
|
||||||
|
|
||||||
void OnProcessUnexpectedShutdown(UtilityProcessHost* aHost);
|
void OnProcessUnexpectedShutdown(UtilityProcessHost* aHost);
|
||||||
|
|
||||||
// Returns the platform pid for this utility sandbox process.
|
// Returns the platform pid for this utility sandbox process.
|
||||||
|
|||||||
@@ -1672,13 +1672,6 @@
|
|||||||
#endif
|
#endif
|
||||||
mirror: always
|
mirror: always
|
||||||
|
|
||||||
# When this pref is enabled, the JS validator will be enabled for
|
|
||||||
# ORB.
|
|
||||||
- name: browser.opaqueResponseBlocking.javascriptValidator
|
|
||||||
type: bool
|
|
||||||
value: @IS_NIGHTLY_BUILD@
|
|
||||||
mirror: always
|
|
||||||
|
|
||||||
# When this pref is enabled, <object> and <embed> elements will create
|
# When this pref is enabled, <object> and <embed> elements will create
|
||||||
# synthetic documents when the resource type they're loading is an image.
|
# synthetic documents when the resource type they're loading is an image.
|
||||||
- name: browser.opaqueResponseBlocking.syntheticBrowsingContext
|
- name: browser.opaqueResponseBlocking.syntheticBrowsingContext
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
#include "mozilla/net/OpaqueResponseUtils.h"
|
#include "mozilla/net/OpaqueResponseUtils.h"
|
||||||
|
|
||||||
#include "mozilla/dom/Document.h"
|
#include "mozilla/dom/Document.h"
|
||||||
#include "mozilla/StaticPrefs_browser.h"
|
|
||||||
#include "ErrorList.h"
|
#include "ErrorList.h"
|
||||||
#include "nsContentUtils.h"
|
#include "nsContentUtils.h"
|
||||||
#include "nsHttpResponseHead.h"
|
#include "nsHttpResponseHead.h"
|
||||||
@@ -238,23 +237,12 @@ NS_IMETHODIMP
|
|||||||
OpaqueResponseBlocker::OnStartRequest(nsIRequest* aRequest) {
|
OpaqueResponseBlocker::OnStartRequest(nsIRequest* aRequest) {
|
||||||
LOGORB();
|
LOGORB();
|
||||||
|
|
||||||
if (mState == State::Sniffing) {
|
Unused << EnsureOpaqueResponseIsAllowedAfterSniff(aRequest);
|
||||||
Unused << EnsureOpaqueResponseIsAllowedAfterSniff(aRequest);
|
|
||||||
}
|
|
||||||
|
|
||||||
// mState will remain State::Sniffing if we need to wait
|
MOZ_ASSERT(mState != State::Sniffing);
|
||||||
// for JS validator to make a decision.
|
|
||||||
//
|
|
||||||
// When the state is Sniffing, we can't call mNext->OnStartRequest
|
|
||||||
// because fetch requests need the cancellation to be done
|
|
||||||
// before its FetchDriver::OnStartRequest is called, otherwise it'll
|
|
||||||
// resolve the promise regardless the decision of JS validator.
|
|
||||||
if (mState != State::Sniffing) {
|
|
||||||
nsresult rv = mNext->OnStartRequest(aRequest);
|
|
||||||
return NS_SUCCEEDED(mStatus) ? rv : mStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NS_OK;
|
nsresult rv = mNext->OnStartRequest(aRequest);
|
||||||
|
return NS_SUCCEEDED(mStatus) ? rv : mStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
@@ -268,13 +256,6 @@ OpaqueResponseBlocker::OnStopRequest(nsIRequest* aRequest,
|
|||||||
statusForStop = mStatus;
|
statusForStop = mStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mState == State::Sniffing) {
|
|
||||||
MOZ_ASSERT(mJSValidator);
|
|
||||||
mPendingOnStopRequestStatus = Some(aStatusCode);
|
|
||||||
mJSValidator->OnStopRequest(aStatusCode);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
return mNext->OnStopRequest(aRequest, statusForStop);
|
return mNext->OnStopRequest(aRequest, statusForStop);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -284,6 +265,7 @@ OpaqueResponseBlocker::OnDataAvailable(nsIRequest* aRequest,
|
|||||||
uint64_t aOffset, uint32_t aCount) {
|
uint64_t aOffset, uint32_t aCount) {
|
||||||
LOGORB();
|
LOGORB();
|
||||||
|
|
||||||
|
MOZ_ASSERT(mState == State::Allowed || mState == State::Blocked);
|
||||||
if (mState == State::Allowed) {
|
if (mState == State::Allowed) {
|
||||||
return mNext->OnDataAvailable(aRequest, aInputStream, aOffset, aCount);
|
return mNext->OnDataAvailable(aRequest, aInputStream, aOffset, aCount);
|
||||||
}
|
}
|
||||||
@@ -292,23 +274,6 @@ OpaqueResponseBlocker::OnDataAvailable(nsIRequest* aRequest,
|
|||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
MOZ_ASSERT(mState == State::Sniffing);
|
|
||||||
|
|
||||||
nsCString data;
|
|
||||||
if (!data.SetLength(aCount, fallible)) {
|
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t read;
|
|
||||||
nsresult rv = aInputStream->Read(data.BeginWriting(), aCount, &read);
|
|
||||||
if (NS_FAILED(rv)) {
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
MOZ_ASSERT(mJSValidator);
|
|
||||||
|
|
||||||
mJSValidator->OnDataAvailable(data);
|
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -317,11 +282,7 @@ nsresult OpaqueResponseBlocker::EnsureOpaqueResponseIsAllowedAfterSniff(
|
|||||||
nsCOMPtr<HttpBaseChannel> httpBaseChannel = do_QueryInterface(aRequest);
|
nsCOMPtr<HttpBaseChannel> httpBaseChannel = do_QueryInterface(aRequest);
|
||||||
MOZ_ASSERT(httpBaseChannel);
|
MOZ_ASSERT(httpBaseChannel);
|
||||||
|
|
||||||
// The `AfterSniff` check shouldn't be run when
|
if (mState != State::Sniffing) {
|
||||||
// 1. We have made a decision already
|
|
||||||
// 2. The JS validator is running, so we should wait
|
|
||||||
// for its result.
|
|
||||||
if (mState != State::Sniffing || mJSValidator) {
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -356,8 +317,7 @@ nsresult OpaqueResponseBlocker::EnsureOpaqueResponseIsAllowedAfterSniff(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
MOZ_ASSERT(mState == State::Sniffing);
|
return ValidateJavaScript(httpBaseChannel);
|
||||||
return ValidateJavaScript(httpBaseChannel, uri, loadInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// The specification for ORB is currently being written:
|
// The specification for ORB is currently being written:
|
||||||
@@ -367,18 +327,8 @@ nsresult OpaqueResponseBlocker::EnsureOpaqueResponseIsAllowedAfterSniff(
|
|||||||
// * `nsHttpChannel::DisableIsOpaqueResponseAllowedAfterSniffCheck`
|
// * `nsHttpChannel::DisableIsOpaqueResponseAllowedAfterSniffCheck`
|
||||||
// * `HttpBaseChannel::OpaqueResponseSafelistCheckAfterSniff`
|
// * `HttpBaseChannel::OpaqueResponseSafelistCheckAfterSniff`
|
||||||
// * `OpaqueResponseBlocker::ValidateJavaScript`
|
// * `OpaqueResponseBlocker::ValidateJavaScript`
|
||||||
nsresult OpaqueResponseBlocker::ValidateJavaScript(HttpBaseChannel* aChannel,
|
nsresult OpaqueResponseBlocker::ValidateJavaScript(HttpBaseChannel* aChannel) {
|
||||||
nsIURI* aURI,
|
|
||||||
nsILoadInfo* aLoadInfo) {
|
|
||||||
MOZ_DIAGNOSTIC_ASSERT(aChannel);
|
MOZ_DIAGNOSTIC_ASSERT(aChannel);
|
||||||
MOZ_ASSERT(aURI && aLoadInfo);
|
|
||||||
|
|
||||||
if (!StaticPrefs::browser_opaqueResponseBlocking_javascriptValidator()) {
|
|
||||||
LOGORB("Allowed: JS Validator is disabled");
|
|
||||||
AllowResponse();
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
int64_t contentLength;
|
int64_t contentLength;
|
||||||
nsresult rv = aChannel->GetContentLength(&contentLength);
|
nsresult rv = aChannel->GetContentLength(&contentLength);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
@@ -387,31 +337,13 @@ nsresult OpaqueResponseBlocker::ValidateJavaScript(HttpBaseChannel* aChannel,
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGORB("Send %s to the validator", aURI->GetSpecOrDefault().get());
|
// XXX(farre): this intentionally allowing responses, because we don't know
|
||||||
// https://whatpr.org/fetch/1442.html#orb-algorithm, step 15
|
// how to block the correct ones until bug 1532644 is completed.
|
||||||
mJSValidator = dom::JSValidatorParent::Create();
|
LOGORB("Allowed (After Sniff): passes all checks");
|
||||||
mJSValidator->IsOpaqueResponseAllowed(
|
AllowResponse();
|
||||||
[self = RefPtr{this}, channel = nsCOMPtr{aChannel}, uri = nsCOMPtr{aURI},
|
|
||||||
loadInfo = nsCOMPtr{aLoadInfo}](bool aAllowed,
|
|
||||||
Maybe<ipc::Shmem> aSharedData) {
|
|
||||||
MOZ_LOG(gORBLog, LogLevel::Debug,
|
|
||||||
("JSValidator resolved for %s with %s",
|
|
||||||
uri->GetSpecOrDefault().get(),
|
|
||||||
aSharedData.isSome() ? "true" : "false"));
|
|
||||||
if (aAllowed) {
|
|
||||||
self->AllowResponse();
|
|
||||||
} else {
|
|
||||||
self->BlockResponse(channel, NS_ERROR_FAILURE);
|
|
||||||
LogORBError(loadInfo, uri);
|
|
||||||
}
|
|
||||||
self->ResolveAndProcessData(channel, aAllowed, aSharedData);
|
|
||||||
if (aSharedData.isSome()) {
|
|
||||||
self->mJSValidator->DeallocShmem(aSharedData.ref());
|
|
||||||
}
|
|
||||||
|
|
||||||
Unused << dom::PJSValidatorParent::Send__delete__(self->mJSValidator);
|
// https://whatpr.org/fetch/1442.html#orb-algorithm, step 15
|
||||||
self->mJSValidator = nullptr;
|
// XXX(farre): Start JavaScript validation.
|
||||||
});
|
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
@@ -422,14 +354,12 @@ bool OpaqueResponseBlocker::IsSniffing() const {
|
|||||||
|
|
||||||
void OpaqueResponseBlocker::AllowResponse() {
|
void OpaqueResponseBlocker::AllowResponse() {
|
||||||
LOGORB("Sniffer is done, allow response, this=%p", this);
|
LOGORB("Sniffer is done, allow response, this=%p", this);
|
||||||
MOZ_ASSERT(mState == State::Sniffing);
|
|
||||||
mState = State::Allowed;
|
mState = State::Allowed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpaqueResponseBlocker::BlockResponse(HttpBaseChannel* aChannel,
|
void OpaqueResponseBlocker::BlockResponse(HttpBaseChannel* aChannel,
|
||||||
nsresult aReason) {
|
nsresult aReason) {
|
||||||
LOGORB("Sniffer is done, block response, this=%p", this);
|
LOGORB("Sniffer is done, block response, this=%p", this);
|
||||||
MOZ_ASSERT(mState == State::Sniffing);
|
|
||||||
mState = State::Blocked;
|
mState = State::Blocked;
|
||||||
mStatus = aReason;
|
mStatus = aReason;
|
||||||
aChannel->SetChannelBlockedByOpaqueResponse();
|
aChannel->SetChannelBlockedByOpaqueResponse();
|
||||||
@@ -437,50 +367,6 @@ void OpaqueResponseBlocker::BlockResponse(HttpBaseChannel* aChannel,
|
|||||||
"OpaqueResponseBlocker::BlockResponse"_ns);
|
"OpaqueResponseBlocker::BlockResponse"_ns);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpaqueResponseBlocker::ResolveAndProcessData(
|
|
||||||
HttpBaseChannel* aChannel, bool aAllowed, Maybe<ipc::Shmem>& aSharedData) {
|
|
||||||
nsresult rv = OnStartRequest(aChannel);
|
|
||||||
|
|
||||||
if (!aAllowed || NS_FAILED(rv)) {
|
|
||||||
MOZ_ASSERT_IF(!aAllowed, mState == State::Blocked);
|
|
||||||
MaybeRunOnStopRequest(aChannel);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
MOZ_ASSERT(mState == State::Allowed);
|
|
||||||
|
|
||||||
if (aSharedData.isNothing()) {
|
|
||||||
MaybeRunOnStopRequest(aChannel);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const ipc::Shmem& mem = aSharedData.ref();
|
|
||||||
nsCOMPtr<nsIInputStream> input;
|
|
||||||
rv = NS_NewByteInputStream(getter_AddRefs(input),
|
|
||||||
Span(mem.get<char>(), mem.Size<char>()),
|
|
||||||
NS_ASSIGNMENT_DEPEND);
|
|
||||||
|
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
||||||
BlockResponse(aChannel, rv);
|
|
||||||
MaybeRunOnStopRequest(aChannel);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// When this line reaches, the state is either State::Allowed or
|
|
||||||
// State::Blocked. The OnDataAvailable call will either call
|
|
||||||
// the next listener or reject the request.
|
|
||||||
OnDataAvailable(aChannel, input, 0, mem.Size<char>());
|
|
||||||
|
|
||||||
MaybeRunOnStopRequest(aChannel);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OpaqueResponseBlocker::MaybeRunOnStopRequest(HttpBaseChannel* aChannel) {
|
|
||||||
MOZ_ASSERT(mState != State::Sniffing);
|
|
||||||
if (mPendingOnStopRequestStatus.isSome()) {
|
|
||||||
OnStopRequest(aChannel, mPendingOnStopRequestStatus.value());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS(OpaqueResponseBlocker, nsIStreamListener, nsIRequestObserver)
|
NS_IMPL_ISUPPORTS(OpaqueResponseBlocker, nsIStreamListener, nsIRequestObserver)
|
||||||
|
|
||||||
} // namespace mozilla::net
|
} // namespace mozilla::net
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
#ifndef mozilla_net_OpaqueResponseUtils_h
|
#ifndef mozilla_net_OpaqueResponseUtils_h
|
||||||
#define mozilla_net_OpaqueResponseUtils_h
|
#define mozilla_net_OpaqueResponseUtils_h
|
||||||
|
|
||||||
#include "mozilla/dom/JSValidatorParent.h"
|
|
||||||
#include "nsIContentPolicy.h"
|
#include "nsIContentPolicy.h"
|
||||||
#include "nsIStreamListener.h"
|
#include "nsIStreamListener.h"
|
||||||
#include "nsUnknownDecoder.h"
|
#include "nsUnknownDecoder.h"
|
||||||
@@ -73,13 +72,7 @@ class OpaqueResponseBlocker final : public nsIStreamListener {
|
|||||||
private:
|
private:
|
||||||
virtual ~OpaqueResponseBlocker() = default;
|
virtual ~OpaqueResponseBlocker() = default;
|
||||||
|
|
||||||
nsresult ValidateJavaScript(HttpBaseChannel* aChannel, nsIURI* aURI,
|
nsresult ValidateJavaScript(HttpBaseChannel* aChannel);
|
||||||
nsILoadInfo* aLoadInfo);
|
|
||||||
|
|
||||||
void ResolveAndProcessData(HttpBaseChannel* aChannel, bool aAllowed,
|
|
||||||
Maybe<ipc::Shmem>& aSharedData);
|
|
||||||
|
|
||||||
void MaybeRunOnStopRequest(HttpBaseChannel* aChannel);
|
|
||||||
|
|
||||||
nsCOMPtr<nsIStreamListener> mNext;
|
nsCOMPtr<nsIStreamListener> mNext;
|
||||||
|
|
||||||
@@ -88,10 +81,6 @@ class OpaqueResponseBlocker final : public nsIStreamListener {
|
|||||||
|
|
||||||
State mState = State::Sniffing;
|
State mState = State::Sniffing;
|
||||||
nsresult mStatus = NS_OK;
|
nsresult mStatus = NS_OK;
|
||||||
|
|
||||||
RefPtr<dom::JSValidatorParent> mJSValidator;
|
|
||||||
|
|
||||||
Maybe<nsresult> mPendingOnStopRequestStatus{Nothing()};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class nsCompressedAudioVideoImageDetector : public nsUnknownDecoder {
|
class nsCompressedAudioVideoImageDetector : public nsUnknownDecoder {
|
||||||
|
|||||||
@@ -1601,6 +1601,7 @@ nsresult nsHttpChannel::CallOnStartRequest() {
|
|||||||
} else if (opaqueResponse == OpaqueResponse::Sniff) {
|
} else if (opaqueResponse == OpaqueResponse::Sniff) {
|
||||||
MOZ_DIAGNOSTIC_ASSERT(mORB);
|
MOZ_DIAGNOSTIC_ASSERT(mORB);
|
||||||
nsresult rv = mORB->EnsureOpaqueResponseIsAllowedAfterSniff(this);
|
nsresult rv = mORB->EnsureOpaqueResponseIsAllowedAfterSniff(this);
|
||||||
|
MOZ_DIAGNOSTIC_ASSERT(!mORB->IsSniffing());
|
||||||
|
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
return rv;
|
return rv;
|
||||||
|
|||||||
@@ -1,13 +1,31 @@
|
|||||||
[script-resource-with-json-parser-breaker.tentative.sub.html]
|
[script-resource-with-json-parser-breaker.tentative.sub.html]
|
||||||
prefs: [browser.opaqueResponseBlocking:true, browser.opaqueResponseBlocking.javascriptValidator:true]
|
prefs: [browser.opaqueResponseBlocking:true]
|
||||||
expected:
|
expected:
|
||||||
if (os == "android") and fission: [OK, TIMEOUT]
|
if (os == "android") and fission: [OK, TIMEOUT]
|
||||||
|
[CORB-blocks 'text/json' that starts with the following JSON parser breaker: {} &&]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
[CORB-blocks 'text/xml' that starts with the following JSON parser breaker: {} &&]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
[CORB-blocks 'text/html' that starts with the following JSON parser breaker: )\]}']
|
[CORB-blocks 'text/html' that starts with the following JSON parser breaker: )\]}']
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
[CORB-blocks 'text/json' that starts with the following JSON parser breaker: {}&&]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
[CORB-blocks 'application/javascript' that starts with the following JSON parser breaker: )\]}']
|
[CORB-blocks 'application/javascript' that starts with the following JSON parser breaker: )\]}']
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
[CORB-blocks 'text/html' that starts with the following JSON parser breaker: {} &&]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
[CORB-blocks 'text/xml' that starts with the following JSON parser breaker: {}&&]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
[CORB-blocks 'text/html' that starts with the following JSON parser breaker: {}&&]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
[CORB-blocks 'text/xml' that starts with the following JSON parser breaker: )\]}']
|
[CORB-blocks 'text/xml' that starts with the following JSON parser breaker: )\]}']
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
@@ -20,5 +38,11 @@
|
|||||||
[CORB-blocks 'application/javascript' that starts with the following JSON parser breaker: {}&&]
|
[CORB-blocks 'application/javascript' that starts with the following JSON parser breaker: {}&&]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
[CORB-blocks 'text/plain' that starts with the following JSON parser breaker: {}&&]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
[CORB-blocks 'text/plain' that starts with the following JSON parser breaker: {} &&]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
[CORB-blocks 'application/javascript' that starts with the following JSON parser breaker: {} &&]
|
[CORB-blocks 'application/javascript' that starts with the following JSON parser breaker: {} &&]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|||||||
@@ -1,15 +1,24 @@
|
|||||||
[known-mime-type.sub.any.worker.html]
|
[known-mime-type.sub.any.worker.html]
|
||||||
prefs: [browser.opaqueResponseBlocking.javascriptValidator:true]
|
expected:
|
||||||
|
if (os == "android") and fission: [OK, TIMEOUT]
|
||||||
[ORB should block opaque font/ttf]
|
[ORB should block opaque font/ttf]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[ORB should block opaque text/plain]
|
[ORB should block opaque text/plain]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
[ORB should block opaque application/json]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
|
||||||
[known-mime-type.sub.any.html]
|
[known-mime-type.sub.any.html]
|
||||||
prefs: [browser.opaqueResponseBlocking.javascriptValidator:true]
|
expected:
|
||||||
|
if (os == "android") and fission: [OK, TIMEOUT]
|
||||||
[ORB should block opaque font/ttf]
|
[ORB should block opaque font/ttf]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[ORB should block opaque text/plain]
|
[ORB should block opaque text/plain]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
[ORB should block opaque application/json]
|
||||||
|
expected: FAIL
|
||||||
|
|||||||
@@ -28,5 +28,5 @@ def main(request, response):
|
|||||||
(b"Content-Type", b"application/json"),
|
(b"Content-Type", b"application/json"),
|
||||||
(b"Set-Cookie", cookie)
|
(b"Set-Cookie", cookie)
|
||||||
]
|
]
|
||||||
body = b"dummy value"
|
body = b"{}"
|
||||||
return headers, body
|
return headers, body
|
||||||
|
|||||||
@@ -74,7 +74,6 @@ enum class UtilityActorName {
|
|||||||
AudioDecoder_AppleMedia,
|
AudioDecoder_AppleMedia,
|
||||||
AudioDecoder_WMF,
|
AudioDecoder_WMF,
|
||||||
MfMediaEngineCDM,
|
MfMediaEngineCDM,
|
||||||
JSOracle,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// String that will be used e.g. to annotate crash reports
|
// String that will be used e.g. to annotate crash reports
|
||||||
|
|||||||
@@ -53,8 +53,6 @@ nsCString GetUtilityActorName(const UtilityActorName aActorName) {
|
|||||||
return "audio-decoder-wmf"_ns;
|
return "audio-decoder-wmf"_ns;
|
||||||
case UtilityActorName::MfMediaEngineCDM:
|
case UtilityActorName::MfMediaEngineCDM:
|
||||||
return "mf-media-engine"_ns;
|
return "mf-media-engine"_ns;
|
||||||
case UtilityActorName::JSOracle:
|
|
||||||
return "js-oracle"_ns;
|
|
||||||
}
|
}
|
||||||
return "unknown"_ns;
|
return "unknown"_ns;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user