Bug 1372072 - Part 1: Spoofing network information API and blocking ontypechange event when 'privacy.resistFingerprinting' is true. r=arthuredelstein,baku

This patch makes the network information API always returns the default type 'unknown'
and blocking the ontypechange event while connection type changed when 'privacy.
resistFingerprinting' is true.

MozReview-Commit-ID: 4eOdHgAGtyY

--HG--
extra : rebase_source : 172f6dd01b45761f441a8ac81fd82e5caa7c68f6
extra : source : 41a89cb123e1b50f28f062f071196e85d92cfb10
This commit is contained in:
Tim Huang 2017-06-13 11:10:30 +08:00
Родитель 7866e6fdb6
Коммит d53b315de9
2 изменённых файлов: 8 добавлений и 2 удалений

Просмотреть файл

@ -100,7 +100,8 @@ Connection::Update(ConnectionType aType, bool aIsWifi, bool aDHCPGateway,
mIsWifi = aIsWifi;
mDHCPGateway = aDHCPGateway;
if (aNotify && previousType != aType) {
if (aNotify && previousType != aType &&
!nsContentUtils::ShouldResistFingerprinting()) {
DispatchTrustedEvent(CHANGE_EVENT_NAME);
}
}

Просмотреть файл

@ -9,6 +9,7 @@
#include "mozilla/DOMEventTargetHelper.h"
#include "mozilla/dom/NetworkInformationBinding.h"
#include "nsContentUtils.h"
#include "nsCycleCollectionParticipant.h"
#include "nsINetworkProperties.h"
@ -52,7 +53,11 @@ public:
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;
ConnectionType Type() const { return mType; }
ConnectionType Type() const
{
return nsContentUtils::ShouldResistFingerprinting() ?
static_cast<ConnectionType>(ConnectionType::Unknown) : mType;
}
IMPL_EVENT_HANDLER(typechange)