Ejemplo n.º 1
0
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());
    }
}
Ejemplo n.º 2
0
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());
    }
}