diff options
Diffstat (limited to 'WebCore/bindings/v8/custom/V8XMLHttpRequestConstructor.cpp')
-rw-r--r-- | WebCore/bindings/v8/custom/V8XMLHttpRequestConstructor.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/WebCore/bindings/v8/custom/V8XMLHttpRequestConstructor.cpp b/WebCore/bindings/v8/custom/V8XMLHttpRequestConstructor.cpp index c913c08..02ce8e2 100644 --- a/WebCore/bindings/v8/custom/V8XMLHttpRequestConstructor.cpp +++ b/WebCore/bindings/v8/custom/V8XMLHttpRequestConstructor.cpp @@ -46,7 +46,7 @@ CALLBACK_FUNC_DECL(XMLHttpRequestConstructor) INC_STATS("DOM.XMLHttpRequest.Constructor"); if (!args.IsConstructCall()) - return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TYPE_ERROR); + return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError); // Expect no parameters. // Allocate a XMLHttpRequest object as its internal field. @@ -55,15 +55,21 @@ CALLBACK_FUNC_DECL(XMLHttpRequestConstructor) WorkerContextExecutionProxy* proxy = WorkerContextExecutionProxy::retrieve(); if (proxy) context = proxy->workerContext(); - else + else { +#endif + Frame* frame = V8Proxy::retrieveFrameForCurrentContext(); + if (!frame) + return throwError("XMLHttpRequest constructor's associated frame is not available", V8Proxy::ReferenceError); + context = frame->document(); +#if ENABLE(WORKERS) + } #endif - context = V8Proxy::retrieveFrame()->document(); RefPtr<XMLHttpRequest> xmlHttpRequest = XMLHttpRequest::create(context); - V8Proxy::SetDOMWrapper(args.Holder(), V8ClassIndex::ToInt(V8ClassIndex::XMLHTTPREQUEST), xmlHttpRequest.get()); + V8DOMWrapper::setDOMWrapper(args.Holder(), V8ClassIndex::ToInt(V8ClassIndex::XMLHTTPREQUEST), xmlHttpRequest.get()); // Add object to the wrapper map. xmlHttpRequest->ref(); - V8Proxy::SetJSWrapperForActiveDOMObject(xmlHttpRequest.get(), v8::Persistent<v8::Object>::New(args.Holder())); + V8DOMWrapper::setJSWrapperForActiveDOMObject(xmlHttpRequest.get(), v8::Persistent<v8::Object>::New(args.Holder())); return args.Holder(); } |