Changeset 65730 in webkit


Ignore:
Timestamp:
Aug 20, 2010 4:34:16 AM (14 years ago)
Author:
yurys@chromium.org
Message:

2010-08-20 Yury Semikhatsky <yurys@chromium.org>

Reviewed by Pavel Feldman.

Web Inspector: discard InjectedScript reference on ScriptState when clearing injected scripts
https://bugs.webkit.org/show_bug.cgi?id=44328

Otherwise if the reference is not cleared we may remove InjectedScript from the
map on InjectedScriptHost but keep it on ScriptState and try to reuse it later.

  • bindings/js/JSInjectedScriptHostCustom.cpp: (WebCore::InjectedScriptHost::discardInjectedScript):
  • bindings/v8/V8HiddenPropertyName.h:
  • bindings/v8/custom/V8InjectedScriptHostCustom.cpp: (WebCore::InjectedScriptHost::discardInjectedScript): (WebCore::InjectedScriptHost::injectedScriptFor):
  • inspector/InjectedScript.h: (WebCore::InjectedScript::scriptState):
  • inspector/InjectedScriptHost.cpp: (WebCore::InjectedScriptHost::discardInjectedScripts):
  • inspector/InjectedScriptHost.h:
Location:
trunk/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r65729 r65730  
     12010-08-20  Yury Semikhatsky  <yurys@chromium.org>
     2
     3        Reviewed by Pavel Feldman.
     4
     5        Web Inspector: discard InjectedScript reference on ScriptState when clearing injected scripts
     6        https://bugs.webkit.org/show_bug.cgi?id=44328
     7
     8        Otherwise if the reference is not cleared we may remove InjectedScript from the
     9        map on InjectedScriptHost but keep it on ScriptState and try to reuse it later.
     10
     11        * bindings/js/JSInjectedScriptHostCustom.cpp:
     12        (WebCore::InjectedScriptHost::discardInjectedScript):
     13        * bindings/v8/V8HiddenPropertyName.h:
     14        * bindings/v8/custom/V8InjectedScriptHostCustom.cpp:
     15        (WebCore::InjectedScriptHost::discardInjectedScript):
     16        (WebCore::InjectedScriptHost::injectedScriptFor):
     17        * inspector/InjectedScript.h:
     18        (WebCore::InjectedScript::scriptState):
     19        * inspector/InjectedScriptHost.cpp:
     20        (WebCore::InjectedScriptHost::discardInjectedScripts):
     21        * inspector/InjectedScriptHost.h:
     22
    1232010-08-20  Nikolas Zimmermann  <nzimmermann@rim.com>
    224
  • trunk/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp

    r65506 r65730  
    104104}
    105105
     106void InjectedScriptHost::discardInjectedScript(ScriptState* scriptState)
     107{
     108    JSDOMGlobalObject* globalObject = static_cast<JSDOMGlobalObject*>(scriptState->lexicalGlobalObject());
     109    globalObject->setInjectedScript(0);
     110}
     111
    106112#if ENABLE(JAVASCRIPT_DEBUGGER)
    107113JSValue JSInjectedScriptHost::currentCallFrame(ExecState* exec)
  • trunk/WebCore/bindings/v8/V8HiddenPropertyName.h

    r62380 r65730  
    4141    V(attributeListener) \
    4242    V(scriptState) \
     43    V(devtoolsInjectedScript) \
    4344    V(sleepFunction) \
    4445    V(toStringString) \
    4546    V(event)
     47
    4648
    4749    class V8HiddenPropertyName {
  • trunk/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp

    r65506 r65730  
    4747#include "V8DOMWindow.h"
    4848#include "V8Database.h"
     49#include "V8HiddenPropertyName.h"
    4950#include "V8JavaScriptCallFrame.h"
    5051#include "V8Node.h"
     
    121122}
    122123
     124void InjectedScriptHost::discardInjectedScript(ScriptState* inspectedScriptState)
     125{
     126    v8::HandleScope handleScope;
     127    v8::Local<v8::Context> context = inspectedScriptState->context();
     128    v8::Context::Scope contextScope(context);
     129
     130    v8::Local<v8::Object> global = context->Global();
     131    // Skip proxy object. The proxy object will survive page navigation while we need
     132    // an object whose lifetime consides with that of the inspected context.
     133    global = v8::Local<v8::Object>::Cast(global->GetPrototype());
     134
     135    v8::Handle<v8::String> key = V8HiddenPropertyName::devtoolsInjectedScript();
     136    global->DeleteHiddenValue(key);
     137}
     138
    123139v8::Handle<v8::Value> V8InjectedScriptHost::nodeForIdCallback(const v8::Arguments& args)
    124140{
     
    207223    global = v8::Local<v8::Object>::Cast(global->GetPrototype());
    208224
    209     v8::Local<v8::String> key = v8::String::New("Devtools_InjectedScript");
     225    v8::Handle<v8::String> key = V8HiddenPropertyName::devtoolsInjectedScript();
    210226    v8::Local<v8::Value> val = global->GetHiddenValue(key);
    211227    if (!val.IsEmpty() && val->IsObject())
  • trunk/WebCore/inspector/InjectedScript.h

    r65072 r65730  
    5555    PassRefPtr<InspectorValue> wrapForConsole(ScriptValue);
    5656    void releaseWrapperObjectGroup(const String&);
     57    ScriptState* scriptState() const { return m_injectedScriptObject.scriptState(); }
    5758
    5859private:
  • trunk/WebCore/inspector/InjectedScriptHost.cpp

    r65072 r65730  
    150150void InjectedScriptHost::discardInjectedScripts()
    151151{
     152    IdToInjectedScriptMap::iterator end = m_idToInjectedScript.end();
     153    for (IdToInjectedScriptMap::iterator it = m_idToInjectedScript.begin(); it != end; ++it)
     154        discardInjectedScript(it->second.scriptState());
    152155    m_idToInjectedScript.clear();
    153156}
  • trunk/WebCore/inspector/InjectedScriptHost.h

    r65669 r65730  
    9898    RemoteInspectorFrontend* remoteFrontend();
    9999    ScriptObject createInjectedScript(const String& source, ScriptState* scriptState, long id);
     100    void discardInjectedScript(ScriptState*);
    100101
    101102    InspectorController* m_inspectorController;
Note: See TracChangeset for help on using the changeset viewer.