Changeset 57207 in webkit
- Timestamp:
- Apr 7, 2010 7:04:56 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r57206 r57207 1 2010-04-07 Vitaly Repeshko <vitalyr@chromium.org> 2 3 Reviewed by Yury Semikhatsky. 4 5 [V8] Throw exception in SerializedScriptValue on input errors 6 https://bugs.webkit.org/show_bug.cgi?id=37160 7 8 When cycles are detected SerializedScriptValue should throw 9 NOT_SUPPORTED_ERR. See 10 http://www.whatwg.org/specs/web-apps/2009-10-27/multipage/urls.html#structured-clone 11 12 * bindings/scripts/CodeGeneratorV8.pm: Custom processing for 13 function arguments of type SerializedScriptValue. 14 15 * bindings/v8/SerializedScriptValue.cpp: 16 (WebCore::SerializedScriptValue::SerializedScriptValue): 17 * bindings/v8/SerializedScriptValue.h: 18 (WebCore::SerializedScriptValue::create): Added a constructor 19 function with an extra paratemer to check whether an exception was 20 thrown. 21 22 SerializedScriptValue::create callers updated to check for 23 exceptions: 24 * bindings/v8/custom/V8DOMWindowCustom.cpp: 25 (WebCore::V8DOMWindow::postMessageCallback): 26 * bindings/v8/custom/V8DedicatedWorkerContextCustom.cpp: 27 (WebCore::V8DedicatedWorkerContext::postMessageCallback): 28 * bindings/v8/custom/V8HistoryCustom.cpp: 29 (WebCore::V8History::pushStateCallback): 30 (WebCore::V8History::replaceStateCallback): 31 * bindings/v8/custom/V8MessagePortCustom.cpp: 32 (WebCore::V8MessagePort::postMessageCallback): 33 * bindings/v8/custom/V8PopStateEventCustom.cpp: 34 (WebCore::V8PopStateEvent::initPopStateEventCallback): 35 * bindings/v8/custom/V8WorkerCustom.cpp: 36 (WebCore::V8Worker::postMessageCallback): 37 1 38 2010-04-07 Alexander Pavlov <apavlov@chromium.org> 2 39 -
trunk/WebCore/bindings/scripts/CodeGeneratorV8.pm
r57134 r57207 1102 1102 } 1103 1103 1104 if (BasicTypeCanFailConversion($parameter)) { 1104 if ($parameter->type eq "SerializedScriptValue") { 1105 $implIncludes{"SerializedScriptValue.h"} = 1; 1106 push(@implContentDecls, " bool ${parameterName}DidThrow = false;\n"); 1107 } elsif (BasicTypeCanFailConversion($parameter)) { 1105 1108 push(@implContentDecls, " bool ${parameterName}Ok;\n"); 1106 1109 } 1107 1110 1108 1111 push(@implContentDecls, " " . GetNativeTypeFromSignature($parameter, $paramIndex) . " $parameterName = "); 1109 push(@implContentDecls, JSValueToNative($parameter, "args[$paramIndex]", 1110 BasicTypeCanFailConversion($parameter) ? "${parameterName}Ok" : undef) . ";\n"); 1112 1113 if ($parameter->type eq "SerializedScriptValue") { 1114 push(@implContentDecls, "SerializedScriptValue::create(args[$paramIndex], ${parameterName}DidThrow);\n"); 1115 push(@implContentDecls, " if (${parameterName}DidThrow)\n return v8::Undefined();\n"); 1116 } else { 1117 push(@implContentDecls, JSValueToNative($parameter, "args[$paramIndex]", 1118 BasicTypeCanFailConversion($parameter) ? "${parameterName}Ok" : undef) . ";\n"); 1119 } 1111 1120 1112 1121 if (TypeCanFailConversion($parameter)) { … … 2485 2494 } 2486 2495 2487 if ($type eq "SerializedScriptValue") { 2488 $implIncludes{"SerializedScriptValue.h"} = 1; 2489 return "SerializedScriptValue::create($value)"; 2490 } 2496 die "Unexpected SerializedScriptValue" if $type eq "SerializedScriptValue"; 2491 2497 2492 2498 if ($type eq "DOMObject") { -
trunk/WebCore/bindings/v8/SerializedScriptValue.cpp
r57145 r57207 37 37 #include "SharedBuffer.h" 38 38 #include "V8ImageData.h" 39 #include "V8Proxy.h" 39 40 40 41 #include <v8.h> … … 870 871 } // namespace 871 872 872 SerializedScriptValue::SerializedScriptValue(v8::Handle<v8::Value> value )873 SerializedScriptValue::SerializedScriptValue(v8::Handle<v8::Value> value, bool& didThrow) 873 874 { 875 didThrow = false; 874 876 Writer writer; 875 877 Serializer serializer(writer); 876 878 if (!serializer.serialize(value)) { 877 // FIXME: throw exception 879 throwError(NOT_SUPPORTED_ERR); 880 didThrow = true; 878 881 return; 879 882 } -
trunk/WebCore/bindings/v8/SerializedScriptValue.h
r56903 r57207 57 57 static PassRefPtr<SerializedScriptValue> create(v8::Handle<v8::Value> value) 58 58 { 59 return adoptRef(new SerializedScriptValue(value)); 59 bool didThrow; 60 return adoptRef(new SerializedScriptValue(value, didThrow)); 61 } 62 63 // Creates a serialized representation of the given V8 value. 64 // 65 // If a serialization error occurs (e.g., cyclic input value) this 66 // function returns an empty representation, schedules a V8 exception to 67 // be thrown using v8::ThrowException(), and sets |didThrow|. In this case 68 // the caller must not invoke any V8 operations until control returns to 69 // V8. When serialization is successful, |didThrow| is false. 70 static PassRefPtr<SerializedScriptValue> create(v8::Handle<v8::Value> value, bool& didThrow) 71 { 72 return adoptRef(new SerializedScriptValue(value, didThrow)); 60 73 } 61 74 … … 100 113 SerializedScriptValue() { } 101 114 102 explicit SerializedScriptValue(v8::Handle<v8::Value>);115 SerializedScriptValue(v8::Handle<v8::Value>, bool& didThrow); 103 116 104 117 SerializedScriptValue(String data, StringDataMode mode); -
trunk/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp
r56166 r57207 321 321 ASSERT(source->frame()); 322 322 323 v8::TryCatch tryCatch; 324 RefPtr<SerializedScriptValue> message = SerializedScriptValue::create(args[0]); 323 bool didThrow = false; 324 RefPtr<SerializedScriptValue> message = SerializedScriptValue::create(args[0], didThrow); 325 if (didThrow) 326 return v8::Undefined(); 327 325 328 MessagePortArray portArray; 326 329 String targetOrigin; … … 330 333 // or 331 334 // postMessage(message, targetOrigin); 335 v8::TryCatch tryCatch; 332 336 if (args.Length() > 2) { 333 337 if (!getMessagePortArray(args[1], portArray)) -
trunk/WebCore/bindings/v8/custom/V8DedicatedWorkerContextCustom.cpp
r53586 r57207 47 47 INC_STATS(L"DOM.DedicatedWorkerContext.postMessage"); 48 48 DedicatedWorkerContext* workerContext = V8DedicatedWorkerContext::toNative(args.Holder()); 49 RefPtr<SerializedScriptValue> message = SerializedScriptValue::create(args[0]); 49 bool didThrow = false; 50 RefPtr<SerializedScriptValue> message = SerializedScriptValue::create(args[0], didThrow); 51 if (didThrow) 52 return v8::Undefined(); 50 53 MessagePortArray portArray; 51 54 if (args.Length() > 1) { -
trunk/WebCore/bindings/v8/custom/V8HistoryCustom.cpp
r57004 r57207 44 44 v8::Handle<v8::Value> V8History::pushStateCallback(const v8::Arguments& args) 45 45 { 46 RefPtr<SerializedScriptValue> historyState = SerializedScriptValue::create(args[0]); 46 bool didThrow = false; 47 RefPtr<SerializedScriptValue> historyState = SerializedScriptValue::create(args[0], didThrow); 48 if (didThrow) 49 return v8::Undefined(); 47 50 48 51 v8::TryCatch tryCatch; … … 65 68 v8::Handle<v8::Value> V8History::replaceStateCallback(const v8::Arguments& args) 66 69 { 67 RefPtr<SerializedScriptValue> historyState = SerializedScriptValue::create(args[0]); 70 bool didThrow = false; 71 RefPtr<SerializedScriptValue> historyState = SerializedScriptValue::create(args[0], didThrow); 72 if (didThrow) 73 return v8::Undefined(); 68 74 69 75 v8::TryCatch tryCatch; -
trunk/WebCore/bindings/v8/custom/V8MessagePortCustom.cpp
r55096 r57207 47 47 INC_STATS("DOM.MessagePort.postMessage"); 48 48 MessagePort* messagePort = V8MessagePort::toNative(args.Holder()); 49 RefPtr<SerializedScriptValue> message = SerializedScriptValue::create(args[0]); 49 bool didThrow = false; 50 RefPtr<SerializedScriptValue> message = SerializedScriptValue::create(args[0], didThrow); 51 if (didThrow) 52 return v8::Undefined(); 50 53 MessagePortArray portArray; 51 54 if (args.Length() > 1) { -
trunk/WebCore/bindings/v8/custom/V8PopStateEventCustom.cpp
r53586 r57207 36 36 #include "V8Proxy.h" 37 37 38 #include <v8.h> 39 38 40 namespace WebCore { 39 41 … … 45 47 bool canBubbleArg = args[1]->BooleanValue(); 46 48 bool cancelableArg = args[2]->BooleanValue(); 47 RefPtr<SerializedScriptValue> stateArg = SerializedScriptValue::create(args[3]); 49 50 bool didThrow = false; 51 RefPtr<SerializedScriptValue> stateArg = SerializedScriptValue::create(args[3], didThrow); 52 if (didThrow) 53 return v8::Undefined(); 48 54 49 55 PopStateEvent* event = V8PopStateEvent::toNative(args.Holder()); -
trunk/WebCore/bindings/v8/custom/V8WorkerCustom.cpp
r55798 r57207 92 92 INC_STATS("DOM.Worker.postMessage"); 93 93 Worker* worker = V8Worker::toNative(args.Holder()); 94 RefPtr<SerializedScriptValue> message = SerializedScriptValue::create(args[0]); 94 bool didThrow = false; 95 RefPtr<SerializedScriptValue> message = SerializedScriptValue::create(args[0], didThrow); 96 if (didThrow) 97 return v8::Undefined(); 95 98 MessagePortArray portArray; 96 99 if (args.Length() > 1) {
Note: See TracChangeset
for help on using the changeset viewer.