forked from mirrors/gecko-dev
Bug 1811442 - Automatically reject requests for MIDI access when no implementation is present r=bholley
Differential Revision: https://phabricator.services.mozilla.com/D167452
This commit is contained in:
parent
8ee1c95687
commit
ca827af9eb
1 changed files with 13 additions and 1 deletions
|
|
@ -16,7 +16,7 @@
|
||||||
#include "mozilla/ipc/Endpoint.h"
|
#include "mozilla/ipc/Endpoint.h"
|
||||||
#include "mozilla/ipc/PBackgroundChild.h"
|
#include "mozilla/ipc/PBackgroundChild.h"
|
||||||
#include "mozilla/ipc/BackgroundChild.h"
|
#include "mozilla/ipc/BackgroundChild.h"
|
||||||
#include "mozilla/Preferences.h"
|
#include "mozilla/StaticPrefs_midi.h"
|
||||||
|
|
||||||
using namespace mozilla::ipc;
|
using namespace mozilla::ipc;
|
||||||
|
|
||||||
|
|
@ -59,6 +59,18 @@ already_AddRefed<Promise> MIDIAccessManager::RequestMIDIAccess(
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef MOZ_WEBMIDI_MIDIR_IMPL
|
||||||
|
if (!StaticPrefs::midi_testing()) {
|
||||||
|
// If we don't have a MIDI implementation and testing is disabled we can't
|
||||||
|
// allow accessing WebMIDI. However we don't want to return something
|
||||||
|
// different from a normal rejection because we don't want websites to use
|
||||||
|
// the error as a way to fingerprint users, so we throw a security error
|
||||||
|
// as if the request had been rejected by the user.
|
||||||
|
aRv.ThrowSecurityError("Access not allowed");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!FeaturePolicyUtils::IsFeatureAllowed(doc, u"midi"_ns)) {
|
if (!FeaturePolicyUtils::IsFeatureAllowed(doc, u"midi"_ns)) {
|
||||||
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
|
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue