Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Unified Diff: third_party/WebKit/Source/bindings/core/v8/custom/V8XMLHttpRequestCustom.cpp

Issue 2472753003: Move fromJSONString to V8Binding (Closed)
Patch Set: Really swallow exception Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/bindings/core/v8/custom/V8XMLHttpRequestCustom.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/custom/V8XMLHttpRequestCustom.cpp b/third_party/WebKit/Source/bindings/core/v8/custom/V8XMLHttpRequestCustom.cpp
index 4e8dee3d101cbfcf60d257dac9f09673c53cba65..f35c837682790188ba404c293790abd8de8b3b10 100644
--- a/third_party/WebKit/Source/bindings/core/v8/custom/V8XMLHttpRequestCustom.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/custom/V8XMLHttpRequestCustom.cpp
@@ -66,6 +66,9 @@ void V8XMLHttpRequest::responseTextAttributeGetterCustom(
void V8XMLHttpRequest::responseAttributeGetterCustom(
const v8::FunctionCallbackInfo<v8::Value>& info) {
XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toImpl(info.Holder());
+ ExceptionState exceptionState(ExceptionState::GetterContext, "response",
+ "XMLHttpRequest", info.Holder(),
+ info.GetIsolate());
switch (xmlHttpRequest->getResponseTypeCode()) {
case XMLHttpRequest::ResponseTypeDefault:
@@ -84,20 +87,18 @@ void V8XMLHttpRequest::responseAttributeGetterCustom(
// Catch syntax error. Swallows an exception (when thrown) as the
// spec says. https://xhr.spec.whatwg.org/#response-body
- v8::TryCatch exceptionCatcher(isolate);
- v8::Local<v8::Value> json;
- if (v8Call(v8::JSON::Parse(isolate, jsonSource.v8Value()), json,
- exceptionCatcher))
- v8SetReturnValue(info, json);
- else
+ v8::Local<v8::Value> json = fromJSONString(
+ isolate, toCoreString(jsonSource.v8Value()), exceptionState);
+ if (exceptionState.hadException()) {
+ exceptionState.clearException();
v8SetReturnValue(info, v8::Null(isolate));
+ } else {
+ v8SetReturnValue(info, json);
+ }
return;
}
case XMLHttpRequest::ResponseTypeDocument: {
- ExceptionState exceptionState(ExceptionState::GetterContext, "response",
- "XMLHttpRequest", info.Holder(),
- info.GetIsolate());
Document* document = xmlHttpRequest->responseXML(exceptionState);
v8SetReturnValueFast(info, document, xmlHttpRequest);
return;
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/V8Binding.cpp ('k') | third_party/WebKit/Source/modules/nfc/NFC.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698