Web Inspector: DOM.performSearch should accept a list of context nodes
authorachicu@adobe.com <achicu@adobe.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Nov 2013 22:08:13 +0000 (22:08 +0000)
committerachicu@adobe.com <achicu@adobe.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Nov 2013 22:08:13 +0000 (22:08 +0000)
commit326c4086cbcb393a8be4283c00d1fa30f601b144
treecdfe44c9ecd54ebd950efe2450ee1f9d646a0fde
parent38ca2fbe26eadad9c87dc7685aad85694e9bd5e8
Web Inspector: DOM.performSearch should accept a list of context nodes
https://bugs.webkit.org/show_bug.cgi?id=124390

Reviewed by Timothy Hatcher.

Source/WebCore:

Extracted the code in InspectorDOMAgent::performSearch into its own helper class
called InspectorNodeFinder. Also added a new array parameter called "nodeIds"
that can be used to limit the search results to just partial subtrees.

Tests: inspector-protocol/dom/dom-search-crash.html
       inspector-protocol/dom/dom-search-with-context.html
       inspector-protocol/dom/dom-search.html

* CMakeLists.txt:
* GNUmakefile.list.am:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* WebCore.xcodeproj/project.pbxproj:
* inspector/protocol/DOM.json:
* inspector/InspectorAllInOne.cpp:
* inspector/InspectorDOMAgent.cpp:
(WebCore::InspectorDOMAgent::performSearch):
* inspector/InspectorDOMAgent.h:
* inspector/InspectorNodeFinder.cpp: Added.
(WebCore::stripCharacters):
(WebCore::InspectorNodeFinder::InspectorNodeFinder):
(WebCore::InspectorNodeFinder::performSearch):
(WebCore::InspectorNodeFinder::searchUsingDOMTreeTraversal):
(WebCore::InspectorNodeFinder::matchesAttribute):
(WebCore::InspectorNodeFinder::matchesElement):
(WebCore::InspectorNodeFinder::searchUsingXPath):
(WebCore::InspectorNodeFinder::searchUsingCSSSelectors):
* inspector/InspectorNodeFinder.h: Added.
(WebCore::InspectorNodeFinder::results):

LayoutTests:

Added new inspector-protocol tests to check for the DOM.performSearch implementation.
Also, ported an existing test from the old "inspector" format.

* http/tests/inspector-protocol/resources/InspectorDOMListener.js: Added boilerplate code that
can be used to track node ids and class names.
(createDOMListener.createNodeAttributesMap):
(createDOMListener.collectNode):
(createDOMListener.onSetChildNodes):
(createDOMListener.onChildNodeRemoved):
(createDOMListener.onChildNodeInserted):
(createDOMListener.return.getNodeById):
(createDOMListener.return.getNodeIdentifier):
* http/tests/inspector-protocol/resources/InspectorTest.js:
(InspectorFrontendAPI.dispatchMessageAsync): Added a way to catch all the messages received in the inspector.
It is useful for debugging the test file.
(InspectorTest.addEventListener): Helper method to register multiple handlers for the same event.
* inspector-protocol/dom/dom-search-crash-expected.txt: Added.
* inspector-protocol/dom/dom-search-crash.html: Added.
* inspector-protocol/dom/dom-search-expected.txt: Added.
* inspector-protocol/dom/dom-search-with-context-expected.txt: Added.
* inspector-protocol/dom/dom-search-with-context.html: Added.
* inspector-protocol/dom/dom-search.html: Added.
* inspector-protocol/dom/resources/dom-search-crash-iframe.html: Cloned from inspector/dom/resources/dom-search-crash-iframe.html
* inspector-protocol/dom/resources/dom-search-iframe.html: Added.
* inspector-protocol/dom/resources/dom-search-queries.js: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@159357 268f45cc-cd09-0410-ab3c-d52691b4dbfc
24 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/inspector-protocol/resources/InspectorDOMListener.js [new file with mode: 0644]
LayoutTests/http/tests/inspector-protocol/resources/InspectorTest.js
LayoutTests/inspector-protocol/dom/dom-search-crash-expected.txt [new file with mode: 0644]
LayoutTests/inspector-protocol/dom/dom-search-crash.html [new file with mode: 0644]
LayoutTests/inspector-protocol/dom/dom-search-expected.txt [new file with mode: 0644]
LayoutTests/inspector-protocol/dom/dom-search-with-context-expected.txt [new file with mode: 0644]
LayoutTests/inspector-protocol/dom/dom-search-with-context.html [new file with mode: 0644]
LayoutTests/inspector-protocol/dom/dom-search.html [new file with mode: 0644]
LayoutTests/inspector-protocol/dom/resources/dom-search-crash-iframe.html [new file with mode: 0644]
LayoutTests/inspector-protocol/dom/resources/dom-search-iframe.html [new file with mode: 0644]
LayoutTests/inspector-protocol/dom/resources/dom-search-queries.js [new file with mode: 0644]
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/inspector/InspectorAllInOne.cpp
Source/WebCore/inspector/InspectorDOMAgent.cpp
Source/WebCore/inspector/InspectorDOMAgent.h
Source/WebCore/inspector/InspectorNodeFinder.cpp [new file with mode: 0644]
Source/WebCore/inspector/InspectorNodeFinder.h [new file with mode: 0644]
Source/WebCore/inspector/protocol/DOM.json