Changeset 54421 in webkit
- Timestamp:
- Feb 5, 2010 6:08:31 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 30 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r54420 r54421 1 2010-02-05 Yury Semikhatsky <yurys@chromium.org> 2 3 Reviewed by Pavel Feldman. 4 5 - Use SerializedScriptValue for passing data between injected script and 6 inspector frontend. 7 - Remove custom JSON implementation from the instpector utility script. 8 - Make sure that only objects created in the same ScriptState can be values 9 of ScriptObject/Array properties and arguments to ScriptFunctionCall. We don't 10 want ScriptObjects to leak between contexts. 11 - Use ScriptState of the 'this' object in ScriptFunctionCall instead of passing 12 it as additional parameter. 13 14 https://bugs.webkit.org/show_bug.cgi?id=33592 15 16 * bindings/js/JSInjectedScriptHostCustom.cpp: 17 (WebCore::JSInjectedScriptHost::reportDidDispatchOnInjectedScript): 18 * bindings/js/ScriptArray.cpp: 19 (WebCore::ScriptArray::set): 20 * bindings/js/ScriptFunctionCall.cpp: 21 (WebCore::ScriptFunctionCall::ScriptFunctionCall): 22 (WebCore::ScriptFunctionCall::appendArgument): 23 * bindings/js/ScriptFunctionCall.h: 24 * bindings/js/ScriptObject.cpp: 25 (WebCore::ScriptObject::set): 26 * bindings/js/ScriptValue.cpp: 27 (WebCore::ScriptValue::serialize): 28 (WebCore::ScriptValue::deserialize): 29 * bindings/js/ScriptValue.h: 30 * bindings/v8/ScriptArray.cpp: 31 (WebCore::ScriptArray::set): 32 * bindings/v8/ScriptFunctionCall.cpp: 33 (WebCore::ScriptFunctionCall::ScriptFunctionCall): 34 (WebCore::ScriptFunctionCall::appendArgument): 35 * bindings/v8/ScriptFunctionCall.h: 36 * bindings/v8/ScriptObject.cpp: 37 (WebCore::ScriptObject::set): 38 * bindings/v8/ScriptState.h: 39 * bindings/v8/ScriptValue.cpp: 40 (WebCore::ScriptValue::serialize): 41 (WebCore::deserialize): 42 * bindings/v8/ScriptValue.h: 43 * bindings/v8/custom/V8InjectedScriptHostCustom.cpp: 44 (WebCore::V8InjectedScriptHost::reportDidDispatchOnInjectedScriptCallback): 45 * inspector/InjectedScript.cpp: 46 (WebCore::InjectedScript::dispatch): 47 (WebCore::InjectedScript::callFrames): 48 (WebCore::InjectedScript::wrapForConsole): 49 (WebCore::InjectedScript::releaseWrapperObjectGroup): 50 * inspector/InjectedScript.h: 51 * inspector/InjectedScriptHost.cpp: 52 (WebCore::InjectedScriptHost::reportDidDispatchOnInjectedScript): 53 * inspector/InjectedScriptHost.h: 54 * inspector/InjectedScriptHost.idl: 55 * inspector/InspectorBackend.cpp: 56 (WebCore::InspectorBackend::dispatchOnInjectedScript): 57 * inspector/InspectorController.cpp: 58 (WebCore::InspectorController::setFrontendProxyObject): 59 (WebCore::InspectorController::didPause): 60 (WebCore::InspectorController::didEvaluateForTestInFrontend): 61 * inspector/InspectorFrontend.cpp: 62 (WebCore::InspectorFrontend::InspectorFrontend): 63 (WebCore::InspectorFrontend::newScriptArray): 64 (WebCore::InspectorFrontend::newScriptObject): 65 (WebCore::InspectorFrontend::populateFrontendSettings): 66 (WebCore::InspectorFrontend::updateConsoleMessageExpiredCount): 67 (WebCore::InspectorFrontend::addConsoleMessage): 68 (WebCore::InspectorFrontend::updateConsoleMessageRepeatCount): 69 (WebCore::InspectorFrontend::updateResource): 70 (WebCore::InspectorFrontend::removeResource): 71 (WebCore::InspectorFrontend::didGetResourceContent): 72 (WebCore::InspectorFrontend::updateFocusedNode): 73 (WebCore::InspectorFrontend::setAttachedWindow): 74 (WebCore::InspectorFrontend::addRecordToTimeline): 75 (WebCore::InspectorFrontend::parsedScriptSource): 76 (WebCore::InspectorFrontend::failedToParseScriptSource): 77 (WebCore::InspectorFrontend::addProfileHeader): 78 (WebCore::InspectorFrontend::setRecordingProfile): 79 (WebCore::InspectorFrontend::didGetProfileHeaders): 80 (WebCore::InspectorFrontend::didGetProfile): 81 (WebCore::InspectorFrontend::pausedScript): 82 (WebCore::InspectorFrontend::setDocument): 83 (WebCore::InspectorFrontend::setDetachedRoot): 84 (WebCore::InspectorFrontend::setChildNodes): 85 (WebCore::InspectorFrontend::childNodeCountUpdated): 86 (WebCore::InspectorFrontend::childNodeInserted): 87 (WebCore::InspectorFrontend::childNodeRemoved): 88 (WebCore::InspectorFrontend::attributesUpdated): 89 (WebCore::InspectorFrontend::didRemoveNode): 90 (WebCore::InspectorFrontend::didGetChildNodes): 91 (WebCore::InspectorFrontend::didApplyDomChange): 92 (WebCore::InspectorFrontend::didGetEventListenersForNode): 93 (WebCore::InspectorFrontend::didGetCookies): 94 (WebCore::InspectorFrontend::didDispatchOnInjectedScript): 95 (WebCore::InspectorFrontend::addDatabase): 96 (WebCore::InspectorFrontend::selectDatabase): 97 (WebCore::InspectorFrontend::didGetDatabaseTableNames): 98 (WebCore::InspectorFrontend::addDOMStorage): 99 (WebCore::InspectorFrontend::selectDOMStorage): 100 (WebCore::InspectorFrontend::didGetDOMStorageEntries): 101 (WebCore::InspectorFrontend::didSetDOMStorageItem): 102 (WebCore::InspectorFrontend::didRemoveDOMStorageItem): 103 (WebCore::InspectorFrontend::updateDOMStorage): 104 (WebCore::InspectorFrontend::addNodesToSearchResult): 105 (WebCore::InspectorFrontend::contextMenuItemSelected): 106 (WebCore::InspectorFrontend::evaluateForTestInFrontend): 107 (WebCore::InspectorFrontend::callSimpleFunction): 108 * inspector/InspectorFrontend.h: 109 (WebCore::InspectorFrontend::scriptState): 110 * inspector/front-end/InjectedScript.js: 111 (injectedScriptConstructor): 112 (injectedScriptConstructor.): 113 * inspector/front-end/InjectedScriptAccess.js: 114 (InjectedScriptAccess._installHandler.InjectedScriptAccess.prototype.methodName.myCallback): 115 (InjectedScriptAccess._installHandler.InjectedScriptAccess.prototype.methodName): 116 (InjectedScriptAccess._installHandler): 117 * inspector/front-end/inspector.js: 118 (WebInspector.pausedScript): 119 (WebInspector.addConsoleMessage): 120 1 121 2010-02-05 Tor Arne Vestbø <tor.arne.vestbo@nokia.com> 2 122 -
trunk/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp
r54334 r54421 54 54 #include "Page.h" 55 55 #if ENABLE(DOM_STORAGE) 56 #include "SerializedScriptValue.h" 56 57 #include "Storage.h" 57 58 #include "JSStorage.h" … … 62 63 #include <runtime/JSArray.h> 63 64 #include <runtime/JSLock.h> 65 #include <wtf/RefPtr.h> 64 66 #include <wtf/Vector.h> 65 67 … … 196 198 #endif 197 199 200 JSValue JSInjectedScriptHost::reportDidDispatchOnInjectedScript(ExecState* exec, const ArgList& args) 201 { 202 if (args.size() < 3) 203 return jsUndefined(); 204 205 if (!args.at(0).isInt32()) 206 return jsUndefined(); 207 int callId = args.at(0).asInt32(); 208 209 RefPtr<SerializedScriptValue> result(SerializedScriptValue::create(exec, args.at(1))); 210 211 bool isException; 212 if (!args.at(2).getBoolean(isException)) 213 return jsUndefined(); 214 impl()->reportDidDispatchOnInjectedScript(callId, result.get(), isException); 215 return jsUndefined(); 216 } 217 198 218 InjectedScript InjectedScriptHost::injectedScriptFor(ScriptState* scriptState) 199 219 { -
trunk/WebCore/bindings/js/ScriptArray.cpp
r46490 r54421 54 54 bool ScriptArray::set(unsigned index, const ScriptObject& value) 55 55 { 56 if (value.scriptState() != m_scriptState) { 57 ASSERT_NOT_REACHED(); 58 return false; 59 } 56 60 JSLock lock(SilenceAssertionsOnly); 57 61 jsArray()->put(m_scriptState, index, value.jsObject()); -
trunk/WebCore/bindings/js/ScriptFunctionCall.cpp
r53371 r54421 43 43 namespace WebCore { 44 44 45 ScriptFunctionCall::ScriptFunctionCall( ScriptState* exec,const ScriptObject& thisObject, const String& name)46 : m_exec( exec)45 ScriptFunctionCall::ScriptFunctionCall(const ScriptObject& thisObject, const String& name) 46 : m_exec(thisObject.scriptState()) 47 47 , m_thisObject(thisObject) 48 48 , m_name(name) … … 52 52 void ScriptFunctionCall::appendArgument(const ScriptObject& argument) 53 53 { 54 if (argument.scriptState() != m_exec) { 55 ASSERT_NOT_REACHED(); 56 return; 57 } 54 58 m_arguments.append(argument.jsObject()); 55 59 } -
trunk/WebCore/bindings/js/ScriptFunctionCall.h
r51621 r54421 49 49 class ScriptFunctionCall { 50 50 public: 51 ScriptFunctionCall( ScriptState* exec,const ScriptObject& thisObject, const String& name);51 ScriptFunctionCall(const ScriptObject& thisObject, const String& name); 52 52 virtual ~ScriptFunctionCall() {}; 53 53 -
trunk/WebCore/bindings/js/ScriptObject.cpp
r51528 r54421 71 71 bool ScriptObject::set(const char* name, const ScriptObject& value) 72 72 { 73 if (value.scriptState() != m_scriptState) { 74 ASSERT_NOT_REACHED(); 75 return false; 76 } 73 77 JSLock lock(SilenceAssertionsOnly); 74 78 PutPropertySlot slot; -
trunk/WebCore/bindings/js/ScriptValue.cpp
r53766 r54421 29 29 #include "config.h" 30 30 #include "ScriptValue.h" 31 32 #include "SerializedScriptValue.h" 31 33 32 34 #include <JavaScriptCore/APICast.h> … … 82 84 } 83 85 86 PassRefPtr<SerializedScriptValue> ScriptValue::serialize(ScriptState* scriptState) 87 { 88 return SerializedScriptValue::create(scriptState, jsValue()); 89 } 90 91 ScriptValue ScriptValue::deserialize(ScriptState* scriptState, SerializedScriptValue* value) 92 { 93 return ScriptValue(value->deserialize(scriptState, scriptState->lexicalGlobalObject())); 94 } 95 84 96 } // namespace WebCore -
trunk/WebCore/bindings/js/ScriptValue.h
r53766 r54421 35 35 #include "ScriptState.h" 36 36 #include <runtime/Protect.h> 37 #include <wtf/PassRefPtr.h> 37 38 38 39 namespace WebCore { 39 40 40 41 class String; 42 class SerializedScriptValue; 41 43 42 44 class ScriptValue { … … 54 56 bool hasNoValue() const { return m_value == JSC::JSValue(); } 55 57 58 PassRefPtr<SerializedScriptValue> serialize(ScriptState*); 59 static ScriptValue deserialize(ScriptState*, SerializedScriptValue*); 60 56 61 private: 57 62 JSC::ProtectedJSValue m_value; -
trunk/WebCore/bindings/v8/ScriptArray.cpp
r46490 r54421 51 51 bool ScriptArray::set(unsigned index, const ScriptObject& value) 52 52 { 53 if (value.scriptState() != m_scriptState) { 54 ASSERT_NOT_REACHED(); 55 return false; 56 } 53 57 ScriptScope scope(m_scriptState); 54 58 v8Object()->Set(v8::Integer::New(index), value.v8Value()); -
trunk/WebCore/bindings/v8/ScriptFunctionCall.cpp
r51642 r54421 46 46 namespace WebCore { 47 47 48 ScriptFunctionCall::ScriptFunctionCall( ScriptState* scriptState,const ScriptObject& thisObject, const String& name)49 : m_scriptState( scriptState)48 ScriptFunctionCall::ScriptFunctionCall(const ScriptObject& thisObject, const String& name) 49 : m_scriptState(thisObject.scriptState()) 50 50 , m_thisObject(thisObject) 51 51 , m_name(name) … … 55 55 void ScriptFunctionCall::appendArgument(const ScriptObject& argument) 56 56 { 57 if (argument.scriptState() != m_scriptState) { 58 ASSERT_NOT_REACHED(); 59 return; 60 } 57 61 m_arguments.append(argument); 58 62 } -
trunk/WebCore/bindings/v8/ScriptFunctionCall.h
r51642 r54421 44 44 class ScriptFunctionCall { 45 45 public: 46 ScriptFunctionCall( ScriptState* scriptState,const ScriptObject& thisObject, const String& name);46 ScriptFunctionCall(const ScriptObject& thisObject, const String& name); 47 47 virtual ~ScriptFunctionCall() {}; 48 48 -
trunk/WebCore/bindings/v8/ScriptObject.cpp
r54305 r54421 68 68 bool ScriptObject::set(const char* name, const ScriptObject& value) 69 69 { 70 if (value.scriptState() != m_scriptState) { 71 ASSERT_NOT_REACHED(); 72 return false; 73 } 70 74 ScriptScope scope(m_scriptState); 71 75 v8Object()->Set(v8::String::New(name), value.v8Value()); -
trunk/WebCore/bindings/v8/ScriptState.h
r54108 r54421 39 39 namespace WebCore { 40 40 class DOMWrapperWorld; 41 class Frame; 41 42 class Node; 42 43 class Page; 43 class Frame;44 44 45 45 class ScriptState : public Noncopyable { -
trunk/WebCore/bindings/v8/ScriptValue.cpp
-
Property
svn:executable
set to
*
r41649 r54421 32 32 #include "ScriptValue.h" 33 33 34 #include "ScriptScope.h" 35 #include "SerializedScriptValue.h" 34 36 #include "V8Binding.h" 35 37 36 38 namespace WebCore { 39 40 PassRefPtr<SerializedScriptValue> ScriptValue::serialize(ScriptState* scriptState) 41 { 42 ScriptScope scope(scriptState); 43 return SerializedScriptValue::create(v8Value()); 44 } 45 46 ScriptValue ScriptValue::deserialize(ScriptState* scriptState, SerializedScriptValue* value) 47 { 48 ScriptScope scope(scriptState); 49 return ScriptValue(value->deserialize()); 50 } 37 51 38 52 bool ScriptValue::getString(String& result) const -
Property
svn:executable
set to
-
trunk/WebCore/bindings/v8/ScriptValue.h
r53766 r54421 36 36 37 37 #include <v8.h> 38 #include <wtf/PassRefPtr.h> 38 39 39 40 #ifndef NDEBUG … … 42 43 43 44 namespace WebCore { 45 46 class SerializedScriptValue; 44 47 45 48 class ScriptValue { … … 122 125 } 123 126 127 PassRefPtr<SerializedScriptValue> serialize(ScriptState*); 128 static ScriptValue deserialize(ScriptState*, SerializedScriptValue*); 129 124 130 void clear() 125 131 { -
trunk/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp
r54334 r54421 40 40 #include "Node.h" 41 41 #include "Page.h" 42 #include "SerializedScriptValue.h" 42 43 43 44 #include "V8Binding.h" … … 46 47 #include "V8Proxy.h" 47 48 #include "V8Storage.h" 49 #include <wtf/RefPtr.h> 48 50 49 51 namespace WebCore { … … 195 197 #endif 196 198 199 v8::Handle<v8::Value> V8InjectedScriptHost::reportDidDispatchOnInjectedScriptCallback(const v8::Arguments& args) 200 { 201 INC_STATS("InjectedScriptHost.reportDidDispatchOnInjectedScript()"); 202 if (args.Length() < 3) 203 return v8::Undefined(); 204 InjectedScriptHost* host = V8InjectedScriptHost::toNative(args.Holder()); 205 int callId = args[0]->ToInt32()->Value(); 206 RefPtr<SerializedScriptValue> result(SerializedScriptValue::create(args[1])); 207 bool isException = args[2]->ToBoolean()->Value(); 208 host->reportDidDispatchOnInjectedScript(callId, result.get(), isException); 209 return v8::Undefined(); 210 } 211 197 212 InjectedScript InjectedScriptHost::injectedScriptFor(ScriptState* inspectedScriptState) 198 213 { -
trunk/WebCore/inspector/InjectedScript.cpp
r54334 r54421 35 35 36 36 #include "PlatformString.h" 37 #include "SerializedScriptValue.h" 37 38 #include "ScriptFunctionCall.h" 38 39 … … 44 45 } 45 46 46 void InjectedScript::dispatch(long callId, const String& methodName, const String& arguments, bool async, String* result, bool* hadException)47 void InjectedScript::dispatch(long callId, const String& methodName, const String& arguments, bool async, RefPtr<SerializedScriptValue>* result, bool* hadException) 47 48 { 48 49 ASSERT(!hasNoValue()); 49 ScriptState* scriptState = m_injectedScriptObject.scriptState(); 50 ScriptFunctionCall function(scriptState, m_injectedScriptObject, "dispatch"); 50 ScriptFunctionCall function(m_injectedScriptObject, "dispatch"); 51 51 function.appendArgument(methodName); 52 52 function.appendArgument(arguments); … … 56 56 ScriptValue resultValue = function.call(*hadException); 57 57 if (!*hadException) 58 *result = resultValue. toString(scriptState);58 *result = resultValue.serialize(m_injectedScriptObject.scriptState()); 59 59 } 60 60 61 61 #if ENABLE(JAVASCRIPT_DEBUGGER) 62 StringInjectedScript::callFrames()62 PassRefPtr<SerializedScriptValue> InjectedScript::callFrames() 63 63 { 64 64 ASSERT(!hasNoValue()); 65 ScriptState* scriptState = m_injectedScriptObject.scriptState(); 66 ScriptFunctionCall function(scriptState, m_injectedScriptObject, "callFrames"); 65 ScriptFunctionCall function(m_injectedScriptObject, "callFrames"); 67 66 ScriptValue callFramesValue = function.call(); 68 return callFramesValue. toString(scriptState);67 return callFramesValue.serialize(m_injectedScriptObject.scriptState()); 69 68 } 70 69 #endif 71 70 72 String InjectedScript::wrapAndStringifyForConsole(ScriptValue value)71 PassRefPtr<SerializedScriptValue> InjectedScript::wrapForConsole(ScriptValue value) 73 72 { 74 73 ASSERT(!hasNoValue()); 75 ScriptState* scriptState = m_injectedScriptObject.scriptState(); 76 ScriptFunctionCall wrapFunction(scriptState, m_injectedScriptObject, "wrapAndStringifyObject"); 74 ScriptFunctionCall wrapFunction(m_injectedScriptObject, "wrapObject"); 77 75 wrapFunction.appendArgument(value); 78 76 wrapFunction.appendArgument("console"); 79 77 ScriptValue r = wrapFunction.call(); 80 if (r.hasNoValue()) 81 return ""; 82 return r.toString(scriptState); 78 return r.serialize(m_injectedScriptObject.scriptState()); 83 79 } 84 80 … … 86 82 { 87 83 ASSERT(!hasNoValue()); 88 ScriptState* scriptState = m_injectedScriptObject.scriptState(); 89 ScriptFunctionCall releaseFunction(scriptState, m_injectedScriptObject, "releaseWrapperObjectGroup"); 84 ScriptFunctionCall releaseFunction(m_injectedScriptObject, "releaseWrapperObjectGroup"); 90 85 releaseFunction.appendArgument(objectGroup); 91 86 releaseFunction.call(); -
trunk/WebCore/inspector/InjectedScript.h
r54334 r54421 35 35 #include "ScriptObject.h" 36 36 #include <wtf/Noncopyable.h> 37 #include <wtf/PassRefPtr.h> 37 38 38 39 namespace WebCore { 39 40 41 class SerializedScriptValue; 40 42 class String; 41 43 … … 47 49 bool hasNoValue() const { return m_injectedScriptObject.hasNoValue(); } 48 50 49 void dispatch(long callId, const String& methodName, const String& arguments, bool async, String* result, bool* hadException);51 void dispatch(long callId, const String& methodName, const String& arguments, bool async, RefPtr<SerializedScriptValue>* result, bool* hadException); 50 52 #if ENABLE(JAVASCRIPT_DEBUGGER) 51 StringcallFrames();53 PassRefPtr<SerializedScriptValue> callFrames(); 52 54 #endif 53 String wrapAndStringifyForConsole(ScriptValue);55 PassRefPtr<SerializedScriptValue> wrapForConsole(ScriptValue); 54 56 void releaseWrapperObjectGroup(const String&); 55 57 -
trunk/WebCore/inspector/InjectedScriptHost.cpp
r54334 r54421 46 46 #include "InspectorResource.h" 47 47 #include "Pasteboard.h" 48 #include "ScriptArray.h"49 #include "ScriptFunctionCall.h"50 48 51 49 #if ENABLE(JAVASCRIPT_DEBUGGER) && USE(JSC) … … 163 161 #endif 164 162 165 void InjectedScriptHost::reportDidDispatchOnInjectedScript(long callId, const String&result, bool isException)163 void InjectedScriptHost::reportDidDispatchOnInjectedScript(long callId, SerializedScriptValue* result, bool isException) 166 164 { 167 165 if (InspectorFrontend* frontend = inspectorFrontend()) -
trunk/WebCore/inspector/InjectedScriptHost.h
r54334 r54421 47 47 class JavaScriptCallFrame; 48 48 class Node; 49 class SerializedScriptValue; 49 50 class Storage; 50 51 … … 83 84 void selectDOMStorage(Storage* storage); 84 85 #endif 85 void reportDidDispatchOnInjectedScript(long callId, const String&result, bool isException);86 void reportDidDispatchOnInjectedScript(long callId, SerializedScriptValue* result, bool isException); 86 87 87 88 InjectedScript injectedScriptFor(ScriptState*); -
trunk/WebCore/inspector/InjectedScriptHost.idl
r53945 r54421 56 56 #endif 57 57 58 void reportDidDispatchOnInjectedScript(in long callId, in DOMStringresult, in boolean isException);58 [Custom] void reportDidDispatchOnInjectedScript(in long callId, in DOMObject result, in boolean isException); 59 59 }; 60 60 } -
trunk/WebCore/inspector/InspectorBackend.cpp
r54334 r54421 50 50 #include "Pasteboard.h" 51 51 #include "ScriptArray.h" 52 #include "S criptFunctionCall.h"52 #include "SerializedScriptValue.h" 53 53 54 54 #if ENABLE(DOM_STORAGE) … … 296 296 return; 297 297 298 Stringresult;298 RefPtr<SerializedScriptValue> result; 299 299 bool hadException = false; 300 300 injectedScript.dispatch(callId, methodName, arguments, async, &result, &hadException); 301 301 if (async) 302 302 return; // InjectedScript will return result asynchronously by means of ::reportDidDispatchOnInjectedScript. 303 frontend->didDispatchOnInjectedScript(callId, result , hadException);303 frontend->didDispatchOnInjectedScript(callId, result.get(), hadException); 304 304 } 305 305 -
trunk/WebCore/inspector/InspectorController.cpp
r54343 r54421 543 543 { 544 544 m_frontendScriptState = scriptState; 545 m_frontend.set(new InspectorFrontend(this, scriptState,webInspectorObj));545 m_frontend.set(new InspectorFrontend(this, webInspectorObj)); 546 546 releaseDOMAgent(); 547 547 m_domAgent = InspectorDOMAgent::create(m_frontend.get()); … … 1570 1570 ASSERT(scriptState); 1571 1571 InjectedScript injectedScript = m_injectedScriptHost->injectedScriptFor(scriptState); 1572 StringcallFrames = injectedScript.callFrames();1573 m_frontend->pausedScript(callFrames );1572 RefPtr<SerializedScriptValue> callFrames = injectedScript.callFrames(); 1573 m_frontend->pausedScript(callFrames.get()); 1574 1574 } 1575 1575 … … 1594 1594 ScriptObject window; 1595 1595 ScriptGlobalObject::get(scriptState, "window", window); 1596 ScriptFunctionCall function( scriptState,window, "didEvaluateForTestInFrontend");1596 ScriptFunctionCall function(window, "didEvaluateForTestInFrontend"); 1597 1597 function.appendArgument(callId); 1598 1598 function.appendArgument(jsonResult); -
trunk/WebCore/inspector/InspectorFrontend.cpp
-
Property
svn:executable
set to
*
r54334 r54421 43 43 #include "ScriptState.h" 44 44 #include "ScriptString.h" 45 #include "ScriptValue.h" 46 #include "SerializedScriptValue.h" 45 47 #include <wtf/OwnPtr.h> 46 48 … … 53 55 namespace WebCore { 54 56 55 InspectorFrontend::InspectorFrontend(InspectorController* inspectorController, Script State* scriptState, ScriptObject webInspector)57 InspectorFrontend::InspectorFrontend(InspectorController* inspectorController, ScriptObject webInspector) 56 58 : m_inspectorController(inspectorController) 57 , m_scriptState(scriptState)58 59 , m_webInspector(webInspector) 59 60 { … … 67 68 ScriptArray InspectorFrontend::newScriptArray() 68 69 { 69 return ScriptArray::createNew( m_scriptState);70 return ScriptArray::createNew(scriptState()); 70 71 } 71 72 72 73 ScriptObject InspectorFrontend::newScriptObject() 73 74 { 74 return ScriptObject::createNew( m_scriptState);75 return ScriptObject::createNew(scriptState()); 75 76 } 76 77 … … 82 83 void InspectorFrontend::populateFrontendSettings(const String& settings) 83 84 { 84 ScriptFunctionCall function(m_ scriptState, m_webInspector, "dispatch");85 ScriptFunctionCall function(m_webInspector, "dispatch"); 85 86 function.appendArgument("populateFrontendSettings"); 86 87 function.appendArgument(settings); … … 90 91 void InspectorFrontend::updateConsoleMessageExpiredCount(unsigned count) 91 92 { 92 ScriptFunctionCall function(m_ scriptState, m_webInspector, "dispatch");93 ScriptFunctionCall function(m_webInspector, "dispatch"); 93 94 function.appendArgument("updateConsoleMessageExpiredCount"); 94 95 function.appendArgument(count); … … 98 99 void InspectorFrontend::addConsoleMessage(const ScriptObject& messageObj, const Vector<ScriptString>& frames, ScriptState* scriptState, const Vector<ScriptValue> arguments, const String& message) 99 100 { 100 ScriptFunctionCall function(m_ scriptState, m_webInspector, "dispatch");101 ScriptFunctionCall function(m_webInspector, "dispatch"); 101 102 function.appendArgument("addConsoleMessage"); 102 103 function.appendArgument(messageObj); 103 104 if (!frames.isEmpty()) { 104 function.appendArgument(false);105 105 for (unsigned i = 0; i < frames.size(); ++i) 106 106 function.appendArgument(frames[i]); 107 107 } else if (!arguments.isEmpty()) { 108 function.appendArgument(true);109 108 InjectedScript injectedScript = m_inspectorController->injectedScriptHost()->injectedScriptFor(scriptState); 110 109 for (unsigned i = 0; i < arguments.size(); ++i) { 111 String s = injectedScript.wrapAndStringifyForConsole(arguments[i]); 112 function.appendArgument(s); 110 RefPtr<SerializedScriptValue> serializedValue = injectedScript.wrapForConsole(arguments[i]); 111 ScriptValue scriptValue = ScriptValue::deserialize(this->scriptState(), serializedValue.get()); 112 if (scriptValue.hasNoValue()) { 113 ASSERT_NOT_REACHED(); 114 return; 115 } 116 function.appendArgument(scriptValue); 113 117 } 114 118 } else { 115 function.appendArgument(false);116 119 function.appendArgument(message); 117 120 } … … 121 124 void InspectorFrontend::updateConsoleMessageRepeatCount(unsigned count) 122 125 { 123 ScriptFunctionCall function(m_ scriptState, m_webInspector, "dispatch");126 ScriptFunctionCall function(m_webInspector, "dispatch"); 124 127 function.appendArgument("updateConsoleMessageRepeatCount"); 125 128 function.appendArgument(count); … … 134 137 bool InspectorFrontend::updateResource(unsigned long identifier, const ScriptObject& resourceObj) 135 138 { 136 ScriptFunctionCall function(m_ scriptState, m_webInspector, "dispatch");139 ScriptFunctionCall function(m_webInspector, "dispatch"); 137 140 function.appendArgument("updateResource"); 138 141 function.appendArgument(identifier); … … 145 148 void InspectorFrontend::removeResource(unsigned long identifier) 146 149 { 147 ScriptFunctionCall function(m_ scriptState, m_webInspector, "dispatch");150 ScriptFunctionCall function(m_webInspector, "dispatch"); 148 151 function.appendArgument("removeResource"); 149 152 function.appendArgument(identifier); … … 153 156 void InspectorFrontend::didGetResourceContent(int callId, const String& content) 154 157 { 155 ScriptFunctionCall function(m_ scriptState, m_webInspector, "dispatch");158 ScriptFunctionCall function(m_webInspector, "dispatch"); 156 159 function.appendArgument("didGetResourceContent"); 157 160 function.appendArgument(callId); … … 162 165 void InspectorFrontend::updateFocusedNode(long nodeId) 163 166 { 164 ScriptFunctionCall function(m_ scriptState, m_webInspector, "dispatch");167 ScriptFunctionCall function(m_webInspector, "dispatch"); 165 168 function.appendArgument("updateFocusedNode"); 166 169 function.appendArgument(nodeId); … … 170 173 void InspectorFrontend::setAttachedWindow(bool attached) 171 174 { 172 ScriptFunctionCall function(m_ scriptState, m_webInspector, "dispatch");175 ScriptFunctionCall function(m_webInspector, "dispatch"); 173 176 function.appendArgument("setAttachedWindow"); 174 177 function.appendArgument(attached); … … 242 245 void InspectorFrontend::addRecordToTimeline(const ScriptObject& record) 243 246 { 244 ScriptFunctionCall function(m_ scriptState, m_webInspector, "dispatch");247 ScriptFunctionCall function(m_webInspector, "dispatch"); 245 248 function.appendArgument("addRecordToTimeline"); 246 249 function.appendArgument(record); … … 276 279 void InspectorFrontend::parsedScriptSource(const JSC::SourceCode& source) 277 280 { 278 ScriptFunctionCall function(m_ scriptState, m_webInspector, "dispatch");281 ScriptFunctionCall function(m_webInspector, "dispatch"); 279 282 function.appendArgument("parsedScriptSource"); 280 283 function.appendArgument(JSC::UString(JSC::UString::from(source.provider()->asID()))); … … 287 290 void InspectorFrontend::failedToParseScriptSource(const JSC::SourceCode& source, int errorLine, const JSC::UString& errorMessage) 288 291 { 289 ScriptFunctionCall function(m_ scriptState, m_webInspector, "dispatch");292 ScriptFunctionCall function(m_webInspector, "dispatch"); 290 293 function.appendArgument("failedToParseScriptSource"); 291 294 function.appendArgument(source.provider()->url()); … … 299 302 void InspectorFrontend::addProfileHeader(const ScriptValue& profile) 300 303 { 301 ScriptFunctionCall function(m_ scriptState, m_webInspector, "dispatch");304 ScriptFunctionCall function(m_webInspector, "dispatch"); 302 305 function.appendArgument("addProfileHeader"); 303 306 function.appendArgument(profile); … … 307 310 void InspectorFrontend::setRecordingProfile(bool isProfiling) 308 311 { 309 ScriptFunctionCall function(m_ scriptState, m_webInspector, "dispatch");312 ScriptFunctionCall function(m_webInspector, "dispatch"); 310 313 function.appendArgument("setRecordingProfile"); 311 314 function.appendArgument(isProfiling); … … 315 318 void InspectorFrontend::didGetProfileHeaders(int callId, const ScriptArray& headers) 316 319 { 317 ScriptFunctionCall function(m_ scriptState, m_webInspector, "dispatch");320 ScriptFunctionCall function(m_webInspector, "dispatch"); 318 321 function.appendArgument("didGetProfileHeaders"); 319 322 function.appendArgument(callId); … … 324 327 void InspectorFrontend::didGetProfile(int callId, const ScriptValue& profile) 325 328 { 326 ScriptFunctionCall function(m_ scriptState, m_webInspector, "dispatch");329 ScriptFunctionCall function(m_webInspector, "dispatch"); 327 330 function.appendArgument("didGetProfile"); 328 331 function.appendArgument(callId); … … 331 334 } 332 335 333 void InspectorFrontend::pausedScript(const String& callFrames) 334 { 335 ScriptFunctionCall function(m_scriptState, m_webInspector, "dispatch"); 336 void InspectorFrontend::pausedScript(SerializedScriptValue* callFrames) 337 { 338 ScriptValue callFramesValue = ScriptValue::deserialize(scriptState(), callFrames); 339 ScriptFunctionCall function(m_webInspector, "dispatch"); 336 340 function.appendArgument("pausedScript"); 337 function.appendArgument(callFrames );341 function.appendArgument(callFramesValue); 338 342 function.call(); 339 343 } … … 347 351 void InspectorFrontend::setDocument(const ScriptObject& root) 348 352 { 349 ScriptFunctionCall function(m_ scriptState, m_webInspector, "dispatch");353 ScriptFunctionCall function(m_webInspector, "dispatch"); 350 354 function.appendArgument("setDocument"); 351 355 function.appendArgument(root); … … 355 359 void InspectorFrontend::setDetachedRoot(const ScriptObject& root) 356 360 { 357 ScriptFunctionCall function(m_ scriptState, m_webInspector, "dispatch");361 ScriptFunctionCall function(m_webInspector, "dispatch"); 358 362 function.appendArgument("setDetachedRoot"); 359 363 function.appendArgument(root); … … 363 367 void InspectorFrontend::setChildNodes(int parentId, const ScriptArray& nodes) 364 368 { 365 ScriptFunctionCall function(m_ scriptState, m_webInspector, "dispatch");369 ScriptFunctionCall function(m_webInspector, "dispatch"); 366 370 function.appendArgument("setChildNodes"); 367 371 function.appendArgument(parentId); … … 372 376 void InspectorFrontend::childNodeCountUpdated(int id, int newValue) 373 377 { 374 ScriptFunctionCall function(m_ scriptState, m_webInspector, "dispatch");378 ScriptFunctionCall function(m_webInspector, "dispatch"); 375 379 function.appendArgument("childNodeCountUpdated"); 376 380 function.appendArgument(id); … … 381 385 void InspectorFrontend::childNodeInserted(int parentId, int prevId, const ScriptObject& node) 382 386 { 383 ScriptFunctionCall function(m_ scriptState, m_webInspector, "dispatch");387 ScriptFunctionCall function(m_webInspector, "dispatch"); 384 388 function.appendArgument("childNodeInserted"); 385 389 function.appendArgument(parentId); … … 391 395 void InspectorFrontend::childNodeRemoved(int parentId, int id) 392 396 { 393 ScriptFunctionCall function(m_ scriptState, m_webInspector, "dispatch");397 ScriptFunctionCall function(m_webInspector, "dispatch"); 394 398 function.appendArgument("childNodeRemoved"); 395 399 function.appendArgument(parentId); … … 400 404 void InspectorFrontend::attributesUpdated(int id, const ScriptArray& attributes) 401 405 { 402 ScriptFunctionCall function(m_ scriptState, m_webInspector, "dispatch");406 ScriptFunctionCall function(m_webInspector, "dispatch"); 403 407 function.appendArgument("attributesUpdated"); 404 408 function.appendArgument(id); … … 409 413 void InspectorFrontend::didRemoveNode(int callId, int nodeId) 410 414 { 411 ScriptFunctionCall function(m_ scriptState, m_webInspector, "dispatch");415 ScriptFunctionCall function(m_webInspector, "dispatch"); 412 416 function.appendArgument("didRemoveNode"); 413 417 function.appendArgument(callId); … … 418 422 void InspectorFrontend::didGetChildNodes(int callId) 419 423 { 420 ScriptFunctionCall function(m_ scriptState, m_webInspector, "dispatch");424 ScriptFunctionCall function(m_webInspector, "dispatch"); 421 425 function.appendArgument("didGetChildNodes"); 422 426 function.appendArgument(callId); … … 426 430 void InspectorFrontend::didApplyDomChange(int callId, bool success) 427 431 { 428 ScriptFunctionCall function(m_ scriptState, m_webInspector, "dispatch");432 ScriptFunctionCall function(m_webInspector, "dispatch"); 429 433 function.appendArgument("didApplyDomChange"); 430 434 function.appendArgument(callId); … … 435 439 void InspectorFrontend::didGetEventListenersForNode(int callId, int nodeId, ScriptArray& listenersArray) 436 440 { 437 ScriptFunctionCall function(m_ scriptState, m_webInspector, "dispatch");441 ScriptFunctionCall function(m_webInspector, "dispatch"); 438 442 function.appendArgument("didGetEventListenersForNode"); 439 443 function.appendArgument(callId); … … 445 449 void InspectorFrontend::didGetCookies(int callId, const ScriptArray& cookies, const String& cookiesString) 446 450 { 447 ScriptFunctionCall function(m_ scriptState, m_webInspector, "dispatch");451 ScriptFunctionCall function(m_webInspector, "dispatch"); 448 452 function.appendArgument("didGetCookies"); 449 453 function.appendArgument(callId); … … 453 457 } 454 458 455 void InspectorFrontend::didDispatchOnInjectedScript(int callId, const String&result, bool isException)456 { 457 ScriptFunctionCall function(m_ scriptState, m_webInspector, "dispatch");459 void InspectorFrontend::didDispatchOnInjectedScript(int callId, SerializedScriptValue* result, bool isException) 460 { 461 ScriptFunctionCall function(m_webInspector, "dispatch"); 458 462 function.appendArgument("didDispatchOnInjectedScript"); 459 463 function.appendArgument(callId); 460 function.appendArgument(result); 464 if (isException) 465 function.appendArgument(""); 466 else { 467 ScriptValue resultValue = ScriptValue::deserialize(scriptState(), result); 468 function.appendArgument(resultValue); 469 } 461 470 function.appendArgument(isException); 462 471 function.call(); … … 466 475 bool InspectorFrontend::addDatabase(const ScriptObject& dbObject) 467 476 { 468 ScriptFunctionCall function(m_ scriptState, m_webInspector, "dispatch");477 ScriptFunctionCall function(m_webInspector, "dispatch"); 469 478 function.appendArgument("addDatabase"); 470 479 function.appendArgument(dbObject); … … 476 485 void InspectorFrontend::selectDatabase(int databaseId) 477 486 { 478 ScriptFunctionCall function(m_ scriptState, m_webInspector, "dispatch");487 ScriptFunctionCall function(m_webInspector, "dispatch"); 479 488 function.appendArgument("selectDatabase"); 480 489 function.appendArgument(databaseId); … … 483 492 void InspectorFrontend::didGetDatabaseTableNames(int callId, const ScriptArray& tableNames) 484 493 { 485 ScriptFunctionCall function(m_ scriptState, m_webInspector, "dispatch");494 ScriptFunctionCall function(m_webInspector, "dispatch"); 486 495 function.appendArgument("didGetDatabaseTableNames"); 487 496 function.appendArgument(callId); … … 494 503 bool InspectorFrontend::addDOMStorage(const ScriptObject& domStorageObj) 495 504 { 496 ScriptFunctionCall function(m_ scriptState, m_webInspector, "dispatch");505 ScriptFunctionCall function(m_webInspector, "dispatch"); 497 506 function.appendArgument("addDOMStorage"); 498 507 function.appendArgument(domStorageObj); … … 504 513 void InspectorFrontend::selectDOMStorage(int storageId) 505 514 { 506 ScriptFunctionCall function(m_ scriptState, m_webInspector, "dispatch");515 ScriptFunctionCall function(m_webInspector, "dispatch"); 507 516 function.appendArgument("selectDOMStorage"); 508 517 function.appendArgument(storageId); … … 512 521 void InspectorFrontend::didGetDOMStorageEntries(int callId, const ScriptArray& entries) 513 522 { 514 ScriptFunctionCall function(m_ scriptState, m_webInspector, "dispatch");523 ScriptFunctionCall function(m_webInspector, "dispatch"); 515 524 function.appendArgument("didGetDOMStorageEntries"); 516 525 function.appendArgument(callId); … … 521 530 void InspectorFrontend::didSetDOMStorageItem(int callId, bool success) 522 531 { 523 ScriptFunctionCall function(m_ scriptState, m_webInspector, "dispatch");532 ScriptFunctionCall function(m_webInspector, "dispatch"); 524 533 function.appendArgument("didSetDOMStorageItem"); 525 534 function.appendArgument(callId); … … 530 539 void InspectorFrontend::didRemoveDOMStorageItem(int callId, bool success) 531 540 { 532 ScriptFunctionCall function(m_ scriptState, m_webInspector, "dispatch");541 ScriptFunctionCall function(m_webInspector, "dispatch"); 533 542 function.appendArgument("didRemoveDOMStorageItem"); 534 543 function.appendArgument(callId); … … 539 548 void InspectorFrontend::updateDOMStorage(int storageId) 540 549 { 541 ScriptFunctionCall function(m_ scriptState, m_webInspector, "dispatch");550 ScriptFunctionCall function(m_webInspector, "dispatch"); 542 551 function.appendArgument("updateDOMStorage"); 543 552 function.appendArgument(storageId); … … 548 557 void InspectorFrontend::addNodesToSearchResult(const String& nodeIds) 549 558 { 550 ScriptFunctionCall function(m_ scriptState, m_webInspector, "dispatch");559 ScriptFunctionCall function(m_webInspector, "dispatch"); 551 560 function.appendArgument("addNodesToSearchResult"); 552 561 function.appendArgument(nodeIds); … … 556 565 void InspectorFrontend::contextMenuItemSelected(int itemId) 557 566 { 558 ScriptFunctionCall function(m_ scriptState, m_webInspector, "dispatch");567 ScriptFunctionCall function(m_webInspector, "dispatch"); 559 568 function.appendArgument("contextMenuItemSelected"); 560 569 function.appendArgument(itemId); … … 569 578 void InspectorFrontend::evaluateForTestInFrontend(int callId, const String& script) 570 579 { 571 ScriptFunctionCall function(m_ scriptState, m_webInspector, "dispatch");580 ScriptFunctionCall function(m_webInspector, "dispatch"); 572 581 function.appendArgument("evaluateForTestInFrontend"); 573 582 function.appendArgument(callId); … … 578 587 void InspectorFrontend::callSimpleFunction(const String& functionName) 579 588 { 580 ScriptFunctionCall function(m_ scriptState, m_webInspector, "dispatch");589 ScriptFunctionCall function(m_webInspector, "dispatch"); 581 590 function.appendArgument(functionName); 582 591 function.call(); -
Property
svn:executable
set to
-
trunk/WebCore/inspector/InspectorFrontend.h
r54329 r54421 51 51 class InspectorResource; 52 52 class Node; 53 class ScriptFunctionCall;54 53 class ScriptString; 54 class SerializedScriptValue; 55 55 class Storage; 56 56 57 57 class InspectorFrontend : public Noncopyable { 58 58 public: 59 InspectorFrontend(InspectorController* inspectorController, Script State*, ScriptObject webInspector);59 InspectorFrontend(InspectorController* inspectorController, ScriptObject webInspector); 60 60 ~InspectorFrontend(); 61 61 … … 97 97 void didGetProfileHeaders(int callId, const ScriptArray& headers); 98 98 void didGetProfile(int callId, const ScriptValue& profile); 99 void pausedScript( const String&callFrames);99 void pausedScript(SerializedScriptValue* callFrames); 100 100 void resumedScript(); 101 101 #endif … … 133 133 134 134 void didGetCookies(int callId, const ScriptArray& cookies, const String& cookiesString); 135 void didDispatchOnInjectedScript(int callId, const String&result, bool isException);135 void didDispatchOnInjectedScript(int callId, SerializedScriptValue* result, bool isException); 136 136 137 137 void addNodesToSearchResult(const String& nodeIds); … … 140 140 void contextMenuCleared(); 141 141 142 ScriptState* scriptState() const { return m_ scriptState; }142 ScriptState* scriptState() const { return m_webInspector.scriptState(); } 143 143 144 144 void evaluateForTestInFrontend(int callId, const String& script); … … 146 146 void callSimpleFunction(const String& functionName); 147 147 InspectorController* m_inspectorController; 148 ScriptState* m_scriptState;149 148 ScriptObject m_webInspector; 150 149 }; -
trunk/WebCore/inspector/front-end/InjectedScript.js
r54334 r54421 53 53 }; 54 54 55 InjectedScript.wrapAndStringifyObject = function(object, objectGroupName) {56 var r = InjectedScript.wrapObject(object, objectGroupName);57 return InjectedScript.JSON.stringify(r);58 };59 60 55 InjectedScript.unwrapObject = function(objectId) { 61 56 return InjectedScript.idToWrappedObject[objectId]; … … 86 81 InjectedScript.dispatch = function(methodName, args, callId) 87 82 { 88 var argsArray = InjectedScript.JSON.parse(args);83 var argsArray = eval("(" + args + ")"); 89 84 if (callId) 90 85 argsArray.splice(0, 0, callId); // Methods that run asynchronously have a call back id parameter. … … 94 89 result = null; 95 90 } 96 return InjectedScript.JSON.stringify(result);91 return result; 97 92 } 98 93 … … 936 931 callFrame = callFrame.caller; 937 932 } while (callFrame); 938 return InjectedScript.JSON.stringify(result);933 return result; 939 934 } 940 935 … … 1221 1216 } 1222 1217 } 1223 InjectedScriptHost.reportDidDispatchOnInjectedScript(callId, InjectedScript.JSON.stringify(result), false);1218 InjectedScriptHost.reportDidDispatchOnInjectedScript(callId, result, false); 1224 1219 } 1225 1220 1226 1221 function errorCallback(tx, error) 1227 1222 { 1228 InjectedScriptHost.reportDidDispatchOnInjectedScript(callId, InjectedScript.JSON.stringify(error), false);1223 InjectedScriptHost.reportDidDispatchOnInjectedScript(callId, error, false); 1229 1224 } 1230 1225 … … 1340 1335 } 1341 1336 1342 InjectedScript.JSON = {};1343 1344 // The following code is a slightly modified version of http://www.json.org/json2.js last modified on 2009-09-29.1345 // Compared to the original version it ignores toJSON method on objects it serializes.1346 // It's done to avoid weird behaviour when inspected application provides it's own implementation1347 // of toJSON methods to the Object and other intrinsic types. We use InjectedScript.JSON implementation1348 // instead of global JSON object since it can have been modified by the inspected code.1349 (function() {1350 1351 function f(n) {1352 // Format integers to have at least two digits.1353 return n < 10 ? '0' + n : n;1354 }1355 1356 var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,1357 escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,1358 gap,1359 indent,1360 meta = { // table of character substitutions1361 '\b': '\\b',1362 '\t': '\\t',1363 '\n': '\\n',1364 '\f': '\\f',1365 '\r': '\\r',1366 '"' : '\\"',1367 '\\': '\\\\'1368 },1369 rep;1370 1371 1372 function quote(string) {1373 1374 // If the string contains no control characters, no quote characters, and no1375 // backslash characters, then we can safely slap some quotes around it.1376 // Otherwise we must also replace the offending characters with safe escape1377 // sequences.1378 1379 escapable.lastIndex = 0;1380 return escapable.test(string) ?1381 '"' + string.replace(escapable, function (a) {1382 var c = meta[a];1383 return typeof c === 'string' ? c :1384 '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);1385 }) + '"' :1386 '"' + string + '"';1387 }1388 1389 1390 function str(key, holder) {1391 1392 // Produce a string from holder[key].1393 1394 var i, // The loop counter.1395 k, // The member key.1396 v, // The member value.1397 length,1398 mind = gap,1399 partial,1400 value = holder[key];1401 1402 // If we were called with a replacer function, then call the replacer to1403 // obtain a replacement value.1404 1405 if (typeof rep === 'function') {1406 value = rep.call(holder, key, value);1407 }1408 1409 // What happens next depends on the value's type.1410 1411 switch (typeof value) {1412 case 'string':1413 return quote(value);1414 1415 case 'number':1416 1417 // JSON numbers must be finite. Encode non-finite numbers as null.1418 1419 return isFinite(value) ? String(value) : 'null';1420 1421 case 'boolean':1422 case 'null':1423 1424 // If the value is a boolean or null, convert it to a string. Note:1425 // typeof null does not produce 'null'. The case is included here in1426 // the remote chance that this gets fixed someday.1427 1428 return String(value);1429 1430 // If the type is 'object', we might be dealing with an object or an array or1431 // null.1432 1433 case 'object':1434 1435 // Due to a specification blunder in ECMAScript, typeof null is 'object',1436 // so watch out for that case.1437 1438 if (!value) {1439 return 'null';1440 }1441 1442 // Make an array to hold the partial results of stringifying this object value.1443 1444 gap += indent;1445 partial = [];1446 1447 // Is the value an array?1448 1449 if (Object.prototype.toString.apply(value) === '[object Array]') {1450 1451 // The value is an array. Stringify every element. Use null as a placeholder1452 // for non-JSON values.1453 1454 length = value.length;1455 for (i = 0; i < length; i += 1) {1456 partial[i] = str(i, value) || 'null';1457 }1458 1459 // Join all of the elements together, separated with commas, and wrap them in1460 // brackets.1461 1462 v = partial.length === 0 ? '[]' :1463 gap ? '[\n' + gap +1464 partial.join(',\n' + gap) + '\n' +1465 mind + ']' :1466 '[' + partial.join(',') + ']';1467 gap = mind;1468 return v;1469 }1470 1471 // If the replacer is an array, use it to select the members to be stringified.1472 1473 if (rep && typeof rep === 'object') {1474 length = rep.length;1475 for (i = 0; i < length; i += 1) {1476 k = rep[i];1477 if (typeof k === 'string') {1478 v = str(k, value);1479 if (v) {1480 partial.push(quote(k) + (gap ? ': ' : ':') + v);1481 }1482 }1483 }1484 } else {1485 1486 // Otherwise, iterate through all of the keys in the object.1487 1488 for (k in value) {1489 if (Object.hasOwnProperty.call(value, k)) {1490 v = str(k, value);1491 if (v) {1492 partial.push(quote(k) + (gap ? ': ' : ':') + v);1493 }1494 }1495 }1496 }1497 1498 // Join all of the member texts together, separated with commas,1499 // and wrap them in braces.1500 1501 v = partial.length === 0 ? '{}' :1502 gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' +1503 mind + '}' : '{' + partial.join(',') + '}';1504 gap = mind;1505 return v;1506 }1507 }1508 1509 InjectedScript.JSON.stringify = function (value, replacer, space) {1510 1511 // The stringify method takes a value and an optional replacer, and an optional1512 // space parameter, and returns a JSON text. The replacer can be a function1513 // that can replace values, or an array of strings that will select the keys.1514 // A default replacer method can be provided. Use of the space parameter can1515 // produce text that is more easily readable.1516 1517 var i;1518 gap = '';1519 indent = '';1520 1521 // If the space parameter is a number, make an indent string containing that1522 // many spaces.1523 1524 if (typeof space === 'number') {1525 for (i = 0; i < space; i += 1) {1526 indent += ' ';1527 }1528 1529 // If the space parameter is a string, it will be used as the indent string.1530 1531 } else if (typeof space === 'string') {1532 indent = space;1533 }1534 1535 // If there is a replacer, it must be a function or an array.1536 // Otherwise, throw an error.1537 1538 rep = replacer;1539 if (replacer && typeof replacer !== 'function' &&1540 (typeof replacer !== 'object' ||1541 typeof replacer.length !== 'number')) {1542 throw new Error('JSON.stringify');1543 }1544 1545 // Make a fake root object containing our value under the key of ''.1546 // Return the result of stringifying the value.1547 1548 return str('', {'': value});1549 };1550 1551 1552 // If the JSON object does not yet have a parse method, give it one.1553 1554 InjectedScript.JSON.parse = function (text, reviver) {1555 1556 // The parse method takes a text and an optional reviver function, and returns1557 // a JavaScript value if the text is a valid JSON text.1558 1559 var j;1560 1561 function walk(holder, key) {1562 1563 // The walk method is used to recursively walk the resulting structure so1564 // that modifications can be made.1565 1566 var k, v, value = holder[key];1567 if (value && typeof value === 'object') {1568 for (k in value) {1569 if (Object.hasOwnProperty.call(value, k)) {1570 v = walk(value, k);1571 if (v !== undefined) {1572 value[k] = v;1573 } else {1574 delete value[k];1575 }1576 }1577 }1578 }1579 return reviver.call(holder, key, value);1580 }1581 1582 1583 // Parsing happens in four stages. In the first stage, we replace certain1584 // Unicode characters with escape sequences. JavaScript handles many characters1585 // incorrectly, either silently deleting them, or treating them as line endings.1586 1587 cx.lastIndex = 0;1588 if (cx.test(text)) {1589 text = text.replace(cx, function (a) {1590 return '\\u' +1591 ('0000' + a.charCodeAt(0).toString(16)).slice(-4);1592 });1593 }1594 1595 // In the second stage, we run the text against regular expressions that look1596 // for non-JSON patterns. We are especially concerned with '()' and 'new'1597 // because they can cause invocation, and '=' because it can cause mutation.1598 // But just to be safe, we want to reject all unexpected forms.1599 1600 // We split the second stage into 4 regexp operations in order to work around1601 // crippling inefficiencies in IE's and Safari's regexp engines. First we1602 // replace the JSON backslash pairs with '@' (a non-JSON character). Second, we1603 // replace all simple value tokens with ']' characters. Third, we delete all1604 // open brackets that follow a colon or comma or that begin the text. Finally,1605 // we look to see that the remaining characters are only whitespace or ']' or1606 // ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.1607 1608 if (/^[\],:{}\s]*$/.1609 test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').1610 replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').1611 replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {1612 1613 // In the third stage we use the eval function to compile the text into a1614 // JavaScript structure. The '{' operator is subject to a syntactic ambiguity1615 // in JavaScript: it can begin a block or an object literal. We wrap the text1616 // in parens to eliminate the ambiguity.1617 1618 j = eval('(' + text + ')');1619 1620 // In the optional fourth stage, we recursively walk the new structure, passing1621 // each name/value pair to a reviver function for possible transformation.1622 1623 return typeof reviver === 'function' ?1624 walk({'': j}, '') : j;1625 }1626 1627 // If the text is not JSON parseable, then a SyntaxError is thrown.1628 1629 throw new SyntaxError('JSON.parse');1630 };1631 }());1632 1633 1337 return InjectedScript; 1634 1338 }); -
trunk/WebCore/inspector/front-end/InjectedScriptAccess.js
r53766 r54421 57 57 { 58 58 if (!isException) 59 callback( JSON.parse(result));59 callback(result); 60 60 else 61 61 WebInspector.console.addMessage(new WebInspector.ConsoleTextMessage("Error dispatching: " + methodName)); -
trunk/WebCore/inspector/front-end/inspector.js
r54351 r54421 1204 1204 WebInspector.pausedScript = function(callFrames) 1205 1205 { 1206 callFrames = JSON.parse(callFrames);1207 1206 this.panels.scripts.debuggerPaused(callFrames); 1208 1207 } … … 1261 1260 } 1262 1261 1263 WebInspector.addConsoleMessage = function(payload, argumentsStringified,opt_args)1262 WebInspector.addConsoleMessage = function(payload, opt_args) 1264 1263 { 1265 1264 var consoleMessage = new WebInspector.ConsoleMessage( … … 1271 1270 payload.groupLevel, 1272 1271 payload.repeatCount); 1273 var parsedArguments = []; 1274 for (var i = 2; i < arguments.length; i++) { 1275 if (argumentsStringified) 1276 parsedArguments.push(JSON.parse(arguments[i])); 1277 else 1278 parsedArguments.push(arguments[i]); 1279 } 1280 consoleMessage.setMessageBody(parsedArguments); 1272 consoleMessage.setMessageBody(Array.prototype.slice.call(arguments, 1)); 1281 1273 this.console.addMessage(consoleMessage); 1282 1274 } -
trunk/WebKit/qt/Api/qwebelement.cpp
r51308 r54421 39 39 #include "PropertyNameArray.h" 40 40 #include "RenderImage.h" 41 #include "ScriptFunctionCall.h"42 41 #include "StaticNodeList.h" 43 42 #include "qt_runtime.h" -
trunk/WebKit/qt/ChangeLog
r54420 r54421 1 2010-02-05 Yury Semikhatsky <yurys@chromium.org> 2 3 Reviewed by Pavel Feldman. 4 5 Remove unused inmport of ScriptFunctionCall.h 6 7 https://bugs.webkit.org/show_bug.cgi?id=33592 8 9 * Api/qwebelement.cpp: 10 1 11 2010-02-05 Tor Arne Vestbø <tor.arne.vestbo@nokia.com> 2 12
Note: See TracChangeset
for help on using the changeset viewer.