Changeset 57812 in webkit
- Timestamp:
- Apr 19, 2010 10:01:39 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r57810 r57812 1 2010-04-19 Yury Semikhatsky <yurys@chromium.org> 2 3 Reviewed by Pavel Feldman. 4 5 Web Inspector: implement JavaScriptCallFrame that works for v8. 6 Implementing this binding for v8 allows to make evaluations on 7 call frames and protects access to the debugger context from 8 inspected context. 9 10 https://bugs.webkit.org/show_bug.cgi?id=37755 11 12 * WebCore.gyp/WebCore.gyp: 13 * WebCore.gypi: 14 * bindings/js/JSJavaScriptCallFrameCustom.cpp: 15 (WebCore::JSJavaScriptCallFrame::scopeType): 16 * bindings/v8/JavaScriptCallFrame.cpp: Added. 17 (WebCore::JavaScriptCallFrame::JavaScriptCallFrame): 18 (WebCore::JavaScriptCallFrame::~JavaScriptCallFrame): 19 (WebCore::JavaScriptCallFrame::caller): 20 (WebCore::JavaScriptCallFrame::sourceID): 21 (WebCore::JavaScriptCallFrame::line): 22 (WebCore::JavaScriptCallFrame::functionName): 23 (WebCore::JavaScriptCallFrame::scopeChain): 24 (WebCore::JavaScriptCallFrame::scopeType): 25 (WebCore::JavaScriptCallFrame::thisObject): 26 (WebCore::JavaScriptCallFrame::evaluate): 27 * bindings/v8/JavaScriptCallFrame.h: Added. 28 (WebCore::JavaScriptCallFrame::create): 29 * bindings/v8/ScriptDebugServer.cpp: 30 (WebCore::ScriptDebugServer::currentCallFrame): 31 * bindings/v8/ScriptDebugServer.h: 32 * bindings/v8/custom/V8InjectedScriptHostCustom.cpp: 33 (WebCore::V8InjectedScriptHost::currentCallFrameCallback): 34 * bindings/v8/custom/V8JavaScriptCallFrameCustom.cpp: Added. 35 (WebCore::V8JavaScriptCallFrame::evaluateCallback): 36 (WebCore::V8JavaScriptCallFrame::scopeChainAccessorGetter): 37 (WebCore::V8JavaScriptCallFrame::scopeTypeCallback): 38 (WebCore::V8JavaScriptCallFrame::thisObjectAccessorGetter): 39 (WebCore::V8JavaScriptCallFrame::typeAccessorGetter): 40 * inspector/JavaScriptCallFrame.idl: 41 * inspector/front-end/InjectedScript.js: 42 (injectedScriptConstructor.): 43 1 44 2010-04-19 Jessie Berlin <jberlin@webkit.org> 2 45 -
trunk/WebCore/WebCore.gyp/WebCore.gyp
r57162 r57812 180 180 '../dom/EventTarget.idl', 181 181 '../html/VoidCallback.idl', 182 183 # JSC-only.184 '../inspector/JavaScriptCallFrame.idl',185 182 186 183 # Bindings with custom Objective-C implementations. -
trunk/WebCore/WebCore.gypi
r57784 r57812 759 759 'bindings/v8/custom/V8InjectedScriptHostCustom.cpp', 760 760 'bindings/v8/custom/V8InspectorFrontendHostCustom.cpp', 761 'bindings/v8/custom/V8JavaScriptCallFrameCustom.cpp', 761 762 'bindings/v8/custom/V8LocationCustom.cpp', 762 763 'bindings/v8/custom/V8MessageChannelConstructor.cpp', … … 805 806 'bindings/v8/IsolatedWorld.cpp', 806 807 'bindings/v8/IsolatedWorld.h', 808 'bindings/v8/JavaScriptCallFrame.cpp', 809 'bindings/v8/JavaScriptCallFrame.h', 807 810 'bindings/v8/MainThreadDOMData.cpp', 808 811 'bindings/v8/MainThreadDOMData.h', -
trunk/WebCore/bindings/js/JSJavaScriptCallFrameCustom.cpp
r53371 r57812 86 86 } 87 87 88 JSValue JSJavaScriptCallFrame::scopeType(ExecState*, const ArgList&) 89 { 90 // FIXME(37663): implement this method the way it's done in the InjectedScipt.js 91 return jsNull(); 92 } 93 88 94 } // namespace WebCore 89 95 -
trunk/WebCore/bindings/v8/ScriptDebugServer.cpp
r57701 r57812 35 35 36 36 #include "Frame.h" 37 #include "JavaScriptCallFrame.h" 37 38 #include "Page.h" 38 39 #include "ScriptDebugListener.h" … … 74 75 if (!m_listenersMap.size()) { 75 76 ensureDebuggerScriptCompiled(); 76 ASSERT(!m_debuggerScript ->IsUndefined());77 ASSERT(!m_debuggerScript.get()->IsUndefined()); 77 78 v8::Debug::SetMessageHandler2(&ScriptDebugServer::onV8DebugMessage); 78 79 v8::Debug::SetHostDispatchHandler(&ScriptDebugServer::onV8DebugHostDispatch, 100 /* ms */); … … 84 85 m_contextDataMap.set(listener, contextData); 85 86 86 v8::Handle<v8::Function> getScriptsFunction = v8::Local<v8::Function>::Cast(m_debuggerScript ->Get(v8::String::New("getScripts")));87 v8::Handle<v8::Function> getScriptsFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::New("getScripts"))); 87 88 v8::Handle<v8::Value> value = v8::Debug::Call(getScriptsFunction); 88 89 if (value.IsEmpty()) … … 126 127 args->Set(v8::String::New("enabled"), v8::Boolean::New(breakpoint.enabled)); 127 128 128 v8::Handle<v8::Function> setBreakpointFunction = v8::Local<v8::Function>::Cast(m_debuggerScript ->Get(v8::String::New("setBreakpoint")));129 v8::Handle<v8::Function> setBreakpointFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::New("setBreakpoint"))); 129 130 v8::Debug::Call(setBreakpointFunction, args); 130 131 #endif … … 142 143 args->Set(v8::String::New("lineNumber"), v8::Integer::New(lineNumber)); 143 144 144 v8::Handle<v8::Function> removeBreakpointFunction = v8::Local<v8::Function>::Cast(m_debuggerScript ->Get(v8::String::New("removeBreakpoint")));145 v8::Handle<v8::Function> removeBreakpointFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::New("removeBreakpoint"))); 145 146 v8::Debug::Call(removeBreakpointFunction, args); 146 147 #endif … … 155 156 v8::Context::Scope contextScope(debuggerContext); 156 157 157 v8::Handle<v8::Function> setBreakpointsActivated = v8::Local<v8::Function>::Cast(m_debuggerScript ->Get(v8::String::New("clearBreakpoints")));158 v8::Handle<v8::Function> setBreakpointsActivated = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::New("clearBreakpoints"))); 158 159 v8::Debug::Call(setBreakpointsActivated); 159 160 #endif … … 170 171 v8::Local<v8::Object> args = v8::Object::New(); 171 172 args->Set(v8::String::New("enabled"), v8::Boolean::New(enabled)); 172 v8::Handle<v8::Function> setBreakpointsActivated = v8::Local<v8::Function>::Cast(m_debuggerScript ->Get(v8::String::New("setBreakpointsActivated")));173 v8::Handle<v8::Function> setBreakpointsActivated = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::New("setBreakpointsActivated"))); 173 174 v8::Debug::Call(setBreakpointsActivated, args); 174 175 #endif … … 219 220 { 220 221 #if ENABLE(V8_SCRIPT_DEBUG_SERVER) 221 if (!m_currentCallFrame. IsEmpty())222 return m_currentCallFrame ;222 if (!m_currentCallFrame.get().IsEmpty()) 223 return m_currentCallFrame.get(); 223 224 224 225 // Check on a bp. 225 v8::Handle<v8::Function> currentCallFrameFunction = v8::Local<v8::Function>::Cast(m_debuggerScript ->Get(v8::String::New("currentCallFrame")));226 v8::Handle<v8::Value> argv[] = { m_executionState };227 v8::Handle<v8::Value> result = currentCallFrameFunction->Call(m_debuggerScript , 1, argv);228 m_currentCallFrame = v8::Persistent<v8::Value>::New(result);226 v8::Handle<v8::Function> currentCallFrameFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::New("currentCallFrame"))); 227 v8::Handle<v8::Value> argv[] = { m_executionState.get() }; 228 v8::Handle<v8::Value> result = currentCallFrameFunction->Call(m_debuggerScript.get(), 1, argv); 229 m_currentCallFrame.set(result); 229 230 return result; 230 231 #else 231 232 return v8::Handle<v8::Value>(); 232 233 #endif 234 } 235 236 PassRefPtr<JavaScriptCallFrame> ScriptDebugServer::currentCallFrame() 237 { 238 return JavaScriptCallFrame::create(v8::Debug::GetDebugContext(), v8::Handle<v8::Object>::Cast(currentCallFrameV8())); 233 239 } 234 240 … … 289 295 v8::Local<v8::Object> args = v8::Object::New(); 290 296 args->Set(v8::String::New("eventData"), message.GetEventData()); 291 v8::Handle<v8::Function> onAfterCompileFunction = v8::Local<v8::Function>::Cast(m_debuggerScript ->Get(v8::String::New("getAfterCompileScript")));297 v8::Handle<v8::Function> onAfterCompileFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::New("getAfterCompileScript"))); 292 298 v8::Handle<v8::Value> argv[] = { message.GetExecutionState(), args }; 293 v8::Handle<v8::Value> value = onAfterCompileFunction->Call(m_debuggerScript , 2, argv);299 v8::Handle<v8::Value> value = onAfterCompileFunction->Call(m_debuggerScript.get(), 2, argv); 294 300 ASSERT(value->IsObject()); 295 301 v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(value); 296 302 dispatchDidParseSource(listener, object); 297 303 } else if (message.GetEvent() == v8::Break) { 298 m_executionState = v8::Persistent<v8::Object>::New(message.GetExecutionState());304 m_executionState.set(message.GetExecutionState()); 299 305 m_currentCallFrameState = mainWorldScriptState(frame); 300 306 listener->didPause(); … … 320 326 void ScriptDebugServer::ensureDebuggerScriptCompiled() 321 327 { 322 if (m_debuggerScript. IsEmpty()) {328 if (m_debuggerScript.get().IsEmpty()) { 323 329 v8::HandleScope scope; 324 330 v8::Local<v8::Context> debuggerContext = v8::Debug::GetDebugContext(); 325 331 v8::Context::Scope contextScope(debuggerContext); 326 m_debuggerScript = v8::Persistent<v8::Object>::New(v8::Handle<v8::Object>::Cast(v8::Script::Compile(v8String(m_debuggerScriptSource))->Run()));332 m_debuggerScript.set(v8::Handle<v8::Object>::Cast(v8::Script::Compile(v8String(m_debuggerScriptSource))->Run())); 327 333 } 328 334 } … … 330 336 void ScriptDebugServer::didResume() 331 337 { 332 if (!m_currentCallFrame.IsEmpty()) { 333 m_currentCallFrame.Dispose(); 334 m_currentCallFrame.Clear(); 335 } 336 if (!m_executionState.IsEmpty()) { 337 m_executionState.Dispose(); 338 m_executionState.Clear(); 339 } 338 m_currentCallFrame.clear(); 339 m_executionState.clear(); 340 340 } 341 341 -
trunk/WebCore/bindings/v8/ScriptDebugServer.h
r57701 r57812 34 34 #if ENABLE(JAVASCRIPT_DEBUGGER) 35 35 36 #include "OwnHandle.h" 36 37 #include "PlatformString.h" 37 38 #include "ScriptBreakpoint.h" … … 45 46 namespace WebCore { 46 47 48 class JavaScriptCallFrame; 47 49 class Page; 48 50 class ScriptDebugListener; … … 97 99 98 100 v8::Handle<v8::Value> currentCallFrameV8(); 101 PassRefPtr<JavaScriptCallFrame> currentCallFrame(); 99 102 100 103 private: … … 132 135 String m_debuggerScriptSource; 133 136 PauseOnExceptionsState m_pauseOnExceptionsState; 134 v8::Persistent<v8::Object> m_debuggerScript;137 OwnHandle<v8::Object> m_debuggerScript; 135 138 ScriptState* m_currentCallFrameState; 136 v8::Persistent<v8::Value> m_currentCallFrame;137 v8::Persistent<v8::Object> m_executionState;139 OwnHandle<v8::Value> m_currentCallFrame; 140 OwnHandle<v8::Object> m_executionState; 138 141 139 142 static MessageLoopDispatchHandler s_messageLoopDispatchHandler; -
trunk/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp
r57701 r57812 47 47 #include "V8DOMWindow.h" 48 48 #include "V8Database.h" 49 #include "V8JavaScriptCallFrame.h" 49 50 #include "V8Node.h" 50 51 #include "V8Proxy.h" … … 159 160 { 160 161 INC_STATS("InjectedScriptHost.currentCallFrame()"); 161 return ScriptDebugServer::shared().currentCallFrameV8();162 return toV8(ScriptDebugServer::shared().currentCallFrame()); 162 163 } 163 164 -
trunk/WebCore/inspector/JavaScriptCallFrame.idl
r52534 r57812 27 27 28 28 interface [Conditional=JAVASCRIPT_DEBUGGER, OmitConstructor] JavaScriptCallFrame { 29 30 // Scope type 31 const unsigned short GLOBAL_SCOPE = 0; 32 const unsigned short LOCAL_SCOPE = 1; 33 const unsigned short WITH_SCOPE = 2; 34 const unsigned short CLOSURE_SCOPE = 3; 35 const unsigned short CATCH_SCOPE = 4; 36 29 37 [Custom] void evaluate(in DOMString script); 30 38 … … 33 41 readonly attribute long line; 34 42 readonly attribute [CustomGetter] Array scopeChain; 43 [Custom] unsigned short scopeType(in int scopeIndex); 35 44 readonly attribute [CustomGetter] Object thisObject; 36 45 readonly attribute DOMString functionName; -
trunk/WebCore/inspector/front-end/InjectedScript.js
r57701 r57812 846 846 847 847 InjectedScript.CallFrameProxy.prototype = { 848 _wrapScopeChain: function(callFrame) 849 { 850 const GLOBAL_SCOPE = 0; 851 const LOCAL_SCOPE = 1; 852 const WITH_SCOPE = 2; 853 const CLOSURE_SCOPE = 3; 854 const CATCH_SCOPE = 4; 848 855 849 850 _wrapScopeChain: function(callFrame)851 {852 var ScopeType = { Global: 0,853 Local: 1,854 With: 2,855 Closure: 3,856 Catch: 4 };857 856 var scopeChain = callFrame.scopeChain; 858 857 var scopeChainProxy = []; 859 for (var i = 0; i < scopeChain.length; i += 2) {860 var scopeType = scopeChain[i];861 var scopeObject = scopeChain[i + 1];862 var scopeObjectProxy = InjectedScript.createProxyObject(scopeObject, { callFrame: this.id, chainIndex: (i + 1)}, true);858 for (var i = 0; i < scopeChain.length; i++) { 859 var scopeType = callFrame.scopeType(i); 860 var scopeObject = scopeChain[i]; 861 var scopeObjectProxy = InjectedScript.createProxyObject(scopeObject, { callFrame: this.id, chainIndex: i }, true); 863 862 864 863 var foundLocalScope = false; 865 864 switch(scopeType) { 866 case ScopeType.Local: {865 case LOCAL_SCOPE: { 867 866 foundLocalScope = true; 868 867 scopeObjectProxy.isLocal = true; … … 870 869 break; 871 870 } 872 case ScopeType.Closure: {871 case CLOSURE_SCOPE: { 873 872 scopeObjectProxy.isClosure = true; 874 873 break; 875 874 } 876 case ScopeType.With: { 875 case WITH_SCOPE: 876 case CATCH_SCOPE: { 877 877 scopeObjectProxy.isWithBlock = true; 878 878 break; -
trunk/WebKit/chromium/src/js/DebuggerScript.js
r57701 r57812 168 168 // Get scope chain array in format: [<scope type>, <scope object>, <scope type>, <scope object>,...] 169 169 var scopeChain = []; 170 var scopeType = []; 170 171 for (var i = 0; i < frameMirror.scopeCount(); i++) { 171 172 var scopeMirror = frameMirror.scope(i); … … 175 176 for (var j = 0; j < properties.length; j++) 176 177 scopeObject[properties[j].name()] = properties[j].value_; 177 scope Chain.push(scopeMirror.scopeType());178 scopeType.push(scopeMirror.scopeType()); 178 179 scopeChain.push(scopeObject); 180 } 181 182 function evaluate(expression) { 183 return frameMirror.evaluate(expression, false).value(); 179 184 } 180 185 … … 186 191 "thisObject": thisObject, 187 192 "scopeChain": scopeChain, 193 "scopeType": scopeType, 194 "evaluate": evaluate, 188 195 "caller": callerFrame 189 196 };
Note: See TracChangeset
for help on using the changeset viewer.