OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2008, 2009, 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2008, 2009, 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
77 v8::Isolate* isolate = info.GetIsolate(); | 77 v8::Isolate* isolate = info.GetIsolate(); |
78 | 78 |
79 ScriptString jsonSource = xmlHttpRequest->responseJSONSource(); | 79 ScriptString jsonSource = xmlHttpRequest->responseJSONSource(); |
80 if (jsonSource.isEmpty()) { | 80 if (jsonSource.isEmpty()) { |
81 v8SetReturnValue(info, v8::Null(isolate)); | 81 v8SetReturnValue(info, v8::Null(isolate)); |
82 return; | 82 return; |
83 } | 83 } |
84 | 84 |
85 // Catch syntax error. Swallows an exception (when thrown) as the | 85 // Catch syntax error. Swallows an exception (when thrown) as the |
86 // spec says. https://xhr.spec.whatwg.org/#response-body | 86 // spec says. https://xhr.spec.whatwg.org/#response-body |
87 v8::TryCatch exceptionCatcher(isolate); | 87 ExceptionState exceptionState(ExceptionState::GetterContext, |
88 v8::Local<v8::Value> json; | 88 "responseText", "XMLHttpRequest", |
89 if (v8Call(v8::JSON::Parse(isolate, jsonSource.v8Value()), json, | 89 info.Holder(), info.GetIsolate()); |
haraken
2016/11/03 14:26:38
Would you put this at line 69? I'd like to make th
| |
90 exceptionCatcher)) | 90 v8::Local<v8::Value> json = fromJSONString( |
91 isolate, toCoreString(jsonSource.v8Value()), exceptionState); | |
92 if (exceptionState.hadException()) | |
93 v8SetReturnValue(info, v8::Null(isolate)); | |
94 else | |
91 v8SetReturnValue(info, json); | 95 v8SetReturnValue(info, json); |
92 else | |
93 v8SetReturnValue(info, v8::Null(isolate)); | |
94 return; | 96 return; |
95 } | 97 } |
96 | 98 |
97 case XMLHttpRequest::ResponseTypeDocument: { | 99 case XMLHttpRequest::ResponseTypeDocument: { |
98 ExceptionState exceptionState(ExceptionState::GetterContext, "response", | 100 ExceptionState exceptionState(ExceptionState::GetterContext, "response", |
99 "XMLHttpRequest", info.Holder(), | 101 "XMLHttpRequest", info.Holder(), |
100 info.GetIsolate()); | 102 info.GetIsolate()); |
101 Document* document = xmlHttpRequest->responseXML(exceptionState); | 103 Document* document = xmlHttpRequest->responseXML(exceptionState); |
102 v8SetReturnValueFast(info, document, xmlHttpRequest); | 104 v8SetReturnValueFast(info, document, xmlHttpRequest); |
103 return; | 105 return; |
(...skipping 13 matching lines...) Expand all Loading... | |
117 | 119 |
118 case XMLHttpRequest::ResponseTypeArrayBuffer: { | 120 case XMLHttpRequest::ResponseTypeArrayBuffer: { |
119 DOMArrayBuffer* arrayBuffer = xmlHttpRequest->responseArrayBuffer(); | 121 DOMArrayBuffer* arrayBuffer = xmlHttpRequest->responseArrayBuffer(); |
120 v8SetReturnValueFast(info, arrayBuffer, xmlHttpRequest); | 122 v8SetReturnValueFast(info, arrayBuffer, xmlHttpRequest); |
121 return; | 123 return; |
122 } | 124 } |
123 } | 125 } |
124 } | 126 } |
125 | 127 |
126 } // namespace blink | 128 } // namespace blink |
OLD | NEW |