| Index: Source/bindings/v8/custom/V8XMLHttpRequestCustom.cpp
|
| diff --git a/Source/bindings/v8/custom/V8XMLHttpRequestCustom.cpp b/Source/bindings/v8/custom/V8XMLHttpRequestCustom.cpp
|
| index 3989c296bd1424df45b4e8171ad81426d91473c0..844431a59152300435bd0c96b5c1fc28ff09d372 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:
|
| + {
|
| + v8::Isolate* isolate = info.GetIsolate();
|
| +
|
| + ExceptionState es(isolate);
|
| + ScriptString jsonSource = xmlHttpRequest->responseJSONSource(es);
|
| + if (es.throwIfNeeded())
|
| + return;
|
| +
|
| + 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());
|
|
|