Changeset 96323 in webkit


Ignore:
Timestamp:
Sep 29, 2011 5:59:17 AM (13 years ago)
Author:
vsevik@chromium.org
Message:

Web Inspector: Make search-in-resource test simpler.
https://bugs.webkit.org/show_bug.cgi?id=69025

Source/WebCore:

Changed search-in-resource test.
Removed error parameter from content provider's searchInContent callback.

Reviewed by Pavel Feldman.

  • inspector/InspectorPageAgent.cpp:

(WebCore::InspectorPageAgent::searchInResource):
(WebCore::InspectorPageAgent::searchInResources):

  • inspector/front-end/Resource.js:

(WebInspector.Resource.prototype.searchInContent):

LayoutTests:

Reviewed by Pavel Feldman.

  • http/tests/inspector/search/search-in-resource-expected.txt:
  • http/tests/inspector/search/search-in-resource.html:
  • http/tests/inspector/search/search-in-resources.html:
  • http/tests/inspector/search/search-test.js:

(initialize_SearchTest.InspectorTest.runAfterResourcesAreCreated):
(initialize_SearchTest.InspectorTest._runAfterResourcesAreCreated):
(initialize_SearchTest.InspectorTest._runAfterResourcesAreCreated.maybeCallback):
(initialize_SearchTest.InspectorTest._runAfterResourcesAreCreated.addSniffer):
(initialize_SearchTest.InspectorTest._runAfterResourcesAreCreated.onResourceBind):
(initialize_SearchTest.InspectorTest._runAfterResourcesAreCreated.visit):
(initialize_SearchTest):

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r96319 r96323  
     12011-09-29  Vsevolod Vlasov  <vsevik@chromium.org>
     2
     3        Web Inspector: Make search-in-resource test simpler.
     4        https://bugs.webkit.org/show_bug.cgi?id=69025
     5
     6        Reviewed by Pavel Feldman.
     7
     8        * http/tests/inspector/search/search-in-resource-expected.txt:
     9        * http/tests/inspector/search/search-in-resource.html:
     10        * http/tests/inspector/search/search-in-resources.html:
     11        * http/tests/inspector/search/search-test.js:
     12        (initialize_SearchTest.InspectorTest.runAfterResourcesAreCreated):
     13        (initialize_SearchTest.InspectorTest._runAfterResourcesAreCreated):
     14        (initialize_SearchTest.InspectorTest._runAfterResourcesAreCreated.maybeCallback):
     15        (initialize_SearchTest.InspectorTest._runAfterResourcesAreCreated.addSniffer):
     16        (initialize_SearchTest.InspectorTest._runAfterResourcesAreCreated.onResourceBind):
     17        (initialize_SearchTest.InspectorTest._runAfterResourcesAreCreated.visit):
     18        (initialize_SearchTest):
     19
    1202011-09-27  Pavel Feldman  <pfeldman@google.com>
    221
  • trunk/LayoutTests/http/tests/inspector/search/search-in-resource-expected.txt

    r96223 r96323  
    99lineNumber: 10, line: '    // SEARCHTestUniqueString();'
    1010
    11 http://127.0.0.1:8000/inspector/search/resources/search.css
    12 Search matches:
    13 lineNumber: 0, line: 'div.searchTestUniqueString {'
    14 lineNumber: 4, line: 'div.searchTestUniqueString:hover {'
    15 lineNumber: 5, line: '    /* another searchTestUniqueString occurence */'
    1611
    17 http://127.0.0.1:8000/inspector/search/resources/search.html
    18 Search matches:
    19 lineNumber: 5, line: '<div>searchTestUniqueString</div>'
    20 lineNumber: 7, line: '<!-- searchTestUniqueString -->'
    21 lineNumber: 9, line: '<div id="searchTestUniqueString">div text</div>'
    22 
    23 
  • trunk/LayoutTests/http/tests/inspector/search/search-in-resource.html

    r96223 r96323  
    22<head>
    33<script src="../inspector-test.js"></script>
    4 <script src="../resource-tree/resource-tree-test.js"></script>
    54<script src="search-test.js"></script>
    65<script>
     
    98    // This file should not match search query.
    109    var text = "searchTest" + "UniqueString";
    11     InspectorTest.runAfterResourcesAreFinished(["search.js", "search.css", "search.html"], step2);
     10    InspectorTest.runAfterResourcesAreCreated(["search.js"], step2);
    1211
    1312    function step2()
     
    1514        var resource = WebInspector.resourceForURL("http://127.0.0.1:8000/inspector/search/resources/search.js");
    1615        InspectorTest.addResult(resource.url);
    17         PageAgent.searchInResource(resource.frameId, resource.url, text, step3);
     16        resource.searchInContent(text, step3);
    1817    }
    1918
    20     function step3(error, searchMatches)
    21     {
    22         InspectorTest.dumpSearchMatches(searchMatches);
    23         var resource = WebInspector.resourceForURL("http://127.0.0.1:8000/inspector/search/resources/search.css");
    24         InspectorTest.addResult(resource.url);
    25         PageAgent.searchInResource(resource.frameId, resource.url, text, step4);
    26     }
    27 
    28     function step4(error, searchMatches)
    29     {
    30         InspectorTest.dumpSearchMatches(searchMatches);
    31         var resource = WebInspector.resourceForURL("http://127.0.0.1:8000/inspector/search/resources/search.html");
    32         InspectorTest.addResult(resource.url);
    33         PageAgent.searchInResource(resource.frameId, resource.url, text, step5);
    34     }
    35 
    36     function step5(error, searchMatches)
     19    function step3(searchMatches)
    3720    {
    3821        InspectorTest.dumpSearchMatches(searchMatches);
  • trunk/LayoutTests/http/tests/inspector/search/search-in-resources.html

    r96223 r96323  
    22<head>
    33<script src="../inspector-test.js"></script>
    4 <script src="../resource-tree/resource-tree-test.js"></script>
    54<script src="search-test.js"></script>
    65<script>
  • trunk/LayoutTests/http/tests/inspector/search/search-test.js

    r96223 r96323  
    1717};
    1818
     19InspectorTest.runAfterResourcesAreCreated = function(resourceURLs, callback)
     20{
     21    InspectorTest._runAfterResourcesAreCreated(resourceURLs.keySet(), callback);
     22}
     23
     24InspectorTest._runAfterResourcesAreCreated = function(resourceURLs, callback)
     25{
     26    function checkResource(resource)
     27    {
     28        for (var url in resourceURLs) {
     29            if (resource.url.indexOf(url) !== -1)
     30                delete resourceURLs[url];
     31        }
     32    }
     33
     34    function maybeCallback()
     35    {
     36        if (!Object.keys(resourceURLs).length) {
     37            callback();
     38            return true;
     39        }
     40    }
     41
     42    function addSniffer(resource)
     43    {
     44        InspectorTest.addSniffer(WebInspector.ResourceTreeModel.prototype, "_bindResourceURL", onResourceBind.bind(this));
     45    }
     46
     47    function onResourceBind(resource)
     48    {
     49        checkResource(resource);
     50        if (!maybeCallback())
     51            addSniffer();
     52    }
     53
     54    function visit(resource)
     55    {
     56        checkResource(resource);
     57        return maybeCallback();
     58    }
     59
     60    var succeeded = WebInspector.resourceTreeModel.forAllResources(visit);
     61    if (!succeeded)
     62        addSniffer();
     63}
     64
    1965};
  • trunk/Source/WebCore/ChangeLog

    r96322 r96323  
     12011-09-29  Vsevolod Vlasov  <vsevik@chromium.org>
     2
     3        Web Inspector: Make search-in-resource test simpler.
     4        https://bugs.webkit.org/show_bug.cgi?id=69025
     5
     6        Changed search-in-resource test.
     7        Removed error parameter from content provider's searchInContent callback.
     8
     9        Reviewed by Pavel Feldman.
     10
     11        * inspector/InspectorPageAgent.cpp:
     12        (WebCore::InspectorPageAgent::searchInResource):
     13        (WebCore::InspectorPageAgent::searchInResources):
     14        * inspector/front-end/Resource.js:
     15        (WebInspector.Resource.prototype.searchInContent):
     16
    1172011-09-29  Hans Wennborg  <hans@chromium.org>
    218
  • trunk/Source/WebCore/inspector/InspectorPageAgent.cpp

    r96223 r96323  
    485485}
    486486
    487 void InspectorPageAgent::searchInResource(ErrorString*, const String& frameId, const String& url, const String& query, RefPtr<InspectorArray>* object)
    488 {
    489     RefPtr<InspectorArray> result = InspectorArray::create();
     487void InspectorPageAgent::searchInResource(ErrorString*, const String& frameId, const String& url, const String& query, RefPtr<InspectorArray>* results)
     488{
     489    *results = InspectorArray::create();
    490490
    491491    Frame* frame = frameForId(frameId);
     
    494494    FrameLoader* frameLoader = frame ? frame->loader() : 0;
    495495    DocumentLoader* loader = frameLoader ? frameLoader->documentLoader() : 0;
    496     if (!loader) {
    497         *object = result;
     496    if (!loader)
    498497        return;
    499     }
    500498
    501499    String content;
     
    509507    }
    510508
    511     if (!success) {
    512         *object = result;
     509    if (!success)
    513510        return;
    514     }
    515 
    516     result = ContentSearchUtils::searchInTextByLines(query, content);
    517     *object = result;
     511
     512    *results = ContentSearchUtils::searchInTextByLines(query, content);
    518513}
    519514
     
    528523}
    529524
    530 void InspectorPageAgent::searchInResources(ErrorString*, const String& text, const bool* const optionalCaseSensitive, const bool* const optionalIsRegex, RefPtr<InspectorArray>* object)
    531 {
    532     RefPtr<InspectorArray> result = InspectorArray::create();
     525void InspectorPageAgent::searchInResources(ErrorString*, const String& text, const bool* const optionalCaseSensitive, const bool* const optionalIsRegex, RefPtr<InspectorArray>* results)
     526{
     527    RefPtr<InspectorArray> searchResults = InspectorArray::create();
    533528
    534529    bool isRegex = optionalIsRegex ? *optionalIsRegex : false;
     
    544539                int matchesCount = ContentSearchUtils::countRegularExpressionMatches(regex, content);
    545540                if (matchesCount)
    546                     result->pushValue(buildObjectForSearchResult(frameId(frame), cachedResource->url(), matchesCount));
     541                    searchResults->pushValue(buildObjectForSearchResult(frameId(frame), cachedResource->url(), matchesCount));
    547542            }
    548543        }
     
    550545            int matchesCount = ContentSearchUtils::countRegularExpressionMatches(regex, content);
    551546            if (matchesCount)
    552                 result->pushValue(buildObjectForSearchResult(frameId(frame), frame->document()->url(), matchesCount));
     547                searchResults->pushValue(buildObjectForSearchResult(frameId(frame), frame->document()->url(), matchesCount));
    553548        }
    554549    }
    555550
    556     *object = result;
     551    *results = searchResults;
    557552}
    558553
  • trunk/Source/WebCore/inspector/front-end/Resource.js

    r96223 r96323  
    870870    searchInContent: function(query, callback)
    871871    {
    872         PageAgent.searchInResource(query, callback);
     872        function callbackWrapper(error, searchMatches)
     873        {
     874            callback(searchMatches || []);
     875        }
     876
     877        PageAgent.searchInResource(this.frameId, this.url, query, callbackWrapper);
    873878    },
    874879
Note: See TracChangeset for help on using the changeset viewer.