Changeset 76105 in webkit
- Timestamp:
- Jan 19, 2011 1:00:58 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 1 deleted
- 32 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r76102 r76105 1 2011-01-18 Pavel Feldman <pfeldman@chromium.org> 2 3 Reviewed by Yury Semikhatsky. 4 5 Web Inspector: make InjectedScriptAccess API a part of Web Inspector protocol. 6 https://bugs.webkit.org/show_bug.cgi?id=52652 7 8 Calls served by the InjectedScript should be first class protocol 9 citizens, not dispatched via single protocol message. 10 11 * http/tests/inspector/extensions-test.js: 12 (initialize_ExtensionsTest.InspectorTest.runExtensionTests): 13 * http/tests/inspector/inspector-test2.js: 14 (initialize_InspectorTest.InspectorTest.evaluateInPage): 15 * http/tests/inspector/resource-har-conversion.html: 16 * inspector/console-command-clear.html: 17 * inspector/console-dir-global.html: 18 1 19 2011-01-18 Eric Seidel <eric@webkit.org> 2 20 -
trunk/LayoutTests/http/tests/inspector/extensions-test.js
r74234 r76105 35 35 InspectorTest.runExtensionTests = function() 36 36 { 37 In jectedScriptAccess.getDefault().evaluate("location.href", "console", function(result) {37 InspectorBackend.evaluate("location.href", "console", function(result) { 38 38 var pageURL = result.description; 39 39 var extensionURL = (/^https?:/.test(pageURL) ? -
trunk/LayoutTests/http/tests/inspector/inspector-test2.js
r74634 r76105 25 25 InspectorTest.evaluateInPage = function(code, callback) 26 26 { 27 In jectedScriptAccess.getDefault().evaluate(code, "console", callback || function() {});27 InspectorBackend.evaluate(code, "console", callback || function() {}); 28 28 } 29 29 -
trunk/LayoutTests/http/tests/inspector/resource-har-conversion.html
r75786 r76105 27 27 28 28 InspectorTest.reloadPageIfNeeded(function() { 29 In jectedScriptAccess.getDefault().evaluate("doXHR()", "console", function() {29 InspectorBackend.evaluate("doXHR()", "console", function() { 30 30 addCookieHeadersToResource(findResourceByURL(/inspector-test2\.js$/)); 31 31 var entries = (new WebInspector.HARLog()).build().entries; -
trunk/LayoutTests/inspector/console-command-clear.html
r65412 r76105 18 18 dumpConsoleMessages(); 19 19 } 20 evaluateInWebInspector("In jectedScriptAccess.getDefault().evaluate('clear()', '', function() {})", callback);20 evaluateInWebInspector("InspectorBackend.evaluate('clear()', '', function() {})", callback); 21 21 } 22 22 -
trunk/LayoutTests/inspector/console-dir-global.html
r65248 r76105 23 23 testController.waitUntilDone(); 24 24 25 In jectedScriptAccess.getDefault().evaluate("window", "console", evalCallback);25 InspectorBackend.evaluate("window", "console", evalCallback); 26 26 27 27 function evalCallback(result) -
trunk/Source/WebCore/ChangeLog
r76104 r76105 1 2011-01-18 Pavel Feldman <pfeldman@chromium.org> 2 3 Reviewed by Yury Semikhatsky. 4 5 Web Inspector: make InjectedScriptAccess API a part of Web Inspector protocol. 6 https://bugs.webkit.org/show_bug.cgi?id=52652 7 8 Calls served by the InjectedScript should be first class protocol 9 citizens, not dispatched via single protocol message. 10 11 * WebCore.gypi: 12 * WebCore.vcproj/WebCore.vcproj: 13 * inspector/CodeGeneratorInspector.pm: 14 * inspector/InjectedScript.cpp: 15 (WebCore::InjectedScript::evaluate): 16 (WebCore::InjectedScript::evaluateInCallFrame): 17 (WebCore::InjectedScript::evaluateOnSelf): 18 (WebCore::InjectedScript::getCompletions): 19 (WebCore::InjectedScript::getProperties): 20 (WebCore::InjectedScript::pushNodeToFrontend): 21 (WebCore::InjectedScript::resolveNode): 22 (WebCore::InjectedScript::getNodeProperties): 23 (WebCore::InjectedScript::getNodePrototypes): 24 (WebCore::InjectedScript::setPropertyValue): 25 (WebCore::InjectedScript::makeCall): 26 * inspector/InjectedScript.h: 27 * inspector/InjectedScriptHost.cpp: 28 (WebCore::InjectedScriptHost::evaluate): 29 (WebCore::InjectedScriptHost::evaluateInCallFrame): 30 (WebCore::InjectedScriptHost::evaluateOnSelf): 31 (WebCore::InjectedScriptHost::getCompletions): 32 (WebCore::InjectedScriptHost::getProperties): 33 (WebCore::InjectedScriptHost::pushNodeToFrontend): 34 (WebCore::InjectedScriptHost::resolveNode): 35 (WebCore::InjectedScriptHost::getNodeProperties): 36 (WebCore::InjectedScriptHost::getNodePrototypes): 37 (WebCore::InjectedScriptHost::setPropertyValue): 38 (WebCore::InjectedScriptHost::injectedScriptForObjectId): 39 (WebCore::InjectedScriptHost::injectedScriptForNodeId): 40 (WebCore::InjectedScriptHost::injectedScriptForMainWorld): 41 * inspector/InjectedScriptHost.h: 42 * inspector/InjectedScriptSource.js: 43 (.): 44 * inspector/Inspector.idl: 45 * inspector/InspectorController.cpp: 46 * inspector/InspectorController.h: 47 * inspector/InspectorValues.cpp: 48 (WebCore::InspectorObject::getNumber): 49 * inspector/InspectorValues.h: 50 * inspector/front-end/AuditRules.js: 51 (WebInspector.AuditRules.evaluateInTargetWindow): 52 * inspector/front-end/ConsoleView.js: 53 (WebInspector.ConsoleView.prototype.completions): 54 (WebInspector.ConsoleView.prototype.doEvalInWindow): 55 * inspector/front-end/ElementsTreeOutline.js: 56 (WebInspector.ElementsTreeElement.prototype._createTooltipForNode): 57 * inspector/front-end/ExtensionPanel.js: 58 (WebInspector.ExtensionWatchSidebarPane.prototype.setExpression): 59 * inspector/front-end/ExtensionServer.js: 60 (WebInspector.ExtensionServer.prototype._onEvaluateOnInspectedPage): 61 * inspector/front-end/InjectedScriptAccess.js: Removed. 62 * inspector/front-end/PropertiesSidebarPane.js: 63 (WebInspector.PropertiesSidebarPane.prototype.update.callback): 64 (WebInspector.PropertiesSidebarPane.prototype.update): 65 * inspector/front-end/RemoteObject.js: 66 (WebInspector.RemoteObject.resolveNode): 67 (WebInspector.RemoteObject.prototype.getProperties): 68 (WebInspector.RemoteObject.prototype.setPropertyValue): 69 (WebInspector.RemoteObject.prototype.pushNodeToFrontend): 70 * inspector/front-end/ScriptsPanel.js: 71 (WebInspector.ScriptsPanel.prototype.doEvalInCallFrame): 72 * inspector/front-end/WebKit.qrc: 73 * inspector/front-end/inspector.html: 74 1 75 2011-01-18 Anton Muhin <antonm@chromium.org> 2 76 -
trunk/Source/WebCore/WebCore.gypi
r76098 r76105 4650 4650 'inspector/front-end/InspectorFrontendHostStub.js', 4651 4651 'inspector/front-end/InjectedFakeWorker.js', 4652 'inspector/front-end/InjectedScriptAccess.js',4653 4652 'inspector/front-end/inspector.js', 4654 4653 'inspector/front-end/KeyboardShortcut.js', -
trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj
r76098 r76105 65470 65470 </File> 65471 65471 <File 65472 RelativePath="..\inspector\front-end\InjectedScriptAccess.js"65473 >65474 </File>65475 <File65476 65472 RelativePath="..\inspector\front-end\inspector.css" 65477 65473 > -
trunk/Source/WebCore/inspector/CodeGeneratorInspector.pm
r75792 r76105 55 55 "header" => "InspectorFileSystemAgent.h", 56 56 "domainAccessor" => "m_inspectorController->m_fileSystemAgent", 57 }; 58 $typeTransform{"InjectedScript"} = { 59 "forwardHeader" => "InjectedScriptHost.h", 60 "domainAccessor" => "m_inspectorController->m_injectedScriptHost", 57 61 }; 58 62 $typeTransform{"Inspector"} = { … … 88 92 "forward" => "InspectorObject", 89 93 "header" => "InspectorValues.h", 90 "JSONType" => "Object" 94 "JSONType" => "Object", 95 "JSType" => "object" 91 96 }; 92 97 $typeTransform{"Array"} = { … … 96 101 "forward" => "InspectorArray", 97 102 "header" => "InspectorValues.h", 98 "JSONType" => "Array" 103 "JSONType" => "Array", 104 "JSType" => "object" 99 105 }; 100 106 $typeTransform{"Value"} = { … … 104 110 "forward" => "InspectorValue", 105 111 "header" => "InspectorValues.h", 106 "JSONType" => "Value" 112 "JSONType" => "Value", 113 "JSType" => "" 107 114 }; 108 115 $typeTransform{"String"} = { … … 113 120 "forwardHeader" => "wtf/Forward.h", 114 121 "header" => "PlatformString.h", 115 "JSONType" => "String" 122 "JSONType" => "String", 123 "JSType" => "string" 116 124 }; 117 125 $typeTransform{"long"} = { … … 121 129 "forward" => "", 122 130 "header" => "", 123 "JSONType" => "Number" 131 "JSONType" => "Number", 132 "JSType" => "number" 124 133 }; 125 134 $typeTransform{"int"} = { … … 130 139 "header" => "", 131 140 "JSONType" => "Number", 141 "JSType" => "number" 132 142 }; 133 143 $typeTransform{"unsigned long"} = { … … 137 147 "forward" => "", 138 148 "header" => "", 139 "JSONType" => "Number" 149 "JSONType" => "Number", 150 "JSType" => "number" 140 151 }; 141 152 $typeTransform{"unsigned int"} = { … … 145 156 "forward" => "", 146 157 "header" => "", 147 "JSONType" => "Number" 158 "JSONType" => "Number", 159 "JSType" => "number" 148 160 }; 149 161 $typeTransform{"double"} = { … … 153 165 "forward" => "", 154 166 "header" => "", 155 "JSONType" => "Number" 167 "JSONType" => "Number", 168 "JSType" => "number" 156 169 }; 157 170 $typeTransform{"boolean"} = { … … 161 174 "forward" => "", 162 175 "header" => "", 163 "JSONType" => "Boolean" 176 "JSONType" => "Boolean", 177 "JSType" => "boolean" 164 178 }; 165 179 $typeTransform{"void"} = { … … 568 582 my $name = $function->signature->name; 569 583 my $domain = $function->signature->extendedAttributes->{"domain"}; 570 my $argumentNames = join(",", map("\"" . $_->name . "\": \"" . lc($typeTransform{$_->type}->{"JSONType"}). "\"", grep($_->direction eq "in", @{$function->parameters})));584 my $argumentNames = join(",", map("\"" . $_->name . "\": \"" . $typeTransform{$_->type}->{"JSType"} . "\"", grep($_->direction eq "in", @{$function->parameters}))); 571 585 push(@JSStubs, " this._registerDelegate('{" . 572 586 "\"seq\": 0, " . … … 626 640 } 627 641 var value = args.shift(); 628 if ( typeof value !== request.arguments[key]) {642 if (request.arguments[key] && typeof value !== request.arguments[key]) { 629 643 console.error("Protocol Error: Invalid type of argument '%s' for 'InspectorBackend.%s' call. It should be '%s' but it is '%s'.", key, request.command, request.arguments[key], typeof value); 630 644 return; -
trunk/Source/WebCore/inspector/InjectedScript.cpp
r65072 r76105 45 45 } 46 46 47 void InjectedScript:: dispatch(const String& methodName, const String& arguments, RefPtr<InspectorValue>* result, bool* hadException)47 void InjectedScript::evaluate(const String& expression, const String& objectGroup, RefPtr<InspectorValue>* result) 48 48 { 49 ASSERT(!hasNoValue());50 if (!canAccessInspectedWindow()) {51 *hadException = true;52 return;53 49 ScriptFunctionCall function(m_injectedScriptObject, "evaluate"); 50 function.appendArgument(expression); 51 function.appendArgument(objectGroup); 52 makeCall(function, result); 53 } 54 54 55 ScriptFunctionCall function(m_injectedScriptObject, "dispatch"); 56 function.appendArgument(methodName); 57 function.appendArgument(arguments); 58 *hadException = false; 59 ScriptValue resultValue = function.call(*hadException); 60 if (!*hadException) 61 *result = resultValue.toInspectorValue(m_injectedScriptObject.scriptState()); 55 void InjectedScript::evaluateInCallFrame(long callFrame, const String& expression, const String& objectGroup, RefPtr<InspectorValue>* result) 56 { 57 ScriptFunctionCall function(m_injectedScriptObject, "evaluateInCallFrame"); 58 function.appendArgument(callFrame); 59 function.appendArgument(expression); 60 function.appendArgument(objectGroup); 61 makeCall(function, result); 62 } 63 64 void InjectedScript::evaluateOnSelf(const String& functionBody, PassRefPtr<InspectorArray> argumentsArray, RefPtr<InspectorValue>* result) 65 { 66 ScriptFunctionCall function(m_injectedScriptObject, "evaluateOnSelf"); 67 function.appendArgument(functionBody); 68 function.appendArgument(argumentsArray->toJSONString()); 69 makeCall(function, result); 70 } 71 72 void InjectedScript::getCompletions(const String& expression, bool includeInspectorCommandLineAPI, long callFrameId, RefPtr<InspectorValue>* result) 73 { 74 ScriptFunctionCall function(m_injectedScriptObject, "getCompletions"); 75 function.appendArgument(expression); 76 function.appendArgument(includeInspectorCommandLineAPI); 77 function.appendArgument(callFrameId); 78 makeCall(function, result); 79 } 80 81 void InjectedScript::getProperties(PassRefPtr<InspectorObject> objectId, bool ignoreHasOwnProperty, bool abbreviate, RefPtr<InspectorValue>* result) 82 { 83 ScriptFunctionCall function(m_injectedScriptObject, "getProperties"); 84 String objectIdString = objectId->toJSONString(); 85 function.appendArgument(objectIdString); 86 function.appendArgument(ignoreHasOwnProperty); 87 function.appendArgument(abbreviate); 88 makeCall(function, result); 89 } 90 91 void InjectedScript::pushNodeToFrontend(PassRefPtr<InspectorObject> objectId, RefPtr<InspectorValue>* result) 92 { 93 ScriptFunctionCall function(m_injectedScriptObject, "pushNodeToFrontend"); 94 function.appendArgument(objectId->toJSONString()); 95 makeCall(function, result); 96 } 97 98 void InjectedScript::resolveNode(long nodeId, RefPtr<InspectorValue>* result) 99 { 100 ScriptFunctionCall function(m_injectedScriptObject, "resolveNode"); 101 function.appendArgument(nodeId); 102 makeCall(function, result); 103 } 104 105 void InjectedScript::getNodeProperties(long nodeId, PassRefPtr<InspectorArray> propertiesArray, RefPtr<InspectorValue>* result) 106 { 107 ScriptFunctionCall function(m_injectedScriptObject, "getNodeProperties"); 108 function.appendArgument(nodeId); 109 function.appendArgument(propertiesArray->toJSONString()); 110 makeCall(function, result); 111 } 112 113 void InjectedScript::getNodePrototypes(long nodeId, RefPtr<InspectorValue>* result) 114 { 115 ScriptFunctionCall function(m_injectedScriptObject, "getNodePrototypes"); 116 function.appendArgument(nodeId); 117 makeCall(function, result); 118 } 119 120 void InjectedScript::setPropertyValue(PassRefPtr<InspectorObject> objectId, const String& propertyName, const String& expression, RefPtr<InspectorValue>* result) 121 { 122 ScriptFunctionCall function(m_injectedScriptObject, "getNodeProperties"); 123 function.appendArgument(objectId->toJSONString()); 124 function.appendArgument(propertyName); 125 function.appendArgument(expression); 126 makeCall(function, result); 62 127 } 63 128 … … 92 157 releaseFunction.call(); 93 158 } 159 94 160 bool InjectedScript::canAccessInspectedWindow() 95 161 { … … 97 163 } 98 164 165 void InjectedScript::makeCall(ScriptFunctionCall& function, RefPtr<InspectorValue>* result) 166 { 167 if (hasNoValue() || !canAccessInspectedWindow()) { 168 *result = InspectorValue::null(); 169 return; 170 } 171 172 bool hadException = false; 173 ScriptValue resultValue = function.call(hadException); 174 175 ASSERT(!hadException); 176 if (!hadException) 177 *result = resultValue.toInspectorValue(m_injectedScriptObject.scriptState()); 178 else 179 *result = InspectorValue::null(); 180 } 181 99 182 } // namespace WebCore 100 183 -
trunk/Source/WebCore/inspector/InjectedScript.h
r65730 r76105 37 37 #include <wtf/Noncopyable.h> 38 38 #include <wtf/PassRefPtr.h> 39 #include <wtf/RefPtr.h> 39 40 40 41 namespace WebCore { 41 42 42 43 class InspectorValue; 44 class ScriptFunctionCall; 43 45 44 46 class InjectedScript { … … 49 51 bool hasNoValue() const { return m_injectedScriptObject.hasNoValue(); } 50 52 51 void dispatch(const String& methodName, const String& arguments, RefPtr<InspectorValue>* result, bool* hadException); 53 void evaluate(const String& expression, const String& objectGroup, RefPtr<InspectorValue>* result); 54 void evaluateInCallFrame(long callFrame, const String& expression, const String& objectGroup, RefPtr<InspectorValue>* result); 55 void evaluateOnSelf(const String& functionBody, PassRefPtr<InspectorArray> argumentsArray, RefPtr<InspectorValue>* result); 56 void getCompletions(const String& expression, bool includeInspectorCommandLineAPI, long callFrameId, RefPtr<InspectorValue>* result); 57 void getProperties(PassRefPtr<InspectorObject> objectId, bool ignoreHasOwnProperty, bool abbreviate, RefPtr<InspectorValue>* result); 58 void pushNodeToFrontend(PassRefPtr<InspectorObject> objectId, RefPtr<InspectorValue>* result); 59 void resolveNode(long nodeId, RefPtr<InspectorValue>* result); 60 void getNodeProperties(long nodeId, PassRefPtr<InspectorArray> propertiesArray, RefPtr<InspectorValue>* result); 61 void getNodePrototypes(long nodeId, RefPtr<InspectorValue>* result); 62 void setPropertyValue(PassRefPtr<InspectorObject> objectId, const String& propertyName, const String& expression, RefPtr<InspectorValue>* result); 63 52 64 #if ENABLE(JAVASCRIPT_DEBUGGER) 53 65 PassRefPtr<InspectorValue> callFrames(); 54 66 #endif 67 55 68 PassRefPtr<InspectorValue> wrapForConsole(ScriptValue); 56 69 void releaseWrapperObjectGroup(const String&); … … 61 74 explicit InjectedScript(ScriptObject); 62 75 bool canAccessInspectedWindow(); 76 77 void makeCall(ScriptFunctionCall&, RefPtr<InspectorValue>* result); 78 63 79 ScriptObject m_injectedScriptObject; 64 80 }; -
trunk/Source/WebCore/inspector/InjectedScriptHost.cpp
r75792 r76105 31 31 #include "config.h" 32 32 #include "InjectedScriptHost.h" 33 #include "InjectedScriptSource.h"34 #include "InspectorDatabaseAgent.h"35 #include "InspectorDOMStorageAgent.h"36 33 37 34 #if ENABLE(INSPECTOR) 38 39 35 40 36 #include "Element.h" … … 43 39 #include "HTMLFrameOwnerElement.h" 44 40 #include "InjectedScript.h" 41 #include "InjectedScriptSource.h" 45 42 #include "InspectorClient.h" 46 43 #include "InspectorConsoleAgent.h" 47 44 #include "InspectorController.h" 48 45 #include "InspectorDOMAgent.h" 46 #include "InspectorDOMStorageAgent.h" 47 #include "InspectorDatabaseAgent.h" 49 48 #include "InspectorFrontend.h" 50 49 #include "Pasteboard.h" … … 80 79 InjectedScriptHost::~InjectedScriptHost() 81 80 { 81 } 82 83 void InjectedScriptHost::evaluate(const String& expression, const String& objectGroup, RefPtr<InspectorValue>* result) 84 { 85 InjectedScript injectedScript = injectedScriptForMainWorld(); 86 if (!injectedScript.hasNoValue()) 87 injectedScript.evaluate(expression, objectGroup, result); 88 } 89 90 void InjectedScriptHost::evaluateInCallFrame(long injectedScriptId, long callFrame, const String& expression, const String& objectGroup, RefPtr<InspectorValue>* result) 91 { 92 InjectedScript injectedScript = injectedScriptId ? m_idToInjectedScript.get(injectedScriptId) : injectedScriptForMainWorld(); 93 if (!injectedScript.hasNoValue()) 94 injectedScript.evaluateInCallFrame(callFrame, expression, objectGroup, result); 95 } 96 97 void InjectedScriptHost::evaluateOnSelf(const String& functionBody, PassRefPtr<InspectorArray> argumentsArray, RefPtr<InspectorValue>* result) 98 { 99 InjectedScript injectedScript = injectedScriptForMainWorld(); 100 if (!injectedScript.hasNoValue()) 101 injectedScript.evaluateOnSelf(functionBody, argumentsArray, result); 102 } 103 104 void InjectedScriptHost::getCompletions(long injectedScriptId, const String& expression, bool includeInspectorCommandLineAPI, long callFrameId, RefPtr<InspectorValue>* result) 105 { 106 InjectedScript injectedScript = injectedScriptId ? m_idToInjectedScript.get(injectedScriptId) : injectedScriptForMainWorld(); 107 if (!injectedScript.hasNoValue()) 108 injectedScript.getCompletions(expression, includeInspectorCommandLineAPI, callFrameId, result); 109 } 110 111 void InjectedScriptHost::getProperties(PassRefPtr<InspectorObject> objectId, bool ignoreHasOwnProperty, bool abbreviate, RefPtr<InspectorValue>* result) 112 { 113 InjectedScript injectedScript = injectedScriptForObjectId(objectId.get()); 114 if (!injectedScript.hasNoValue()) 115 injectedScript.getProperties(objectId, ignoreHasOwnProperty, abbreviate, result); 116 } 117 118 void InjectedScriptHost::pushNodeToFrontend(PassRefPtr<InspectorObject> objectId, RefPtr<InspectorValue>* result) 119 { 120 InjectedScript injectedScript = injectedScriptForObjectId(objectId.get()); 121 if (!injectedScript.hasNoValue()) 122 injectedScript.pushNodeToFrontend(objectId, result); 123 } 124 125 void InjectedScriptHost::resolveNode(long nodeId, RefPtr<InspectorValue>* result) 126 { 127 InjectedScript injectedScript = injectedScriptForNodeId(nodeId); 128 if (!injectedScript.hasNoValue()) 129 injectedScript.resolveNode(nodeId, result); 130 } 131 132 void InjectedScriptHost::getNodeProperties(long nodeId, PassRefPtr<InspectorArray> propertiesArray, RefPtr<InspectorValue>* result) 133 { 134 InjectedScript injectedScript = injectedScriptForNodeId(nodeId); 135 if (!injectedScript.hasNoValue()) 136 injectedScript.getNodeProperties(nodeId, propertiesArray, result); 137 } 138 139 void InjectedScriptHost::getNodePrototypes(long nodeId, RefPtr<InspectorValue>* result) 140 { 141 InjectedScript injectedScript = injectedScriptForNodeId(nodeId); 142 if (!injectedScript.hasNoValue()) 143 injectedScript.getNodePrototypes(nodeId, result); 144 } 145 146 void InjectedScriptHost::setPropertyValue(PassRefPtr<InspectorObject> objectId, const String& propertyName, const String& expression, RefPtr<InspectorValue>* result) 147 { 148 InjectedScript injectedScript = injectedScriptForObjectId(objectId.get()); 149 if (!injectedScript.hasNoValue()) 150 injectedScript.setPropertyValue(objectId, propertyName, expression, result); 82 151 } 83 152 … … 215 284 #endif // ENABLE(WORKERS) 216 285 286 InjectedScript InjectedScriptHost::injectedScriptForObjectId(InspectorObject* objectId) 287 { 288 long injectedScriptId = 0; 289 bool success = objectId->getNumber("injectedScriptId", &injectedScriptId); 290 if (success) 291 return m_idToInjectedScript.get(injectedScriptId); 292 return InjectedScript(); 293 } 294 295 InjectedScript InjectedScriptHost::injectedScriptForNodeId(long nodeId) 296 { 297 if (!m_inspectorController) 298 return InjectedScript(); 299 300 Frame* frame = 0; 301 if (nodeId) { 302 ASSERT(m_inspectorController->domAgent()); 303 Node* node = m_inspectorController->domAgent()->nodeForId(nodeId); 304 if (node) { 305 Document* document = node->ownerDocument(); 306 if (document) 307 frame = document->frame(); 308 } 309 } else 310 frame = m_inspectorController->inspectedPage()->mainFrame(); 311 312 if (frame) 313 return injectedScriptFor(mainWorldScriptState(frame)); 314 315 return InjectedScript(); 316 } 317 318 InjectedScript InjectedScriptHost::injectedScriptForMainWorld() 319 { 320 return injectedScriptFor(mainWorldScriptState(m_inspectorController->inspectedPage()->mainFrame())); 321 } 322 217 323 } // namespace WebCore 218 324 -
trunk/Source/WebCore/inspector/InjectedScriptHost.h
r75715 r76105 59 59 ~InjectedScriptHost(); 60 60 61 // Part of the protocol. 62 void evaluate(const String& expression, const String& objectGroup, RefPtr<InspectorValue>* result); 63 void evaluateInCallFrame(long injectedScriptId, long callFrame, const String& expression, const String& objectGroup, RefPtr<InspectorValue>* result); 64 void evaluateOnSelf(const String& functionBody, PassRefPtr<InspectorArray> argumentsArray, RefPtr<InspectorValue>* result); 65 void getCompletions(long injectedScriptId, const String& expression, bool includeInspectorCommandLineAPI, long callFrameId, RefPtr<InspectorValue>* result); 66 void getProperties(PassRefPtr<InspectorObject> objectId, bool ignoreHasOwnProperty, bool abbreviate, RefPtr<InspectorValue>* result); 67 void pushNodeToFrontend(PassRefPtr<InspectorObject> objectId, RefPtr<InspectorValue>* result); 68 void resolveNode(long nodeId, RefPtr<InspectorValue>* result); 69 void getNodeProperties(long nodeId, PassRefPtr<InspectorArray> propertiesArray, RefPtr<InspectorValue>* result); 70 void getNodePrototypes(long nodeId, RefPtr<InspectorValue>* result); 71 void setPropertyValue(PassRefPtr<InspectorObject> objectId, const String& propertyName, const String& expression, RefPtr<InspectorValue>* result); 72 61 73 InspectorController* inspectorController() { return m_inspectorController; } 62 74 void disconnectController() { m_inspectorController = 0; } … … 98 110 void discardInjectedScript(ScriptState*); 99 111 112 InjectedScript injectedScriptForObjectId(InspectorObject* objectId); 113 InjectedScript injectedScriptForNodeId(long nodeId); 114 InjectedScript injectedScriptForMainWorld(); 115 100 116 InspectorController* m_inspectorController; 101 117 long m_nextInjectedScriptId; -
trunk/Source/WebCore/inspector/InjectedScriptSource.js
r76013 r76105 61 61 } 62 62 group.push(id); 63 objectId = this._serializeObjectId(id, objectGroupName); 63 objectId = { injectedScriptId: injectedScriptId, 64 id: id, 65 groupName: objectGroupName }; 64 66 } 65 67 return InjectedScript.RemoteObject.fromObject(object, objectId, abbreviate); … … 69 71 }, 70 72 71 _serializeObjectId: function(id, groupName)72 {73 return injectedScriptId + ":" + id + ":" + groupName;74 },75 76 73 _parseObjectId: function(objectId) 77 74 { 78 var tokens = objectId.split(":"); 79 var parsedObjectId = {}; 80 parsedObjectId.id = parseInt(tokens[1]); 81 parsedObjectId.groupName = tokens[2]; 82 return parsedObjectId; 75 return eval("(" + objectId + ")"); 83 76 }, 84 77 … … 104 97 }, 105 98 106 getPrototypes: function(nodeId)107 {108 this.releaseWrapperObjectGroup("prototypes");109 var node = this._nodeForId(nodeId);110 if (!node)111 return false;112 113 var result = [];114 var prototype = node;115 do {116 result.push(this._wrapObject(prototype, "prototypes"));117 prototype = prototype.__proto__;118 } while (prototype)119 return result;120 },121 122 99 getProperties: function(objectId, ignoreHasOwnProperty, abbreviate) 123 100 { 124 101 var parsedObjectId = this._parseObjectId(objectId); 125 102 var object = this._objectForId(parsedObjectId); 103 126 104 if (!this._isDefined(object)) 127 105 return false; … … 215 193 var expressionResult; 216 194 // Evaluate on call frame if call frame id is available. 217 if ( typeof callFrameId === "number") {195 if (callFrameId !== -1) { 218 196 var callFrame = this._callFrameForId(callFrameId); 219 197 if (!callFrame) … … 324 302 }, 325 303 326 _objectForId: function( parsedObjectId)327 { 328 return this._idToWrappedObject[ parsedObjectId.id];304 _objectForId: function(objectId) 305 { 306 return this._idToWrappedObject[objectId.id]; 329 307 }, 330 308 … … 343 321 if (!node) 344 322 return false; 323 properties = eval("(" + properties + ")"); 345 324 var result = {}; 346 325 for (var i = 0; i < properties.length; ++i) 347 326 result[properties[i]] = node[properties[i]]; 327 return result; 328 }, 329 330 getNodePrototypes: function(nodeId) 331 { 332 this.releaseWrapperObjectGroup("prototypes"); 333 var node = this._nodeForId(nodeId); 334 if (!node) 335 return false; 336 337 var result = []; 338 var prototype = node; 339 do { 340 result.push(this._wrapObject(prototype, "prototypes")); 341 prototype = prototype.__proto__; 342 } while (prototype) 348 343 return result; 349 344 }, … … 360 355 evaluateOnSelf: function(funcBody, args) 361 356 { 362 var func = window.eval("(" + funcBody + ")");363 return func.apply(this, args|| []);357 var func = eval("(" + funcBody + ")"); 358 return func.apply(this, eval("(" + args + ")") || []); 364 359 }, 365 360 -
trunk/Source/WebCore/inspector/Inspector.idl
r76026 r76105 37 37 /////////////////////////////////////////////////////////////////////// 38 38 39 // HUGE FIXME: we need to expose InjectedScript methods here. Or document InjectedScript capabilities.40 [domain=Inspector] void dispatchOnInjectedScript(in long injectedScriptId, in String methodName, in String arguments, out Value result, out boolean isException);41 39 [domain=Inspector] void addScriptToEvaluateOnLoad(in String scriptSource); 42 40 [domain=Inspector] void removeAllScriptsToEvaluateOnLoad(); … … 72 70 [domain=Inspector] void getCookies(out Array cookies, out String cookiesString); 73 71 [domain=Inspector] void deleteCookie(in String cookieName, in String domain); 72 73 /////////////////////////////////////////////////////////////////////// 74 // Injected Script 75 /////////////////////////////////////////////////////////////////////// 76 77 [domain=InjectedScript] void evaluate(in String expression, in String objectGroup, out Value result); 78 [domain=InjectedScript] void evaluateInCallFrame(in long injectedScriptId, in long callFrame, in String expression, in String objectGroup, out Value result); 79 [domain=InjectedScript] void evaluateOnSelf(in String functionBody, in Array argumentsArray, out Value result); 80 [domain=InjectedScript] void getCompletions(in long injectedScriptId, in String expression, in boolean includeInspectorCommandLineAPI, in long callFrameId, out Value result); 81 [domain=InjectedScript] void getProperties(in Object objectId, in boolean ignoreHasOwnProperty, in boolean abbreviate, out Value result); 82 [domain=InjectedScript] void pushNodeToFrontend(in Object objectId, out Value result); 83 [domain=InjectedScript] void resolveNode(in long nodeId, out Value result); 84 [domain=InjectedScript] void getNodeProperties(in long nodeId, in Array propertiesArray, out Value result); 85 [domain=InjectedScript] void getNodePrototypes(in long nodeId, out Value result); 86 [domain=InjectedScript] void setPropertyValue(in Object objectId, in String propertyName, in String expression, out Value result); 74 87 75 88 /////////////////////////////////////////////////////////////////////// -
trunk/Source/WebCore/inspector/InspectorController.cpp
r76021 r76105 1158 1158 #endif 1159 1159 1160 void InspectorController::dispatchOnInjectedScript(long injectedScriptId, const String& methodName, const String& arguments, RefPtr<InspectorValue>* result, bool* hadException)1161 {1162 if (!m_frontend)1163 return;1164 1165 // FIXME: explicitly pass injectedScriptId along with node id to the frontend.1166 bool injectedScriptIdIsNodeId = injectedScriptId <= 0;1167 1168 InjectedScript injectedScript;1169 if (injectedScriptIdIsNodeId)1170 injectedScript = injectedScriptForNodeId(-injectedScriptId);1171 else1172 injectedScript = injectedScriptHost()->injectedScriptForId(injectedScriptId);1173 1174 if (injectedScript.hasNoValue())1175 return;1176 1177 injectedScript.dispatch(methodName, arguments, result, hadException);1178 }1179 1180 1160 void InspectorController::releaseWrapperObjectGroup(long injectedScriptId, const String& objectGroup) 1181 1161 { … … 1465 1445 } 1466 1446 1467 InjectedScript InspectorController::injectedScriptForNodeId(long id)1468 {1469 1470 Frame* frame = 0;1471 if (id) {1472 ASSERT(m_domAgent);1473 Node* node = m_domAgent->nodeForId(id);1474 if (node) {1475 Document* document = node->ownerDocument();1476 if (document)1477 frame = document->frame();1478 }1479 } else1480 frame = m_inspectedPage->mainFrame();1481 1482 if (frame)1483 return m_injectedScriptHost->injectedScriptFor(mainWorldScriptState(frame));1484 1485 return InjectedScript();1486 }1487 1488 1447 void InspectorController::addScriptToEvaluateOnLoad(const String& source) 1489 1448 { -
trunk/Source/WebCore/inspector/InspectorController.h
r75949 r76105 225 225 #endif 226 226 227 void setInjectedScriptSource(const String& source);228 void dispatchOnInjectedScript(long injectedScriptId, const String& methodName, const String& arguments, RefPtr<InspectorValue>* result, bool* hadException);229 230 227 // Generic code called from custom implementations. 231 228 void releaseWrapperObjectGroup(long injectedScriptId, const String& objectGroup); 232 229 233 230 void evaluateForTestInFrontend(long testCallId, const String& script); 234 235 InjectedScript injectedScriptForNodeId(long id);236 231 237 232 void addScriptToEvaluateOnLoad(const String& source); … … 284 279 285 280 void focusNode(); 286 287 281 bool isMainResourceLoader(DocumentLoader* loader, const KURL& requestUrl); 288 289 282 void didEvaluateForTestInFrontend(long callId, const String& jsonResult); 290 283 -
trunk/Source/WebCore/inspector/InspectorValues.cpp
r70198 r76105 648 648 } 649 649 650 bool InspectorObject::getNumber(const String& name, long* output) const 651 { 652 RefPtr<InspectorValue> value = get(name); 653 if (!value) 654 return false; 655 return value->asNumber(output); 656 } 657 650 658 bool InspectorObject::getNumber(const String& name, double* output) const 651 659 { -
trunk/Source/WebCore/inspector/InspectorValues.h
r69437 r76105 181 181 const_iterator find(const String& name) const; 182 182 bool getBoolean(const String& name, bool* output) const; 183 bool getNumber(const String& name, long* output) const; 183 184 bool getNumber(const String& name, double* output) const; 184 185 bool getString(const String& name, String* output) const; -
trunk/Source/WebCore/inspector/front-end/AuditRules.js
r75714 r76105 66 66 WebInspector.AuditRules.evaluateInTargetWindow = function(func, args, callback) 67 67 { 68 In jectedScriptAccess.getDefault().evaluateOnSelf(func.toString(), args, callback);68 InspectorBackend.evaluateOnSelf(func.toString(), args, callback); 69 69 } 70 70 … … 722 722 } 723 723 724 WebInspector.AuditRules.evaluateInTargetWindow(pushImageNodes, null, receivedImages);724 WebInspector.AuditRules.evaluateInTargetWindow(pushImageNodes, [], receivedImages); 725 725 } 726 726 } … … 798 798 } 799 799 800 WebInspector.AuditRules.evaluateInTargetWindow(routine, null, evalCallback);800 WebInspector.AuditRules.evaluateInTargetWindow(routine, [], evalCallback); 801 801 } 802 802 } … … 845 845 } 846 846 847 WebInspector.AuditRules.evaluateInTargetWindow(routine, null, evalCallback.bind(this));847 WebInspector.AuditRules.evaluateInTargetWindow(routine, [], evalCallback.bind(this)); 848 848 } 849 849 } -
trunk/Source/WebCore/inspector/front-end/ConsoleView.js
r76019 r76105 356 356 357 357 var includeInspectorCommandLineAPI = (!dotNotation && !bracketNotation); 358 var callFrameId = WebInspector.panels.scripts.selectedCallFrameId() ;358 var callFrameId = WebInspector.panels.scripts.selectedCallFrameId() || -1; 359 359 var injectedScriptAccess; 360 360 if (WebInspector.panels.scripts && WebInspector.panels.scripts.paused) { 361 361 var selectedCallFrame = WebInspector.panels.scripts.sidebarPanes.callstack.selectedCallFrame; 362 injectedScriptAccess = InjectedScriptAccess.get(selectedCallFrame.worldId);362 var injectedScriptId = selectedCallFrame.worldId; 363 363 } else 364 injectedScriptAccess = InjectedScriptAccess.getDefault();365 injectedScriptAccess.getCompletions(expressionString, includeInspectorCommandLineAPI, callFrameId, reportCompletions);364 var injectedScriptId = 0; 365 InspectorBackend.getCompletions(injectedScriptId, expressionString, includeInspectorCommandLineAPI, callFrameId, reportCompletions); 366 366 }, 367 367 … … 533 533 { 534 534 callback(WebInspector.RemoteObject.fromPayload(result)); 535 } ;536 In jectedScriptAccess.getDefault().evaluate(expression, objectGroup, evalCallback);535 } 536 InspectorBackend.evaluate(expression, objectGroup, evalCallback); 537 537 }, 538 538 -
trunk/Source/WebCore/inspector/front-end/ElementsTreeOutline.js
r74634 r76105 412 412 this.tooltip = WebInspector.UIString("%d × %d pixels (Natural: %d × %d pixels)", properties.offsetWidth, properties.offsetHeight, properties.naturalWidth, properties.naturalHeight); 413 413 } 414 415 InjectedScriptAccess.getForNode(node).getNodeProperties(node.id, ["naturalHeight", "naturalWidth", "offsetHeight", "offsetWidth"], setTooltip.bind(this)); 414 InspectorBackend.getNodeProperties(node.id, ["naturalHeight", "naturalWidth", "offsetHeight", "offsetWidth"], setTooltip.bind(this)); 416 415 }, 417 416 -
trunk/Source/WebCore/inspector/front-end/ExtensionPanel.js
r71107 r76105 96 96 setExpression: function(expression, title) 97 97 { 98 In jectedScriptAccess.getDefault().evaluate(expression, this._onEvaluate.bind(this, title));98 InspectorBackend.evaluate(expression, "extension-watch", this._onEvaluate.bind(this, title)); 99 99 }, 100 100 -
trunk/Source/WebCore/inspector/front-end/ExtensionServer.js
r76030 r76105 273 273 "with (window.console._commandLineAPI) with (window) {' + unescape('" + escape(message.expression) + 274 274 "') + '}'));"; 275 In jectedScriptAccess.getDefault().evaluate(evalExpression, callback.bind(this));275 InspectorBackend.evaluate(evalExpression, "none", callback.bind(this)); 276 276 }, 277 277 -
trunk/Source/WebCore/inspector/front-end/PropertiesSidebarPane.js
r71139 r76105 43 43 } 44 44 45 var self = this;46 var callback = function(prototypes){47 var body = self.bodyElement;45 function callback(prototypes) 46 { 47 var body = this.bodyElement; 48 48 body.removeChildren(); 49 self.sections = [];49 this.sections = []; 50 50 51 51 // Get array of prototype user-friendly names. … … 56 56 title = title.replace(/Prototype$/, ""); 57 57 var section = new WebInspector.ObjectPropertiesSection(prototype, title); 58 self.sections.push(section);58 this.sections.push(section); 59 59 body.appendChild(section.element); 60 60 } 61 } ;62 In jectedScriptAccess.getForNode(node).getPrototypes(node.id, callback);61 } 62 InspectorBackend.getNodePrototypes(node.id, callback.bind(this)); 63 63 } 64 64 } -
trunk/Source/WebCore/inspector/front-end/RemoteObject.js
r71107 r76105 53 53 callback(object ? WebInspector.RemoteObject.fromPayload(object) : null); 54 54 } 55 In jectedScriptAccess.getForNode(node).resolveNode(node.id, mycallback);55 InspectorBackend.resolveNode(node.id, mycallback); 56 56 } 57 57 … … 119 119 callback(properties); 120 120 } 121 In jectedScriptAccess.getForObjectId(this._objectId).getProperties(this._objectId,ignoreHasOwnProperty, abbreviate, remoteObjectBinder);121 InspectorBackend.getProperties(this._objectId, !!ignoreHasOwnProperty, abbreviate, remoteObjectBinder); 122 122 }, 123 123 … … 128 128 return; 129 129 } 130 In jectedScriptAccess.getForObjectId(this._objectId).setPropertyValue(this._objectId, name, value, callback);130 InspectorBackend.setPropertyValue(this._objectId, name, value, callback); 131 131 }, 132 132 133 133 pushNodeToFrontend: function(callback) 134 134 { 135 In jectedScriptAccess.getForObjectId(this._objectId).pushNodeToFrontend(this._objectId, callback);135 InspectorBackend.pushNodeToFrontend(this._objectId, callback); 136 136 } 137 137 } -
trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js
r76021 r76105 367 367 callback(WebInspector.RemoteObject.fromPayload(result)); 368 368 } 369 In jectedScriptAccess.get(callFrame.worldId).evaluateInCallFrame(callFrame.id, code, objectGroup, evalCallback);369 InspectorBackend.evaluateInCallFrame(callFrame.worldId, callFrame.id, code, objectGroup, evalCallback); 370 370 }, 371 371 -
trunk/Source/WebCore/inspector/front-end/WebKit.qrc
r76009 r76105 52 52 <file>ImageView.js</file> 53 53 <file>InjectedFakeWorker.js</file> 54 <file>InjectedScriptAccess.js</file>55 54 <file>inspector.js</file> 56 55 <file>InspectorFrontendHostStub.js</file> -
trunk/Source/WebCore/inspector/front-end/inspector.html
r76009 r76105 144 144 <script type="text/javascript" src="DebuggerModel.js"></script> 145 145 <script type="text/javascript" src="DOMAgent.js"></script> 146 <script type="text/javascript" src="InjectedScriptAccess.js"></script>147 146 <script type="text/javascript" src="TimelineAgent.js"></script> 148 147 <script type="text/javascript" src="TimelinePanel.js"></script> -
trunk/Source/WebKit/chromium/ChangeLog
r76075 r76105 1 2011-01-18 Pavel Feldman <pfeldman@chromium.org> 2 3 Reviewed by Yury Semikhatsky. 4 5 Web Inspector: make InjectedScriptAccess API a part of Web Inspector protocol. 6 https://bugs.webkit.org/show_bug.cgi?id=52652 7 8 Calls served by the InjectedScript should be first class protocol 9 citizens, not dispatched via single protocol message. 10 11 * src/js/Tests.js: 12 1 13 2011-01-18 Victoria Kirst <vrk@chromium.org> 2 14 -
trunk/Source/WebKit/chromium/src/js/Tests.js
r75938 r76105 742 742 743 743 /** 744 * Executes the 'code' with InjectedScriptAccess.getProperties overriden745 * so that all callbacks passed to InjectedScriptAccess.getProperties are746 * extended with the "hook".747 * @param {Function} hook The hook function.748 * @param {Function} code A code snippet to be executed.749 */750 TestSuite.prototype._hookGetPropertiesCallback = function(hook, code)751 {752 var accessor = InjectedScriptAccess.prototype;753 var orig = accessor.getProperties;754 accessor.getProperties = function(objectProxy, ignoreHasOwnProperty, abbreviate, callback) {755 orig.call(this, objectProxy, ignoreHasOwnProperty, abbreviate,756 function() {757 callback.apply(this, arguments);758 hook();759 });760 };761 try {762 code();763 } finally {764 accessor.getProperties = orig;765 }766 };767 768 769 /**770 744 * Key event with given key identifier. 771 745 */
Note: See TracChangeset
for help on using the changeset viewer.