Ticket #22084: 0001-PATCH-Bug-1372072-Part-1-Spoofing-network-informatio.patch

File 0001-PATCH-Bug-1372072-Part-1-Spoofing-network-informatio.patch, 1.9 KB (added by igt0, 18 months ago)

Version 2 - Backport code from Firefox

  • dom/network/Connection.cpp

    From d5734439dca78ef28cc82427a3775a9884678c24 Mon Sep 17 00:00:00 2001
    From: Tim Huang <tihuang@mozilla.com>
    Date: Wed, 13 Dec 2017 15:29:00 -0200
    Subject: [PATCH 1/2] [PATCH] 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
    ---
    ---
     dom/network/Connection.cpp | 3 ++-
     dom/network/Connection.h   | 8 +++++++-
     2 files changed, 9 insertions(+), 2 deletions(-)
    
    diff --git a/dom/network/Connection.cpp b/dom/network/Connection.cpp
    index 3bf6f40384a6..cc06b5e14b6a 100644
    a b Connection::Notify(const hal::NetworkInformation& aNetworkInfo) 
    7878
    7979  UpdateFromNetworkInfo(aNetworkInfo);
    8080
    81   if (previousType == mType) {
     81  if (previousType == mType ||
     82      nsContentUtils::ShouldResistFingerprinting()) {
    8283    return;
    8384  }
    8485
  • dom/network/Connection.h

    diff --git a/dom/network/Connection.h b/dom/network/Connection.h
    index 907aea144bc0..59759b4b805f 100644
    a b  
    1313#include "mozilla/dom/NetworkInformationBinding.h"
    1414#include "nsCycleCollectionParticipant.h"
    1515#include "nsINetworkProperties.h"
     16#include "nsContentUtils.h"
     17
    1618
    1719namespace mozilla {
    1820
    public: 
    4446
    4547  virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
    4648
    47   ConnectionType Type() const { return mType; }
     49  ConnectionType Type() const
     50  {
     51    return nsContentUtils::ShouldResistFingerprinting() ?
     52             static_cast<ConnectionType>(ConnectionType::Unknown) : mType;
     53  }
    4854
    4955  IMPL_EVENT_HANDLER(typechange)
    5056