InjectedScript InjectedScriptManager::injectedScriptFor(ExecState* inspectedExecState)
{
    auto it = m_scriptStateToId.find(inspectedExecState);
    if (it != m_scriptStateToId.end()) {
        auto it1 = m_idToInjectedScript.find(it->value);
        if (it1 != m_idToInjectedScript.end())
            return it1->value;
    }

    if (!m_environment.canAccessInspectedScriptState(inspectedExecState))
        return InjectedScript();

    int id = injectedScriptIdFor(inspectedExecState);
    Deprecated::ScriptObject injectedScriptObject = createInjectedScript(injectedScriptSource(), inspectedExecState, id);
    if (injectedScriptObject.scriptState() != inspectedExecState) {
        WTFLogAlways("Failed to parse/execute InjectedScriptSource.js!");
        WTFLogAlways("%s\n", injectedScriptSource().ascii().data());
        RELEASE_ASSERT_NOT_REACHED();
    }

    InjectedScript result(injectedScriptObject, &m_environment);
    m_idToInjectedScript.set(id, result);
    didCreateInjectedScript(result);
    return result;
}
InjectedScript InjectedScriptHost::injectedScriptFor(ScriptState* scriptState)
{
    JSLock lock(SilenceAssertionsOnly);
    JSDOMGlobalObject* globalObject = static_cast<JSDOMGlobalObject*>(scriptState->lexicalGlobalObject());
    JSObject* injectedScript = globalObject->injectedScript();
    if (injectedScript)
        return InjectedScript(ScriptObject(scriptState, injectedScript));

    ASSERT(!m_injectedScriptSource.isEmpty());
    ScriptObject injectedScriptObject = createInjectedScript(m_injectedScriptSource, this, scriptState, m_nextInjectedScriptId);
    globalObject->setInjectedScript(injectedScriptObject.jsObject());
    InjectedScript result(injectedScriptObject);
    m_idToInjectedScript.set(m_nextInjectedScriptId, result);
    m_nextInjectedScriptId++;
    return result;
}
Ejemplo n.º 3
0
InjectedScript InjectedScriptManager::injectedScriptFor(JSC::ExecState* inspectedExecState)
{
    ExecStateToId::iterator it = m_scriptStateToId.find(inspectedExecState);
    if (it != m_scriptStateToId.end()) {
        IdToInjectedScriptMap::iterator it1 = m_idToInjectedScript.find(it->value);
        if (it1 != m_idToInjectedScript.end())
            return it1->value;
    }

    if (!m_inspectedStateAccessCheck(inspectedExecState))
        return InjectedScript();

    int id = injectedScriptIdFor(inspectedExecState);
    ScriptObject injectedScriptObject = createInjectedScript(injectedScriptSource(), inspectedExecState, id);
    InjectedScript result(injectedScriptObject, m_inspectedStateAccessCheck);
    m_idToInjectedScript.set(id, result);
    return result;
}
pair<long, ScriptObject> InjectedScriptHost::injectScript(const String& source, ScriptState* scriptState)
{
    long id = m_nextInjectedScriptId++;
    return std::make_pair(id, createInjectedScript(source, scriptState, id));
}
Ejemplo n.º 5
0
pair<int, ScriptObject> InjectedScriptManager::injectScript(const String& source, ScriptState* scriptState)
{
    int id = injectedScriptIdFor(scriptState);
    return std::make_pair(id, createInjectedScript(source, scriptState, id));
}