From 9c1a71c164852a00dec4f1d0599050823314781c Mon Sep 17 00:00:00 2001 From: Arthur Edelstein Date: Mon, 24 Apr 2017 08:18:25 -0700 Subject: [PATCH] Bug 10286: Touch API fingerprinting resistance --- dom/events/Touch.cpp | 7 +++++++ dom/events/Touch.h | 16 ++++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/dom/events/Touch.cpp b/dom/events/Touch.cpp index a538fa6959d0a..39d50e3c65ca9 100644 --- a/dom/events/Touch.cpp +++ b/dom/events/Touch.cpp @@ -188,5 +188,12 @@ Touch::GetParentObject() return mTarget->GetOwnerGlobal(); } +bool +Touch::ResistFingerprinting() const +{ + return !nsContentUtils::LegacyIsCallerChromeOrNativeCode() && + nsContentUtils::ResistFingerprinting(); +} + } // namespace dom } // namespace mozilla diff --git a/dom/events/Touch.h b/dom/events/Touch.h index f98f7f951f207..858fb165395ff 100644 --- a/dom/events/Touch.h +++ b/dom/events/Touch.h @@ -67,16 +67,19 @@ public: // WebIDL int32_t Identifier() const { return mIdentifier; } EventTarget* GetTarget() const; - int32_t ScreenX() const { return mScreenPoint.x; } - int32_t ScreenY() const { return mScreenPoint.y; } + int32_t ScreenX() const { return ResistFingerprinting() ? + mClientPoint.x : mScreenPoint.x; } + int32_t ScreenY() const { return ResistFingerprinting() ? + mClientPoint.y : mScreenPoint.y; } int32_t ClientX() const { return mClientPoint.x; } int32_t ClientY() const { return mClientPoint.y; } int32_t PageX() const { return mPagePoint.x; } int32_t PageY() const { return mPagePoint.y; } - int32_t RadiusX() const { return mRadius.x; } - int32_t RadiusY() const { return mRadius.y; } - float RotationAngle() const { return mRotationAngle; } - float Force() const { return mForce; } + int32_t RadiusX() const { return ResistFingerprinting() ? 1 : mRadius.x; } + int32_t RadiusY() const { return ResistFingerprinting() ? 1 : mRadius.y; } + float RotationAngle() const { return ResistFingerprinting() ? + 0.0 : mRotationAngle; } + float Force() const { return ResistFingerprinting() ? 0.0 : mForce; } nsCOMPtr mTarget; LayoutDeviceIntPoint mRefPoint; @@ -90,6 +93,7 @@ public: float mRotationAngle; float mForce; protected: + bool ResistFingerprinting() const; ~Touch(); bool mPointsInitialized; -- GitLab