author | Wes Kocher <wkocher@mozilla.com> |
Fri, 11 Aug 2017 13:49:34 -0700 | |
changeset 645368 | c4965deefa3b5946753796c10388ff2b48242c4b |
parent 645367 | f3df0300efae1abf2470e00b0fe4dfcd7ffa6edf |
child 645369 | 4858624ff8c430b970c882a52ba80c7e512f11b8 |
push id | 73753 |
push user | bmo:emilio+bugs@crisal.io |
push date | Sat, 12 Aug 2017 22:07:14 +0000 |
reviewers | backout |
bugs | 1382499 |
milestone | 57.0a1 |
backs out | 0ebb9924affaa4dc16687986d57dda7c773d8a25 c25b50b0edc52e54a87e6f02b6782830872ece05 1dcdc22d4919cca28f1b83ace94d4b476deb4c88 |
--- a/browser/components/resistfingerprinting/test/mochitest/mochitest.ini +++ b/browser/components/resistfingerprinting/test/mochitest/mochitest.ini @@ -7,9 +7,8 @@ support-files = [test_device_sensor_event.html] [test_geolocation.html] scheme = https [test_reduce_time_precision.html] [test_hide_gamepad_info.html] support-files = test_hide_gamepad_info_iframe.html [test_speech_synthesis.html] -[test_bug1382499_touch_api.html]
deleted file mode 100644 --- a/browser/components/resistfingerprinting/test/mochitest/test_bug1382499_touch_api.html +++ /dev/null @@ -1,51 +0,0 @@ -<!DOCTYPE html> -<meta charset="utf-8"> -<link rel="stylesheet" href="/tests/SimpleTest/test.css"/> -<script src="/tests/SimpleTest/SimpleTest.js"></script> -<script src="/tests/SimpleTest/EventUtils.js"></script> -<script> -/* global SimpleTest SpecialPowers synthesizeTouch */ - -SimpleTest.waitForExplicitFinish(); - -function promiseEvent(target, eventName) { - return new Promise(resolve => { - target.addEventListener(eventName, function eventOccurred(event) { - target.removeEventListener(eventName, eventOccurred, false); - resolve(event); - }, false); - }); -} - -function promiseTouchEvent(target, type, offsetX, offsetY, params) { - let touchEventPromise = promiseEvent(target, type); - params.type = type; - synthesizeTouch(target, offsetX, offsetY, params); - return touchEventPromise; -}; - -document.addEventListener("DOMContentLoaded", async () => { - const target0 = document.getElementById("target0"); - const touchParams = {force: 1.0, angle: 1.0, rx: 2, ry: 3}; - await SpecialPowers.pushPrefEnv({set: [["dom.w3c_touch_events.enabled", 1]]}); - for (let resist of [false, true]) { - await SpecialPowers.pushPrefEnv({set: [["privacy.resistFingerprinting", resist]]}); - info("starting test with fingerprinting resistance " + (resist ? "on" : "off")); - let touchEvent = await promiseTouchEvent(target0, "touchstart", 5, 5, touchParams); - info("touch event received"); - let touch = touchEvent.touches[0]; - if (resist) { - is(touch.screenX, touch.clientX, "touch.screenX should be the same as touch.clientX"); - is(touch.screenY, touch.clientY, "touch.screenY should be the same as touch.clientY"); - // radiusX/radiusY may differ from the original rx/ry because of AppUnitsPerCSSPixel and AppUnitsPerDevPixel. - // So only check if the values are spoofed. - is(touch.radiusX, 0, "touch.radiusX"); - is(touch.radiusY, 0, "touch.radiusY"); - } - is(touch.force, resist ? 0.0 : touchParams.force, "touch.force"); - is(touch.rotationAngle, resist ? 0 : touchParams.angle, "touch.rotationAngle"); - } - SimpleTest.finish(); -}); -</script> -<div id="target0">target 0</div>
--- a/dom/events/Touch.cpp +++ b/dom/events/Touch.cpp @@ -155,56 +155,16 @@ Touch::ScreenY(CallerType aCallerType) c { if (nsContentUtils::ResistFingerprinting(aCallerType)) { return ClientY(); } return mScreenPoint.y; } -int32_t -Touch::RadiusX(CallerType aCallerType) const -{ - if (nsContentUtils::ResistFingerprinting(aCallerType)) { - return 0; - } - - return mRadius.x; -} - -int32_t -Touch::RadiusY(CallerType aCallerType) const -{ - if (nsContentUtils::ResistFingerprinting(aCallerType)) { - return 0; - } - - return mRadius.y; -} - -float -Touch::RotationAngle(CallerType aCallerType) const -{ - if (nsContentUtils::ResistFingerprinting(aCallerType)) { - return 0.0f; - } - - return mRotationAngle; -} - -float -Touch::Force(CallerType aCallerType) const -{ - if (nsContentUtils::ResistFingerprinting(aCallerType)) { - return 0.0f; - } - - return mForce; -} - void Touch::InitializePoints(nsPresContext* aPresContext, WidgetEvent* aEvent) { if (mPointsInitialized) { return; } mClientPoint = Event::GetClientCoords( aPresContext, aEvent, mRefPoint, mClientPoint); @@ -219,20 +179,20 @@ Touch::SetTarget(EventTarget* aTarget) { mTarget = aTarget; } bool Touch::Equals(Touch* aTouch) { return mRefPoint == aTouch->mRefPoint && - mForce == aTouch->mForce && - mRotationAngle == aTouch->mRotationAngle && - mRadius.x == aTouch->mRadius.x && - mRadius.y == aTouch->mRadius.y; + mForce == aTouch->Force() && + mRotationAngle == aTouch->RotationAngle() && + mRadius.x == aTouch->RadiusX() && + mRadius.y == aTouch->RadiusY(); } JSObject* Touch::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) { return TouchBinding::Wrap(aCx, this, aGivenProto); }
--- a/dom/events/Touch.h +++ b/dom/events/Touch.h @@ -69,20 +69,20 @@ public: int32_t Identifier() const { return mIdentifier; } EventTarget* GetTarget() const; int32_t ScreenX(CallerType aCallerType) const; int32_t ScreenY(CallerType aCallerType) const; 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(CallerType aCallerType) const; - int32_t RadiusY(CallerType aCallerType) const; - float RotationAngle(CallerType aCallerType) const; - float Force(CallerType aCallerType) const; + int32_t RadiusX() const { return mRadius.x; } + int32_t RadiusY() const { return mRadius.y; } + float RotationAngle() const { return mRotationAngle; } + float Force() const { return mForce; } nsCOMPtr<EventTarget> mTarget; LayoutDeviceIntPoint mRefPoint; bool mChanged; uint32_t mMessage; int32_t mIdentifier; CSSIntPoint mPagePoint; CSSIntPoint mClientPoint;
--- a/dom/webidl/Touch.webidl +++ b/dom/webidl/Touch.webidl @@ -33,17 +33,13 @@ interface Touch { [NeedsCallerType] readonly attribute long screenX; [NeedsCallerType] readonly attribute long screenY; readonly attribute long clientX; readonly attribute long clientY; readonly attribute long pageX; readonly attribute long pageY; - [NeedsCallerType] readonly attribute long radiusX; - [NeedsCallerType] readonly attribute long radiusY; - [NeedsCallerType] readonly attribute float rotationAngle; - [NeedsCallerType] readonly attribute float force; };
--- a/layout/base/PresShell.cpp +++ b/layout/base/PresShell.cpp @@ -7102,18 +7102,18 @@ DispatchPointerFromMouseOrTouch(PresShel } WidgetPointerEvent event(touchEvent->IsTrusted(), pointerMessage, touchEvent->mWidget); event.mIsPrimary = i == 0; event.pointerId = touch->Identifier(); event.mRefPoint = touch->mRefPoint; event.mModifiers = touchEvent->mModifiers; - event.mWidth = touch->RadiusX(CallerType::System); - event.mHeight = touch->RadiusY(CallerType::System); + event.mWidth = touch->RadiusX(); + event.mHeight = touch->RadiusY(); event.tiltX = touch->tiltX; event.tiltY = touch->tiltY; event.mTime = touchEvent->mTime; event.mTimeStamp = touchEvent->mTimeStamp; event.mFlags = touchEvent->mFlags; event.button = button; event.buttons = buttons; event.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH;
--- a/testing/mochitest/tests/SimpleTest/EventUtils.js +++ b/testing/mochitest/tests/SimpleTest/EventUtils.js @@ -403,17 +403,17 @@ function synthesizeMouseAtPoint(left, to function synthesizeTouchAtPoint(left, top, aEvent, aWindow = window) { var utils = _getDOMWindowUtils(aWindow); if (utils) { var id = aEvent.id || utils.DEFAULT_TOUCH_POINTER_ID; var rx = aEvent.rx || 1; - var ry = aEvent.ry || 1; + var ry = aEvent.rx || 1; var angle = aEvent.angle || 0; var force = aEvent.force || 1; var modifiers = _parseModifiers(aEvent, aWindow); if (("type" in aEvent) && aEvent.type) { utils.sendTouchEvent(aEvent.type, [id], [left], [top], [rx], [ry], [angle], [force], 1, modifiers); } else {
--- a/widget/InputData.cpp +++ b/widget/InputData.cpp @@ -1,17 +1,16 @@ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "InputData.h" #include "mozilla/dom/Touch.h" -#include "nsContentUtils.h" #include "nsDebug.h" #include "nsThreadUtils.h" #include "mozilla/MouseEvents.h" #include "mozilla/TouchEvents.h" #include "UnitTransforms.h" namespace mozilla { @@ -126,20 +125,20 @@ MultiTouchInput::MultiTouchInput(const W break; } for (size_t i = 0; i < aTouchEvent.mTouches.Length(); i++) { const Touch* domTouch = aTouchEvent.mTouches[i]; // Extract data from weird interfaces. int32_t identifier = domTouch->Identifier(); - int32_t radiusX = domTouch->RadiusX(CallerType::System); - int32_t radiusY = domTouch->RadiusY(CallerType::System); - float rotationAngle = domTouch->RotationAngle(CallerType::System); - float force = domTouch->Force(CallerType::System); + int32_t radiusX = domTouch->RadiusX(); + int32_t radiusY = domTouch->RadiusY(); + float rotationAngle = domTouch->RotationAngle(); + float force = domTouch->Force(); SingleTouchData data(identifier, ViewAs<ScreenPixel>(domTouch->mRefPoint, PixelCastJustification::LayoutDeviceIsScreenForUntransformedEvent), ScreenSize(radiusX, radiusY), rotationAngle, force);