本文整理汇总了C++中deprecated::ScriptValue类的典型用法代码示例。如果您正苦于以下问题:C++ ScriptValue类的具体用法?C++ ScriptValue怎么用?C++ ScriptValue使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ScriptValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: jsUndefined
static JSC::JSValue handleInitMessageEvent(JSMessageEvent* jsEvent, JSC::ExecState* exec)
{
const String& typeArg = exec->argument(0).toString(exec)->value(exec);
bool canBubbleArg = exec->argument(1).toBoolean(exec);
bool cancelableArg = exec->argument(2).toBoolean(exec);
const String originArg = exec->argument(4).toString(exec)->value(exec);
const String lastEventIdArg = exec->argument(5).toString(exec)->value(exec);
DOMWindow* sourceArg = toDOMWindow(exec->argument(6));
std::unique_ptr<MessagePortArray> messagePorts;
OwnPtr<ArrayBufferArray> arrayBuffers;
if (!exec->argument(7).isUndefinedOrNull()) {
messagePorts = std::make_unique<MessagePortArray>();
arrayBuffers = adoptPtr(new ArrayBufferArray);
fillMessagePortArray(exec, exec->argument(7), *messagePorts, *arrayBuffers);
if (exec->hadException())
return jsUndefined();
}
Deprecated::ScriptValue dataArg = Deprecated::ScriptValue(exec->vm(), exec->argument(3));
if (exec->hadException())
return jsUndefined();
MessageEvent& event = jsEvent->impl();
event.initMessageEvent(typeArg, canBubbleArg, cancelableArg, dataArg, originArg, lastEventIdArg, sourceArg, WTF::move(messagePorts));
jsEvent->m_data.set(exec->vm(), jsEvent, dataArg.jsValue());
return jsUndefined();
}
示例2: ensureInjected
void InjectedScriptModule::ensureInjected(InjectedScriptManager* injectedScriptManager, InjectedScript injectedScript)
{
ASSERT(!injectedScript.hasNoValue());
if (injectedScript.hasNoValue())
return;
// FIXME: Make the InjectedScript a module itself.
JSC::APIEntryShim entryShim(injectedScript.scriptState());
Deprecated::ScriptFunctionCall function(injectedScript.injectedScriptObject(), ASCIILiteral("module"), injectedScriptManager->inspectorEnvironment().functionCallHandler());
function.appendArgument(name());
bool hadException = false;
Deprecated::ScriptValue resultValue = injectedScript.callFunctionWithEvalEnabled(function, hadException);
ASSERT(!hadException);
if (hadException || resultValue.hasNoValue() || !resultValue.isObject()) {
Deprecated::ScriptFunctionCall function(injectedScript.injectedScriptObject(), ASCIILiteral("injectModule"), injectedScriptManager->inspectorEnvironment().functionCallHandler());
function.appendArgument(name());
function.appendArgument(source());
function.appendArgument(host(injectedScriptManager, injectedScript.scriptState()));
resultValue = injectedScript.callFunctionWithEvalEnabled(function, hadException);
if (hadException || (returnsObject() && (resultValue.hasNoValue() || !resultValue.isObject()))) {
ASSERT_NOT_REACHED();
return;
}
}
if (returnsObject()) {
Deprecated::ScriptObject moduleObject(injectedScript.scriptState(), resultValue);
initialize(moduleObject, &injectedScriptManager->inspectorEnvironment());
}
}
示例3: ensureInjected
void InjectedScriptModule::ensureInjected(InjectedScriptManager* injectedScriptManager, InjectedScript injectedScript)
{
ASSERT(!injectedScript.hasNoValue());
if (injectedScript.hasNoValue())
return;
// FIXME: Make the InjectedScript a module itself.
Deprecated::ScriptFunctionCall function(injectedScript.injectedScriptObject(), "module", WebCore::functionCallHandlerFromAnyThread);
function.appendArgument(name());
bool hadException = false;
Deprecated::ScriptValue resultValue = injectedScript.callFunctionWithEvalEnabled(function, hadException);
ASSERT(!hadException);
if (hadException || resultValue.hasNoValue() || !resultValue.isObject()) {
Deprecated::ScriptFunctionCall function(injectedScript.injectedScriptObject(), "injectModule", WebCore::functionCallHandlerFromAnyThread);
function.appendArgument(name());
function.appendArgument(source());
function.appendArgument(host(injectedScriptManager, injectedScript.scriptState()));
resultValue = injectedScript.callFunctionWithEvalEnabled(function, hadException);
if (hadException || (returnsObject() && (resultValue.hasNoValue() || !resultValue.isObject()))) {
ASSERT_NOT_REACHED();
return;
}
}
if (returnsObject()) {
Deprecated::ScriptObject moduleObject(injectedScript.scriptState(), resultValue);
initialize(moduleObject, injectedScriptManager->inspectedStateAccessCheck());
}
}
示例4: evaluate
void WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode)
{
if (isExecutionForbidden())
return;
Deprecated::ScriptValue exception;
evaluate(sourceCode, &exception);
if (exception.jsValue()) {
JSLockHolder lock(vm());
reportException(m_workerGlobalScopeWrapper->globalExec(), exception.jsValue());
}
}
示例5: ASSERT
RefPtr<InspectorObject> InspectorDebuggerAgent::buildExceptionPauseReason(const Deprecated::ScriptValue& exception, const InjectedScript& injectedScript)
{
ASSERT(!exception.hasNoValue());
if (exception.hasNoValue())
return nullptr;
ASSERT(!injectedScript.hasNoValue());
if (injectedScript.hasNoValue())
return nullptr;
return injectedScript.wrapObject(exception, InspectorDebuggerAgent::backtraceObjectGroup)->openAccessors();
}
示例6: callWrapContextFunction
Deprecated::ScriptObject InjectedScriptCanvasModule::callWrapContextFunction(const String& functionName, const Deprecated::ScriptObject& context)
{
Deprecated::ScriptFunctionCall function(injectedScriptObject(), functionName, WebCore::functionCallHandlerFromAnyThread);
function.appendArgument(context);
bool hadException = false;
Deprecated::ScriptValue resultValue = callFunctionWithEvalEnabled(function, hadException);
if (hadException || resultValue.hasNoValue() || !resultValue.isObject()) {
ASSERT_NOT_REACHED();
return Deprecated::ScriptObject();
}
return Deprecated::ScriptObject(context.scriptState(), resultValue);
}
示例7: inspectedObject
JSValue JSCommandLineAPIHost::inspectedObject(ExecState* exec)
{
CommandLineAPIHost::InspectableObject* object = impl().inspectedObject();
if (!object)
return jsUndefined();
JSLockHolder lock(exec);
Deprecated::ScriptValue scriptValue = object->get(exec);
if (scriptValue.hasNoValue())
return jsUndefined();
return scriptValue.jsValue();
}
示例8: getHeapObjectId
void InspectorHeapProfilerAgent::getHeapObjectId(ErrorString* errorString, const String& objectId, String* heapSnapshotObjectId)
{
InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForObjectId(objectId);
if (injectedScript.hasNoValue()) {
*errorString = "Inspected context has gone";
return;
}
Deprecated::ScriptValue value = injectedScript.findObjectById(objectId);
if (value.hasNoValue() || value.isUndefined()) {
*errorString = "Object with given id not found";
return;
}
unsigned id = ScriptProfiler::getHeapObjectId(value);
*heapSnapshotObjectId = String::number(id);
}
示例9: function
PassRefPtr<Array<Inspector::TypeBuilder::Debugger::CallFrame>> InjectedScript::wrapCallFrames(const Deprecated::ScriptValue& callFrames)
{
ASSERT(!hasNoValue());
Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("wrapCallFrames"), inspectorEnvironment()->functionCallHandler());
function.appendArgument(callFrames);
bool hadException = false;
Deprecated::ScriptValue callFramesValue = callFunctionWithEvalEnabled(function, hadException);
ASSERT(!hadException);
RefPtr<InspectorValue> result = callFramesValue.toInspectorValue(scriptState());
if (result->type() == InspectorValue::TypeArray)
return Array<Inspector::TypeBuilder::Debugger::CallFrame>::runtimeCast(result);
return Array<Inspector::TypeBuilder::Debugger::CallFrame>::create();
}
示例10: effectiveObjectStore
RefPtr<WebCore::IDBRequest> IDBCursor::update(JSC::ExecState& exec, Deprecated::ScriptValue& value, ExceptionCode& ec)
{
LOG(IndexedDB, "IDBCursor::update");
if (sourcesDeleted()) {
ec = IDBDatabaseException::InvalidStateError;
return nullptr;
}
if (!transaction().isActive()) {
ec = IDBDatabaseException::TransactionInactiveError;
return nullptr;
}
if (transaction().isReadOnly()) {
ec = IDBDatabaseException::ReadOnlyError;
return nullptr;
}
if (!m_gotValue) {
ec = IDBDatabaseException::InvalidStateError;
return nullptr;
}
if (isKeyCursor()) {
ec = IDBDatabaseException::InvalidStateError;
return nullptr;
}
return effectiveObjectStore().put(exec, value.jsValue(), m_deprecatedCurrentPrimaryKey.jsValue(), ec);
}
示例11: didPause
void InspectorDebuggerAgent::didPause(JSC::ExecState* scriptState, const Deprecated::ScriptValue& callFrames, const Deprecated::ScriptValue& exception)
{
ASSERT(scriptState && !m_pausedScriptState);
m_pausedScriptState = scriptState;
m_currentCallStack = callFrames;
if (!exception.hasNoValue()) {
InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(scriptState);
if (!injectedScript.hasNoValue()) {
m_breakReason = InspectorDebuggerFrontendDispatcher::Reason::Exception;
m_breakAuxData = injectedScript.wrapObject(exception, InspectorDebuggerAgent::backtraceObjectGroup)->openAccessors();
// m_breakAuxData might be null after this.
}
}
m_frontendDispatcher->paused(currentCallFrames(), m_breakReason, m_breakAuxData);
m_javaScriptPauseScheduled = false;
if (m_continueToLocationBreakpointID != JSC::noBreakpointID) {
scriptDebugServer().removeBreakpoint(m_continueToLocationBreakpointID);
m_continueToLocationBreakpointID = JSC::noBreakpointID;
}
if (m_listener)
m_listener->didPause();
}
示例12: injectIDBKeyIntoScriptValue
bool injectIDBKeyIntoScriptValue(DOMRequestState* requestState, PassRefPtr<IDBKey> key, Deprecated::ScriptValue& value, const IDBKeyPath& keyPath)
{
LOG(StorageAPI, "injectIDBKeyIntoScriptValue");
ASSERT(keyPath.type() == IndexedDB::KeyPathType::String);
Vector<String> keyPathElements;
IDBKeyPathParseError error;
IDBParseKeyPath(keyPath.string(), keyPathElements, error);
ASSERT(error == IDBKeyPathParseError::None);
if (keyPathElements.isEmpty())
return false;
ExecState* exec = requestState->exec();
JSValue parent = ensureNthValueOnKeyPath(exec, value.jsValue(), keyPathElements, keyPathElements.size() - 1);
if (parent.isUndefined())
return false;
if (!set(exec, parent, keyPathElements.last(), idbKeyToJSValue(exec, exec->lexicalGlobalObject(), key.get())))
return false;
return true;
}
示例13: inspectedObject
JSValue JSCommandLineAPIHost::inspectedObject(ExecState* exec)
{
if (exec->argumentCount() < 1)
return jsUndefined();
CommandLineAPIHost::InspectableObject* object = impl().inspectedObject(exec->uncheckedArgument(0).toInt32(exec));
if (!object)
return jsUndefined();
JSLockHolder lock(exec);
Deprecated::ScriptValue scriptValue = object->get(exec);
if (scriptValue.hasNoValue())
return jsUndefined();
return scriptValue.jsValue();
}
示例14: wrapFunction
PassRefPtr<Inspector::TypeBuilder::Runtime::RemoteObject> InjectedScript::wrapObject(const Deprecated::ScriptValue& value, const String& groupName, bool generatePreview) const
{
ASSERT(!hasNoValue());
Deprecated::ScriptFunctionCall wrapFunction(injectedScriptObject(), ASCIILiteral("wrapObject"), inspectorEnvironment()->functionCallHandler());
wrapFunction.appendArgument(value);
wrapFunction.appendArgument(groupName);
wrapFunction.appendArgument(hasAccessToInspectedScriptState());
wrapFunction.appendArgument(generatePreview);
bool hadException = false;
Deprecated::ScriptValue r = callFunctionWithEvalEnabled(wrapFunction, hadException);
if (hadException)
return nullptr;
RefPtr<InspectorObject> rawResult = r.toInspectorValue(scriptState())->asObject();
return Inspector::TypeBuilder::Runtime::RemoteObject::runtimeCast(rawResult);
}
示例15: makeCall
void InjectedScriptBase::makeCall(Deprecated::ScriptFunctionCall& function, RefPtr<InspectorValue>* result)
{
if (hasNoValue() || !hasAccessToInspectedScriptState()) {
*result = InspectorValue::null();
return;
}
bool hadException = false;
Deprecated::ScriptValue resultValue = callFunctionWithEvalEnabled(function, hadException);
ASSERT(!hadException);
if (!hadException) {
*result = resultValue.toInspectorValue(m_injectedScriptObject.scriptState());
if (!*result)
*result = InspectorString::create(String::format("Object has too long reference chain (must not be longer than %d)", InspectorValue::maxDepth));
} else
*result = InspectorString::create("Exception while making a call.");
}