v8::Handle<v8::Value> V8DOMFormData::appendCallback(const v8::Arguments& args) { if (args.Length() < 2) return throwError(v8SyntaxError, "Not enough arguments", args.GetIsolate()); DOMFormData* domFormData = V8DOMFormData::toNative(args.Holder()); String name = toWebCoreStringWithNullCheck(args[0]); v8::Handle<v8::Value> arg = args[1]; if (V8Blob::HasInstance(arg)) { v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg); Blob* blob = V8Blob::toNative(object); ASSERT(blob); String filename; if (args.Length() >= 3 && !args[2]->IsUndefined()) filename = toWebCoreStringWithNullCheck(args[2]); domFormData->append(name, blob, filename); } else domFormData->append(name, toWebCoreStringWithNullCheck(arg)); return v8::Undefined(); }
v8::Handle<v8::Value> V8CanvasRenderingContext2D::createPatternCallback(const v8::Arguments& args) { INC_STATS("DOM.CanvasRenderingContext2D.createPattern()"); CanvasRenderingContext2D* context = V8CanvasRenderingContext2D::toNative(args.Holder()); v8::Handle<v8::Value> arg = args[0]; if (V8HTMLImageElement::HasInstance(arg)) { HTMLImageElement* imageElement = V8HTMLImageElement::toNative(v8::Handle<v8::Object>::Cast(arg)); ExceptionCode ec = 0; RefPtr<CanvasPattern> pattern = context->createPattern(imageElement, toWebCoreStringWithNullCheck(args[1]), ec); if (ec != 0) { V8Proxy::setDOMException(ec); return notHandledByInterceptor(); } return toV8(pattern.release()); } if (V8HTMLCanvasElement::HasInstance(arg)) { HTMLCanvasElement* canvasElement = V8HTMLCanvasElement::toNative(v8::Handle<v8::Object>::Cast(arg)); ExceptionCode ec = 0; RefPtr<CanvasPattern> pattern = context->createPattern(canvasElement, toWebCoreStringWithNullCheck(args[1]), ec); if (ec != 0) { V8Proxy::setDOMException(ec); return notHandledByInterceptor(); } return toV8(pattern.release()); } V8Proxy::setDOMException(TYPE_MISMATCH_ERR); return notHandledByInterceptor(); }
void ScriptDebugServer::dispatchDidParseSource(ScriptDebugListener* listener, v8::Handle<v8::Object> object) { listener->didParseSource( toWebCoreStringWithNullCheck(object->Get(v8::String::New("id"))), toWebCoreStringWithNullCheck(object->Get(v8::String::New("name"))), toWebCoreStringWithNullCheck(object->Get(v8::String::New("source"))), object->Get(v8::String::New("lineOffset"))->ToInteger()->Value()); }
String V8CustomXPathNSResolver::lookupNamespaceURI(const String& prefix) { v8::Handle<v8::Function> lookupNamespaceURIFunc; v8::Handle<v8::String> lookupNamespaceURIName = v8::String::NewSymbol("lookupNamespaceURI"); // Check if the resolver has a function property named lookupNamespaceURI. if (m_resolver->Has(lookupNamespaceURIName)) { v8::Handle<v8::Value> lookupNamespaceURI = m_resolver->Get(lookupNamespaceURIName); if (lookupNamespaceURI->IsFunction()) lookupNamespaceURIFunc = v8::Handle<v8::Function>::Cast(lookupNamespaceURI); } if (lookupNamespaceURIFunc.IsEmpty() && !m_resolver->IsFunction()) { activeDOMWindow(BindingState::instance())->console()->addMessage(JSMessageSource, ErrorMessageLevel, "XPathNSResolver does not have a lookupNamespaceURI method."); return String(); } // Catch exceptions from calling the namespace resolver. v8::TryCatch tryCatch; tryCatch.SetVerbose(true); // Print exceptions to console. const int argc = 1; v8::Handle<v8::Value> argv[argc] = { v8String(prefix, m_isolate) }; v8::Handle<v8::Function> function = lookupNamespaceURIFunc.IsEmpty() ? v8::Handle<v8::Function>::Cast(m_resolver) : lookupNamespaceURIFunc; v8::Handle<v8::Value> retval = ScriptController::callFunctionWithInstrumentation(0, function, m_resolver, argc, argv); // Eat exceptions from namespace resolver and return an empty string. This will most likely cause NAMESPACE_ERR. if (tryCatch.HasCaught()) return String(); return toWebCoreStringWithNullCheck(retval); }
String V8CustomXPathNSResolver::lookupNamespaceURI(const String& prefix) { v8::Handle<v8::Function> lookupNamespaceURIFunc; v8::Handle<v8::String> lookupNamespaceURIName = v8::String::New("lookupNamespaceURI"); // Check if the resolver has a function property named lookupNamespaceURI. if (m_resolver->Has(lookupNamespaceURIName)) { v8::Handle<v8::Value> lookupNamespaceURI = m_resolver->Get(lookupNamespaceURIName); if (lookupNamespaceURI->IsFunction()) lookupNamespaceURIFunc = v8::Handle<v8::Function>::Cast(lookupNamespaceURI); } if (lookupNamespaceURIFunc.IsEmpty() && !m_resolver->IsFunction()) { if (ScriptExecutionContext* context = getScriptExecutionContext()) context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "XPathNSResolver does not have a lookupNamespaceURI method.", 0, String(), 0); return String(); } // Catch exceptions from calling the namespace resolver. v8::TryCatch try_catch; try_catch.SetVerbose(true); // Print exceptions to console. const int argc = 1; v8::Handle<v8::Value> argv[argc] = { v8String(prefix) }; v8::Handle<v8::Function> function = lookupNamespaceURIFunc.IsEmpty() ? v8::Handle<v8::Function>::Cast(m_resolver) : lookupNamespaceURIFunc; v8::Handle<v8::Value> retval = V8Proxy::instrumentedCallFunction(0 /* page */, function, m_resolver, argc, argv); // Eat exceptions from namespace resolver and return an empty string. This will most likely cause NAMESPACE_ERR. if (try_catch.HasCaught()) return String(); return toWebCoreStringWithNullCheck(retval); }
String V8CustomXPathNSResolver::lookupNamespaceURI(const String& prefix) { v8::Handle<v8::Function> lookupNamespaceURIFunc; v8::Handle<v8::String> lookupNamespaceURIName = v8::String::New("lookupNamespaceURI"); // Check if the resolver has a function property named lookupNamespaceURI. if (m_resolver->Has(lookupNamespaceURIName)) { v8::Handle<v8::Value> lookupNamespaceURI = m_resolver->Get(lookupNamespaceURIName); if (lookupNamespaceURI->IsFunction()) lookupNamespaceURIFunc = v8::Handle<v8::Function>::Cast(lookupNamespaceURI); } if (lookupNamespaceURIFunc.IsEmpty() && !m_resolver->IsFunction()) { Frame* frame = V8Proxy::retrieveFrameForEnteredContext(); logInfo(frame, "XPathNSResolver does not have a lookupNamespaceURI method.", String()); return String(); } // Catch exceptions from calling the namespace resolver. v8::TryCatch try_catch; try_catch.SetVerbose(true); // Print exceptions to console. const int argc = 1; v8::Handle<v8::Value> argv[argc] = { v8String(prefix) }; v8::Handle<v8::Function> function = lookupNamespaceURIFunc.IsEmpty() ? v8::Handle<v8::Function>::Cast(m_resolver) : lookupNamespaceURIFunc; V8Proxy* proxy = V8Proxy::retrieve(); v8::Handle<v8::Value> retval = proxy->callFunction(function, m_resolver, argc, argv); // Eat exceptions from namespace resolver and return an empty string. This will most likely cause NAMESPACE_ERR. if (try_catch.HasCaught()) return String(); return toWebCoreStringWithNullCheck(retval); }
v8::Handle<v8::Value> V8CSSStyleDeclaration::namedPropertySetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) { INC_STATS("DOM.CSSStyleDeclaration.NamedPropertySetter"); CSSStyleDeclaration* imp = V8CSSStyleDeclaration::toNative(info.Holder()); CSSPropertyInfo* propInfo = cssPropertyInfo(name); if (!propInfo) return notHandledByInterceptor(); String propertyValue = toWebCoreStringWithNullCheck(value); if (propInfo->hadPixelOrPosPrefix) propertyValue.append("px"); ExceptionCode ec = 0; int importantIndex = propertyValue.find("!important", 0, false); bool important = false; if (importantIndex != -1) { important = true; propertyValue = propertyValue.left(importantIndex - 1); } imp->setProperty(propInfo->propID, propertyValue, important, ec); if (ec) throwError(ec); return value; }
v8::Handle<v8::Value> V8XMLHttpRequest::openCallback(const v8::Arguments& args) { INC_STATS("DOM.XMLHttpRequest.open()"); // Four cases: // open(method, url) // open(method, url, async) // open(method, url, async, user) // open(method, url, async, user, passwd) if (args.Length() < 2) return throwError("Not enough arguments", V8Proxy::SyntaxError); XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(args.Holder()); String method = toWebCoreString(args[0]); String urlstring = toWebCoreString(args[1]); ScriptExecutionContext* context = getScriptExecutionContext(); if (!context) return v8::Undefined(); KURL url = context->completeURL(urlstring); ExceptionCode ec = 0; if (args.Length() >= 3) { bool async = args[2]->BooleanValue(); if (args.Length() >= 4 && !args[3]->IsUndefined()) { String user = toWebCoreStringWithNullCheck(args[3]); if (args.Length() >= 5 && !args[4]->IsUndefined()) { String passwd = toWebCoreStringWithNullCheck(args[4]); xmlHttpRequest->open(method, url, async, user, passwd, ec); } else xmlHttpRequest->open(method, url, async, user, ec); } else xmlHttpRequest->open(method, url, async, ec); } else xmlHttpRequest->open(method, url, ec); if (ec) return throwError(ec); return v8::Undefined(); }
v8::Handle<v8::Value> V8XMLHttpRequest::openMethodCustom(const v8::Arguments& args) { // Four cases: // open(method, url) // open(method, url, async) // open(method, url, async, user) // open(method, url, async, user, passwd) if (args.Length() < 2) return throwNotEnoughArgumentsError(args.GetIsolate()); XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(args.Holder()); String method = toWebCoreString(args[0]); String urlstring = toWebCoreString(args[1]); ScriptExecutionContext* context = getScriptExecutionContext(); KURL url = context->completeURL(urlstring); ExceptionCode ec = 0; if (args.Length() >= 3) { bool async = args[2]->BooleanValue(); if (args.Length() >= 4 && !args[3]->IsUndefined()) { String user = toWebCoreStringWithNullCheck(args[3]); if (args.Length() >= 5 && !args[4]->IsUndefined()) { String passwd = toWebCoreStringWithNullCheck(args[4]); xmlHttpRequest->open(method, url, async, user, passwd, ec); } else xmlHttpRequest->open(method, url, async, user, ec); } else xmlHttpRequest->open(method, url, async, ec); } else xmlHttpRequest->open(method, url, ec); if (ec) return setDOMException(ec, args.GetIsolate()); return v8::Undefined(); }
static PassRefPtr<JSONValue> v8ToJSONValue(v8::Handle<v8::Value> value, int maxDepth) { if (value.IsEmpty()) { ASSERT_NOT_REACHED(); return 0; } if (!maxDepth) return 0; maxDepth--; if (value->IsNull() || value->IsUndefined()) return JSONValue::null(); if (value->IsBoolean()) return JSONBasicValue::create(value->BooleanValue()); if (value->IsNumber()) return JSONBasicValue::create(value->NumberValue()); if (value->IsString()) return JSONString::create(toWebCoreString(value)); if (value->IsArray()) { v8::Handle<v8::Array> array = v8::Handle<v8::Array>::Cast(value); RefPtr<JSONArray> inspectorArray = JSONArray::create(); uint32_t length = array->Length(); for (uint32_t i = 0; i < length; i++) { v8::Local<v8::Value> value = array->Get(v8::Int32::New(i)); RefPtr<JSONValue> element = v8ToJSONValue(value, maxDepth); if (!element) return 0; inspectorArray->pushValue(element); } return inspectorArray; } if (value->IsObject()) { RefPtr<JSONObject> jsonObject = JSONObject::create(); v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(value); v8::Local<v8::Array> propertyNames = object->GetPropertyNames(); uint32_t length = propertyNames->Length(); for (uint32_t i = 0; i < length; i++) { v8::Local<v8::Value> name = propertyNames->Get(v8::Int32::New(i)); // FIXME(yurys): v8::Object should support GetOwnPropertyNames if (name->IsString() && !object->HasRealNamedProperty(v8::Handle<v8::String>::Cast(name))) continue; RefPtr<JSONValue> propertyValue = v8ToJSONValue(object->Get(name), maxDepth); if (!propertyValue) return 0; jsonObject->setValue(toWebCoreStringWithNullCheck(name), propertyValue); } return jsonObject; } ASSERT_NOT_REACHED(); return 0; }
String eventListenerHandlerBody(ScriptExecutionContext* context, ScriptState* scriptState, EventListener* listener) { if (listener->type() != EventListener::JSEventListenerType) return ""; ScriptScope scope(scriptState); V8AbstractEventListener* v8Listener = static_cast<V8AbstractEventListener*>(listener); v8::Handle<v8::Object> function = v8Listener->getListenerObject(context); if (function.IsEmpty()) return ""; return toWebCoreStringWithNullCheck(function); }
/* v8::Handle<v8::Value> V8DOMFormData::constructorCallback(const v8::Arguments& args) { INC_STATS("DOM.FormData.Constructor"); if (!args.IsConstructCall()) return throwError("DOM object constructor cannot be called as a function.", V8Proxy::SyntaxError); HTMLFormElement* form = 0; if (args.Length() > 0 && V8HTMLFormElement::HasInstance(args[0])) form = V8HTMLFormElement::toNative(args[0]->ToObject()); RefPtr<DOMFormData> domFormData = DOMFormData::create(form); V8DOMWrapper::setDOMWrapper(args.Holder(), &info, domFormData.get()); return toV8(domFormData.release(), args.Holder()); } */ v8::Handle<v8::Value> V8DOMFormData::appendCallback(const v8::Arguments& args) { INC_STATS("DOM.FormData.append()"); if (args.Length() < 2) return throwError("Not enough arguments", V8Proxy::SyntaxError); DOMFormData* domFormData = V8DOMFormData::toNative(args.Holder()); String name = toWebCoreStringWithNullCheck(args[0]); v8::Handle<v8::Value> arg = args[1]; if (V8Blob::HasInstance(arg)) { v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg); Blob* blob = V8Blob::toNative(object); ASSERT(blob); domFormData->append(name, blob); } else domFormData->append(name, toWebCoreStringWithNullCheck(arg)); return v8::Undefined(); }
static void populateContextMenuItems(v8::Local<v8::Array>& itemArray, ContextMenu& menu) { for (size_t i = 0; i < itemArray->Length(); ++i) { v8::Local<v8::Object> item = v8::Local<v8::Object>::Cast(itemArray->Get(i)); v8::Local<v8::Value> type = item->Get(v8::String::New("type")); v8::Local<v8::Value> id = item->Get(v8::String::New("id")); v8::Local<v8::Value> label = item->Get(v8::String::New("label")); v8::Local<v8::Value> enabled = item->Get(v8::String::New("enabled")); v8::Local<v8::Value> checked = item->Get(v8::String::New("checked")); v8::Local<v8::Value> subItems = item->Get(v8::String::New("subItems")); if (!type->IsString()) continue; String typeString = toWebCoreStringWithNullCheck(type); if (typeString == "separator") { ContextMenuItem item(ContextMenuItem(SeparatorType, ContextMenuItemCustomTagNoAction, String())); menu.appendItem(item); } else if (typeString == "subMenu" && subItems->IsArray()) { ContextMenu subMenu; v8::Local<v8::Array> subItemsArray = v8::Local<v8::Array>::Cast(subItems); populateContextMenuItems(subItemsArray, subMenu); ContextMenuItem item(SubmenuType, ContextMenuItemCustomTagNoAction, toWebCoreStringWithNullCheck(label), &subMenu); menu.appendItem(item); } else { ContextMenuAction typedId = static_cast<ContextMenuAction>(ContextMenuItemBaseCustomTag + id->ToInt32()->Value()); ContextMenuItem menuItem((typeString == "checkbox" ? CheckableActionType : ActionType), typedId, toWebCoreStringWithNullCheck(label)); if (checked->IsBoolean()) menuItem.setChecked(checked->ToBoolean()->Value()); if (enabled->IsBoolean()) menuItem.setEnabled(enabled->ToBoolean()->Value()); menu.appendItem(menuItem); } } }
v8::Handle<v8::Value> V8XMLHttpRequest::sendMethodCustom(const v8::Arguments& args) { XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(args.Holder()); InspectorInstrumentation::willSendXMLHttpRequest(xmlHttpRequest->scriptExecutionContext(), xmlHttpRequest->url()); ExceptionCode ec = 0; if (args.Length() < 1) xmlHttpRequest->send(ec); else { v8::Handle<v8::Value> arg = args[0]; WrapperWorldType currentWorldType = worldType(args.GetIsolate()); if (isUndefinedOrNull(arg)) xmlHttpRequest->send(ec); else if (isDocumentType(arg, args.GetIsolate(), currentWorldType)) { v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg); Document* document = V8Document::toNative(object); ASSERT(document); xmlHttpRequest->send(document, ec); } else if (V8Blob::HasInstance(arg, args.GetIsolate(), currentWorldType)) { v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg); Blob* blob = V8Blob::toNative(object); ASSERT(blob); xmlHttpRequest->send(blob, ec); } else if (V8DOMFormData::HasInstance(arg, args.GetIsolate(), currentWorldType)) { v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg); DOMFormData* domFormData = V8DOMFormData::toNative(object); ASSERT(domFormData); xmlHttpRequest->send(domFormData, ec); #if ENABLE(WEBGL) || ENABLE(BLOB) } else if (V8ArrayBuffer::HasInstance(arg, args.GetIsolate(), currentWorldType)) { v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg); ArrayBuffer* arrayBuffer = V8ArrayBuffer::toNative(object); ASSERT(arrayBuffer); xmlHttpRequest->send(arrayBuffer, ec); } else if (V8ArrayBufferView::HasInstance(arg, args.GetIsolate(), currentWorldType)) { v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg); ArrayBufferView* arrayBufferView = V8ArrayBufferView::toNative(object); ASSERT(arrayBufferView); xmlHttpRequest->send(arrayBufferView, ec); #endif } else xmlHttpRequest->send(toWebCoreStringWithNullCheck(arg), ec); } if (ec) return setDOMException(ec, args.GetIsolate()); return v8::Undefined(); }
void V8Node::nodeValueAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) { Node* imp = V8Node::toNative(info.Holder()); String nodeValue = toWebCoreStringWithNullCheck(value); if (imp->nodeType() == Node::ATTRIBUTE_NODE) { Element * ownerElement = V8Attr::toNative(info.Holder())->ownerElement(); if (ownerElement && !V8BindingSecurity::allowSettingSrcToJavascriptURL(V8BindingState::Only(), ownerElement, imp->nodeName(), nodeValue)) return; } ExceptionCode ec = 0; imp->setNodeValue(nodeValue, ec); if (ec) throwError(ec); }
v8::Handle<v8::Value> V8InspectorFrontendHost::showContextMenuCallback(const v8::Arguments& args) { if (args.Length() < 2) return v8::Undefined(); v8::Local<v8::Object> eventWrapper = v8::Local<v8::Object>::Cast(args[0]); if (!V8MouseEvent::info.equals(V8DOMWrapper::domWrapperType(eventWrapper))) return v8::Undefined(); Event* event = V8Event::toNative(eventWrapper); if (!args[1]->IsArray()) return v8::Undefined(); v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(args[1]); Vector<ContextMenuItem*> items; for (size_t i = 0; i < array->Length(); ++i) { v8::Local<v8::Object> item = v8::Local<v8::Object>::Cast(array->Get(v8::Integer::New(i))); v8::Local<v8::Value> type = item->Get(v8::String::New("type")); v8::Local<v8::Value> id = item->Get(v8::String::New("id")); v8::Local<v8::Value> label = item->Get(v8::String::New("label")); v8::Local<v8::Value> enabled = item->Get(v8::String::New("enabled")); v8::Local<v8::Value> checked = item->Get(v8::String::New("checked")); if (!type->IsString()) continue; String typeString = toWebCoreStringWithNullCheck(type); if (typeString == "separator") { items.append(new ContextMenuItem(SeparatorType, ContextMenuItemCustomTagNoAction, String())); } else { ContextMenuAction typedId = static_cast<ContextMenuAction>(ContextMenuItemBaseCustomTag + id->ToInt32()->Value()); ContextMenuItem* menuItem = new ContextMenuItem((typeString == "checkbox" ? CheckableActionType : ActionType), typedId, toWebCoreStringWithNullCheck(label)); if (checked->IsBoolean()) menuItem->setChecked(checked->ToBoolean()->Value()); if (enabled->IsBoolean()) menuItem->setEnabled(enabled->ToBoolean()->Value()); items.append(menuItem); } } InspectorFrontendHost* frontendHost = V8InspectorFrontendHost::toNative(args.Holder()); frontendHost->showContextMenu(event, items); return v8::Undefined(); }
v8::Handle<v8::Value> V8XMLHttpRequest::sendCallback(const v8::Arguments& args) { INC_STATS("DOM.XMLHttpRequest.send()"); XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(args.Holder()); InspectorInstrumentation::willSendXMLHttpRequest(xmlHttpRequest->scriptExecutionContext(), xmlHttpRequest->url()); ExceptionCode ec = 0; if (args.Length() < 1) xmlHttpRequest->send(ec); else { v8::Handle<v8::Value> arg = args[0]; if (isUndefinedOrNull(arg)) xmlHttpRequest->send(ec); else if (isDocumentType(arg)) { v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg); Document* document = V8Document::toNative(object); ASSERT(document); xmlHttpRequest->send(document, ec); } else if (V8Blob::HasInstance(arg)) { v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg); Blob* blob = V8Blob::toNative(object); ASSERT(blob); xmlHttpRequest->send(blob, ec); } else if (V8DOMFormData::HasInstance(arg)) { v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg); DOMFormData* domFormData = V8DOMFormData::toNative(object); ASSERT(domFormData); xmlHttpRequest->send(domFormData, ec); #if ENABLE(WEBGL) || ENABLE(BLOB) } else if (V8ArrayBuffer::HasInstance(arg)) { v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg); ArrayBuffer* arrayBuffer = V8ArrayBuffer::toNative(object); ASSERT(arrayBuffer); xmlHttpRequest->send(arrayBuffer, ec); #endif } else xmlHttpRequest->send(toWebCoreStringWithNullCheck(arg), ec); } if (ec) return throwError(ec); return v8::Undefined(); }
String ScriptPreprocessor::preprocessSourceCode(const String& sourceCode, const String& sourceName, v8::Handle<v8::Value> functionName) { if (!isValid()) return sourceCode; v8::HandleScope handleScope(m_isolate); v8::Context::Scope contextScope(m_context.newLocal(m_isolate)); v8::Handle<v8::String> sourceCodeString = v8String(sourceCode, m_isolate); v8::Handle<v8::String> sourceNameString = v8String(sourceName, m_isolate); v8::Handle<v8::Value> argv[] = { sourceCodeString, sourceNameString, functionName}; v8::TryCatch tryCatch; tryCatch.SetVerbose(true); TemporaryChange<bool> isPreprocessing(m_isPreprocessing, true); v8::Handle<v8::Value> resultValue = V8ScriptRunner::callAsFunction(m_preprocessorFunction.newLocal(m_isolate), m_context.newLocal(m_isolate)->Global(), WTF_ARRAY_LENGTH(argv), argv); if (!resultValue.IsEmpty() && resultValue->IsString()) return toWebCoreStringWithNullCheck(resultValue.As<v8::String>()); return sourceCode; }
v8::Handle<v8::Value> V8XMLHttpRequest::sendCallback(const v8::Arguments& args) { INC_STATS("DOM.XMLHttpRequest.send()"); XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(args.Holder()); ExceptionCode ec = 0; if (args.Length() < 1) xmlHttpRequest->send(ec); else { v8::Handle<v8::Value> arg = args[0]; if (isUndefinedOrNull(arg)) xmlHttpRequest->send(ec); else if (isDocumentType(arg)) { v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg); Document* document = V8Document::toNative(object); ASSERT(document); xmlHttpRequest->send(document, ec); } else if (V8Blob::HasInstance(arg)) { v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg); Blob* blob = V8Blob::toNative(object); ASSERT(blob); xmlHttpRequest->send(blob, ec); } else if (V8DOMFormData::HasInstance(arg)) { v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg); DOMFormData* domFormData = V8DOMFormData::toNative(object); ASSERT(domFormData); xmlHttpRequest->send(domFormData, ec); } else xmlHttpRequest->send(toWebCoreStringWithNullCheck(arg), ec); } if (ec) return throwError(ec); return v8::Undefined(); }