Fix error when beacon.enabled set to false.

master
Fedor 2021-01-17 16:11:13 +02:00 committed by Fedor
parent 7d3ec22993
commit 0811addcc1
2 changed files with 10 additions and 1 deletions

View File

@ -94,6 +94,9 @@
#include "mozilla/DetailedPromise.h" #include "mozilla/DetailedPromise.h"
#endif #endif
static const char* sBeaconEnabledStr =
"beacon.enabled";
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {
@ -861,6 +864,12 @@ Navigator::SendBeacon(const nsAString& aUrl,
const Nullable<ArrayBufferViewOrBlobOrStringOrFormData>& aData, const Nullable<ArrayBufferViewOrBlobOrStringOrFormData>& aData,
ErrorResult& aRv) ErrorResult& aRv)
{ {
if (!Preferences::GetBool(sBeaconEnabledStr, false)) {
aRv = NS_OK;
return true;
}
if (!mWindow) { if (!mWindow) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return false; return false;

View File

@ -292,7 +292,7 @@ partial interface Navigator {
}; };
partial interface Navigator { partial interface Navigator {
[Throws, Pref="beacon.enabled"] [Throws]
boolean sendBeacon(DOMString url, boolean sendBeacon(DOMString url,
optional (ArrayBufferView or Blob or DOMString or FormData)? data = null); optional (ArrayBufferView or Blob or DOMString or FormData)? data = null);
}; };