*/
#include "config.h"
-#include "V8XMLHttpRequest.h"
+#include "bindings/core/v8/V8XMLHttpRequest.h"
-#include "V8Blob.h"
-#include "V8Document.h"
-#include "V8FormData.h"
-#include "V8HTMLDocument.h"
-#include "V8Stream.h"
+#include "bindings/core/v8/V8Blob.h"
+#include "bindings/core/v8/V8Document.h"
+#include "bindings/core/v8/V8FormData.h"
+#include "bindings/core/v8/V8HTMLDocument.h"
+#include "bindings/core/v8/V8Stream.h"
#include "bindings/v8/ExceptionMessages.h"
#include "bindings/v8/ExceptionState.h"
#include "bindings/v8/V8Binding.h"
-#include "bindings/v8/V8Utilities.h"
#include "bindings/v8/custom/V8ArrayBufferCustom.h"
#include "bindings/v8/custom/V8ArrayBufferViewCustom.h"
#include "core/dom/Document.h"
void V8XMLHttpRequest::constructorCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
- ExecutionContext* context = getExecutionContext();
+ ExecutionContext* context = currentExecutionContext(info.GetIsolate());
RefPtr<SecurityOrigin> securityOrigin;
if (context->isDocument()) {
- if (DOMWrapperWorld* world = isolatedWorldForEnteredContext())
- securityOrigin = world->isolatedWorldSecurityOrigin();
+ DOMWrapperWorld& world = DOMWrapperWorld::current(info.GetIsolate());
+ if (world.isIsolatedWorld())
+ securityOrigin = world.isolatedWorldSecurityOrigin();
}
- RefPtr<XMLHttpRequest> xmlHttpRequest = XMLHttpRequest::create(context, securityOrigin);
+ RefPtrWillBeRawPtr<XMLHttpRequest> xmlHttpRequest = XMLHttpRequest::create(context, securityOrigin);
v8::Handle<v8::Object> wrapper = info.Holder();
V8DOMWrapper::associateObjectWithWrapper<V8XMLHttpRequest>(xmlHttpRequest.release(), &wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Dependent);
void V8XMLHttpRequest::responseTextAttributeGetterCustom(const v8::PropertyCallbackInfo<v8::Value>& info)
{
XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(info.Holder());
- ExceptionState es(info.GetIsolate());
- ScriptValue text = xmlHttpRequest->responseText(es);
- if (es.throwIfNeeded())
+ ExceptionState exceptionState(ExceptionState::GetterContext, "responseText", "XMLHttpRequest", info.Holder(), info.GetIsolate());
+ ScriptString text = xmlHttpRequest->responseText(exceptionState);
+ if (exceptionState.throwIfNeeded())
return;
- if (text.hasNoValue()) {
+ if (text.isEmpty()) {
v8SetReturnValueString(info, emptyString(), info.GetIsolate());
return;
}
{
v8::Isolate* isolate = info.GetIsolate();
- ExceptionState es(isolate);
ScriptString jsonSource = xmlHttpRequest->responseJSONSource();
- if (es.throwIfNeeded())
- return;
-
- if (jsonSource.hasNoValue() || !jsonSource.v8Value()->IsString()) {
- v8SetReturnValue(info, v8NullWithCheck(isolate));
+ if (jsonSource.isEmpty()) {
+ v8SetReturnValue(info, v8::Null(isolate));
return;
}
// Catch syntax error.
v8::TryCatch exceptionCatcher;
-
- v8::Handle<v8::Value> json = v8::JSON::Parse(jsonSource.v8Value().As<v8::String>());
-
+ v8::Handle<v8::Value> json = v8::JSON::Parse(jsonSource.v8Value());
if (exceptionCatcher.HasCaught() || json.IsEmpty())
- v8SetReturnValue(info, v8NullWithCheck(isolate));
+ v8SetReturnValue(info, v8::Null(isolate));
else
v8SetReturnValue(info, json);
-
return;
}
case XMLHttpRequest::ResponseTypeDocument:
{
- ExceptionState es(info.GetIsolate());
- Document* document = xmlHttpRequest->responseXML(es);
- if (es.throwIfNeeded())
+ ExceptionState exceptionState(ExceptionState::GetterContext, "response", "XMLHttpRequest", info.Holder(), info.GetIsolate());
+ Document* document = xmlHttpRequest->responseXML(exceptionState);
+ if (exceptionState.throwIfNeeded())
return;
v8SetReturnValueFast(info, document, xmlHttpRequest);
return;
{
ArrayBuffer* arrayBuffer = xmlHttpRequest->responseArrayBuffer();
if (arrayBuffer) {
- arrayBuffer->setDeallocationObserver(V8ArrayBufferDeallocationObserver::instance());
+ arrayBuffer->setDeallocationObserver(V8ArrayBufferDeallocationObserver::instanceTemplate());
}
v8SetReturnValueFast(info, arrayBuffer, xmlHttpRequest);
return;
// open(method, url, async, user)
// open(method, url, async, user, passwd)
+ ExceptionState exceptionState(ExceptionState::ExecutionContext, "open", "XMLHttpRequest", info.Holder(), info.GetIsolate());
+
if (info.Length() < 2) {
- throwTypeError(ExceptionMessages::failedToExecute("open", "XMLHttpRequest", ExceptionMessages::notEnoughArguments(2, info.Length())), info.GetIsolate());
+ exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, info.Length()));
+ exceptionState.throwIfNeeded();
return;
}
XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(info.Holder());
- V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, method, info[0]);
- V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, urlstring, info[1]);
+ TOSTRING_VOID(V8StringResource<>, method, info[0]);
+ TOSTRING_VOID(V8StringResource<>, urlstring, info[1]);
- ExecutionContext* context = getExecutionContext();
+ ExecutionContext* context = currentExecutionContext(info.GetIsolate());
KURL url = context->completeURL(urlstring);
- ExceptionState es(info.GetIsolate());
-
if (info.Length() >= 3) {
bool async = info[2]->BooleanValue();
if (info.Length() >= 4 && !info[3]->IsUndefined()) {
- String user = toWebCoreStringWithNullCheck(info[3]);
+ TOSTRING_VOID(V8StringResource<WithNullCheck>, user, info[3]);
if (info.Length() >= 5 && !info[4]->IsUndefined()) {
- String passwd = toWebCoreStringWithNullCheck(info[4]);
- xmlHttpRequest->open(method, url, async, user, passwd, es);
+ TOSTRING_VOID(V8StringResource<WithNullCheck>, password, info[4]);
+ xmlHttpRequest->open(method, url, async, user, password, exceptionState);
} else {
- xmlHttpRequest->open(method, url, async, user, es);
+ xmlHttpRequest->open(method, url, async, user, exceptionState);
}
} else {
- xmlHttpRequest->open(method, url, async, es);
+ xmlHttpRequest->open(method, url, async, exceptionState);
}
} else {
- xmlHttpRequest->open(method, url, es);
+ xmlHttpRequest->open(method, url, exceptionState);
}
- es.throwIfNeeded();
+ exceptionState.throwIfNeeded();
}
-static bool isDocumentType(v8::Handle<v8::Value> value, v8::Isolate* isolate, WrapperWorldType currentWorldType)
+static bool isDocumentType(v8::Handle<v8::Value> value, v8::Isolate* isolate)
{
// FIXME: add other document types.
- return V8Document::HasInstance(value, isolate, currentWorldType) || V8HTMLDocument::HasInstance(value, isolate, currentWorldType);
+ return V8Document::hasInstance(value, isolate) || V8HTMLDocument::hasInstance(value, isolate);
}
void V8XMLHttpRequest::sendMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
InspectorInstrumentation::willSendXMLHttpRequest(xmlHttpRequest->executionContext(), xmlHttpRequest->url());
- ExceptionState es(info.GetIsolate());
+ ExceptionState exceptionState(ExceptionState::ExecutionContext, "send", "XMLHttpRequest", info.Holder(), info.GetIsolate());
if (info.Length() < 1)
- xmlHttpRequest->send(es);
+ xmlHttpRequest->send(exceptionState);
else {
v8::Handle<v8::Value> arg = info[0];
- WrapperWorldType currentWorldType = worldType(info.GetIsolate());
if (isUndefinedOrNull(arg)) {
- xmlHttpRequest->send(es);
- } else if (isDocumentType(arg, info.GetIsolate(), currentWorldType)) {
+ xmlHttpRequest->send(exceptionState);
+ } else if (isDocumentType(arg, info.GetIsolate())) {
v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg);
Document* document = V8Document::toNative(object);
ASSERT(document);
- xmlHttpRequest->send(document, es);
- } else if (V8Blob::HasInstance(arg, info.GetIsolate(), currentWorldType)) {
+ xmlHttpRequest->send(document, exceptionState);
+ } else if (V8Blob::hasInstance(arg, info.GetIsolate())) {
v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg);
Blob* blob = V8Blob::toNative(object);
ASSERT(blob);
- xmlHttpRequest->send(blob, es);
- } else if (V8FormData::HasInstance(arg, info.GetIsolate(), currentWorldType)) {
+ xmlHttpRequest->send(blob, exceptionState);
+ } else if (V8FormData::hasInstance(arg, info.GetIsolate())) {
v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg);
DOMFormData* domFormData = V8FormData::toNative(object);
ASSERT(domFormData);
- xmlHttpRequest->send(domFormData, es);
- } else if (V8ArrayBuffer::HasInstance(arg, info.GetIsolate(), currentWorldType)) {
+ xmlHttpRequest->send(domFormData, exceptionState);
+ } else if (V8ArrayBuffer::hasInstance(arg, info.GetIsolate())) {
v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg);
ArrayBuffer* arrayBuffer = V8ArrayBuffer::toNative(object);
ASSERT(arrayBuffer);
- xmlHttpRequest->send(arrayBuffer, es);
- } else if (V8ArrayBufferView::HasInstance(arg, info.GetIsolate(), currentWorldType)) {
+ xmlHttpRequest->send(arrayBuffer, exceptionState);
+ } else if (V8ArrayBufferView::hasInstance(arg, info.GetIsolate())) {
v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg);
ArrayBufferView* arrayBufferView = V8ArrayBufferView::toNative(object);
ASSERT(arrayBufferView);
- xmlHttpRequest->send(arrayBufferView, es);
+ xmlHttpRequest->send(arrayBufferView, exceptionState);
} else {
- xmlHttpRequest->send(toWebCoreStringWithNullCheck(arg), es);
+ TOSTRING_VOID(V8StringResource<WithNullCheck>, argString, arg);
+ xmlHttpRequest->send(argString, exceptionState);
}
}
- es.throwIfNeeded();
+ exceptionState.throwIfNeeded();
}
} // namespace WebCore