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 : 78449fb4888b787062ff2139e36c219e0eac0b2c
This commit is contained in:
Tim Huang 2017-06-13 11:10:30 +08:00
parent 73924a682a
commit db3305baa3
2 changed files with 8 additions and 2 deletions

View File

@ -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);
}
}

View File

@ -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)