Bug 1266066 - Add a console warning for attempts to preventDefault() from a passive listener. r=smaug

MozReview-Commit-ID: G1nzkUxMEuE
This commit is contained in:
Kartikaya Gupta 2016-05-12 14:51:02 -04:00
parent b867e298b4
commit d671429ba2
3 changed files with 13 additions and 0 deletions

View File

@ -11,3 +11,4 @@
*/
DOCUMENT_WARNING(IgnoringWillChangeOverBudget)
DOCUMENT_WARNING(PreventDefaultFromPassiveListener)

View File

@ -521,6 +521,16 @@ Event::PreventDefaultInternal(bool aCalledByDefaultHandler)
return;
}
if (mEvent->mFlags.mInPassiveListener) {
nsCOMPtr<nsPIDOMWindowInner> win(do_QueryInterface(mOwner));
if (win) {
if (nsIDocument* doc = win->GetExtantDoc()) {
nsString type;
GetType(type);
const char16_t* params[] = { type.get() };
doc->WarnOnceAbout(nsIDocument::ePreventDefaultFromPassiveListener,
false, params, ArrayLength(params));
}
}
return;
}

View File

@ -224,3 +224,5 @@ RewriteYoutubeEmbed=Rewriting old-style Youtube Flash embed (%S) to iframe embed
RewriteYoutubeEmbedInvalidQuery=Rewriting old-style Youtube Flash embed (%S) to iframe embed (%S). Query was invalid and removed from URL. Please update page to use iframe instead of embed/object, if possible.
# LOCALIZATION NOTE: Do not translate "ServiceWorker". %1$S is the ServiceWorker scope URL. %2$S is an error string.
PushMessageDecryptionFailure=The ServiceWorker for scope %1$S encountered an error decrypting a push message: %2$S. For help with encryption, please see https://developer.mozilla.org/en-US/docs/Web/API/Push_API/Using_the_Push_API#Encryption
# LOCALIZATION NOTE: %1$S is the type of a DOM event. 'passive' is a literal parameter from the DOM spec.
PreventDefaultFromPassiveListenerWarning=Ignoring preventDefault() call on event of type %1$S from a listener registered as passive.