зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1811863 - Make WorkerNavigator use more precise RFP check. r=dom-worker-reviewers,smaug
This refactors the code to be closer to the main-thread Navigator implementation, but the new CallerType and old workerPrivate->UsesSystemPrincipal() is functionally identical. Differential Revision: https://phabricator.services.mozilla.com/D167821
This commit is contained in:
Родитель
49eb23edff
Коммит
29918f4073
|
@ -21,7 +21,6 @@
|
||||||
#include "mozilla/dom/WorkerNavigatorBinding.h"
|
#include "mozilla/dom/WorkerNavigatorBinding.h"
|
||||||
#include "mozilla/dom/WorkerStatus.h"
|
#include "mozilla/dom/WorkerStatus.h"
|
||||||
#include "mozilla/dom/network/Connection.h"
|
#include "mozilla/dom/network/Connection.h"
|
||||||
#include "mozilla/StaticPrefs_privacy.h"
|
|
||||||
#include "mozilla/webgpu/Instance.h"
|
#include "mozilla/webgpu/Instance.h"
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
#include "nsDebug.h"
|
#include "nsDebug.h"
|
||||||
|
@ -102,17 +101,20 @@ void WorkerNavigator::GetAppName(nsString& aAppName,
|
||||||
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
|
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
|
||||||
MOZ_ASSERT(workerPrivate);
|
MOZ_ASSERT(workerPrivate);
|
||||||
|
|
||||||
if ((!mProperties.mAppNameOverridden.IsEmpty() ||
|
if (aCallerType != CallerType::System) {
|
||||||
StaticPrefs::privacy_resistFingerprinting()) &&
|
if (workerPrivate->GlobalScope()->ShouldResistFingerprinting()) {
|
||||||
!workerPrivate->UsesSystemPrincipal()) {
|
|
||||||
// We will spoof this value when 'privacy.resistFingerprinting' is true.
|
|
||||||
// See nsRFPService.h for spoofed value.
|
// See nsRFPService.h for spoofed value.
|
||||||
aAppName = StaticPrefs::privacy_resistFingerprinting()
|
aAppName.AssignLiteral(SPOOFED_APPNAME);
|
||||||
? NS_LITERAL_STRING_FROM_CSTRING(SPOOFED_APPNAME)
|
return;
|
||||||
: mProperties.mAppNameOverridden;
|
|
||||||
} else {
|
|
||||||
aAppName = mProperties.mAppName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!mProperties.mAppNameOverridden.IsEmpty()) {
|
||||||
|
aAppName = mProperties.mAppNameOverridden;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
aAppName = mProperties.mAppName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorkerNavigator::GetAppVersion(nsString& aAppVersion,
|
void WorkerNavigator::GetAppVersion(nsString& aAppVersion,
|
||||||
|
@ -121,17 +123,20 @@ void WorkerNavigator::GetAppVersion(nsString& aAppVersion,
|
||||||
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
|
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
|
||||||
MOZ_ASSERT(workerPrivate);
|
MOZ_ASSERT(workerPrivate);
|
||||||
|
|
||||||
if ((!mProperties.mAppVersionOverridden.IsEmpty() ||
|
if (aCallerType != CallerType::System) {
|
||||||
StaticPrefs::privacy_resistFingerprinting()) &&
|
if (workerPrivate->GlobalScope()->ShouldResistFingerprinting()) {
|
||||||
!workerPrivate->UsesSystemPrincipal()) {
|
|
||||||
// We will spoof this value when 'privacy.resistFingerprinting' is true.
|
|
||||||
// See nsRFPService.h for spoofed value.
|
// See nsRFPService.h for spoofed value.
|
||||||
aAppVersion = StaticPrefs::privacy_resistFingerprinting()
|
aAppVersion.AssignLiteral(SPOOFED_APPVERSION);
|
||||||
? NS_LITERAL_STRING_FROM_CSTRING(SPOOFED_APPVERSION)
|
return;
|
||||||
: mProperties.mAppVersionOverridden;
|
|
||||||
} else {
|
|
||||||
aAppVersion = mProperties.mAppVersion;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!mProperties.mAppVersionOverridden.IsEmpty()) {
|
||||||
|
aAppVersion = mProperties.mAppVersionOverridden;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
aAppVersion = mProperties.mAppVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorkerNavigator::GetPlatform(nsString& aPlatform, CallerType aCallerType,
|
void WorkerNavigator::GetPlatform(nsString& aPlatform, CallerType aCallerType,
|
||||||
|
@ -139,17 +144,20 @@ void WorkerNavigator::GetPlatform(nsString& aPlatform, CallerType aCallerType,
|
||||||
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
|
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
|
||||||
MOZ_ASSERT(workerPrivate);
|
MOZ_ASSERT(workerPrivate);
|
||||||
|
|
||||||
if ((!mProperties.mPlatformOverridden.IsEmpty() ||
|
if (aCallerType != CallerType::System) {
|
||||||
StaticPrefs::privacy_resistFingerprinting()) &&
|
if (workerPrivate->GlobalScope()->ShouldResistFingerprinting()) {
|
||||||
!workerPrivate->UsesSystemPrincipal()) {
|
|
||||||
// We will spoof this value when 'privacy.resistFingerprinting' is true.
|
|
||||||
// See nsRFPService.h for spoofed value.
|
// See nsRFPService.h for spoofed value.
|
||||||
aPlatform = StaticPrefs::privacy_resistFingerprinting()
|
aPlatform.AssignLiteral(SPOOFED_PLATFORM);
|
||||||
? NS_LITERAL_STRING_FROM_CSTRING(SPOOFED_PLATFORM)
|
return;
|
||||||
: mProperties.mPlatformOverridden;
|
|
||||||
} else {
|
|
||||||
aPlatform = mProperties.mPlatform;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!mProperties.mPlatformOverridden.IsEmpty()) {
|
||||||
|
aPlatform = mProperties.mPlatformOverridden;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
aPlatform = mProperties.mPlatform;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче