Bug 1570212 - Convert device.sensors.test.events to a static pref. r=mccr8

Differential Revision: https://phabricator.services.mozilla.com/D40159

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nicholas Nethercote 2019-08-02 11:59:05 +00:00
Родитель eb6de3be4d
Коммит cdffde3415
2 изменённых файлов: 7 добавлений и 11 удалений

Просмотреть файл

@ -150,8 +150,6 @@ class DeviceSensorTestEvent : public Runnable {
uint32_t mType;
};
static bool sTestSensorEvents = false;
NS_IMETHODIMP nsDeviceSensors::AddWindowListener(uint32_t aType,
nsIDOMWindow* aWindow) {
if (!IsSensorAllowedByPref(aType, aWindow)) return NS_OK;
@ -164,14 +162,7 @@ NS_IMETHODIMP nsDeviceSensors::AddWindowListener(uint32_t aType,
mWindowListeners[aType]->AppendElement(aWindow);
static bool sPrefCacheInitialized = false;
if (!sPrefCacheInitialized) {
sPrefCacheInitialized = true;
Preferences::AddBoolVarCache(&sTestSensorEvents,
"device.sensors.test.events", false);
}
if (sTestSensorEvents) {
if (StaticPrefs::device_sensors_test_events()) {
nsCOMPtr<nsIRunnable> event = new DeviceSensorTestEvent(this, aType);
NS_DispatchToCurrentThread(event);
}
@ -446,7 +437,7 @@ void nsDeviceSensors::FireDOMMotionEvent(Document* doc, EventTarget* target,
TimeDuration::FromMilliseconds(DEFAULT_SENSOR_POLL);
bool fireEvent =
(TimeStamp::Now() > mLastDOMMotionEventTime + sensorPollDuration) ||
sTestSensorEvents;
StaticPrefs::device_sensors_test_events();
switch (type) {
case nsIDeviceSensorData::TYPE_LINEAR_ACCELERATION:

Просмотреть файл

@ -1097,6 +1097,11 @@
value: false
mirror: always
- name: device.sensors.test.events
type: bool
value: false
mirror: always
#---------------------------------------------------------------------------
# Prefs starting with "devtools."
#---------------------------------------------------------------------------