Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(316)

Unified Diff: third_party/WebKit/Source/core/events/EventTarget.cpp

Issue 2863183003: DevTools: report adding mutation event listener as a violations. (Closed)
Patch Set: same Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/events/EventTarget.cpp
diff --git a/third_party/WebKit/Source/core/events/EventTarget.cpp b/third_party/WebKit/Source/core/events/EventTarget.cpp
index c3d395b70091abac31014faee6c00a895e1481b3..ebf6e7d513d2acd7e3a3a6b2d01caff95ae10caa 100644
--- a/third_party/WebKit/Source/core/events/EventTarget.cpp
+++ b/third_party/WebKit/Source/core/events/EventTarget.cpp
@@ -336,6 +336,16 @@ void EventTarget::AddedEventListener(
UseCounter::Count(executing_window->document(),
UseCounter::kSlotChangeEventAddListener);
}
+ } else if (EventUtil::IsDOMMutationEventType(event_type)) {
+ if (ExecutionContext* context = GetExecutionContext()) {
+ String message_text = String::Format(
+ "Added synchronous DOM mutation listener to a '%s' event. "
+ "Consider using MutationObserver to make the page more responsive.",
+ event_type.GetString().Utf8().data());
+ PerformanceMonitor::ReportGenericViolation(
+ context, PerformanceMonitor::kDiscouragedAPIUse, message_text, 0,
+ nullptr);
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698