Changeset 96491 in webkit
- Timestamp:
- Oct 3, 2011 5:56:52 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 5 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r96486 r96491 1 2011-10-03 Vsevolod Vlasov <vsevik@chromium.org> 2 3 Web Inspector: Add support for backend search in script content. 4 https://bugs.webkit.org/show_bug.cgi?id=69015 5 6 Reviewed by Pavel Feldman. 7 8 * http/tests/inspector/resource-tree/resource-tree-test.js: 9 (initialize_ResourceTreeTest): 10 * http/tests/inspector/resources-test.js: 11 (initialize_ResourceTest.InspectorTest.runAfterResourcesAreFinished): 12 (initialize_ResourceTest.InspectorTest._runAfterResourcesAreFinished): 13 (initialize_ResourceTest.InspectorTest._runAfterResourcesAreFinished.maybeCallback): 14 (initialize_ResourceTest.InspectorTest._runAfterResourcesAreFinished.addSniffer): 15 (initialize_ResourceTest.InspectorTest._runAfterResourcesAreFinished.resourceAddedToFrame): 16 (initialize_ResourceTest.InspectorTest._runAfterResourcesAreFinished.visit): 17 (initialize_ResourceTest): 18 * http/tests/inspector/search/resources/search-concatenated.html: Added. 19 * http/tests/inspector/search/search-in-concatenated-script-expected.txt: Added. 20 * http/tests/inspector/search/search-in-concatenated-script.html: Added. 21 * http/tests/inspector/search/search-in-resource.html: 22 * http/tests/inspector/search/search-in-script-expected.txt: Added. 23 * http/tests/inspector/search/search-in-script.html: Added. 24 * http/tests/inspector/search/search-test.js: 25 (initialize_SearchTest): 26 1 27 2011-10-03 Kristóf Kosztyó <kkristof@inf.u-szeged.hu> 2 28 -
trunk/LayoutTests/http/tests/inspector/resource-tree/resource-tree-test.js
r95287 r96491 87 87 } 88 88 89 InspectorTest.runAfterResourcesAreFinished = function(resourceURLs, callback)90 {91 InspectorTest._runAfterResourcesAreFinished(resourceURLs.keySet(), callback);92 }93 94 InspectorTest._runAfterResourcesAreFinished = function(resourceURLs, callback)95 {96 function visit(resource)97 {98 if (!resource.finished)99 return true;100 101 for (var url in resourceURLs) {102 if (resource.url.indexOf(url) !== -1)103 delete resourceURLs[url];104 }105 106 if (!Object.keys(resourceURLs).length) {107 callback();108 return true;109 }110 }111 112 var succeeded = WebInspector.resourceTreeModel.forAllResources(visit);113 if (!succeeded)114 setTimeout(InspectorTest._runAfterResourcesAreFinished.bind(InspectorTest, resourceURLs, callback), 0);115 }116 117 89 }; -
trunk/LayoutTests/http/tests/inspector/resources-test.js
r90010 r96491 28 28 } 29 29 30 InspectorTest.runAfterResourcesAreFinished = function(resourceURLs, callback) 31 { 32 InspectorTest._runAfterResourcesAreFinished(resourceURLs.keySet(), callback); 30 33 } 34 35 InspectorTest._runAfterResourcesAreFinished = function(resourceURLs, callback) 36 { 37 function checkResource(resource) 38 { 39 for (var url in resourceURLs) { 40 if (resource.url.indexOf(url) !== -1) 41 delete resourceURLs[url]; 42 } 43 } 44 45 function maybeCallback() 46 { 47 if (!Object.keys(resourceURLs).length) { 48 callback(); 49 return true; 50 } 51 } 52 53 function addSniffer(resource) 54 { 55 InspectorTest.addSniffer(WebInspector.ResourceTreeModel.prototype, "_addResourceToFrame", resourceAddedToFrame.bind(this)); 56 } 57 58 function resourceAddedToFrame(resource) 59 { 60 checkResource(resource); 61 if (!maybeCallback()) 62 addSniffer(); 63 } 64 65 function visit(resource) 66 { 67 checkResource(resource); 68 return maybeCallback(); 69 } 70 71 var succeeded = WebInspector.resourceTreeModel.forAllResources(visit); 72 if (!succeeded) 73 addSniffer(); 74 } 75 76 } -
trunk/LayoutTests/http/tests/inspector/search/search-in-resource.html
r96323 r96491 2 2 <head> 3 3 <script src="../inspector-test.js"></script> 4 <script src="../resources-test.js"></script> 4 5 <script src="search-test.js"></script> 5 6 <script> … … 8 9 // This file should not match search query. 9 10 var text = "searchTest" + "UniqueString"; 10 InspectorTest.runAfterResourcesAre Created(["search.js"], step2);11 InspectorTest.runAfterResourcesAreFinished(["search.js"], step2); 11 12 12 13 function step2() -
trunk/LayoutTests/http/tests/inspector/search/search-test.js
r96323 r96491 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 65 19 }; -
trunk/Source/WebCore/ChangeLog
r96487 r96491 1 2011-10-03 Vsevolod Vlasov <vsevik@chromium.org> 2 3 Web Inspector: Add support for backend search in script content. 4 https://bugs.webkit.org/show_bug.cgi?id=69015 5 6 Reviewed by Pavel Feldman. 7 8 Tests: http/tests/inspector/search/search-in-concatenated-script.html 9 http/tests/inspector/search/search-in-script.html 10 11 * inspector/Inspector.json: 12 * inspector/InspectorDebuggerAgent.cpp: 13 (WebCore::InspectorDebuggerAgent::searchInContent): 14 (WebCore::InspectorDebuggerAgent::getScriptSource): 15 * inspector/InspectorDebuggerAgent.h: 16 * inspector/front-end/ContentProviders.js: 17 (WebInspector.ScriptContentProvider.prototype.requestContent): 18 (WebInspector.ScriptContentProvider.prototype.searchInContent): 19 (WebInspector.ConcatenatedScriptsContentProvider.prototype.searchInContent.maybeCallback): 20 (WebInspector.ConcatenatedScriptsContentProvider.prototype.searchInContent.searchCallback): 21 (WebInspector.ConcatenatedScriptsContentProvider.prototype.searchInContent): 22 * inspector/front-end/Script.js: 23 (WebInspector.Script.prototype.requestSource): 24 (WebInspector.Script.prototype.searchInContent): 25 1 26 2011-10-03 Pavel Feldman <pfeldman@google.com> 2 27 -
trunk/Source/WebCore/inspector/Inspector.json
r96485 r96491 1743 1743 }, 1744 1744 { 1745 "name": "searchInContent", 1746 "parameters": [ 1747 { "name": "scriptId", "$ref": "ScriptId", "description": "Id of the script to search in." }, 1748 { "name": "query", "type": "string", "description": "String to search for." } 1749 ], 1750 "returns": [ 1751 { "name": "result", "type": "array", "items": { "$ref": "Page.SearchMatch" }, "description": "List of search matches." } 1752 ], 1753 "description": "Searches for given string in script content." 1754 }, 1755 { 1745 1756 "name": "setScriptSource", 1746 1757 "parameters": [ -
trunk/Source/WebCore/inspector/InspectorDebuggerAgent.cpp
r96227 r96491 32 32 33 33 #if ENABLE(JAVASCRIPT_DEBUGGER) && ENABLE(INSPECTOR) 34 #include "ContentSearchUtils.h" 34 35 #include "InjectedScript.h" 35 36 #include "InjectedScriptManager.h" … … 321 322 } 322 323 324 void InspectorDebuggerAgent::searchInContent(ErrorString* error, const String& scriptId, const String& query, RefPtr<InspectorArray>* results) 325 { 326 ScriptsMap::iterator it = m_scripts.find(scriptId); 327 if (it != m_scripts.end()) 328 *results = ContentSearchUtils::searchInTextByLines(query, it->second.source); 329 else 330 *error = "No script for id: " + scriptId; 331 } 332 323 333 void InspectorDebuggerAgent::setScriptSource(ErrorString* error, const String& scriptId, const String& newContent, const bool* const preview, RefPtr<InspectorArray>* newCallFrames, RefPtr<InspectorObject>* result) 324 334 { … … 333 343 } 334 344 335 void InspectorDebuggerAgent::getScriptSource(ErrorString*, const String& scriptId, String* scriptSource) 336 { 337 *scriptSource = m_scripts.get(scriptId).source; 345 void InspectorDebuggerAgent::getScriptSource(ErrorString* error, const String& scriptId, String* scriptSource) 346 { 347 ScriptsMap::iterator it = m_scripts.find(scriptId); 348 if (it != m_scripts.end()) 349 *scriptSource = it->second.source; 350 else 351 *error = "No script for id: " + scriptId; 338 352 } 339 353 -
trunk/Source/WebCore/inspector/InspectorDebuggerAgent.h
r95901 r96491 82 82 void continueToLocation(ErrorString*, PassRefPtr<InspectorObject> location); 83 83 84 void searchInContent(ErrorString*, const String& scriptId, const String& query, RefPtr<InspectorArray>*); 84 85 void setScriptSource(ErrorString*, const String& scriptId, const String& newContent, const bool* const preview, RefPtr<InspectorArray>* newCallFrames, RefPtr<InspectorObject>* result); 85 86 void getScriptSource(ErrorString*, const String& scriptId, String* scriptSource); -
trunk/Source/WebCore/inspector/front-end/ContentProviders.js
r96313 r96491 47 47 } 48 48 this._script.requestSource(didRequestSource.bind(this)); 49 }, 50 51 searchInContent: function(query, callback) 52 { 53 this._script.searchInContent(query, callback); 49 54 } 50 55 } … … 76 81 for (var i = 0; i < scripts.length; ++i) 77 82 scripts[i].requestSource(didRequestSource.bind(this)); 83 }, 84 85 searchInContent: function(query, callback) 86 { 87 var results = {}; 88 var scriptsLeft = this._scripts.length; 89 90 function maybeCallback() 91 { 92 if (!scriptsLeft) { 93 var result = []; 94 for (var i = 0; i < this._scripts.length; ++i) 95 result = result.concat(results[this._scripts[i].scriptId]); 96 callback(result); 97 } 98 } 99 100 function searchCallback(script, searchMatches) 101 { 102 results[script.scriptId] = []; 103 for (var i = 0; i < searchMatches.length; ++i) { 104 var searchMatch = {}; 105 searchMatch.lineNumber = searchMatches[i].lineNumber + script.lineOffset; 106 searchMatch.lineContent = searchMatches[i].lineContent; 107 results[script.scriptId].push(searchMatch); 108 } 109 scriptsLeft--; 110 maybeCallback.call(this); 111 } 112 113 maybeCallback(); 114 for (var i = 0; i < this._scripts.length; ++i) 115 this._scripts[i].searchInContent(query, searchCallback.bind(this, this._scripts[i])); 78 116 }, 79 117 -
trunk/Source/WebCore/inspector/front-end/Script.js
r93701 r96491 50 50 function didGetScriptSource(error, source) 51 51 { 52 if (error) 53 console.error(error); 52 54 this._source = source; 53 55 callback(this._source); … … 56 58 }, 57 59 60 searchInContent: function(query, callback) 61 { 62 function innerCallback(error, searchMatches) 63 { 64 if (error) 65 console.error(error); 66 callback(searchMatches); 67 } 68 69 DebuggerAgent.searchInContent(this.scriptId, query, innerCallback.bind(this)); 70 }, 71 58 72 editSource: function(newSource, callback) 59 73 {
Note: See TracChangeset
for help on using the changeset viewer.