Changeset 96323 in webkit
- Timestamp:
- Sep 29, 2011 5:59:17 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r96319 r96323 1 2011-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 1 20 2011-09-27 Pavel Feldman <pfeldman@google.com> 2 21 -
trunk/LayoutTests/http/tests/inspector/search/search-in-resource-expected.txt
r96223 r96323 9 9 lineNumber: 10, line: ' // SEARCHTestUniqueString();' 10 10 11 http://127.0.0.1:8000/inspector/search/resources/search.css12 Search matches:13 lineNumber: 0, line: 'div.searchTestUniqueString {'14 lineNumber: 4, line: 'div.searchTestUniqueString:hover {'15 lineNumber: 5, line: ' /* another searchTestUniqueString occurence */'16 11 17 http://127.0.0.1:8000/inspector/search/resources/search.html18 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 2 2 <head> 3 3 <script src="../inspector-test.js"></script> 4 <script src="../resource-tree/resource-tree-test.js"></script>5 4 <script src="search-test.js"></script> 6 5 <script> … … 9 8 // This file should not match search query. 10 9 var text = "searchTest" + "UniqueString"; 11 InspectorTest.runAfterResourcesAre Finished(["search.js", "search.css", "search.html"], step2);10 InspectorTest.runAfterResourcesAreCreated(["search.js"], step2); 12 11 13 12 function step2() … … 15 14 var resource = WebInspector.resourceForURL("http://127.0.0.1:8000/inspector/search/resources/search.js"); 16 15 InspectorTest.addResult(resource.url); 17 PageAgent.searchInResource(resource.frameId, resource.url,text, step3);16 resource.searchInContent(text, step3); 18 17 } 19 18 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) 37 20 { 38 21 InspectorTest.dumpSearchMatches(searchMatches); -
trunk/LayoutTests/http/tests/inspector/search/search-in-resources.html
r96223 r96323 2 2 <head> 3 3 <script src="../inspector-test.js"></script> 4 <script src="../resource-tree/resource-tree-test.js"></script>5 4 <script src="search-test.js"></script> 6 5 <script> -
trunk/LayoutTests/http/tests/inspector/search/search-test.js
r96223 r96323 17 17 }; 18 18 19 InspectorTest.runAfterResourcesAreCreated = function(resourceURLs, callback) 20 { 21 InspectorTest._runAfterResourcesAreCreated(resourceURLs.keySet(), callback); 22 } 23 24 InspectorTest._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 19 65 }; -
trunk/Source/WebCore/ChangeLog
r96322 r96323 1 2011-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 1 17 2011-09-29 Hans Wennborg <hans@chromium.org> 2 18 -
trunk/Source/WebCore/inspector/InspectorPageAgent.cpp
r96223 r96323 485 485 } 486 486 487 void InspectorPageAgent::searchInResource(ErrorString*, const String& frameId, const String& url, const String& query, RefPtr<InspectorArray>* object)488 { 489 RefPtr<InspectorArray> result= InspectorArray::create();487 void InspectorPageAgent::searchInResource(ErrorString*, const String& frameId, const String& url, const String& query, RefPtr<InspectorArray>* results) 488 { 489 *results = InspectorArray::create(); 490 490 491 491 Frame* frame = frameForId(frameId); … … 494 494 FrameLoader* frameLoader = frame ? frame->loader() : 0; 495 495 DocumentLoader* loader = frameLoader ? frameLoader->documentLoader() : 0; 496 if (!loader) { 497 *object = result; 496 if (!loader) 498 497 return; 499 }500 498 501 499 String content; … … 509 507 } 510 508 511 if (!success) { 512 *object = result; 509 if (!success) 513 510 return; 514 } 515 516 result = ContentSearchUtils::searchInTextByLines(query, content); 517 *object = result; 511 512 *results = ContentSearchUtils::searchInTextByLines(query, content); 518 513 } 519 514 … … 528 523 } 529 524 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();525 void InspectorPageAgent::searchInResources(ErrorString*, const String& text, const bool* const optionalCaseSensitive, const bool* const optionalIsRegex, RefPtr<InspectorArray>* results) 526 { 527 RefPtr<InspectorArray> searchResults = InspectorArray::create(); 533 528 534 529 bool isRegex = optionalIsRegex ? *optionalIsRegex : false; … … 544 539 int matchesCount = ContentSearchUtils::countRegularExpressionMatches(regex, content); 545 540 if (matchesCount) 546 result->pushValue(buildObjectForSearchResult(frameId(frame), cachedResource->url(), matchesCount));541 searchResults->pushValue(buildObjectForSearchResult(frameId(frame), cachedResource->url(), matchesCount)); 547 542 } 548 543 } … … 550 545 int matchesCount = ContentSearchUtils::countRegularExpressionMatches(regex, content); 551 546 if (matchesCount) 552 result->pushValue(buildObjectForSearchResult(frameId(frame), frame->document()->url(), matchesCount));547 searchResults->pushValue(buildObjectForSearchResult(frameId(frame), frame->document()->url(), matchesCount)); 553 548 } 554 549 } 555 550 556 * object = result;551 *results = searchResults; 557 552 } 558 553 -
trunk/Source/WebCore/inspector/front-end/Resource.js
r96223 r96323 870 870 searchInContent: function(query, callback) 871 871 { 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); 873 878 }, 874 879
Note: See TracChangeset
for help on using the changeset viewer.