Changeset 239987 in webkit
- Timestamp:
- Jan 15, 2019, 8:31:05 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 5 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/inspector/audit/run-dom-expected.txt (added)
-
LayoutTests/inspector/audit/run-dom.html (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/inspector/InspectorAuditDOMObject.cpp (modified) (1 diff)
-
Source/WebCore/inspector/InspectorAuditDOMObject.h (modified) (2 diffs)
-
Source/WebCore/inspector/InspectorAuditDOMObject.idl (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r239986 r239987 1 2019-01-15 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: Audit: provide a way to determine whether a give node has event listeners 4 https://bugs.webkit.org/show_bug.cgi?id=193226 5 <rdar://problem/46800005> 6 7 Reviewed by Joseph Pecoraro. 8 9 * inspector/audit/run-dom.html: Added. 10 * inspector/audit/run-dom-expected.txt: Added. 11 1 12 2019-01-15 Devin Rousso <drousso@apple.com> 2 13 -
trunk/Source/WebCore/ChangeLog
r239986 r239987 1 2019-01-15 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: Audit: provide a way to determine whether a give node has event listeners 4 https://bugs.webkit.org/show_bug.cgi?id=193226 5 <rdar://problem/46800005> 6 7 Reviewed by Joseph Pecoraro. 8 9 Test: inspector/audit/run-dom.html 10 11 * inspector/InspectorAuditDOMObject.idl: 12 * inspector/InspectorAuditDOMObject.h: 13 * inspector/InspectorAuditDOMObject.cpp: 14 (WebCore::InspectorAuditDOMObject::hasEventListeners): Added. 15 1 16 2019-01-15 Devin Rousso <drousso@apple.com> 2 17 -
trunk/Source/WebCore/inspector/InspectorAuditDOMObject.cpp
r239976 r239987 28 28 #include "InspectorAuditDOMObject.h" 29 29 30 #include "Node.h" 31 #include <wtf/text/AtomicString.h> 32 #include <wtf/text/WTFString.h> 33 30 34 namespace WebCore { 31 35 32 36 using namespace Inspector; 33 37 34 InspectorAuditDOMObject::InspectorAuditDOMObject() 38 #define ERROR_IF_NO_ACTIVE_AUDIT() \ 39 if (!m_auditAgent.hasActiveAudit()) \ 40 return Exception { NotAllowedError, "Cannot be called outside of a Web Inspector Audit"_s }; 41 42 InspectorAuditDOMObject::InspectorAuditDOMObject(InspectorAuditAgent& auditAgent) 43 : m_auditAgent(auditAgent) 35 44 { 36 45 } 37 46 47 ExceptionOr<bool> InspectorAuditDOMObject::hasEventListeners(Node& node, const String& type) 48 { 49 ERROR_IF_NO_ACTIVE_AUDIT(); 50 51 if (EventTargetData* eventTargetData = node.eventTargetData()) { 52 Vector<AtomicString> eventTypes; 53 if (type.isNull()) 54 eventTypes = eventTargetData->eventListenerMap.eventTypes(); 55 else 56 eventTypes.append(type); 57 58 for (AtomicString& type : eventTypes) { 59 for (const RefPtr<RegisteredEventListener>& listener : node.eventListeners(type)) { 60 if (listener->callback().type() == EventListener::JSEventListenerType) 61 return true; 62 } 63 } 64 } 65 66 return false; 67 } 68 38 69 } // namespace WebCore -
trunk/Source/WebCore/inspector/InspectorAuditDOMObject.h
r239976 r239987 26 26 #pragma once 27 27 28 #include "ExceptionOr.h" 28 29 #include <JavaScriptCore/InspectorAuditAgent.h> 29 30 #include <wtf/Ref.h> … … 32 33 namespace WebCore { 33 34 35 class Node; 36 34 37 class InspectorAuditDOMObject : public RefCounted<InspectorAuditDOMObject> { 35 38 public: 36 static Ref<InspectorAuditDOMObject> create(Inspector::InspectorAuditAgent& )39 static Ref<InspectorAuditDOMObject> create(Inspector::InspectorAuditAgent& auditAgent) 37 40 { 38 return adoptRef(*new InspectorAuditDOMObject( ));41 return adoptRef(*new InspectorAuditDOMObject(auditAgent)); 39 42 } 40 43 44 ExceptionOr<bool> hasEventListeners(Node&, const String& type); 45 41 46 private: 42 explicit InspectorAuditDOMObject(); 47 explicit InspectorAuditDOMObject(Inspector::InspectorAuditAgent&); 48 49 Inspector::InspectorAuditAgent& m_auditAgent; 43 50 }; 44 51 -
trunk/Source/WebCore/inspector/InspectorAuditDOMObject.idl
r239976 r239987 29 29 NoInterfaceObject, 30 30 ] interface InspectorAuditDOMObject { 31 [MayThrowException] boolean hasEventListeners(Node node, optional DOMString type); 31 32 };
Note:
See TracChangeset
for help on using the changeset viewer.