зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 3 changesets (bug 1857488) for causing valgrind bustages related to Fingerprinting. CLOSED TREE
Backed out changeset f2961f6ece1f (bug 1857488) Backed out changeset df299aac1633 (bug 1857488) Backed out changeset b640c254626e (bug 1857488)
This commit is contained in:
Родитель
62ccd5e253
Коммит
b68697c09d
|
@ -70,9 +70,6 @@ struct DevTools : public ::testing::Test {
|
||||||
JSObject* createGlobal() {
|
JSObject* createGlobal() {
|
||||||
/* Create the global object. */
|
/* Create the global object. */
|
||||||
JS::RealmOptions options;
|
JS::RealmOptions options;
|
||||||
// dummy
|
|
||||||
options.behaviors().setReduceTimerPrecisionCallerType(
|
|
||||||
JS::RTPCallerTypeToken{0});
|
|
||||||
return JS_NewGlobalObject(cx, getGlobalClass(), nullptr,
|
return JS_NewGlobalObject(cx, getGlobalClass(), nullptr,
|
||||||
JS::FireOnNewGlobalHook, options);
|
JS::FireOnNewGlobalHook, options);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,9 +10,6 @@
|
||||||
DEF_TEST(DoesCrossCompartmentBoundaries, {
|
DEF_TEST(DoesCrossCompartmentBoundaries, {
|
||||||
// Create a new global to get a new compartment.
|
// Create a new global to get a new compartment.
|
||||||
JS::RealmOptions options;
|
JS::RealmOptions options;
|
||||||
// dummy
|
|
||||||
options.behaviors().setReduceTimerPrecisionCallerType(
|
|
||||||
JS::RTPCallerTypeToken{0});
|
|
||||||
JS::Rooted<JSObject*> newGlobal(
|
JS::Rooted<JSObject*> newGlobal(
|
||||||
cx, JS_NewGlobalObject(cx, getGlobalClass(), nullptr,
|
cx, JS_NewGlobalObject(cx, getGlobalClass(), nullptr,
|
||||||
JS::FireOnNewGlobalHook, options));
|
JS::FireOnNewGlobalHook, options));
|
||||||
|
|
|
@ -10,9 +10,6 @@
|
||||||
DEF_TEST(DoesntCrossCompartmentBoundaries, {
|
DEF_TEST(DoesntCrossCompartmentBoundaries, {
|
||||||
// Create a new global to get a new compartment.
|
// Create a new global to get a new compartment.
|
||||||
JS::RealmOptions options;
|
JS::RealmOptions options;
|
||||||
// dummy
|
|
||||||
options.behaviors().setReduceTimerPrecisionCallerType(
|
|
||||||
JS::RTPCallerTypeToken{0});
|
|
||||||
JS::Rooted<JSObject*> newGlobal(
|
JS::Rooted<JSObject*> newGlobal(
|
||||||
cx, JS_NewGlobalObject(cx, getGlobalClass(), nullptr,
|
cx, JS_NewGlobalObject(cx, getGlobalClass(), nullptr,
|
||||||
JS::FireOnNewGlobalHook, options));
|
JS::FireOnNewGlobalHook, options));
|
||||||
|
|
|
@ -16295,12 +16295,6 @@ bool Document::RecomputeResistFingerprinting() {
|
||||||
("Finished RecomputeResistFingerprinting with result %x",
|
("Finished RecomputeResistFingerprinting with result %x",
|
||||||
mShouldResistFingerprinting));
|
mShouldResistFingerprinting));
|
||||||
|
|
||||||
if (previous != mShouldResistFingerprinting) {
|
|
||||||
if (auto win = nsGlobalWindowInner::Cast(GetInnerWindow())) {
|
|
||||||
win->RefreshReduceTimerPrecisionCallerType();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return previous != mShouldResistFingerprinting;
|
return previous != mShouldResistFingerprinting;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3621,12 +3621,6 @@ void nsGlobalWindowInner::RefreshRealmPrincipal() {
|
||||||
nsJSPrincipals::get(mDoc->NodePrincipal()));
|
nsJSPrincipals::get(mDoc->NodePrincipal()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsGlobalWindowInner::RefreshReduceTimerPrecisionCallerType() {
|
|
||||||
JS::SetRealmReduceTimerPrecisionCallerType(
|
|
||||||
js::GetNonCCWObjectRealm(GetWrapperPreserveColor()),
|
|
||||||
RTPCallerTypeToToken(GetRTPCallerType()));
|
|
||||||
}
|
|
||||||
|
|
||||||
already_AddRefed<nsIWidget> nsGlobalWindowInner::GetMainWidget() {
|
already_AddRefed<nsIWidget> nsGlobalWindowInner::GetMainWidget() {
|
||||||
FORWARD_TO_OUTER(GetMainWidget, (), nullptr);
|
FORWARD_TO_OUTER(GetMainWidget, (), nullptr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -363,7 +363,6 @@ class nsGlobalWindowInner final : public mozilla::dom::EventTarget,
|
||||||
|
|
||||||
// Inner windows only.
|
// Inner windows only.
|
||||||
void RefreshRealmPrincipal();
|
void RefreshRealmPrincipal();
|
||||||
void RefreshReduceTimerPrecisionCallerType();
|
|
||||||
|
|
||||||
// For accessing protected field mFullscreen
|
// For accessing protected field mFullscreen
|
||||||
friend class FullscreenTransitionTask;
|
friend class FullscreenTransitionTask;
|
||||||
|
|
|
@ -2414,8 +2414,6 @@ nsresult nsGlobalWindowOuter::SetNewDocument(Document* aDocument,
|
||||||
|
|
||||||
MOZ_RELEASE_ASSERT(newInnerWindow->mDoc == aDocument);
|
MOZ_RELEASE_ASSERT(newInnerWindow->mDoc == aDocument);
|
||||||
|
|
||||||
newInnerWindow->RefreshReduceTimerPrecisionCallerType();
|
|
||||||
|
|
||||||
if (!aState) {
|
if (!aState) {
|
||||||
if (reUseInnerWindow) {
|
if (reUseInnerWindow) {
|
||||||
// The StorageAccess state may have changed. Invalidate the cached
|
// The StorageAccess state may have changed. Invalidate the cached
|
||||||
|
@ -2490,7 +2488,7 @@ nsresult nsGlobalWindowOuter::SetNewDocument(Document* aDocument,
|
||||||
&nsGlobalWindowInner::FireOnNewGlobalObject));
|
&nsGlobalWindowInner::FireOnNewGlobalObject));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!newInnerWindow->mHasNotifiedGlobalCreated && mDoc) {
|
if (newInnerWindow && !newInnerWindow->mHasNotifiedGlobalCreated && mDoc) {
|
||||||
// We should probably notify. However if this is the, arguably bad,
|
// We should probably notify. However if this is the, arguably bad,
|
||||||
// situation when we're creating a temporary non-chrome-about-blank
|
// situation when we're creating a temporary non-chrome-about-blank
|
||||||
// document in a chrome docshell, don't notify just yet. Instead wait
|
// document in a chrome docshell, don't notify just yet. Instead wait
|
||||||
|
|
|
@ -2954,15 +2954,6 @@ bool CreateGlobal(JSContext* aCx, T* aNative, nsWrapperCache* aCache,
|
||||||
if (!CreateGlobalOptions<T>::PostCreateGlobal(aCx, aGlobal)) {
|
if (!CreateGlobalOptions<T>::PostCreateGlobal(aCx, aGlobal)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initializing this at this point for nsGlobalWindowInner makes no sense,
|
|
||||||
// because GetRTPCallerType doesn't return the correct result before
|
|
||||||
// the global is completely initialized with a document.
|
|
||||||
if constexpr (!std::is_base_of_v<nsGlobalWindowInner, T>) {
|
|
||||||
JS::SetRealmReduceTimerPrecisionCallerType(
|
|
||||||
js::GetNonCCWObjectRealm(aGlobal),
|
|
||||||
RTPCallerTypeToToken(aNative->GetRTPCallerType()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aInitStandardClasses && !JS::InitRealmStandardClasses(aCx)) {
|
if (aInitStandardClasses && !JS::InitRealmStandardClasses(aCx)) {
|
||||||
|
|
|
@ -138,10 +138,6 @@ JSObject* SimpleGlobalObject::Create(GlobalType globalType,
|
||||||
RefPtr<SimpleGlobalObject> globalObject =
|
RefPtr<SimpleGlobalObject> globalObject =
|
||||||
new SimpleGlobalObject(global, globalType);
|
new SimpleGlobalObject(global, globalType);
|
||||||
|
|
||||||
JS::SetRealmReduceTimerPrecisionCallerType(
|
|
||||||
js::GetNonCCWObjectRealm(global),
|
|
||||||
RTPCallerTypeToToken(globalObject->GetRTPCallerType()));
|
|
||||||
|
|
||||||
// Pass on ownership of globalObject to |global|.
|
// Pass on ownership of globalObject to |global|.
|
||||||
JS::SetObjectISupports(global, globalObject.forget().take());
|
JS::SetObjectISupports(global, globalObject.forget().take());
|
||||||
|
|
||||||
|
|
|
@ -32,8 +32,7 @@
|
||||||
#include "mozilla/FloatingPoint.h" // mozilla::{IsFinite,}, mozilla::UnspecifiedNaN
|
#include "mozilla/FloatingPoint.h" // mozilla::{IsFinite,}, mozilla::UnspecifiedNaN
|
||||||
#include "mozilla/MathAlgorithms.h" // mozilla::Abs
|
#include "mozilla/MathAlgorithms.h" // mozilla::Abs
|
||||||
|
|
||||||
#include "js/Conversions.h" // JS::ToInteger
|
#include "js/Conversions.h" // JS::ToInteger
|
||||||
#include "js/RealmOptions.h" // JS::RTPCallerTypeToken
|
|
||||||
#include "js/TypeDecls.h"
|
#include "js/TypeDecls.h"
|
||||||
#include "js/Value.h" // JS::CanonicalizeNaN, JS::DoubleValue, JS::Value
|
#include "js/Value.h" // JS::CanonicalizeNaN, JS::DoubleValue, JS::Value
|
||||||
|
|
||||||
|
@ -188,26 +187,15 @@ JS_PUBLIC_API double DayFromYear(double year);
|
||||||
JS_PUBLIC_API double DayWithinYear(double time, double year);
|
JS_PUBLIC_API double DayWithinYear(double time, double year);
|
||||||
|
|
||||||
// The callback will be a wrapper function that accepts a double (the time
|
// The callback will be a wrapper function that accepts a double (the time
|
||||||
// to clamp and jitter) and a JS::RTPCallerTypeToken (a wrapper for
|
// to clamp and jitter). Inside the JS Engine, other parameters that may be
|
||||||
// mozilla::RTPCallerType) that can be used to decide the proper clamping
|
// needed are all constant, so they are handled inside the wrapper function
|
||||||
// behavior to use. Inside the JS Engine, other parameters that may be needed
|
using ReduceMicrosecondTimePrecisionCallback = double (*)(double, JSContext*);
|
||||||
// are all constant, so they are handled inside the wrapper function
|
|
||||||
using ReduceMicrosecondTimePrecisionCallback =
|
|
||||||
double (*)(double, JS::RTPCallerTypeToken, JSContext*);
|
|
||||||
|
|
||||||
// Set a callback into the toolkit/components/resistfingerprinting function that
|
// Set a callback into the toolkit/components/resistfingerprinting function that
|
||||||
// will centralize time resolution and jitter into one place.
|
// will centralize time resolution and jitter into one place.
|
||||||
// Defining such a callback requires all Realms that are created afterwards
|
|
||||||
// to have a set JS::RTPCallerTypeToken, via RealmBehaviors or
|
|
||||||
// JS::SetRealmReduceTimerPrecisionCallerType.
|
|
||||||
JS_PUBLIC_API void SetReduceMicrosecondTimePrecisionCallback(
|
JS_PUBLIC_API void SetReduceMicrosecondTimePrecisionCallback(
|
||||||
ReduceMicrosecondTimePrecisionCallback callback);
|
ReduceMicrosecondTimePrecisionCallback callback);
|
||||||
|
|
||||||
// Get the previously set ReduceMicrosecondTimePrecisionCallback callback or
|
|
||||||
// nullptr.
|
|
||||||
JS_PUBLIC_API ReduceMicrosecondTimePrecisionCallback
|
|
||||||
GetReduceMicrosecondTimePrecisionCallback();
|
|
||||||
|
|
||||||
// Sets the time resolution for fingerprinting protection, and whether jitter
|
// Sets the time resolution for fingerprinting protection, and whether jitter
|
||||||
// should occur. If resolution is set to zero, then no rounding or jitter will
|
// should occur. If resolution is set to zero, then no rounding or jitter will
|
||||||
// occur. This is used if the callback above is not specified.
|
// occur. This is used if the callback above is not specified.
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
#define js_RealmOptions_h
|
#define js_RealmOptions_h
|
||||||
|
|
||||||
#include "mozilla/Assertions.h" // MOZ_ASSERT
|
#include "mozilla/Assertions.h" // MOZ_ASSERT
|
||||||
#include "mozilla/Maybe.h"
|
|
||||||
|
|
||||||
#include "jstypes.h" // JS_PUBLIC_API
|
#include "jstypes.h" // JS_PUBLIC_API
|
||||||
|
|
||||||
|
@ -321,12 +320,6 @@ class JS_PUBLIC_API RealmCreationOptions {
|
||||||
bool alwaysUseFdlibm_ = false;
|
bool alwaysUseFdlibm_ = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
// This is a wrapper for mozilla::RTPCallerType, that can't easily
|
|
||||||
// be exposed to the JS engine for layering reasons.
|
|
||||||
struct RTPCallerTypeToken {
|
|
||||||
uint8_t value;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RealmBehaviors specifies behaviors of a realm that can be changed after the
|
* RealmBehaviors specifies behaviors of a realm that can be changed after the
|
||||||
* realm's been created.
|
* realm's been created.
|
||||||
|
@ -335,17 +328,6 @@ class JS_PUBLIC_API RealmBehaviors {
|
||||||
public:
|
public:
|
||||||
RealmBehaviors() = default;
|
RealmBehaviors() = default;
|
||||||
|
|
||||||
// When a JS::ReduceMicrosecondTimePrecisionCallback callback is defined via
|
|
||||||
// JS::SetReduceMicrosecondTimePrecisionCallback, a JS::RTPCallerTypeToken (a
|
|
||||||
// wrapper for mozilla::RTPCallerType) needs to be set for every Realm.
|
|
||||||
mozilla::Maybe<RTPCallerTypeToken> reduceTimerPrecisionCallerType() const {
|
|
||||||
return rtpCallerType;
|
|
||||||
}
|
|
||||||
RealmBehaviors& setReduceTimerPrecisionCallerType(RTPCallerTypeToken type) {
|
|
||||||
rtpCallerType = mozilla::Some(type);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
// For certain globals, we know enough about the code that will run in them
|
// For certain globals, we know enough about the code that will run in them
|
||||||
// that we can discard script source entirely.
|
// that we can discard script source entirely.
|
||||||
bool discardSource() const { return discardSource_; }
|
bool discardSource() const { return discardSource_; }
|
||||||
|
@ -360,6 +342,29 @@ class JS_PUBLIC_API RealmBehaviors {
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class Override {
|
||||||
|
public:
|
||||||
|
Override() : mode_(Default) {}
|
||||||
|
|
||||||
|
bool get(bool defaultValue) const {
|
||||||
|
if (mode_ == Default) {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
return mode_ == ForceTrue;
|
||||||
|
}
|
||||||
|
|
||||||
|
void set(bool overrideValue) {
|
||||||
|
mode_ = overrideValue ? ForceTrue : ForceFalse;
|
||||||
|
}
|
||||||
|
|
||||||
|
void reset() { mode_ = Default; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
enum Mode { Default, ForceTrue, ForceFalse };
|
||||||
|
|
||||||
|
Mode mode_;
|
||||||
|
};
|
||||||
|
|
||||||
// A Realm can stop being "live" in all the ways that matter before its global
|
// A Realm can stop being "live" in all the ways that matter before its global
|
||||||
// is actually GCed. Consumers that tear down parts of a Realm or its global
|
// is actually GCed. Consumers that tear down parts of a Realm or its global
|
||||||
// before that point should set isNonLive accordingly.
|
// before that point should set isNonLive accordingly.
|
||||||
|
@ -370,7 +375,6 @@ class JS_PUBLIC_API RealmBehaviors {
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mozilla::Maybe<RTPCallerTypeToken> rtpCallerType;
|
|
||||||
bool discardSource_ = false;
|
bool discardSource_ = false;
|
||||||
bool clampAndJitterTime_ = true;
|
bool clampAndJitterTime_ = true;
|
||||||
bool isNonLive_ = false;
|
bool isNonLive_ = false;
|
||||||
|
@ -419,11 +423,6 @@ extern JS_PUBLIC_API const RealmBehaviors& RealmBehaviorsRef(JSContext* cx);
|
||||||
|
|
||||||
extern JS_PUBLIC_API void SetRealmNonLive(Realm* realm);
|
extern JS_PUBLIC_API void SetRealmNonLive(Realm* realm);
|
||||||
|
|
||||||
// This behaves like RealmBehaviors::setReduceTimerPrecisionCallerType, but
|
|
||||||
// can be used even after the Realm has already been created.
|
|
||||||
extern JS_PUBLIC_API void SetRealmReduceTimerPrecisionCallerType(
|
|
||||||
Realm* realm, RTPCallerTypeToken type);
|
|
||||||
|
|
||||||
} // namespace JS
|
} // namespace JS
|
||||||
|
|
||||||
#endif // js_RealmOptions_h
|
#endif // js_RealmOptions_h
|
||||||
|
|
|
@ -46,7 +46,6 @@
|
||||||
#include "js/CompileOptions.h"
|
#include "js/CompileOptions.h"
|
||||||
#include "js/ContextOptions.h" // JS::ContextOptions{,Ref}
|
#include "js/ContextOptions.h" // JS::ContextOptions{,Ref}
|
||||||
#include "js/Conversions.h"
|
#include "js/Conversions.h"
|
||||||
#include "js/Date.h" // JS::GetReduceMicrosecondTimePrecisionCallback
|
|
||||||
#include "js/ErrorInterceptor.h"
|
#include "js/ErrorInterceptor.h"
|
||||||
#include "js/ErrorReport.h" // JSErrorBase
|
#include "js/ErrorReport.h" // JSErrorBase
|
||||||
#include "js/friend/ErrorMessages.h" // js::GetErrorMessage, JSMSG_*
|
#include "js/friend/ErrorMessages.h" // js::GetErrorMessage, JSMSG_*
|
||||||
|
@ -1762,11 +1761,6 @@ const JS::RealmBehaviors& JS::RealmBehaviorsRef(JSContext* cx) {
|
||||||
|
|
||||||
void JS::SetRealmNonLive(Realm* realm) { realm->setNonLive(); }
|
void JS::SetRealmNonLive(Realm* realm) { realm->setNonLive(); }
|
||||||
|
|
||||||
void JS::SetRealmReduceTimerPrecisionCallerType(Realm* realm,
|
|
||||||
JS::RTPCallerTypeToken type) {
|
|
||||||
realm->setReduceTimerPrecisionCallerType(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
JS_PUBLIC_API JSObject* JS_NewGlobalObject(JSContext* cx, const JSClass* clasp,
|
JS_PUBLIC_API JSObject* JS_NewGlobalObject(JSContext* cx, const JSClass* clasp,
|
||||||
JSPrincipals* principals,
|
JSPrincipals* principals,
|
||||||
JS::OnNewGlobalHookOption hookOption,
|
JS::OnNewGlobalHookOption hookOption,
|
||||||
|
@ -1823,18 +1817,7 @@ JS_PUBLIC_API void JS_FireOnNewGlobalObject(JSContext* cx,
|
||||||
// This infallibility will eat OOM and slow script, but if that happens
|
// This infallibility will eat OOM and slow script, but if that happens
|
||||||
// we'll likely run up into them again soon in a fallible context.
|
// we'll likely run up into them again soon in a fallible context.
|
||||||
cx->check(global);
|
cx->check(global);
|
||||||
|
|
||||||
Rooted<js::GlobalObject*> globalObject(cx, &global->as<GlobalObject>());
|
Rooted<js::GlobalObject*> globalObject(cx, &global->as<GlobalObject>());
|
||||||
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
|
|
||||||
if (JS::GetReduceMicrosecondTimePrecisionCallback()) {
|
|
||||||
MOZ_DIAGNOSTIC_ASSERT(globalObject->realm()
|
|
||||||
->behaviors()
|
|
||||||
.reduceTimerPrecisionCallerType()
|
|
||||||
.isSome(),
|
|
||||||
"Trying to create a global without setting an "
|
|
||||||
"explicit RTPCallerType!");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
DebugAPI::onNewGlobalObject(cx, globalObject);
|
DebugAPI::onNewGlobalObject(cx, globalObject);
|
||||||
cx->runtime()->ensureRealmIsRecordingAllocations(globalObject);
|
cx->runtime()->ensureRealmIsRecordingAllocations(globalObject);
|
||||||
}
|
}
|
||||||
|
|
|
@ -498,11 +498,6 @@ JS_PUBLIC_API void JS::SetReduceMicrosecondTimePrecisionCallback(
|
||||||
sReduceMicrosecondTimePrecisionCallback = callback;
|
sReduceMicrosecondTimePrecisionCallback = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_PUBLIC_API JS::ReduceMicrosecondTimePrecisionCallback
|
|
||||||
JS::GetReduceMicrosecondTimePrecisionCallback() {
|
|
||||||
return sReduceMicrosecondTimePrecisionCallback;
|
|
||||||
}
|
|
||||||
|
|
||||||
JS_PUBLIC_API void JS::SetTimeResolutionUsec(uint32_t resolution, bool jitter) {
|
JS_PUBLIC_API void JS::SetTimeResolutionUsec(uint32_t resolution, bool jitter) {
|
||||||
sResolutionUsec = resolution;
|
sResolutionUsec = resolution;
|
||||||
sJitter = jitter;
|
sJitter = jitter;
|
||||||
|
@ -1843,9 +1838,7 @@ static ClippedTime NowAsMillis(JSContext* cx) {
|
||||||
double now = PRMJ_Now();
|
double now = PRMJ_Now();
|
||||||
bool clampAndJitter = cx->realm()->behaviors().clampAndJitterTime();
|
bool clampAndJitter = cx->realm()->behaviors().clampAndJitterTime();
|
||||||
if (clampAndJitter && sReduceMicrosecondTimePrecisionCallback) {
|
if (clampAndJitter && sReduceMicrosecondTimePrecisionCallback) {
|
||||||
now = sReduceMicrosecondTimePrecisionCallback(
|
now = sReduceMicrosecondTimePrecisionCallback(now, cx);
|
||||||
now, cx->realm()->behaviors().reduceTimerPrecisionCallerType().value(),
|
|
||||||
cx);
|
|
||||||
} else if (clampAndJitter && sResolutionUsec) {
|
} else if (clampAndJitter && sResolutionUsec) {
|
||||||
double clamped = floor(now / sResolutionUsec) * sResolutionUsec;
|
double clamped = floor(now / sResolutionUsec) * sResolutionUsec;
|
||||||
|
|
||||||
|
|
|
@ -471,9 +471,6 @@ class JS::Realm : public JS::shadow::Realm {
|
||||||
const JS::RealmBehaviors& behaviors() const { return behaviors_; }
|
const JS::RealmBehaviors& behaviors() const { return behaviors_; }
|
||||||
|
|
||||||
void setNonLive() { behaviors_.setNonLive(); }
|
void setNonLive() { behaviors_.setNonLive(); }
|
||||||
void setReduceTimerPrecisionCallerType(JS::RTPCallerTypeToken type) {
|
|
||||||
behaviors_.setReduceTimerPrecisionCallerType(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Whether to preserve JIT code on non-shrinking GCs. */
|
/* Whether to preserve JIT code on non-shrinking GCs. */
|
||||||
bool preserveJitCode() { return creationOptions_.preserveJitCode(); }
|
bool preserveJitCode() { return creationOptions_.preserveJitCode(); }
|
||||||
|
|
|
@ -44,10 +44,6 @@ class SandboxPrivate final : public nsIGlobalObject,
|
||||||
nsIScriptObjectPrincipal* sop =
|
nsIScriptObjectPrincipal* sop =
|
||||||
static_cast<nsIScriptObjectPrincipal*>(sbp.forget().take());
|
static_cast<nsIScriptObjectPrincipal*>(sbp.forget().take());
|
||||||
JS::SetObjectISupports(global, sop);
|
JS::SetObjectISupports(global, sop);
|
||||||
|
|
||||||
JS::SetRealmReduceTimerPrecisionCallerType(
|
|
||||||
js::GetNonCCWObjectRealm(global),
|
|
||||||
RTPCallerTypeToToken(GetPrivate(global)->GetRTPCallerType()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static SandboxPrivate* GetPrivate(JSObject* obj) {
|
static SandboxPrivate* GetPrivate(JSObject* obj) {
|
||||||
|
|
|
@ -552,10 +552,6 @@ nsresult InitClassesWithNewWrappedGlobal(JSContext* aJSContext,
|
||||||
// If this changes, ShouldRFP needs to be updated accordingly.
|
// If this changes, ShouldRFP needs to be updated accordingly.
|
||||||
MOZ_RELEASE_ASSERT(aPrincipal->IsSystemPrincipal());
|
MOZ_RELEASE_ASSERT(aPrincipal->IsSystemPrincipal());
|
||||||
|
|
||||||
// Similarly we can thus hardcode the RTPCallerType.
|
|
||||||
aOptions.behaviors().setReduceTimerPrecisionCallerType(
|
|
||||||
RTPCallerTypeToToken(RTPCallerType::SystemPrincipal));
|
|
||||||
|
|
||||||
InitGlobalObjectOptions(aOptions, /* aSystemPrincipal */ true,
|
InitGlobalObjectOptions(aOptions, /* aSystemPrincipal */ true,
|
||||||
/* aSecureContext */ true,
|
/* aSecureContext */ true,
|
||||||
/* aForceUTC */ false, /* aAlwaysUseFdlibm */ false,
|
/* aForceUTC */ false, /* aAlwaysUseFdlibm */ false,
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
Services.prefs.setBoolPref("privacy.resistFingerprinting", true);
|
|
||||||
registerCleanupFunction(() => {
|
|
||||||
Services.prefs.clearUserPref("privacy.resistFingerprinting");
|
|
||||||
});
|
|
||||||
|
|
||||||
add_task(function test_sandbox_rfp() {
|
|
||||||
var sb = Cu.Sandbox('http://example.com');
|
|
||||||
var date = Cu.evalInSandbox('Date.now()', sb);
|
|
||||||
ok(date > 1672553000000, "Date.now() works with resistFingerprinting");
|
|
||||||
});
|
|
||||||
|
|
||||||
add_task(function test_sandbox_system() {
|
|
||||||
var sb = Cu.Sandbox(Services.scriptSecurityManager.getSystemPrincipal());
|
|
||||||
var date = Cu.evalInSandbox('Date.now()', sb);
|
|
||||||
ok(date > 1672553000000, "Date.now() works with systemprincipal");
|
|
||||||
});
|
|
|
@ -137,7 +137,6 @@ head = head_ongc.js
|
||||||
[test_onGarbageCollection-05.js]
|
[test_onGarbageCollection-05.js]
|
||||||
head = head_ongc.js
|
head = head_ongc.js
|
||||||
[test_reflect_parse.js]
|
[test_reflect_parse.js]
|
||||||
[test_resistFingerprinting_date_now.js]
|
|
||||||
[test_localeCompare.js]
|
[test_localeCompare.js]
|
||||||
[test_recursive_import.js]
|
[test_recursive_import.js]
|
||||||
[test_xpcomutils.js]
|
[test_xpcomutils.js]
|
||||||
|
|
|
@ -455,10 +455,7 @@ class JSContextWrapper {
|
||||||
|
|
||||||
JS::RealmOptions options;
|
JS::RealmOptions options;
|
||||||
options.creationOptions().setNewCompartmentInSystemZone();
|
options.creationOptions().setNewCompartmentInSystemZone();
|
||||||
options.behaviors()
|
options.behaviors().setClampAndJitterTime(false);
|
||||||
.setClampAndJitterTime(false)
|
|
||||||
.setReduceTimerPrecisionCallerType(
|
|
||||||
RTPCallerTypeToToken(RTPCallerType::Normal));
|
|
||||||
mGlobal = JS_NewGlobalObject(mContext, &sGlobalClass, nullptr,
|
mGlobal = JS_NewGlobalObject(mContext, &sGlobalClass, nullptr,
|
||||||
JS::DontFireOnNewGlobalHook, options);
|
JS::DontFireOnNewGlobalHook, options);
|
||||||
if (!mGlobal) {
|
if (!mGlobal) {
|
||||||
|
|
|
@ -661,16 +661,13 @@ double nsRFPService::ReduceTimePrecisionAsSecsRFPOnly(
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
double nsRFPService::ReduceTimePrecisionAsUSecsWrapper(
|
double nsRFPService::ReduceTimePrecisionAsUSecsWrapper(double aTime,
|
||||||
double aTime, JS::RTPCallerTypeToken aCallerType, JSContext* aCx) {
|
JSContext* aCx) {
|
||||||
MOZ_ASSERT(aCx);
|
MOZ_ASSERT(aCx);
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
nsCOMPtr<nsIGlobalObject> global = xpc::CurrentNativeGlobal(aCx);
|
nsCOMPtr<nsIGlobalObject> global = xpc::CurrentNativeGlobal(aCx);
|
||||||
MOZ_ASSERT(global->GetRTPCallerType() == RTPCallerTypeFromToken(aCallerType));
|
MOZ_ASSERT(global);
|
||||||
#endif
|
RTPCallerType callerType = global->GetRTPCallerType();
|
||||||
|
|
||||||
RTPCallerType callerType = RTPCallerTypeFromToken(aCallerType);
|
|
||||||
return nsRFPService::ReduceTimePrecisionImpl(
|
return nsRFPService::ReduceTimePrecisionImpl(
|
||||||
aTime, MicroSeconds, TimerResolution(callerType),
|
aTime, MicroSeconds, TimerResolution(callerType),
|
||||||
0, /* For absolute timestamps (all the JS engine does), supply zero
|
0, /* For absolute timestamps (all the JS engine does), supply zero
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
#include "mozilla/BasicEvents.h"
|
#include "mozilla/BasicEvents.h"
|
||||||
#include "mozilla/gfx/Types.h"
|
#include "mozilla/gfx/Types.h"
|
||||||
#include "mozilla/TypedEnumBits.h"
|
#include "mozilla/TypedEnumBits.h"
|
||||||
#include "js/RealmOptions.h"
|
|
||||||
#include "nsHashtablesFwd.h"
|
#include "nsHashtablesFwd.h"
|
||||||
#include "nsICookieJarSettings.h"
|
#include "nsICookieJarSettings.h"
|
||||||
#include "nsIFingerprintingWebCompatService.h"
|
#include "nsIFingerprintingWebCompatService.h"
|
||||||
|
@ -139,19 +138,6 @@ enum class RTPCallerType : uint8_t {
|
||||||
CrossOriginIsolated = (1 << 2)
|
CrossOriginIsolated = (1 << 2)
|
||||||
};
|
};
|
||||||
|
|
||||||
inline JS::RTPCallerTypeToken RTPCallerTypeToToken(RTPCallerType aType) {
|
|
||||||
return JS::RTPCallerTypeToken{uint8_t(aType)};
|
|
||||||
}
|
|
||||||
|
|
||||||
inline RTPCallerType RTPCallerTypeFromToken(JS::RTPCallerTypeToken aToken) {
|
|
||||||
MOZ_RELEASE_ASSERT(
|
|
||||||
aToken.value == uint8_t(RTPCallerType::Normal) ||
|
|
||||||
aToken.value == uint8_t(RTPCallerType::SystemPrincipal) ||
|
|
||||||
aToken.value == uint8_t(RTPCallerType::ResistFingerprinting) ||
|
|
||||||
aToken.value == uint8_t(RTPCallerType::CrossOriginIsolated));
|
|
||||||
return static_cast<RTPCallerType>(aToken.value);
|
|
||||||
}
|
|
||||||
|
|
||||||
enum TimerPrecisionType {
|
enum TimerPrecisionType {
|
||||||
DangerouslyNone = 1,
|
DangerouslyNone = 1,
|
||||||
UnconditionalAKAHighRes = 2,
|
UnconditionalAKAHighRes = 2,
|
||||||
|
@ -211,6 +197,10 @@ class nsRFPService final : public nsIObserver, public nsIRFPService {
|
||||||
static double ReduceTimePrecisionAsSecsRFPOnly(double aTime,
|
static double ReduceTimePrecisionAsSecsRFPOnly(double aTime,
|
||||||
int64_t aContextMixin,
|
int64_t aContextMixin,
|
||||||
RTPCallerType aRTPCallerType);
|
RTPCallerType aRTPCallerType);
|
||||||
|
|
||||||
|
// Used by the JS Engine, as it doesn't know about the TimerPrecisionType enum
|
||||||
|
static double ReduceTimePrecisionAsUSecsWrapper(double aTime, JSContext* aCx);
|
||||||
|
|
||||||
// Public only for testing purposes
|
// Public only for testing purposes
|
||||||
static double ReduceTimePrecisionImpl(double aTime, TimeScale aTimeScale,
|
static double ReduceTimePrecisionImpl(double aTime, TimeScale aTimeScale,
|
||||||
double aResolutionUSec,
|
double aResolutionUSec,
|
||||||
|
@ -358,10 +348,6 @@ class nsRFPService final : public nsIObserver, public nsIRFPService {
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
|
|
||||||
// Used by the JS Engine
|
|
||||||
static double ReduceTimePrecisionAsUSecsWrapper(
|
|
||||||
double aTime, JS::RTPCallerTypeToken aCallerType, JSContext* aCx);
|
|
||||||
|
|
||||||
static TimerPrecisionType GetTimerPrecisionType(RTPCallerType aRTPCallerType);
|
static TimerPrecisionType GetTimerPrecisionType(RTPCallerType aRTPCallerType);
|
||||||
|
|
||||||
static TimerPrecisionType GetTimerPrecisionTypeRFPOnly(
|
static TimerPrecisionType GetTimerPrecisionTypeRFPOnly(
|
||||||
|
|
|
@ -135,9 +135,6 @@ static void CreateGlobalAndRunTest(JSContext* cx) {
|
||||||
&JS::DefaultGlobalClassOps};
|
&JS::DefaultGlobalClassOps};
|
||||||
|
|
||||||
JS::RealmOptions options;
|
JS::RealmOptions options;
|
||||||
// dummy
|
|
||||||
options.behaviors().setReduceTimerPrecisionCallerType(
|
|
||||||
JS::RTPCallerTypeToken{0});
|
|
||||||
JS::PersistentRootedObject global(cx);
|
JS::PersistentRootedObject global(cx);
|
||||||
global = JS_NewGlobalObject(cx, &GlobalClass, nullptr,
|
global = JS_NewGlobalObject(cx, &GlobalClass, nullptr,
|
||||||
JS::FireOnNewGlobalHook, options);
|
JS::FireOnNewGlobalHook, options);
|
||||||
|
|
|
@ -332,9 +332,6 @@ TEST(JSHolderMap, GCIntegration)
|
||||||
&JS::DefaultGlobalClassOps};
|
&JS::DefaultGlobalClassOps};
|
||||||
|
|
||||||
JS::RealmOptions options;
|
JS::RealmOptions options;
|
||||||
// dummy
|
|
||||||
options.behaviors().setReduceTimerPrecisionCallerType(
|
|
||||||
JS::RTPCallerTypeToken{0});
|
|
||||||
JS::RootedObject global(cx);
|
JS::RootedObject global(cx);
|
||||||
global = JS_NewGlobalObject(cx, &GlobalClass, nullptr,
|
global = JS_NewGlobalObject(cx, &GlobalClass, nullptr,
|
||||||
JS::FireOnNewGlobalHook, options);
|
JS::FireOnNewGlobalHook, options);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче