Changeset 241110 in webkit
- Timestamp:
- Feb 6, 2019 4:31:56 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r241105 r241110 1 2019-02-06 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: DOM: don't send the entire function string with each event listener 4 https://bugs.webkit.org/show_bug.cgi?id=194293 5 <rdar://problem/47822809> 6 7 Reviewed by Joseph Pecoraro. 8 9 * inspector/dom/getEventListenersForNode.html: 10 * inspector/dom/getEventListenersForNode-expected.txt: 11 1 12 2019-02-06 Andy Estes <aestes@apple.com> 2 13 -
trunk/LayoutTests/inspector/dom/getEventListenersForNode-expected.txt
r213873 r241110 4 4 == Running test suite: DOM.getEventListenersForNode 5 5 -- Running test case: DOM.getEventListenersForNode.Basic 6 Event: alpha 6 Event: A 7 Node: body 8 Capture: true 9 Attribute: false 10 Handler Name: bodyA 11 PASS: The Event Listener has a source location. 12 13 Event: B 7 14 Node: body 8 15 Capture: true 9 16 Attribute: false 10 17 PASS: The Event Listener has a source location. 11 PASS: The Event Listener has a function.12 18 13 Event: beta19 Event: E 14 20 Node: div#x 15 21 Capture: false 16 22 Attribute: false 17 Once: true 23 Handler Name: ObjectEventHandler 18 24 PASS: The Event Listener has a source location. 19 PASS: The Event Listener has a function.20 25 21 Event: alpha 26 Event: D 27 Node: div#x 28 Capture: false 29 Attribute: false 30 Handler Name: handleEvent 31 PASS: The Event Listener has a source location. 32 33 Event: C 22 34 Node: div#x 23 35 Capture: false 24 36 Attribute: false 25 37 PASS: The Event Listener has a source location. 26 PASS: The Event Listener has a function.27 38 28 Event: alpha 39 Event: B 40 Node: div#x 41 Capture: false 42 Attribute: false 43 Handler Name: xB 44 Once: true 45 PASS: The Event Listener has a source location. 46 47 Event: A 48 Node: div#x 49 Capture: false 50 Attribute: false 51 Handler Name: xA 52 PASS: The Event Listener has a source location. 53 54 Event: click 55 Node: div#x 56 Capture: false 57 Attribute: true 58 Handler Name: onclick 59 PASS: The Event Listener has a source location. 60 61 Event: B 29 62 Node: #document 30 63 Capture: false … … 32 65 Passive: true 33 66 PASS: The Event Listener has a source location. 34 PASS: The Event Listener has a function. 67 68 Event: A 69 Node: #document 70 Capture: false 71 Attribute: false 72 Handler Name: documentA 73 Passive: true 74 PASS: The Event Listener has a source location. 35 75 36 76 -
trunk/LayoutTests/inspector/dom/getEventListenersForNode.html
r236766 r241110 28 28 InspectorTest.log(`Attribute: ${eventListener.isAttribute}`); 29 29 30 if (eventListener.handlerName) 31 InspectorTest.log(`Handler Name: ${eventListener.handlerName}`); 30 32 if (eventListener.passive) 31 33 InspectorTest.log(`Passive: ${eventListener.passive}`); … … 34 36 35 37 InspectorTest.expectThat(eventListener.location, "The Event Listener has a source location."); 36 InspectorTest.expectThat(eventListener.handlerBody, "The Event Listener has a function.");37 38 38 39 InspectorTest.log(""); … … 63 64 <p>Testing DOMAgent.getEventListenersForNode.</p> 64 65 65 <div id="x" ></div>66 <div id="x" onclick="(function xClick(event) { })()"></div> 66 67 <script> 68 class ObjectEventHandler { 69 handleEvent(event) { } 70 } 71 67 72 let element = document.getElementById("x"); 68 element.addEventListener("alpha", (event) => {}); 69 element.addEventListener("beta", (event) => {}, {once: true}); 73 element.addEventListener("A", function xA(event) { }); 74 element.addEventListener("B", function xB(event) { }, {once: true}); 75 element.addEventListener("C", (event) => { }); 76 element.addEventListener("D", { handleEvent(event) { } }); 77 element.addEventListener("E", new ObjectEventHandler); 70 78 71 document.body.addEventListener("alpha", (event) => {}, true); 79 document.body.addEventListener("A", function bodyA(event) { }, true); 80 document.body.addEventListener("B", (event) => {}, true); 72 81 73 document.addEventListener("alpha", (event) => {}, {passive: true}); 82 document.addEventListener("A", function documentA(event) { }, {passive: true}); 83 document.addEventListener("B", (event) => {}, {passive: true}); 74 84 </script> 75 85 </body> -
trunk/Source/JavaScriptCore/ChangeLog
r241104 r241110 1 2019-02-06 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: DOM: don't send the entire function string with each event listener 4 https://bugs.webkit.org/show_bug.cgi?id=194293 5 <rdar://problem/47822809> 6 7 Reviewed by Joseph Pecoraro. 8 9 * inspector/protocol/DOM.json: 10 11 * runtime/JSFunction.h: 12 Export `calculatedDisplayName`. 13 1 14 2019-02-06 Yusuke Suzuki <ysuzuki@apple.com> 2 15 -
trunk/Source/JavaScriptCore/inspector/protocol/DOM.json
r239183 r241110 80 80 { "name": "isAttribute", "type": "boolean", "description": "<code>EventListener</code>'s isAttribute." }, 81 81 { "name": "nodeId", "$ref": "NodeId", "description": "Target <code>DOMNode</code> id." }, 82 { "name": "handlerBody", "type": "string", "description": "Event handler function body." },83 82 { "name": "location", "$ref": "Debugger.Location", "optional": true, "description": "Handler code location." }, 84 { "name": " sourceName", "type": "string", "optional": true, "description": "Source script URL." },85 { "name": "handler ", "$ref": "Runtime.RemoteObject", "optional": true, "description": "Event handler function value." },83 { "name": "handlerName", "type": "string", "optional": true, "description": "Event handler function name." }, 84 { "name": "handlerObject", "$ref": "Runtime.RemoteObject", "optional": true, "description": "Event handler function value." }, 86 85 { "name": "passive", "type": "boolean", "optional": true, "description": "<code>EventListener</code>'s passive." }, 87 86 { "name": "once", "type": "boolean", "optional": true, "description": "<code>EventListener</code>'s once." }, -
trunk/Source/JavaScriptCore/runtime/JSFunction.h
r240965 r241110 89 89 JS_EXPORT_PRIVATE String name(VM&); 90 90 JS_EXPORT_PRIVATE String displayName(VM&); 91 const String calculatedDisplayName(VM&);91 JS_EXPORT_PRIVATE const String calculatedDisplayName(VM&); 92 92 93 93 ExecutableBase* executable() const { return m_executable.get(); } -
trunk/Source/WebCore/ChangeLog
r241105 r241110 1 2019-02-06 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: DOM: don't send the entire function string with each event listener 4 https://bugs.webkit.org/show_bug.cgi?id=194293 5 <rdar://problem/47822809> 6 7 Reviewed by Joseph Pecoraro. 8 9 Test: inspector/dom/getEventListenersForNode.html 10 11 * inspector/agents/InspectorDOMAgent.cpp: 12 (WebCore::InspectorDOMAgent::buildObjectForEventListener): 13 1 14 2019-02-06 Andy Estes <aestes@apple.com> 2 15 -
trunk/Source/WebCore/inspector/agents/InspectorDOMAgent.cpp
r239183 r241110 1664 1664 Ref<EventListener> eventListener = registeredEventListener.callback(); 1665 1665 1666 JSC::ExecState* state = nullptr; 1667 JSC::JSObject* handler = nullptr; 1668 String body; 1666 JSC::ExecState* exec = nullptr; 1667 JSC::JSObject* handlerObject = nullptr; 1668 JSC::JSFunction* handlerFunction = nullptr; 1669 String handlerName; 1669 1670 int lineNumber = 0; 1670 1671 int columnNumber = 0; 1671 1672 String scriptID; 1672 String sourceName;1673 1673 if (is<JSEventListener>(eventListener.get())) { 1674 1674 auto& scriptListener = downcast<JSEventListener>(eventListener.get()); 1675 1675 1676 JSC::JSLockHolder lock(scriptListener.isolatedWorld().vm()); 1676 state = execStateFromNode(scriptListener.isolatedWorld(), &node->document()); 1677 handler = scriptListener.jsFunction(node->document()); 1678 if (handler && state) { 1679 body = handler->toString(state)->value(state); 1680 if (auto function = JSC::jsDynamicCast<JSC::JSFunction*>(state->vm(), handler)) { 1681 if (!function->isHostOrBuiltinFunction()) { 1682 if (auto executable = function->jsExecutable()) { 1683 lineNumber = executable->firstLine() - 1; 1684 columnNumber = executable->startColumn() - 1; 1685 scriptID = executable->sourceID() == JSC::SourceProvider::nullID ? emptyString() : String::number(executable->sourceID()); 1686 sourceName = executable->sourceURL(); 1687 } 1677 1678 exec = execStateFromNode(scriptListener.isolatedWorld(), &node->document()); 1679 handlerObject = scriptListener.jsFunction(node->document()); 1680 if (handlerObject && exec) { 1681 handlerFunction = JSC::jsDynamicCast<JSC::JSFunction*>(exec->vm(), handlerObject); 1682 1683 if (!handlerFunction) { 1684 auto scope = DECLARE_CATCH_SCOPE(exec->vm()); 1685 1686 // If the handler is not actually a function, see if it implements the EventListener interface and use that. 1687 auto handleEventValue = handlerObject->get(exec, JSC::Identifier::fromString(exec, "handleEvent")); 1688 1689 if (UNLIKELY(scope.exception())) 1690 scope.clearException(); 1691 1692 if (handleEventValue) 1693 handlerFunction = JSC::jsDynamicCast<JSC::JSFunction*>(exec->vm(), handleEventValue); 1694 } 1695 1696 if (handlerFunction && !handlerFunction->isHostOrBuiltinFunction()) { 1697 // If the listener implements the EventListener interface, use the class name instead of 1698 // "handleEvent", unless it is a plain object. 1699 if (handlerFunction != handlerObject) 1700 handlerName = JSC::JSObject::calculatedClassName(handlerObject); 1701 if (handlerName.isEmpty() || handlerName == "Object"_s) 1702 handlerName = handlerFunction->calculatedDisplayName(exec->vm()); 1703 1704 if (auto executable = handlerFunction->jsExecutable()) { 1705 lineNumber = executable->firstLine() - 1; 1706 columnNumber = executable->startColumn() - 1; 1707 scriptID = executable->sourceID() == JSC::SourceProvider::nullID ? emptyString() : String::number(executable->sourceID()); 1688 1708 } 1689 1709 } … … 1697 1717 .setIsAttribute(eventListener->isAttribute()) 1698 1718 .setNodeId(pushNodePathToFrontend(node)) 1699 .setHandlerBody(body)1700 1719 .release(); 1701 if (objectGroupId && handler && state) {1702 InjectedScript injectedScript = m_injectedScriptManager.injectedScriptFor( state);1720 if (objectGroupId && handlerObject && exec) { 1721 InjectedScript injectedScript = m_injectedScriptManager.injectedScriptFor(exec); 1703 1722 if (!injectedScript.hasNoValue()) 1704 value->setHandler (injectedScript.wrapObject(handler, *objectGroupId));1723 value->setHandlerObject(injectedScript.wrapObject(handlerObject, *objectGroupId)); 1705 1724 } 1706 1725 if (!scriptID.isNull()) { … … 1711 1730 location->setColumnNumber(columnNumber); 1712 1731 value->setLocation(WTFMove(location)); 1713 if (!sourceName.isEmpty())1714 value->setSourceName(sourceName);1715 }1732 } 1733 if (!handlerName.isEmpty()) 1734 value->setHandlerName(handlerName); 1716 1735 if (registeredEventListener.isPassive()) 1717 1736 value->setPassive(true); -
trunk/Source/WebInspectorUI/ChangeLog
r241039 r241110 1 2019-02-06 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: DOM: don't send the entire function string with each event listener 4 https://bugs.webkit.org/show_bug.cgi?id=194293 5 <rdar://problem/47822809> 6 7 Reviewed by Joseph Pecoraro. 8 9 * UserInterface/Views/EventListenerSectionGroup.js: 10 (WI.EventListenerSectionGroup.prototype._functionTextOrLink): 11 1 12 2019-02-06 Joseph Pecoraro <pecoraro@apple.com> 2 13 -
trunk/Source/WebInspectorUI/UserInterface/Views/EventListenerSectionGroup.js
r236766 r241110 81 81 _functionTextOrLink() 82 82 { 83 var match = this._eventListener.handlerBody.match(/function ([^\(]+?)\(/); 84 if (match) { 85 var anonymous = false; 86 var functionName = match[1]; 87 } else { 88 var anonymous = true; 89 var functionName = WI.UIString("(anonymous function)"); 83 let anonymous = false; 84 let functionName = this._eventListener.handlerName; 85 86 // COMPATIBILITY (iOS 12.2): DOM.EventListener.handlerBody was replaced by DOM.EventListener.handlerName. 87 if (!functionName && this._eventListener.handlerBody) { 88 let match = this._eventListener.handlerBody.match(/function ([^\(]+?)\(/); 89 if (match) 90 functionName = match[1]; 91 } 92 93 if (!functionName) { 94 anonymous = true; 95 functionName = WI.UIString("(anonymous function)"); 90 96 } 91 97
Note: See TracChangeset
for help on using the changeset viewer.