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;
}
Пример #2
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;
}
Пример #3
0
pair<int, ScriptObject> InjectedScriptManager::injectScript(const String& source, ScriptState* scriptState)
{
    int id = injectedScriptIdFor(scriptState);
    return std::make_pair(id, createInjectedScript(source, scriptState, id));
}