Index: Source/bindings/v8/custom/V8XMLHttpRequestCustom.cpp |
diff --git a/Source/bindings/v8/custom/V8XMLHttpRequestCustom.cpp b/Source/bindings/v8/custom/V8XMLHttpRequestCustom.cpp |
index 43022213a4ba580285c8db4904c7e4dd41ac1b60..fb7f192cb95c72ee3b0e2874f3e19dccb4e39900 100644 |
--- a/Source/bindings/v8/custom/V8XMLHttpRequestCustom.cpp |
+++ b/Source/bindings/v8/custom/V8XMLHttpRequestCustom.cpp |
@@ -47,6 +47,8 @@ |
#include "core/xml/XMLHttpRequest.h" |
#include "wtf/ArrayBuffer.h" |
+#include <v8.h> |
+ |
namespace WebCore { |
void V8XMLHttpRequest::constructorCustom(const v8::FunctionCallbackInfo<v8::Value>& args) |
@@ -90,6 +92,33 @@ void V8XMLHttpRequest::responseAttrGetterCustom(v8::Local<v8::String> name, cons |
responseTextAttrGetterCustom(name, info); |
return; |
+ case XMLHttpRequest::ResponseTypeJson: |
abarth-chromium
2013/08/06 19:28:33
ResponseTypeJson -> ResponseTypeJSON
tyoshino (SeeGerritForStatus)
2013/08/07 03:37:46
Done.
|
+ { |
+ ExceptionState es(info.GetIsolate()); |
+ ScriptString jsonSource = xmlHttpRequest->responseJsonSource(es); |
abarth-chromium
2013/08/06 19:28:33
responseJsonSource -> responseJSONSource
tyoshino (SeeGerritForStatus)
2013/08/07 03:37:46
Done.
|
+ if (es.throwIfNeeded()) |
+ return; |
+ |
+ v8::Isolate* isolate = info.GetIsolate(); |
abarth-chromium
2013/08/06 19:28:33
Should we grab the isolate at the top of the block
tyoshino (SeeGerritForStatus)
2013/08/07 03:37:46
Yes! Done
|
+ |
+ if (jsonSource.hasNoValue() || !jsonSource.v8Value()->IsString()) { |
+ v8SetReturnValue(info, v8NullWithCheck(isolate)); |
+ return; |
+ } |
+ |
+ // Catch syntax error. |
+ v8::TryCatch exceptionCatcher; |
+ |
+ v8::Handle<v8::Value> json = v8::JSON::Parse(jsonSource.v8Value().As<v8::String>()); |
+ |
+ if (exceptionCatcher.HasCaught() || json.IsEmpty()) |
+ v8SetReturnValue(info, v8NullWithCheck(isolate)); |
+ else |
+ v8SetReturnValue(info, json); |
+ |
+ return; |
+ } |
+ |
case XMLHttpRequest::ResponseTypeDocument: |
{ |
ExceptionState es(info.GetIsolate()); |