void V8InjectedScriptHost::inspectCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { if (info.Length() < 2) return; InjectedScriptHost* host = V8InjectedScriptHost::unwrap(info.GetIsolate()->GetCurrentContext(), info.Holder()); ScriptState* scriptState = ScriptState::current(info.GetIsolate()); ScriptState::Scope scope(scriptState); host->inspectImpl(toJSONValue(scriptState->context(), info[0]), toJSONValue(scriptState->context(), info[1])); }
static v8::Handle<v8::Value> didCreateWorkerCallback(const v8::Arguments& args) { INC_STATS("DOM.InjectedScriptHost.didCreateWorker"); InjectedScriptHost* imp = V8InjectedScriptHost::toNative(args.Holder()); EXCEPTION_BLOCK(int, id, toInt32(args[0])); STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, url, args[1]); EXCEPTION_BLOCK(bool, isFakeWorker, args[2]->BooleanValue()); imp->didCreateWorker(id, url, isFakeWorker); return v8::Handle<v8::Value>(); }
void V8InjectedScriptHost::storageIdMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info) { if (info.Length() > 0 && V8Storage::HasInstance(info[0], info.GetIsolate(), worldType(info.GetIsolate()))) { Storage* storage = V8Storage::toNative(v8::Handle<v8::Object>::Cast(info[0])); if (storage) { InjectedScriptHost* host = V8InjectedScriptHost::toNative(info.Holder()); v8SetReturnValueStringOrUndefined(info, host->storageIdImpl(storage), info.GetIsolate()); return; } } }
void V8InjectedScriptHost::collectionEntriesCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { if (info.Length() < 1 || !info[0]->IsObject()) return; v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(info[0]); InjectedScriptHost* host = V8InjectedScriptHost::unwrap(info.GetIsolate()->GetCurrentContext(), info.Holder()); V8DebuggerImpl& debugger = static_cast<V8DebuggerImpl&>(host->debugger()); v8SetReturnValue(info, debugger.collectionEntries(object)); }
void V8InjectedScriptHost::setFunctionVariableValueMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info) { v8::Handle<v8::Value> functionValue = info[0]; int scopeIndex = info[1]->Int32Value(); String variableName = toWebCoreStringWithUndefinedOrNullCheck(info[2]); v8::Handle<v8::Value> newValue = info[3]; InjectedScriptHost* host = V8InjectedScriptHost::toNative(info.Holder()); ScriptDebugServer& debugServer = host->scriptDebugServer(); v8SetReturnValue(info, debugServer.setFunctionVariableValue(functionValue, scopeIndex, variableName, newValue)); }
void V8InjectedScriptHost::getInternalPropertiesMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info) { if (info.Length() < 1) return; v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(info[0]); InjectedScriptHost* host = V8InjectedScriptHost::toNative(info.Holder()); ScriptDebugServer& debugServer = host->scriptDebugServer(); v8SetReturnValue(info, debugServer.getInternalProperties(object)); }
v8::Handle<v8::Value> V8InjectedScriptHost::setFunctionVariableValueMethodCustom(const v8::Arguments& args) { v8::Handle<v8::Value> functionValue = args[0]; int scopeIndex = args[1]->Int32Value(); String variableName = toWebCoreStringWithUndefinedOrNullCheck(args[2]); v8::Handle<v8::Value> newValue = args[3]; InjectedScriptHost* host = V8InjectedScriptHost::toNative(args.Holder()); ScriptDebugServer& debugServer = host->scriptDebugServer(); return debugServer.setFunctionVariableValue(functionValue, scopeIndex, variableName, newValue); }
void V8InjectedScriptHost::unmonitorFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { String scriptId; int lineNumber; int columnNumber; if (!getFunctionLocation(info, &scriptId, &lineNumber, &columnNumber)) return; InjectedScriptHost* host = V8InjectedScriptHost::unwrap(info.GetIsolate()->GetCurrentContext(), info.Holder()); host->unmonitorFunction(scriptId, lineNumber, columnNumber); }
v8::Handle<v8::Value> V8InjectedScriptHost::storageIdCallback(const v8::Arguments& args) { if (args.Length() < 1) return v8::Undefined(); INC_STATS("InjectedScriptHost.storageId()"); InjectedScriptHost* host = V8InjectedScriptHost::toNative(args.Holder()); Storage* storage = V8Storage::toNative(v8::Handle<v8::Object>::Cast(args[0])); if (storage) return v8StringOrUndefined(host->storageIdImpl(storage), args.GetIsolate()); return v8::Undefined(); }
v8::Handle<v8::Value> V8InjectedScriptHost::getInternalPropertiesMethodCustom(const v8::Arguments& args) { if (args.Length() < 1) return v8::Undefined(); v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(args[0]); InjectedScriptHost* host = V8InjectedScriptHost::toNative(args.Holder()); ScriptDebugServer& debugServer = host->scriptDebugServer(); return debugServer.getInternalProperties(object); }
void V8InjectedScriptHost::unmonitorFunctionMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info) { String scriptId; int lineNumber; int columnNumber; if (!getFunctionLocation(info, &scriptId, &lineNumber, &columnNumber)) return; InjectedScriptHost* host = V8InjectedScriptHost::toNative(info.Holder()); host->unmonitorFunction(scriptId, lineNumber, columnNumber); }
v8::Handle<v8::Value> V8InjectedScriptHost::inspectedObjectMethodCustom(const v8::Arguments& args) { if (args.Length() < 1) return v8::Undefined(); if (!args[0]->IsInt32()) return throwTypeError("argument has to be an integer", args.GetIsolate()); InjectedScriptHost* host = V8InjectedScriptHost::toNative(args.Holder()); InjectedScriptHost::InspectableObject* object = host->inspectedObject(args[0]->ToInt32()->Value()); return object->get(ScriptState::current()).v8Value(); }
JSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionAddNodesToSearchResult(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) { UNUSED_PARAM(args); if (!thisValue.inherits(&JSInjectedScriptHost::s_info)) return throwError(exec, TypeError); JSInjectedScriptHost* castedThisObj = static_cast<JSInjectedScriptHost*>(asObject(thisValue)); InjectedScriptHost* imp = static_cast<InjectedScriptHost*>(castedThisObj->impl()); const UString& nodeIds = args.at(0).toString(exec); imp->addNodesToSearchResult(nodeIds); return jsUndefined(); }
v8::Handle<v8::Value> V8InjectedScriptHost::inspectMethodCustom(const v8::Arguments& args) { if (args.Length() < 2) return v8::Undefined(); InjectedScriptHost* host = V8InjectedScriptHost::toNative(args.Holder()); ScriptValue object(args[0]); ScriptValue hints(args[1]); host->inspectImpl(object.toInspectorValue(ScriptState::current()), hints.toInspectorValue(ScriptState::current())); return v8::Undefined(); }
v8::Handle<v8::Value> V8InjectedScriptHost::databaseIdCallback(const v8::Arguments& args) { INC_STATS("InjectedScriptHost.databaseId()"); if (args.Length() < 1) return v8::Undefined(); #if ENABLE(SQL_DATABASE) InjectedScriptHost* host = V8InjectedScriptHost::toNative(args.Holder()); Database* database = V8Database::toNative(v8::Handle<v8::Object>::Cast(args[0])); if (database) return v8StringOrUndefined(host->databaseIdImpl(database), args.GetIsolate()); #endif return v8::Undefined(); }
JSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionPushNodeByPathToFrontend(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) { UNUSED_PARAM(args); if (!thisValue.inherits(&JSInjectedScriptHost::s_info)) return throwError(exec, TypeError); JSInjectedScriptHost* castedThisObj = static_cast<JSInjectedScriptHost*>(asObject(thisValue)); InjectedScriptHost* imp = static_cast<InjectedScriptHost*>(castedThisObj->impl()); const UString& path = args.at(0).toString(exec); JSC::JSValue result = jsNumber(exec, imp->pushNodeByPathToFrontend(path)); return result; }
v8::Handle<v8::Value> V8InjectedScriptHost::inspectedNodeCallback(const v8::Arguments& args) { INC_STATS("InjectedScriptHost.inspectedNode()"); if (args.Length() < 1) return v8::Undefined(); InjectedScriptHost* host = V8InjectedScriptHost::toNative(args.Holder()); Node* node = host->inspectedNode(args[0]->ToInt32()->Value()); if (!node) return v8::Undefined(); return toV8(node); }
void V8InjectedScriptHost::setFunctionVariableValueCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { if (info.Length() < 4 || !info[0]->IsFunction() || !info[1]->IsInt32() || !info[2]->IsString()) return; v8::Local<v8::Value> functionValue = info[0]; int scopeIndex = info[1].As<v8::Int32>()->Value(); String variableName = toCoreStringWithUndefinedOrNullCheck(info[2]); v8::Local<v8::Value> newValue = info[3]; InjectedScriptHost* host = V8InjectedScriptHost::unwrap(info.GetIsolate()->GetCurrentContext(), info.Holder()); V8DebuggerImpl& debugger = static_cast<V8DebuggerImpl&>(host->debugger()); v8SetReturnValue(info, debugger.setFunctionVariableValue(functionValue, scopeIndex, variableName, newValue)); }
v8::Handle<v8::Value> V8InjectedScriptHost::getInternalPropertiesCallback(const v8::Arguments& args) { INC_STATS("InjectedScriptHost.getInternalProperties()"); if (args.Length() < 1) return v8::Undefined(); v8::HandleScope handleScope; v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(args[0]); InjectedScriptHost* host = V8InjectedScriptHost::toNative(args.Holder()); ScriptDebugServer& debugServer = host->scriptDebugServer(); return debugServer.getInternalProperties(object); }
void V8InjectedScriptHost::inspectedObjectMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info) { if (info.Length() < 1) return; if (!info[0]->IsInt32()) { throwTypeError("argument has to be an integer", info.GetIsolate()); return; } InjectedScriptHost* host = V8InjectedScriptHost::toNative(info.Holder()); InjectedScriptHost::InspectableObject* object = host->inspectedObject(info[0]->ToInt32()->Value()); v8SetReturnValue(info, object->get(ScriptState::current()).v8Value()); }
void V8InjectedScriptHost::inspectedObjectCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { if (info.Length() < 1) return; if (!info[0]->IsInt32()) { V8ThrowException::throwTypeError(info.GetIsolate(), "argument has to be an integer"); return; } v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext(); InjectedScriptHost* host = V8InjectedScriptHost::unwrap(context, info.Holder()); InjectedScriptHost::InspectableObject* object = host->inspectedObject(info[0].As<v8::Int32>()->Value()); v8SetReturnValue(info, object->get(context)); }
JSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionDidDestroyWorker(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) { UNUSED_PARAM(args); if (!thisValue.inherits(&JSInjectedScriptHost::s_info)) return throwError(exec, TypeError); JSInjectedScriptHost* castedThisObj = static_cast<JSInjectedScriptHost*>(asObject(thisValue)); InjectedScriptHost* imp = static_cast<InjectedScriptHost*>(castedThisObj->impl()); int id = args.at(0).toInt32(exec); #if ENABLE(WORKERS) imp->didDestroyWorker(id); #endif return jsUndefined(); }
JSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionNextWorkerId(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) { UNUSED_PARAM(args); if (!thisValue.inherits(&JSInjectedScriptHost::s_info)) return throwError(exec, TypeError); JSInjectedScriptHost* castedThisObj = static_cast<JSInjectedScriptHost*>(asObject(thisValue)); InjectedScriptHost* imp = static_cast<InjectedScriptHost*>(castedThisObj->impl()); #if ENABLE(WORKERS) JSC::JSValue result = jsNumber(exec, imp->nextWorkerId()); #else JSC::JSValue result = jsNumber(exec, 0); // TODO: Change this to something that would actually work. #endif return result; }
void V8InjectedScriptHost::monitorFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { String scriptId; int lineNumber; int columnNumber; if (!getFunctionLocation(info, &scriptId, &lineNumber, &columnNumber)) return; v8::Local<v8::Value> name; if (info.Length() > 0 && info[0]->IsFunction()) { v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(info[0]); name = function->GetName(); if (!name->IsString() || !v8::Local<v8::String>::Cast(name)->Length()) name = function->GetInferredName(); } InjectedScriptHost* host = V8InjectedScriptHost::unwrap(info.GetIsolate()->GetCurrentContext(), info.Holder()); host->monitorFunction(scriptId, lineNumber, columnNumber, toCoreStringWithUndefinedOrNullCheck(name)); }
void V8InjectedScriptHost::monitorFunctionMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info) { String scriptId; int lineNumber; int columnNumber; if (!getFunctionLocation(info, &scriptId, &lineNumber, &columnNumber)) return; v8::Handle<v8::Value> name; if (info.Length() > 0 && info[0]->IsFunction()) { v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(info[0]); name = function->GetName(); if (!name->IsString() || !v8::Handle<v8::String>::Cast(name)->Length()) name = function->GetInferredName(); } InjectedScriptHost* host = V8InjectedScriptHost::toNative(info.Holder()); host->monitorFunction(scriptId, lineNumber, columnNumber, toWebCoreStringWithUndefinedOrNullCheck(name)); }
v8::Handle<v8::Value> V8InjectedScriptHost::functionDetailsCallback(const v8::Arguments& args) { INC_STATS("InjectedScriptHost.functionDetailsCallback()"); if (args.Length() < 1) return v8::Undefined(); v8::HandleScope handleScope; v8::Handle<v8::Value> value = args[0]; if (!value->IsFunction()) return v8::Undefined(); v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(value); int lineNumber = function->GetScriptLineNumber(); int columnNumber = function->GetScriptColumnNumber(); v8::Local<v8::Object> location = v8::Object::New(); location->Set(v8::String::NewSymbol("lineNumber"), v8Integer(lineNumber, args.GetIsolate())); location->Set(v8::String::NewSymbol("columnNumber"), v8Integer(columnNumber, args.GetIsolate())); location->Set(v8::String::NewSymbol("scriptId"), function->GetScriptId()->ToString()); v8::Local<v8::Object> result = v8::Object::New(); result->Set(v8::String::NewSymbol("location"), location); v8::Handle<v8::Value> name = function->GetName(); if (name->IsString() && v8::Handle<v8::String>::Cast(name)->Length()) result->Set(v8::String::NewSymbol("name"), name); v8::Handle<v8::Value> inferredName = function->GetInferredName(); if (inferredName->IsString() && v8::Handle<v8::String>::Cast(inferredName)->Length()) result->Set(v8::String::NewSymbol("inferredName"), inferredName); InjectedScriptHost* host = V8InjectedScriptHost::toNative(args.Holder()); ScriptDebugServer& debugServer = host->scriptDebugServer(); v8::Handle<v8::Value> scopes = debugServer.functionScopes(function); if (!scopes.IsEmpty() && scopes->IsArray()) result->Set(v8::String::NewSymbol("rawScopes"), scopes); return result; }
void V8InjectedScriptHost::functionDetailsMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info) { if (info.Length() < 1) return; v8::Handle<v8::Value> value = info[0]; if (!value->IsFunction()) return; v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(value); int lineNumber = function->GetScriptLineNumber(); int columnNumber = function->GetScriptColumnNumber(); v8::Local<v8::Object> location = v8::Object::New(); location->Set(v8::String::NewSymbol("lineNumber"), v8::Integer::New(lineNumber, info.GetIsolate())); location->Set(v8::String::NewSymbol("columnNumber"), v8::Integer::New(columnNumber, info.GetIsolate())); location->Set(v8::String::NewSymbol("scriptId"), function->GetScriptId()->ToString()); v8::Local<v8::Object> result = v8::Object::New(); result->Set(v8::String::NewSymbol("location"), location); v8::Handle<v8::Value> name = function->GetName(); if (name->IsString() && v8::Handle<v8::String>::Cast(name)->Length()) result->Set(v8::String::NewSymbol("name"), name); v8::Handle<v8::Value> inferredName = function->GetInferredName(); if (inferredName->IsString() && v8::Handle<v8::String>::Cast(inferredName)->Length()) result->Set(v8::String::NewSymbol("inferredName"), inferredName); // FIXME: pass function displayName from V8 (crbug.com/17356). InjectedScriptHost* host = V8InjectedScriptHost::toNative(info.Holder()); ScriptDebugServer& debugServer = host->scriptDebugServer(); v8::Handle<v8::Value> scopes = debugServer.functionScopes(function); if (!scopes.IsEmpty() && scopes->IsArray()) result->Set(v8::String::NewSymbol("rawScopes"), scopes); v8SetReturnValue(info, result); }
void V8InjectedScriptHost::getEventListenersCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { if (info.Length() < 1) return; InjectedScriptHost* host = V8InjectedScriptHost::unwrap(info.GetIsolate()->GetCurrentContext(), info.Holder()); V8DebuggerClient* client = static_cast<V8DebuggerImpl&>(host->debugger()).client(); EventListenerInfoMap listenerInfo; client->eventListeners(info[0], listenerInfo); v8::Local<v8::Object> result = v8::Object::New(info.GetIsolate()); Vector<String> types; for (auto& it : listenerInfo) types.append(it.key); nonCopyingSort(types.begin(), types.end(), WTF::codePointCompareLessThan); for (const String& type : types) { v8::Local<v8::Array> listeners = wrapListenerFunctions(info.GetIsolate(), *listenerInfo.get(type)); if (!listeners->Length()) continue; result->Set(v8String(info.GetIsolate(), type), listeners); } v8SetReturnValue(info, result); }
static v8::Handle<v8::Value> clearConsoleMessagesCallback(const v8::Arguments& args) { InjectedScriptHost* imp = V8InjectedScriptHost::toNative(args.Holder()); imp->clearConsoleMessages(); return v8Undefined(); }
static void WeakReferenceCallback(v8::Persistent<v8::Value> object, void* parameter) { InjectedScriptHost* nativeObject = static_cast<InjectedScriptHost*>(parameter); nativeObject->deref(); object.Dispose(); }