Bug 1876470 - AddEventListener/RemoveEventListener should not throw, r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D226337
This commit is contained in:
@@ -89,15 +89,15 @@ bool EventTarget::ComputeWantsUntrusted(
|
||||
void EventTarget::AddEventListener(
|
||||
const nsAString& aType, EventListener* aCallback,
|
||||
const AddEventListenerOptionsOrBoolean& aOptions,
|
||||
const Nullable<bool>& aWantsUntrusted, ErrorResult& aRv) {
|
||||
bool wantsUntrusted = ComputeWantsUntrusted(aWantsUntrusted, &aOptions, aRv);
|
||||
if (aRv.Failed()) {
|
||||
const Nullable<bool>& aWantsUntrusted) {
|
||||
IgnoredErrorResult rv;
|
||||
bool wantsUntrusted = ComputeWantsUntrusted(aWantsUntrusted, &aOptions, rv);
|
||||
if (NS_WARN_IF(rv.Failed())) {
|
||||
return;
|
||||
}
|
||||
|
||||
EventListenerManager* elm = GetOrCreateListenerManager();
|
||||
if (!elm) {
|
||||
aRv.Throw(NS_ERROR_UNEXPECTED);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ nsresult EventTarget::AddEventListener(const nsAString& aType,
|
||||
|
||||
void EventTarget::RemoveEventListener(
|
||||
const nsAString& aType, EventListener* aListener,
|
||||
const EventListenerOptionsOrBoolean& aOptions, ErrorResult& aRv) {
|
||||
const EventListenerOptionsOrBoolean& aOptions) {
|
||||
EventListenerManager* elm = GetExistingListenerManager();
|
||||
if (elm) {
|
||||
elm->RemoveEventListener(aType, aListener, aOptions);
|
||||
|
||||
@@ -69,11 +69,9 @@ class EventTarget : public nsISupports, public nsWrapperCache {
|
||||
ErrorResult& aRv);
|
||||
void AddEventListener(const nsAString& aType, EventListener* aCallback,
|
||||
const AddEventListenerOptionsOrBoolean& aOptions,
|
||||
const Nullable<bool>& aWantsUntrusted,
|
||||
ErrorResult& aRv);
|
||||
const Nullable<bool>& aWantsUntrusted);
|
||||
void RemoveEventListener(const nsAString& aType, EventListener* aCallback,
|
||||
const EventListenerOptionsOrBoolean& aOptions,
|
||||
ErrorResult& aRv);
|
||||
const EventListenerOptionsOrBoolean& aOptions);
|
||||
|
||||
protected:
|
||||
/**
|
||||
|
||||
@@ -35,12 +35,10 @@ interface EventTarget {
|
||||
differs in content and chrome. In content that default boolean
|
||||
value is true, while in chrome the default boolean value is
|
||||
false. */
|
||||
[Throws]
|
||||
undefined addEventListener(DOMString type,
|
||||
EventListener? listener,
|
||||
optional (AddEventListenerOptions or boolean) options = {},
|
||||
optional boolean? wantsUntrusted = null);
|
||||
[Throws]
|
||||
undefined removeEventListener(DOMString type,
|
||||
EventListener? listener,
|
||||
optional (EventListenerOptions or boolean) options = {});
|
||||
|
||||
@@ -16,10 +16,8 @@ interface MediaQueryList : EventTarget {
|
||||
readonly attribute UTF8String media;
|
||||
readonly attribute boolean matches;
|
||||
|
||||
[Throws]
|
||||
undefined addListener(EventListener? listener);
|
||||
|
||||
[Throws]
|
||||
undefined removeListener(EventListener? listener);
|
||||
|
||||
attribute EventHandler onchange;
|
||||
|
||||
@@ -68,7 +68,7 @@ bool MediaQueryList::Matches() {
|
||||
return mMatches;
|
||||
}
|
||||
|
||||
void MediaQueryList::AddListener(EventListener* aListener, ErrorResult& aRv) {
|
||||
void MediaQueryList::AddListener(EventListener* aListener) {
|
||||
if (!aListener) {
|
||||
return;
|
||||
}
|
||||
@@ -76,11 +76,10 @@ void MediaQueryList::AddListener(EventListener* aListener, ErrorResult& aRv) {
|
||||
AddEventListenerOptionsOrBoolean options;
|
||||
options.SetAsBoolean() = false;
|
||||
|
||||
AddEventListener(u"change"_ns, aListener, options, Nullable<bool>(), aRv);
|
||||
AddEventListener(u"change"_ns, aListener, options, Nullable<bool>());
|
||||
}
|
||||
|
||||
void MediaQueryList::RemoveListener(EventListener* aListener,
|
||||
ErrorResult& aRv) {
|
||||
void MediaQueryList::RemoveListener(EventListener* aListener) {
|
||||
if (!aListener) {
|
||||
return;
|
||||
}
|
||||
@@ -88,7 +87,7 @@ void MediaQueryList::RemoveListener(EventListener* aListener,
|
||||
EventListenerOptionsOrBoolean options;
|
||||
options.SetAsBoolean() = false;
|
||||
|
||||
RemoveEventListener(u"change"_ns, aListener, options, aRv);
|
||||
RemoveEventListener(u"change"_ns, aListener, options);
|
||||
}
|
||||
|
||||
bool MediaQueryList::HasListeners() const {
|
||||
|
||||
@@ -53,8 +53,8 @@ class MediaQueryList final : public DOMEventTargetHelper,
|
||||
// WebIDL methods
|
||||
void GetMedia(nsACString& aMedia) const;
|
||||
bool Matches();
|
||||
void AddListener(EventListener* aListener, ErrorResult& aRv);
|
||||
void RemoveListener(EventListener* aListener, ErrorResult& aRv);
|
||||
void AddListener(EventListener* aListener);
|
||||
void RemoveListener(EventListener* aListener);
|
||||
|
||||
IMPL_EVENT_HANDLER(change)
|
||||
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
[non-fully-active.https.html]
|
||||
expected:
|
||||
if (os == "android") and fission: [ERROR, TIMEOUT]
|
||||
ERROR
|
||||
[Permission change events shouldn't fire on non-fully active document]
|
||||
expected: TIMEOUT
|
||||
|
||||
Reference in New Issue
Block a user