Bug 1337161 - Hide information of connected gamepads from content when privacy.resistFingerprinting is true r=arthuredelstein,smaug

MozReview-Commit-ID: Di6ba9B4w0d

--HG--
extra : rebase_source : 69b392d4c0fa7ed5ac8f4fa02091153537a99798
This commit is contained in:
Chung-Sheng Fu 2017-06-15 17:59:26 +08:00
Родитель d61a420f11
Коммит 49fb1d27d8
2 изменённых файлов: 16 добавлений и 2 удалений

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

@ -13870,6 +13870,13 @@ nsGlobalWindow::GetGamepads(nsTArray<RefPtr<Gamepad> >& aGamepads)
{
MOZ_ASSERT(IsInnerWindow());
aGamepads.Clear();
// navigator.getGamepads() always returns an empty array when
// privacy.resistFingerprinting is true.
if (nsContentUtils::ShouldResistFingerprinting()) {
return;
}
// mGamepads.Count() may not be sufficient, but it's not harmful.
aGamepads.SetCapacity(mGamepads.Count());
for (auto iter = mGamepads.Iter(); !iter.Done(); iter.Next()) {

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

@ -20,6 +20,7 @@
#include "mozilla/StaticPtr.h"
#include "nsAutoPtr.h"
#include "nsContentUtils.h"
#include "nsGlobalWindow.h"
#include "nsIDOMEvent.h"
#include "nsIDOMDocument.h"
@ -138,7 +139,7 @@ GamepadManager::AddListener(nsGlobalWindow* aWindow)
MOZ_ASSERT(aWindow->IsInnerWindow());
MOZ_ASSERT(NS_IsMainThread());
if (!mEnabled || mShuttingDown) {
if (!mEnabled || mShuttingDown || nsContentUtils::ShouldResistFingerprinting()) {
return;
}
@ -315,6 +316,12 @@ GamepadManager::FireAxisMoveEvent(EventTarget* aTarget,
void
GamepadManager::NewConnectionEvent(uint32_t aIndex, bool aConnected)
{
// Do not fire gamepadconnected and gamepaddisconnected events when
// privacy.resistFingerprinting is true.
if (nsContentUtils::ShouldResistFingerprinting()) {
return;
}
if (mShuttingDown) {
return;
}
@ -398,7 +405,7 @@ GamepadManager::FireConnectionEvent(EventTarget* aTarget,
void
GamepadManager::SyncGamepadState(uint32_t aIndex, Gamepad* aGamepad)
{
if (mShuttingDown || !mEnabled) {
if (mShuttingDown || !mEnabled || nsContentUtils::ShouldResistFingerprinting()) {
return;
}