Changeset 92471 in webkit
- Timestamp:
- Aug 5, 2011 2:37:02 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r92470 r92471 1 2011-08-05 Yury Semikhatsky <yurys@chromium.org> 2 3 Web Inspector: constrain maximum depth for returnByValue objects 4 https://bugs.webkit.org/show_bug.cgi?id=65761 5 6 Reviewed by Pavel Feldman. 7 8 * inspector/protocol/runtime-agent-expected.txt: 9 * inspector/protocol/runtime-agent.html: 10 1 11 2011-08-05 Zoltan Horvath <zoltan@webkit.org> 2 12 -
trunk/LayoutTests/inspector/protocol/runtime-agent-expected.txt
r91750 r92471 74 74 value : "callFunctionOn function works fine" 75 75 } 76 } 77 id : <number> 78 } 79 80 ----------------------------------------------------------- 81 RuntimeAgent.evaluate("var o = {n:2011, b:true, s:\"a string\", o:{n:2011}}; o","test",false,true,null,true) 82 83 request: 84 { 85 method : "Runtime.evaluate" 86 params : { 87 expression : "var o = {n:2011, b:true, s:"a string", o:{n:2011}}; o" 88 objectGroup : "test" 89 includeCommandLineAPI : false 90 doNotPauseOnExceptions : true 91 returnByValue : true 92 } 93 id : <number> 94 } 95 96 response: 97 { 98 result : { 99 result : { 100 type : "object" 101 value : { 102 n : 2011 103 b : true 104 s : "a string" 105 o : { 106 n : 2011 107 } 108 } 109 } 110 } 111 id : <number> 112 } 113 114 ----------------------------------------------------------- 115 RuntimeAgent.evaluate("var x = {}; x.self = x; x","test",false,true,null,true) 116 117 request: 118 { 119 method : "Runtime.evaluate" 120 params : { 121 expression : "var x = {}; x.self = x; x" 122 objectGroup : "test" 123 includeCommandLineAPI : false 124 doNotPauseOnExceptions : true 125 returnByValue : true 126 } 127 id : <number> 128 } 129 130 response: 131 { 132 error : { 133 code : -32000 134 message : "Object has too long reference chain(must not be longer than 1000)" 135 } 136 id : <number> 137 } 138 139 ----------------------------------------------------------- 140 RuntimeAgent.callFunctionOn(<string>,"function() { this.self = this; return this; }",null,true) 141 142 request: 143 { 144 method : "Runtime.callFunctionOn" 145 params : { 146 objectId : <string> 147 functionDeclaration : "function() { this.self = this; return this; }" 148 returnByValue : true 149 } 150 id : <number> 151 } 152 153 response: 154 { 155 error : { 156 code : -32000 157 message : "Object has too long reference chain(must not be longer than 1000)" 76 158 } 77 159 id : <number> … … 100 182 type : "string" 101 183 value : "callFunctionOn function works fine" 184 } 185 } 186 { 187 name : "self" 188 value : { 189 type : "object" 190 objectId : <string> 191 className : <string> 192 description : "TestObject" 102 193 } 103 194 } -
trunk/LayoutTests/inspector/protocol/runtime-agent.html
r91750 r92471 21 21 ["RuntimeAgent", "evaluate", 'testObject', 'test'], 22 22 ["RuntimeAgent", "callFunctionOn", result.objectId, 'function() { this.assignedByCallFunctionOn = "callFunctionOn function works fine"; return this.assignedByCallFunctionOn; }'], 23 24 // test returnByValue: 25 ["RuntimeAgent", "evaluate", 'var o = {n:2011, b:true, s:"a string", o:{n:2011}}; o', 'test', false, true, undefined, true], 26 ["RuntimeAgent", "evaluate", 'var x = {}; x.self = x; x', 'test', false, true, undefined, true], 27 ["RuntimeAgent", "callFunctionOn", result.objectId, 'function() { this.self = this; return this; }', undefined, true], 28 23 29 ["RuntimeAgent", "getProperties", result.objectId, false], 24 30 ["RuntimeAgent", "releaseObject", result.objectId], -
trunk/Source/WebCore/ChangeLog
r92469 r92471 1 2011-08-05 Yury Semikhatsky <yurys@chromium.org> 2 3 Web Inspector: constrain maximum depth for returnByValue objects 4 https://bugs.webkit.org/show_bug.cgi?id=65761 5 6 Set maximum depth to 20 for objects returned by value as a result of evaluations. 7 8 Reviewed by Pavel Feldman. 9 10 * bindings/js/ScriptValue.cpp: 11 (WebCore::jsToInspectorValue): 12 (WebCore::ScriptValue::toInspectorValue): 13 * bindings/v8/ScriptValue.cpp: 14 (WebCore::v8ToInspectorValue): 15 (WebCore::ScriptValue::toInspectorValue): 16 * inspector/InjectedScript.cpp: 17 (WebCore::InjectedScript::makeCall): 18 * inspector/InspectorValues.h: 19 1 20 2011-08-05 Mark Pilgrim <pilgrim@chromium.org> 2 21 -
trunk/Source/WebCore/bindings/js/ScriptValue.cpp
r83645 r92471 112 112 113 113 #if ENABLE(INSPECTOR) 114 static PassRefPtr<InspectorValue> jsToInspectorValue(ScriptState* scriptState, JSValue value )114 static PassRefPtr<InspectorValue> jsToInspectorValue(ScriptState* scriptState, JSValue value, int maxDepth) 115 115 { 116 116 if (!value) { … … 118 118 return 0; 119 119 } 120 121 if (!maxDepth) 122 return 0; 123 maxDepth--; 124 120 125 if (value.isNull() || value.isUndefined()) 121 126 return InspectorValue::null(); … … 135 140 for (unsigned i = 0; i < length; i++) { 136 141 JSValue element = array->getIndex(i); 137 RefPtr<InspectorValue> elementValue = jsToInspectorValue(scriptState, element); 138 if (!elementValue) { 139 ASSERT_NOT_REACHED(); 140 elementValue = InspectorValue::null(); 141 } 142 RefPtr<InspectorValue> elementValue = jsToInspectorValue(scriptState, element, maxDepth); 143 if (!elementValue) 144 return 0; 142 145 inspectorArray->pushValue(elementValue); 143 146 } … … 151 154 const Identifier& name = propertyNames[i]; 152 155 JSValue propertyValue = object->get(scriptState, name); 153 RefPtr<InspectorValue> inspectorValue = jsToInspectorValue(scriptState, propertyValue); 154 if (!inspectorValue) { 155 ASSERT_NOT_REACHED(); 156 inspectorValue = InspectorValue::null(); 157 } 156 RefPtr<InspectorValue> inspectorValue = jsToInspectorValue(scriptState, propertyValue, maxDepth); 157 if (!inspectorValue) 158 return 0; 158 159 inspectorObject->setValue(String(name.characters(), name.length()), inspectorValue); 159 160 } … … 166 167 PassRefPtr<InspectorValue> ScriptValue::toInspectorValue(ScriptState* scriptState) const 167 168 { 168 return jsToInspectorValue(scriptState, m_value.get() );169 return jsToInspectorValue(scriptState, m_value.get(), InspectorValue::maxDepth); 169 170 } 170 171 #endif // ENABLE(INSPECTOR) -
trunk/Source/WebCore/bindings/v8/ScriptValue.cpp
r82664 r92471 74 74 75 75 #if ENABLE(INSPECTOR) 76 static PassRefPtr<InspectorValue> v8ToInspectorValue(v8::Handle<v8::Value> value )76 static PassRefPtr<InspectorValue> v8ToInspectorValue(v8::Handle<v8::Value> value, int maxDepth) 77 77 { 78 78 if (value.IsEmpty()) { … … 80 80 return 0; 81 81 } 82 83 if (!maxDepth) 84 return 0; 85 maxDepth--; 86 82 87 if (value->IsNull() || value->IsUndefined()) 83 88 return InspectorValue::null(); … … 94 99 for (uint32_t i = 0; i < length; i++) { 95 100 v8::Local<v8::Value> value = array->Get(v8::Int32::New(i)); 96 RefPtr<InspectorValue> element = v8ToInspectorValue(value); 97 if (!element) { 98 ASSERT_NOT_REACHED(); 99 element = InspectorValue::null(); 100 } 101 RefPtr<InspectorValue> element = v8ToInspectorValue(value, maxDepth); 102 if (!element) 103 return 0; 101 104 inspectorArray->pushValue(element); 102 105 } … … 113 116 if (name->IsString() && !object->HasRealNamedProperty(v8::Handle<v8::String>::Cast(name))) 114 117 continue; 115 RefPtr<InspectorValue> propertyValue = v8ToInspectorValue(object->Get(name)); 116 if (!propertyValue) { 117 ASSERT_NOT_REACHED(); 118 continue; 119 } 118 RefPtr<InspectorValue> propertyValue = v8ToInspectorValue(object->Get(name), maxDepth); 119 if (!propertyValue) 120 return 0; 120 121 inspectorObject->setValue(toWebCoreStringWithNullCheck(name), propertyValue); 121 122 } … … 131 132 // v8::Object::GetPropertyNames() expects current context to be not null. 132 133 v8::Context::Scope contextScope(scriptState->context()); 133 return v8ToInspectorValue(m_value );134 return v8ToInspectorValue(m_value, InspectorValue::maxDepth); 134 135 } 135 136 #endif -
trunk/Source/WebCore/inspector/InjectedScript.cpp
r92377 r92471 193 193 194 194 ASSERT(!hadException); 195 if (!hadException) 195 if (!hadException) { 196 196 *result = resultValue.toInspectorValue(m_injectedScriptObject.scriptState()); 197 else 197 if (!*result) 198 *result = InspectorString::create(String::format("Object has too long reference chain(must not be longer than %d)", InspectorValue::maxDepth)); 199 } else 198 200 *result = InspectorString::create("Exception while making a call."); 199 201 } -
trunk/Source/WebCore/inspector/InspectorValues.h
r77489 r92471 49 49 class InspectorValue : public RefCounted<InspectorValue> { 50 50 public: 51 static const int maxDepth = 1000; 52 51 53 InspectorValue() : m_type(TypeNull) { } 52 54 virtual ~InspectorValue() { }
Note: See TracChangeset
for help on using the changeset viewer.