Bug 1485264 - Removed dom.event.highrestimestamp.enabled pref r=smaug
authorJosef Citrine <jcit@pm.me>
Fri, 01 Mar 2019 18:49:44 +0000
changeset 519862 47629d4e3150e77e91201d93d5d9e8b7cda8f909
parent 519861 9b1e57540da771540bf6dc10be8c150582ee1b84
child 519863 bd930453714efe8f6aa756938c1c09a24ec79cd4
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1485264
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1485264 - Removed dom.event.highrestimestamp.enabled pref r=smaug Differential Revision: https://phabricator.services.mozilla.com/D21580
dom/events/Event.cpp
dom/events/test/test_eventTimeStamp.html
dom/smil/test/test_smilTimeEvents.xhtml
editor/libeditor/tests/test_dom_input_event_on_htmleditor.html
editor/libeditor/tests/test_dom_input_event_on_texteditor.html
modules/libpref/init/all.js
--- a/dom/events/Event.cpp
+++ b/dom/events/Event.cpp
@@ -35,40 +35,30 @@
 #include "nsJSEnvironment.h"
 #include "nsLayoutUtils.h"
 #include "nsPIWindowRoot.h"
 #include "nsRFPService.h"
 
 namespace mozilla {
 namespace dom {
 
-static bool sReturnHighResTimeStamp = false;
-static bool sReturnHighResTimeStampIsSet = false;
-
 Event::Event(EventTarget* aOwner, nsPresContext* aPresContext,
              WidgetEvent* aEvent) {
   ConstructorInit(aOwner, aPresContext, aEvent);
 }
 
 Event::Event(nsPIDOMWindowInner* aParent) {
   ConstructorInit(nsGlobalWindowInner::Cast(aParent), nullptr, nullptr);
 }
 
 void Event::ConstructorInit(EventTarget* aOwner, nsPresContext* aPresContext,
                             WidgetEvent* aEvent) {
   SetOwner(aOwner);
   mIsMainThreadEvent = NS_IsMainThread();
 
-  if (mIsMainThreadEvent && !sReturnHighResTimeStampIsSet) {
-    Preferences::AddBoolVarCache(&sReturnHighResTimeStamp,
-                                 "dom.event.highrestimestamp.enabled",
-                                 sReturnHighResTimeStamp);
-    sReturnHighResTimeStampIsSet = true;
-  }
-
   mPrivateDataDuplicated = false;
   mWantsPopupControlCheck = false;
 
   if (aEvent) {
     mEvent = aEvent;
     mEventIsInternal = false;
   } else {
     mEventIsInternal = true;
@@ -687,25 +677,16 @@ bool Event::ReturnValue(CallerType aCall
 
 void Event::SetReturnValue(bool aReturnValue, CallerType aCallerType) {
   if (!aReturnValue) {
     PreventDefaultInternal(aCallerType == CallerType::System);
   }
 }
 
 double Event::TimeStamp() {
-  if (!sReturnHighResTimeStamp) {
-    // In the situation where you have set a very old, not-very-supported
-    // non-default preference, we will always reduce the precision,
-    // regardless of system principal or not.
-    // The timestamp is absolute, so we supply a zero context mix-in.
-    double ret = static_cast<double>(mEvent->mTime);
-    return nsRFPService::ReduceTimePrecisionAsMSecs(ret, 0);
-  }
-
   if (mEvent->mTimeStamp.IsNull()) {
     return 0.0;
   }
 
   if (mIsMainThreadEvent) {
     if (NS_WARN_IF(!mOwner)) {
       return 0.0;
     }
--- a/dom/events/test/test_eventTimeStamp.html
+++ b/dom/events/test/test_eventTimeStamp.html
@@ -35,18 +35,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 SimpleTest.waitForExplicitFinish();
 SimpleTest.requestFlakyTimeout("untriaged");
 
 // This file performs tests that normalize the timeOrigin within a worker
 // and compare it to the page. When this occurs, time can appear to go backwards.
 // This is a known (and accepted) regression of privacy.reduceTimerPrecision so
 // we need to turn it off.
 SpecialPowers.pushPrefEnv({ "set": [
-    ["privacy.reduceTimerPrecision", false],
-    ["dom.event.highrestimestamp.enabled", true]
+    ["privacy.reduceTimerPrecision", false]
   ]}, testRegularEvents);
 
 // Event.timeStamp should be relative to the time origin which is:
 //
 //   Non-worker context: navigation start
 //   Dedicated worker: navigation start of the document that created the worker
 //   Shared worker: creation time of the shared worker
 //
--- a/dom/smil/test/test_smilTimeEvents.xhtml
+++ b/dom/smil/test/test_smilTimeEvents.xhtml
@@ -231,29 +231,25 @@ function handleOnEnd(evt)
 
 function sanityCheckEvent(evt)
 {
   is(evt.target, gAnim, "Unexpected event target");
   is(evt.currentTarget, gAnim, "Unexpected event current target");
   is(evt.eventPhase, evt.AT_TARGET);
   is(evt.bubbles, false, "Event should not bubble");
   is(evt.cancelable, false, "Event should not be cancelable");
-  if (SpecialPowers.getBoolPref("dom.event.highrestimestamp.enabled")) {
-    var lessThanOrEqualsAllowed = SpecialPowers.getBoolPref("privacy.reduceTimerPrecision");
-    var now = window.performance.now();
-    ok(evt.timeStamp > 0 &&
-       (
-        (evt.timeStamp < now && !lessThanOrEqualsAllowed) ||
-        (evt.timeStamp <= now && lessThanOrEqualsAllowed)
-       ),
-       "Event timeStamp (" + evt.timeStamp + ") should be > 0 but " +
-       "before the current time (" + now + ")");
-  } else {
-    is(evt.timeStamp, 0, "Event timeStamp should be 0");
-  }
+  var lessThanOrEqualsAllowed = SpecialPowers.getBoolPref("privacy.reduceTimerPrecision");
+  var now = window.performance.now();
+  ok(evt.timeStamp > 0 &&
+      (
+      (evt.timeStamp < now && !lessThanOrEqualsAllowed) ||
+      (evt.timeStamp <= now && lessThanOrEqualsAllowed)
+      ),
+      "Event timeStamp (" + evt.timeStamp + ") should be > 0 but " +
+      "before the current time (" + now + ")");
   ok(evt.view !== null, "Event view not set");
 }
 
 function checkExpectedEvent(evt)
 {
   sanityCheckEvent(evt);
   ok(gExpectedEvents.length > 0, "Unexpected event: " + evt.type);
   if (gExpectedEvents.length == 0) return;
--- a/editor/libeditor/tests/test_dom_input_event_on_htmleditor.html
+++ b/editor/libeditor/tests/test_dom_input_event_on_htmleditor.html
@@ -64,31 +64,21 @@ function runTests() {
 
     var handler = function(aEvent) {
       is(aEvent.target, eventTarget,
          "input event is fired on unexpected element: " + aEvent.target.tagName);
       ok(aEvent instanceof InputEvent,
          "input event should be dispatched with InputEvent interface");
       ok(!aEvent.cancelable, "input event must not be cancelable");
       ok(aEvent.bubbles, "input event must be bubbles");
-      if (SpecialPowers.getBoolPref("dom.event.highrestimestamp.enabled")) {
-        let duration = Math.abs(window.performance.now() - aEvent.timeStamp);
-        ok(duration < 30 * 1000,
-           "perhaps, timestamp wasn't set correctly :" + aEvent.timeStamp +
-           " (expected it to be within 30s of the current time but it " +
-           "differed by " + duration + "ms)");
-      } else {
-        var eventTime = new Date(aEvent.timeStamp);
-        let duration = Math.abs(Date.now() - aEvent.timeStamp);
-        ok(duration < 30 * 1000,
-           "perhaps, timestamp wasn't set correctly :" +
-           eventTime.toLocaleString() +
-           " (expected it to be within 30s of the current time but it " +
-           "differed by " + duration + "ms)");
-      }
+      let duration = Math.abs(window.performance.now() - aEvent.timeStamp);
+      ok(duration < 30 * 1000,
+         "perhaps, timestamp wasn't set correctly :" + aEvent.timeStamp +
+         " (expected it to be within 30s of the current time but it " +
+         "differed by " + duration + "ms)");
       inputEvent = aEvent;
     };
 
     aWindow.addEventListener("input", handler, true);
 
     inputEvent = null;
     synthesizeKey("a", { }, aWindow);
     is(editTarget.innerHTML, "a", aDescription + "wrong element was edited");
--- a/editor/libeditor/tests/test_dom_input_event_on_texteditor.html
+++ b/editor/libeditor/tests/test_dom_input_event_on_texteditor.html
@@ -36,31 +36,21 @@ function runTests() {
 
     var handler = function(aEvent) {
       is(aEvent.target, aElement,
          "input event is fired on unexpected element: " + aEvent.target.tagName);
       ok(aEvent instanceof InputEvent,
          "input event should be dispatched with InputEvent interface");
       ok(!aEvent.cancelable, "input event must not be cancelable");
       ok(aEvent.bubbles, "input event must be bubbles");
-      if (SpecialPowers.getBoolPref("dom.event.highrestimestamp.enabled")) {
-        let duration = Math.abs(window.performance.now() - aEvent.timeStamp);
-        ok(duration < 30 * 1000,
-           "perhaps, timestamp wasn't set correctly :" + aEvent.timeStamp +
-           " (expected it to be within 30s of the current time but it " +
-           "differed by " + duration + "ms)");
-      } else {
-        var eventTime = new Date(aEvent.timeStamp);
-        let duration = Math.abs(Date.now() - aEvent.timeStamp);
-        ok(duration < 30 * 1000,
-           "perhaps, timestamp wasn't set correctly :" +
-           eventTime.toLocaleString() +
-           " (expected it to be within 30s of the current time but it " +
-           "differed by " + duration + "ms)");
-      }
+      let duration = Math.abs(window.performance.now() - aEvent.timeStamp);
+      ok(duration < 30 * 1000,
+         "perhaps, timestamp wasn't set correctly :" + aEvent.timeStamp +
+         " (expected it to be within 30s of the current time but it " +
+         "differed by " + duration + "ms)");
       inputEvent = aEvent;
     };
 
     aElement.addEventListener("input", handler, true);
 
     inputEvent = null;
     sendString("a");
     is(aElement.value, "a", aDescription + "'a' key didn't change the value");
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -1443,17 +1443,16 @@ pref("privacy.resistFingerprinting.jsmlo
 pref("privacy.reduceTimerPrecision", true);
 // Dynamically tune the resolution of the timer reduction for both of the two above prefs
 pref("privacy.resistFingerprinting.reduceTimerPrecision.microseconds", 1000);
 // Enable jittering the clock one precision value forward
 pref("privacy.resistFingerprinting.reduceTimerPrecision.jitter", true);
 
 pref("dom.event.contextmenu.enabled",       true);
 pref("dom.event.clipboardevents.enabled",   true);
-pref("dom.event.highrestimestamp.enabled",  true);
 pref("dom.event.coalesce_mouse_move",       true);
 
 pref("javascript.enabled",                  true);
 pref("javascript.options.strict",           false);
 #ifdef DEBUG
 pref("javascript.options.strict.debug",     false);
 #endif
 pref("javascript.options.unboxed_objects",  false);