Changeset 53467 in webkit


Ignore:
Timestamp:
Jan 19, 2010 6:27:58 AM (14 years ago)
Author:
yurys@chromium.org
Message:

2010-01-19 Yury Semikhatsky <yurys@chromium.org>

Reviewed by Pavel Feldman.

Inject inspector script directly into the inspected context. All the
communication between the script and the frontend is serialized into
JSON strings. It allows to get rid of object quarantines in Web Inspector.

https://bugs.webkit.org/show_bug.cgi?id=32554

  • bindings/js/JSInjectedScriptHostCustom.cpp: (WebCore::JSInjectedScriptHost::databaseForId): (WebCore::JSInjectedScriptHost::currentCallFrame): (WebCore::JSInjectedScriptHost::nodeForId): (WebCore::JSInjectedScriptHost::pushNodePathToFrontend): (WebCore::JSInjectedScriptHost::selectDatabase): (WebCore::JSInjectedScriptHost::selectDOMStorage):
  • bindings/js/ScriptController.cpp: (WebCore::ScriptController::mainWorldScriptState):
  • bindings/js/ScriptController.h:
  • bindings/js/ScriptObject.h: (WebCore::ScriptObject::scriptState):
  • bindings/js/ScriptValue.cpp:
  • bindings/js/ScriptValue.h:
  • bindings/v8/ScriptObject.h: (WebCore::ScriptObject::scriptState):
  • bindings/v8/ScriptValue.h:
  • bindings/v8/custom/V8InjectedScriptHostCustom.cpp:
  • inspector/ConsoleMessage.cpp: (WebCore::ConsoleMessage::ConsoleMessage): (WebCore::ConsoleMessage::addToConsole): (WebCore::ConsoleMessage::isEqual):
  • inspector/ConsoleMessage.h:
  • inspector/InjectedScriptHost.cpp: (WebCore::InjectedScriptHost::releaseWrapperObjectGroup):
  • inspector/InjectedScriptHost.h:
  • inspector/InjectedScriptHost.idl:
  • inspector/InspectorBackend.cpp: (WebCore::InspectorBackend::setInjectedScriptSource): (WebCore::InspectorBackend::dispatchOnInjectedScript): (WebCore::InspectorBackend::releaseWrapperObjectGroup):
  • inspector/InspectorBackend.h:
  • inspector/InspectorBackend.idl:
  • inspector/InspectorController.cpp: (WebCore::InspectorController::InspectorController): (WebCore::InspectorController::clearConsoleMessages): (WebCore::InspectorController::inspectedWindowScriptObjectCleared): (WebCore::InspectorController::windowScriptObjectAvailable): (WebCore::InspectorController::scriptObjectReady): (WebCore::InspectorController::setFrontendProxyObject): (WebCore::InspectorController::close): (WebCore::InspectorController::resetScriptObjects): (WebCore::InspectorController::didPause): (WebCore::InspectorController::injectedScriptForNodeId):
  • inspector/InspectorController.h:
  • inspector/InspectorFrontend.cpp: (WebCore::InspectorFrontend::addConsoleMessage): (WebCore::InspectorFrontend::pausedScript):
  • inspector/InspectorFrontend.h:
  • inspector/front-end/AuditsPanel.js: (WebInspector.AuditsPanel.prototype._reloadResources):
  • inspector/front-end/ConsoleView.js: (WebInspector.ConsoleView.prototype.requestClearMessages): (WebInspector.ConsoleView.prototype.doEvalInWindow):
  • inspector/front-end/DOMAgent.js: (WebInspector.DOMNode): (WebInspector.CSSStyleDeclaration): (WebInspector.CSSStyleDeclaration.parseRule):
  • inspector/front-end/Database.js: (WebInspector.Database.prototype.executeSql):
  • inspector/front-end/ElementsPanel.js: (WebInspector.ElementsPanel.this.treeOutline.focusedNodeChanged.InjectedScriptAccess.get addInspectedNode): (WebInspector.ElementsPanel.this.treeOutline.focusedNodeChanged): (WebInspector.ElementsPanel.prototype.setDocument): (WebInspector.ElementsPanel.prototype.searchCanceled): (WebInspector.ElementsPanel.prototype.performSearch):
  • inspector/front-end/ElementsTreeOutline.js: (WebInspector.ElementsTreeElement.prototype.createTooltipForImageNode):
  • inspector/front-end/EventListenersSidebarPane.js: ():
  • inspector/front-end/InjectedScript.js: (injectedScriptConstructor): (injectedScriptConstructor.):
  • inspector/front-end/InjectedScriptAccess.js: (InjectedScriptAccess): (InjectedScriptAccess.getDefault): (get InjectedScriptAccess): (InjectedScriptAccess._installHandler.InjectedScriptAccess.prototype.methodName): (InjectedScriptAccess._installHandler):
  • inspector/front-end/MetricsSidebarPane.js: (WebInspector.MetricsSidebarPane): (WebInspector.MetricsSidebarPane.prototype.update.inlineStyleCallback):
  • inspector/front-end/ObjectPropertiesSection.js:
  • inspector/front-end/ObjectProxy.js: (WebInspector.ObjectProxy):
  • inspector/front-end/PropertiesSidebarPane.js: (WebInspector.PropertiesSidebarPane.prototype.update.callback):
  • inspector/front-end/ResourcesPanel.js: (WebInspector.ResourceSidebarTreeElement.prototype.ondblclick):
  • inspector/front-end/ScriptsPanel.js:
  • inspector/front-end/StylesSidebarPane.js: (WebInspector.StylePropertyTreeElement.prototype):
  • inspector/front-end/WatchExpressionsSidebarPane.js: (WebInspector.WatchExpressionsSection.prototype.update):
  • inspector/front-end/inspector.js: (WebInspector.loaded): (WebInspector.pausedScript): (WebInspector.addConsoleMessage): (WebInspector.log.logMessage): (WebInspector.log):

2010-01-19 Yury Semikhatsky <yurys@chromium.org>

Reviewed by Pavel Feldman.

Inject inspector script directly into the inspected context. All the
communication between the script and the frontend is serialized into
JSON strings. It allows to get rid of object quarantines in Web Inspector.

Refactor test case due to InjectedScriptAccess changes.

https://bugs.webkit.org/show_bug.cgi?id=32554

  • inspector/styles-iframe.html:
Location:
trunk
Files:
42 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r53466 r53467  
     12010-01-19  Yury Semikhatsky  <yurys@chromium.org>
     2
     3        Reviewed by Pavel Feldman.
     4
     5        Inject inspector script directly into the inspected context. All the
     6        communication between the script and the frontend is serialized into
     7        JSON strings. It allows to get rid of object quarantines in Web Inspector.
     8
     9        Refactor test case due to InjectedScriptAccess changes.
     10
     11        https://bugs.webkit.org/show_bug.cgi?id=32554
     12
     13        * inspector/styles-iframe.html:
     14 
    1152010-01-19  MORITA Hajime  <morrita@gmail.com>
    216
  • trunk/LayoutTests/inspector/styles-iframe.html

    r50582 r53467  
    5757{
    5858    // 1. Get styles for body, store them in mainStyles var.
    59     var bodyId = WebInspector.domAgent.document.body.id;
     59    var body = WebInspector.domAgent.document.body;
    6060    var mainStyles = null;
    6161    function mainFrameCallback(styles) {
    6262        mainStyles = styles;
    6363    }
    64     InjectedScriptAccess.getStyles(bodyId, false, mainFrameCallback);
     64    InjectedScriptAccess.get(body.injectedScriptId).getStyles(body.id, false, mainFrameCallback);
    6565
    6666    // 2. Find iframe node
    6767    var innerMapping = WebInspector.domAgent._idToDOMNode;
    68     var iframeBodyId = null;
     68    var iframeBody = null;
    6969
    7070    for (var nodeId in innerMapping) {
    7171        if (innerMapping[nodeId].nodeName === "IFRAME")
    72             iframeBodyId = innerMapping[nodeId].firstChild.lastChild.id;
     72            iframeBody = innerMapping[nodeId].firstChild.lastChild;
    7373    }
    74     if (typeof iframeBodyId !== "number") {
     74    if (!iframeBody) {
    7575        testController.notifyDone(["No iframe node found"]);
    7676        return;
     
    8181        testController.notifyDone([mainStyles, styles]);
    8282    }
    83     InjectedScriptAccess.getStyles(iframeBodyId, false, iframeCallback);
     83    InjectedScriptAccess.get(iframeBody.injectedScriptId).getStyles(iframeBody.id, false, iframeCallback);
    8484}
    8585
  • trunk/WebCore/ChangeLog

    r53465 r53467  
     12010-01-19  Yury Semikhatsky  <yurys@chromium.org>
     2
     3        Reviewed by Pavel Feldman.
     4
     5        Inject inspector script directly into the inspected context. All the
     6        communication between the script and the frontend is serialized into
     7        JSON strings. It allows to get rid of object quarantines in Web Inspector.
     8
     9        https://bugs.webkit.org/show_bug.cgi?id=32554
     10
     11        * bindings/js/JSInjectedScriptHostCustom.cpp:
     12        (WebCore::JSInjectedScriptHost::databaseForId):
     13        (WebCore::JSInjectedScriptHost::currentCallFrame):
     14        (WebCore::JSInjectedScriptHost::nodeForId):
     15        (WebCore::JSInjectedScriptHost::pushNodePathToFrontend):
     16        (WebCore::JSInjectedScriptHost::selectDatabase):
     17        (WebCore::JSInjectedScriptHost::selectDOMStorage):
     18        * bindings/js/ScriptController.cpp:
     19        (WebCore::ScriptController::mainWorldScriptState):
     20        * bindings/js/ScriptController.h:
     21        * bindings/js/ScriptObject.h:
     22        (WebCore::ScriptObject::scriptState):
     23        * bindings/js/ScriptValue.cpp:
     24        * bindings/js/ScriptValue.h:
     25        * bindings/v8/ScriptObject.h:
     26        (WebCore::ScriptObject::scriptState):
     27        * bindings/v8/ScriptValue.h:
     28        * bindings/v8/custom/V8InjectedScriptHostCustom.cpp:
     29        * inspector/ConsoleMessage.cpp:
     30        (WebCore::ConsoleMessage::ConsoleMessage):
     31        (WebCore::ConsoleMessage::addToConsole):
     32        (WebCore::ConsoleMessage::isEqual):
     33        * inspector/ConsoleMessage.h:
     34        * inspector/InjectedScriptHost.cpp:
     35        (WebCore::InjectedScriptHost::releaseWrapperObjectGroup):
     36        * inspector/InjectedScriptHost.h:
     37        * inspector/InjectedScriptHost.idl:
     38        * inspector/InspectorBackend.cpp:
     39        (WebCore::InspectorBackend::setInjectedScriptSource):
     40        (WebCore::InspectorBackend::dispatchOnInjectedScript):
     41        (WebCore::InspectorBackend::releaseWrapperObjectGroup):
     42        * inspector/InspectorBackend.h:
     43        * inspector/InspectorBackend.idl:
     44        * inspector/InspectorController.cpp:
     45        (WebCore::InspectorController::InspectorController):
     46        (WebCore::InspectorController::clearConsoleMessages):
     47        (WebCore::InspectorController::inspectedWindowScriptObjectCleared):
     48        (WebCore::InspectorController::windowScriptObjectAvailable):
     49        (WebCore::InspectorController::scriptObjectReady):
     50        (WebCore::InspectorController::setFrontendProxyObject):
     51        (WebCore::InspectorController::close):
     52        (WebCore::InspectorController::resetScriptObjects):
     53        (WebCore::InspectorController::didPause):
     54        (WebCore::InspectorController::injectedScriptForNodeId):
     55        * inspector/InspectorController.h:
     56        * inspector/InspectorFrontend.cpp:
     57        (WebCore::InspectorFrontend::addConsoleMessage):
     58        (WebCore::InspectorFrontend::pausedScript):
     59        * inspector/InspectorFrontend.h:
     60        * inspector/front-end/AuditsPanel.js:
     61        (WebInspector.AuditsPanel.prototype._reloadResources):
     62        * inspector/front-end/ConsoleView.js:
     63        (WebInspector.ConsoleView.prototype.requestClearMessages):
     64        (WebInspector.ConsoleView.prototype.doEvalInWindow):
     65        * inspector/front-end/DOMAgent.js:
     66        (WebInspector.DOMNode):
     67        (WebInspector.CSSStyleDeclaration):
     68        (WebInspector.CSSStyleDeclaration.parseRule):
     69        * inspector/front-end/Database.js:
     70        (WebInspector.Database.prototype.executeSql):
     71        * inspector/front-end/ElementsPanel.js:
     72        (WebInspector.ElementsPanel.this.treeOutline.focusedNodeChanged.InjectedScriptAccess.get addInspectedNode):
     73        (WebInspector.ElementsPanel.this.treeOutline.focusedNodeChanged):
     74        (WebInspector.ElementsPanel.prototype.setDocument):
     75        (WebInspector.ElementsPanel.prototype.searchCanceled):
     76        (WebInspector.ElementsPanel.prototype.performSearch):
     77        * inspector/front-end/ElementsTreeOutline.js:
     78        (WebInspector.ElementsTreeElement.prototype.createTooltipForImageNode):
     79        * inspector/front-end/EventListenersSidebarPane.js:
     80        ():
     81        * inspector/front-end/InjectedScript.js:
     82        (injectedScriptConstructor):
     83        (injectedScriptConstructor.):
     84        * inspector/front-end/InjectedScriptAccess.js:
     85        (InjectedScriptAccess):
     86        (InjectedScriptAccess.getDefault):
     87        (get InjectedScriptAccess):
     88        (InjectedScriptAccess._installHandler.InjectedScriptAccess.prototype.methodName):
     89        (InjectedScriptAccess._installHandler):
     90        * inspector/front-end/MetricsSidebarPane.js:
     91        (WebInspector.MetricsSidebarPane):
     92        (WebInspector.MetricsSidebarPane.prototype.update.inlineStyleCallback):
     93        * inspector/front-end/ObjectPropertiesSection.js:
     94        * inspector/front-end/ObjectProxy.js:
     95        (WebInspector.ObjectProxy):
     96        * inspector/front-end/PropertiesSidebarPane.js:
     97        (WebInspector.PropertiesSidebarPane.prototype.update.callback):
     98        * inspector/front-end/ResourcesPanel.js:
     99        (WebInspector.ResourceSidebarTreeElement.prototype.ondblclick):
     100        * inspector/front-end/ScriptsPanel.js:
     101        * inspector/front-end/StylesSidebarPane.js:
     102        (WebInspector.StylePropertyTreeElement.prototype):
     103        * inspector/front-end/WatchExpressionsSidebarPane.js:
     104        (WebInspector.WatchExpressionsSection.prototype.update):
     105        * inspector/front-end/inspector.js:
     106        (WebInspector.loaded):
     107        (WebInspector.pausedScript):
     108        (WebInspector.addConsoleMessage):
     109        (WebInspector.log.logMessage):
     110        (WebInspector.log):
     111
    11122010-01-19  Steve Block  <steveblock@google.com>
    2113
  • trunk/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp

    r53119 r53467  
    4848#include "InspectorResource.h"
    4949#include "JSDOMWindow.h"
    50 #include "JSInspectedObjectWrapper.h"
    51 #include "JSInspectorCallbackWrapper.h"
    5250#include "JSNode.h"
    5351#include "JSRange.h"
     
    113111    if (!database)
    114112        return jsUndefined();
    115     // Could use currentWorld(exec) ... but which exec!  The following mixed use of exec & inspectedWindow->globalExec() scares me!
    116     JSDOMWindow* inspectedWindow = toJSDOMWindow(ic->inspectedPage()->mainFrame(), debuggerWorld());
    117     return JSInspectedObjectWrapper::wrap(inspectedWindow->globalExec(), toJS(exec, database));
    118 }
    119 #endif
    120 
    121 JSValue JSInjectedScriptHost::inspectedWindow(ExecState*, const ArgList&)
    122 {
     113    return toJS(exec, database);
     114}
     115#endif
     116
     117#if ENABLE(JAVASCRIPT_DEBUGGER)
     118
     119JSValue JSInjectedScriptHost::currentCallFrame(ExecState* exec, const ArgList&)
     120{
     121    JavaScriptCallFrame* callFrame = impl()->currentCallFrame();
     122    if (!callFrame || !callFrame->isValid())
     123        return jsUndefined();
     124
     125    JSLock lock(SilenceAssertionsOnly);
     126    return toJS(exec, callFrame);
     127}
     128
     129#endif
     130
     131JSValue JSInjectedScriptHost::nodeForId(ExecState* exec, const ArgList& args)
     132{
     133    if (args.size() < 1)
     134        return jsUndefined();
     135
     136    Node* node = impl()->nodeForId(args.at(0).toInt32(exec));
     137    if (!node)
     138        return jsUndefined();
     139
    123140    InspectorController* ic = impl()->inspectorController();
    124141    if (!ic)
    125142        return jsUndefined();
    126     JSDOMWindow* inspectedWindow = toJSDOMWindow(ic->inspectedPage()->mainFrame(), debuggerWorld());
    127     return JSInspectedObjectWrapper::wrap(inspectedWindow->globalExec(), inspectedWindow);
    128 }
    129 
    130 JSValue JSInjectedScriptHost::wrapCallback(ExecState* exec, const ArgList& args)
    131 {
    132     if (args.size() < 1)
    133         return jsUndefined();
    134 
    135     return JSInspectorCallbackWrapper::wrap(exec, args.at(0));
    136 }
    137 
    138 #if ENABLE(JAVASCRIPT_DEBUGGER)
    139 
    140 JSValue JSInjectedScriptHost::currentCallFrame(ExecState* exec, const ArgList&)
    141 {
    142     JavaScriptCallFrame* callFrame = impl()->currentCallFrame();
    143     if (!callFrame || !callFrame->isValid())
    144         return jsUndefined();
    145 
    146     // FIXME: I am not sure if this is actually needed. Can we just use exec?
    147     ExecState* globalExec = callFrame->scopeChain()->globalObject->globalExec();
    148 
    149     JSLock lock(SilenceAssertionsOnly);
    150     return JSInspectedObjectWrapper::wrap(globalExec, toJS(exec, callFrame));
    151 }
    152 
    153 #endif
    154 
    155 JSValue JSInjectedScriptHost::nodeForId(ExecState* exec, const ArgList& args)
    156 {
    157     if (args.size() < 1)
    158         return jsUndefined();
    159 
    160     Node* node = impl()->nodeForId(args.at(0).toInt32(exec));
    161     if (!node)
    162         return jsUndefined();
    163 
    164     InspectorController* ic = impl()->inspectorController();
    165     if (!ic)
    166         return jsUndefined();
    167 
    168     JSLock lock(SilenceAssertionsOnly);
    169     JSDOMWindow* inspectedWindow = toJSDOMWindow(ic->inspectedPage()->mainFrame(), debuggerWorld());
    170     return JSInspectedObjectWrapper::wrap(inspectedWindow->globalExec(), toJS(exec, deprecatedGlobalObjectForPrototype(inspectedWindow->globalExec()), node));
    171 }
    172 
    173 JSValue JSInjectedScriptHost::wrapObject(ExecState* exec, const ArgList& args)
    174 {
    175     if (args.size() < 2)
    176         return jsUndefined();
    177 
    178     return impl()->wrapObject(ScriptValue(args.at(0)), args.at(1).toString(exec)).jsValue();
    179 }
    180 
    181 JSValue JSInjectedScriptHost::unwrapObject(ExecState* exec, const ArgList& args)
    182 {
    183     if (args.size() < 1)
    184         return jsUndefined();
    185 
    186     return impl()->unwrapObject(args.at(0).toString(exec)).jsValue();
     143
     144    JSLock lock(SilenceAssertionsOnly);
     145    return toJS(exec, node);
    187146}
    188147
     
    192151        return jsUndefined();
    193152
    194     JSQuarantinedObjectWrapper* wrapper = JSQuarantinedObjectWrapper::asWrapper(args.at(0));
    195     if (!wrapper)
    196         return jsUndefined();
    197 
    198     Node* node = toNode(wrapper->unwrappedObject());
     153    Node* node = toNode(args.at(0));
    199154    if (!node)
    200155        return jsUndefined();
     
    211166        return jsUndefined();
    212167
    213     JSQuarantinedObjectWrapper* wrapper = JSQuarantinedObjectWrapper::asWrapper(args.at(0));
    214     if (!wrapper)
    215         return jsUndefined();
    216 
    217     Database* database = toDatabase(wrapper->unwrappedObject());
     168    Database* database = toDatabase(args.at(0));
    218169    if (database)
    219170        impl()->selectDatabase(database);
     
    231182        return jsUndefined();
    232183
    233     JSQuarantinedObjectWrapper* wrapper = JSQuarantinedObjectWrapper::asWrapper(args.at(0));
    234     if (!wrapper)
    235         return jsUndefined();
    236 
    237     Storage* storage = toStorage(wrapper->unwrappedObject());
     184    Storage* storage = toStorage(args.at(0));
    238185    if (storage)
    239186        impl()->selectDOMStorage(storage);
  • trunk/WebCore/bindings/js/ScriptController.cpp

    r53295 r53467  
    381381#endif
    382382
     383ScriptState* ScriptController::mainWorldScriptState()
     384{
     385    JSDOMWindowShell* shell = windowShell(mainThreadNormalWorld());
     386    return shell->window()->globalExec();
     387}
     388
    383389JSObject* ScriptController::jsObjectForPluginElement(HTMLPlugInElement* plugin)
    384390{
  • trunk/WebCore/bindings/js/ScriptController.h

    r53295 r53467  
    2525#include "JSDOMWindowShell.h"
    2626#include "ScriptInstance.h"
     27#include "ScriptState.h"
    2728#include <runtime/Protect.h>
    2829#include <wtf/RefPtr.h>
     
    160161    XSSAuditor* xssAuditor() { return m_XSSAuditor.get(); }
    161162
     163    ScriptState* mainWorldScriptState();
     164
    162165private:
    163166    JSDOMWindowShell* initScript(DOMWrapperWorld* world);
  • trunk/WebCore/bindings/js/ScriptObject.h

    r51528 r53467  
    4848        ScriptObject() {}
    4949        JSC::JSObject* jsObject() const { return asObject(jsValue()); }
     50        ScriptState* scriptState() const { return m_scriptState; }
    5051
    5152        bool set(const String& name, const String&);
  • trunk/WebCore/bindings/js/ScriptValue.cpp

    r51927 r53467  
    3333#include <JavaScriptCore/JSValueRef.h>
    3434
    35 #include "JSInspectedObjectWrapper.h"
    36 
    3735#include <runtime/JSLock.h>
    3836#include <runtime/Protect.h>
     
    4240
    4341namespace WebCore {
    44 
    45 #if ENABLE(INSPECTOR)
    46 ScriptValue ScriptValue::quarantineValue(ScriptState* scriptState, const ScriptValue& value)
    47 {
    48     JSLock lock(SilenceAssertionsOnly);
    49     return ScriptValue(JSInspectedObjectWrapper::wrap(scriptState, value.jsValue()));
    50 }
    51 #endif
    5242
    5343bool ScriptValue::getString(ScriptState* scriptState, String& result) const
  • trunk/WebCore/bindings/js/ScriptValue.h

    r51801 r53467  
    4242class ScriptValue {
    4343public:
    44     static ScriptValue quarantineValue(ScriptState* scriptState, const ScriptValue& value);
    45 
    4644    ScriptValue(JSC::JSValue value = JSC::JSValue()) : m_value(value) {}
    4745    virtual ~ScriptValue() {}
  • trunk/WebCore/bindings/v8/ScriptObject.h

    r51528 r53467  
    4949
    5050        v8::Local<v8::Object> v8Object() const;
     51        ScriptState* scriptState() const { return m_scriptState; }
    5152
    5253        bool set(const String& name, const String&);
  • trunk/WebCore/bindings/v8/ScriptValue.h

    r51821 r53467  
    4545class ScriptValue {
    4646public:
    47     static ScriptValue quarantineValue(ScriptState* scriptState, const ScriptValue& value)
    48     {
    49         return value;
    50     }
    51 
    5247    ScriptValue() {}
    5348
  • trunk/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp

    r53271 r53467  
    115115}
    116116
    117 v8::Handle<v8::Value> V8InjectedScriptHost::inspectedWindowCallback(const v8::Arguments& args)
    118 {
    119     INC_STATS("InjectedScriptHost.inspectedWindow()");
    120 
    121     InjectedScriptHost* host = V8InjectedScriptHost::toNative(args.Holder());
    122     InspectorController* ic = host->inspectorController();
    123     if (!ic)
    124         return v8::Undefined();
    125     return V8DOMWrapper::convertToV8Object<DOMWindow>(V8ClassIndex::DOMWINDOW, ic->inspectedPage()->mainFrame()->domWindow());
    126 }
    127 
    128 v8::Handle<v8::Value> V8InjectedScriptHost::wrapCallbackCallback(const v8::Arguments& args)
    129 {
    130     INC_STATS("InjectedScriptHost.wrapCallback()");
    131     return args[0];
    132 }
    133 
    134117v8::Handle<v8::Value> V8InjectedScriptHost::nodeForIdCallback(const v8::Arguments& args)
    135118{
     
    149132
    150133    return V8DOMWrapper::convertToV8Object(V8ClassIndex::NODE, node);
    151 }
    152 
    153 v8::Handle<v8::Value> V8InjectedScriptHost::wrapObjectCallback(const v8::Arguments& args)
    154 {
    155     INC_STATS("InjectedScriptHost.wrapObject()");
    156     if (args.Length() < 2)
    157         return v8::Undefined();
    158 
    159     InjectedScriptHost* host = V8InjectedScriptHost::toNative(args.Holder());
    160     return host->wrapObject(ScriptValue(args[0]), toWebCoreStringWithNullCheck(args[1])).v8Value();
    161 }
    162 
    163 v8::Handle<v8::Value> V8InjectedScriptHost::unwrapObjectCallback(const v8::Arguments& args)
    164 {
    165     INC_STATS("InjectedScriptHost.unwrapObject()");
    166     if (args.Length() < 1)
    167         return v8::Undefined();
    168 
    169     InjectedScriptHost* host = V8InjectedScriptHost::toNative(args.Holder());
    170     return host->unwrapObject(toWebCoreStringWithNullCheck(args[0])).v8Value();
    171134}
    172135
  • trunk/WebCore/inspector/ConsoleMessage.cpp

    r51598 r53467  
    5555    , m_level(l)
    5656#if ENABLE(INSPECTOR)
    57     , m_wrappedArguments(callStack->at(0).argumentCount())
     57    , m_arguments(callStack->at(0).argumentCount())
     58    , m_scriptState(callStack->state())
    5859#endif
    5960    , m_frames(storeTrace ? callStack->size() : 0)
     
    7576#if ENABLE(INSPECTOR)
    7677    for (unsigned i = 0; i < lastCaller.argumentCount(); ++i)
    77         m_wrappedArguments[i] = ScriptObject::quarantineValue(callStack->state(), lastCaller.argumentAt(i));
     78        m_arguments[i] = lastCaller.argumentAt(i);
    7879#endif
    7980}
     
    9091    jsonObj.set("groupLevel", static_cast<int>(m_groupLevel));
    9192    jsonObj.set("repeatCount", static_cast<int>(m_repeatCount));
    92     frontend->addConsoleMessage(jsonObj, m_frames, m_wrappedArguments,  m_message);
     93    frontend->addConsoleMessage(jsonObj, m_frames, m_scriptState, m_arguments,  m_message);
    9394}
    9495
     
    102103{
    103104#if ENABLE(INSPECTOR)
    104     if (msg->m_wrappedArguments.size() != m_wrappedArguments.size())
     105    if (msg->m_arguments.size() != m_arguments.size())
    105106        return false;
    106     if (!state && msg->m_wrappedArguments.size())
     107    if (!state && msg->m_arguments.size())
    107108        return false;
    108109
    109     ASSERT_ARG(state, state || msg->m_wrappedArguments.isEmpty());
     110    ASSERT_ARG(state, state || msg->m_arguments.isEmpty());
    110111
    111     for (size_t i = 0; i < msg->m_wrappedArguments.size(); ++i) {
    112         if (!m_wrappedArguments[i].isEqual(state, msg->m_wrappedArguments[i]))
     112    for (size_t i = 0; i < msg->m_arguments.size(); ++i) {
     113        if (!m_arguments[i].isEqual(state, msg->m_arguments[i]))
    113114            return false;
    114115    }
  • trunk/WebCore/inspector/ConsoleMessage.h

    r52294 r53467  
    6464        String m_message;
    6565#if ENABLE(INSPECTOR)
    66         Vector<ScriptValue> m_wrappedArguments;
     66        Vector<ScriptValue> m_arguments;
     67        ScriptState* m_scriptState;
    6768#endif
    6869        Vector<ScriptString> m_frames;
  • trunk/WebCore/inspector/InjectedScriptHost.cpp

    r53119 r53467  
    9999}
    100100
    101 ScriptValue InjectedScriptHost::wrapObject(const ScriptValue& object, const String& objectGroup)
    102 {
    103     if (m_inspectorController)
    104         return m_inspectorController->wrapObject(object, objectGroup);
    105     return ScriptValue();
    106 }
    107 
    108 ScriptValue InjectedScriptHost::unwrapObject(const String& objectId)
    109 {
    110     if (m_inspectorController)
    111         return m_inspectorController->unwrapObject(objectId);
    112     return ScriptValue();
    113 }
    114 
    115101long InjectedScriptHost::pushNodePathToFrontend(Node* node, bool withChildren, bool selectInUI)
    116102{
     
    192178}
    193179
     180void InjectedScriptHost::releaseWrapperObjectGroup(long injectedScriptId, const String& objectGroup)
     181{
     182    if (injectedScriptId) {
     183         ScriptObject injectedScript = m_idToInjectedScript.get(injectedScriptId);
     184         if (!injectedScript.hasNoValue())
     185             releaseWrapperObjectGroup(injectedScript, objectGroup);
     186    } else {
     187         // Iterate over all injected scripts if injectedScriptId is not specified.
     188         for (IdToInjectedScriptMap::iterator it = m_idToInjectedScript.begin(); it != m_idToInjectedScript.end(); ++it)
     189              releaseWrapperObjectGroup(it->second, objectGroup);
     190    }
     191}
     192
    194193InspectorDOMAgent* InjectedScriptHost::inspectorDOMAgent()
    195194{
     
    206205}
    207206
     207void InjectedScriptHost::releaseWrapperObjectGroup(const ScriptObject& injectedScript, const String& objectGroup)
     208{
     209    ScriptFunctionCall releaseFunction(injectedScript.scriptState(), injectedScript, "releaseWrapperObjectGroup");
     210    releaseFunction.appendArgument(objectGroup);
     211    releaseFunction.call();
     212}
     213
    208214} // namespace WebCore
    209215
  • trunk/WebCore/inspector/InjectedScriptHost.h

    r53119 r53467  
    6767    void copyText(const String& text);
    6868    Node* nodeForId(long nodeId);
    69     ScriptValue wrapObject(const ScriptValue& object, const String& objectGroup);
    70     ScriptValue unwrapObject(const String& objectId);
    7169    long pushNodePathToFrontend(Node* node, bool withChildren, bool selectInUI);
    7270
     
    8987    ScriptObject injectedScriptForId(long);
    9088    void discardInjectedScripts();
     89    void releaseWrapperObjectGroup(long injectedScriptId, const String& objectGroup);
    9190
    9291private:
     
    9493    InspectorDOMAgent* inspectorDOMAgent();
    9594    InspectorFrontend* inspectorFrontend();
     95
     96    void releaseWrapperObjectGroup(const ScriptObject& injectedScript, const String& objectGroup);
    9697
    9798    InspectorController* m_inspectorController;
  • trunk/WebCore/inspector/InjectedScriptHost.idl

    r52662 r53467  
    3333module core {
    3434    interface [Conditional=INSPECTOR] InjectedScriptHost {
    35         [Custom] DOMWindow inspectedWindow();
    36         [Custom] DOMObject wrapCallback(in DOMObject callback);
    3735        void clearConsoleMessages();
    3836
    3937        void copyText(in DOMString text);
    4038        [Custom] DOMObject nodeForId(in long nodeId);
    41         [Custom] long wrapObject(in DOMObject object, in DOMString objectGroup);
    42         [Custom] DOMObject unwrapObject(in long objectId);
    4339        [Custom] int pushNodePathToFrontend(in DOMObject node, in boolean withChildren, in boolean selectInUI);
    4440
  • trunk/WebCore/inspector/InspectorBackend.cpp

    r52547 r53467  
    4141#include "FrameLoader.h"
    4242#include "HTMLFrameOwnerElement.h"
     43#include "InjectedScriptHost.h"
    4344#include "InspectorClient.h"
    4445#include "InspectorController.h"
     
    257258#endif
    258259
    259 void InspectorBackend::dispatchOnInjectedScript(long callId, const String& methodName, const String& arguments, bool async)
     260void InspectorBackend::setInjectedScriptSource(const String& source)
     261{
     262    if (m_inspectorController)
     263        m_inspectorController->injectedScriptHost()->setInjectedScriptSource(source);
     264}
     265
     266void InspectorBackend::dispatchOnInjectedScript(long callId, long injectedScriptId, const String& methodName, const String& arguments, bool async)
    260267{
    261268    InspectorFrontend* frontend = inspectorFrontend();
     
    263270        return;
    264271
    265     ScriptFunctionCall function(m_inspectorController->m_scriptState, m_inspectorController->m_injectedScriptObj, "dispatch");
     272    // FIXME: explicitly pass injectedScriptId along with node id to the frontend.
     273    bool injectedScriptIdIsNodeId = injectedScriptId <= 0;
     274
     275    ScriptObject injectedScript;
     276    if (injectedScriptIdIsNodeId)
     277        injectedScript = m_inspectorController->injectedScriptForNodeId(-injectedScriptId);
     278    else
     279        injectedScript = m_inspectorController->injectedScriptHost()->injectedScriptForId(injectedScriptId);
     280
     281    if (injectedScript.hasNoValue())
     282        return;
     283
     284    ScriptFunctionCall function(injectedScript.scriptState(), injectedScript, "dispatch");
    266285    function.appendArgument(methodName);
    267286    function.appendArgument(arguments);
     
    275294        frontend->didDispatchOnInjectedScript(callId, "", true);
    276295    else
    277         frontend->didDispatchOnInjectedScript(callId, result.toString(m_inspectorController->m_scriptState), false);
     296        frontend->didDispatchOnInjectedScript(callId, result.toString(injectedScript.scriptState()), false);
    278297}
    279298
     
    372391}
    373392
    374 void InspectorBackend::releaseWrapperObjectGroup(const String& objectGroup)
    375 {
    376     if (m_inspectorController)
    377         m_inspectorController->releaseWrapperObjectGroup(objectGroup);
     393void InspectorBackend::releaseWrapperObjectGroup(long injectedScriptId, const String& objectGroup)
     394{
     395    if (!m_inspectorController)
     396        return;
     397    m_inspectorController->injectedScriptHost()->releaseWrapperObjectGroup(injectedScriptId, objectGroup);
    378398}
    379399
  • trunk/WebCore/inspector/InspectorBackend.h

    r52547 r53467  
    105105#endif
    106106
    107     void dispatchOnInjectedScript(long callId, const String& methodName, const String& arguments, bool async);
     107    void setInjectedScriptSource(const String& source);
     108    void dispatchOnInjectedScript(long callId, long injectedScriptId, const String& methodName, const String& arguments, bool async);
    108109    void getChildNodes(long callId, long nodeId);
    109110    void setAttribute(long callId, long elementId, const String& name, const String& value);
     
    120121
    121122    // Generic code called from custom implementations.
    122     void releaseWrapperObjectGroup(const String& objectGroup);
     123    void releaseWrapperObjectGroup(long injectedScriptId, const String& objectGroup);
    123124    void didEvaluateForTestInFrontend(long callId, const String& jsonResult);
    124125
  • trunk/WebCore/inspector/InspectorBackend.idl

    r52662 r53467  
    7676        void getProfile(in long callId, in unsigned long uid);
    7777#endif
    78         void dispatchOnInjectedScript(in long callId, in DOMString methodName, in DOMString arguments, in boolean async);
     78        void setInjectedScriptSource(in DOMString scriptSource);
     79        void dispatchOnInjectedScript(in long callId, in long injectedScriptId, in DOMString methodName, in DOMString arguments, in boolean async);
    7980        void getChildNodes(in long callId, in long nodeId);
    8081        void setAttribute(in long callId, in long elementId, in DOMString name, in DOMString value);
     
    9091        void deleteCookie(in DOMString cookieName, in DOMString domain);
    9192
    92         void releaseWrapperObjectGroup(in DOMString objectGroup);
     93        void releaseWrapperObjectGroup(in long injectedScriptId, in DOMString objectGroup);
    9394        void didEvaluateForTestInFrontend(in long callId, in DOMString jsonResult);
    9495
  • trunk/WebCore/inspector/InspectorController.cpp

    r53080 r53467  
    144144    , m_inspectorFrontendHost(InspectorFrontendHost::create(this, client))
    145145    , m_injectedScriptHost(InjectedScriptHost::create(this))
    146     , m_lastBoundObjectId(1)
    147146#if ENABLE(JAVASCRIPT_DEBUGGER)
    148147    , m_debuggerEnabled(false)
     
    376375    m_previousMessage = 0;
    377376    m_groupLevel = 0;
    378     releaseWrapperObjectGroup("console");
     377    m_injectedScriptHost->releaseWrapperObjectGroup(0 /* release the group in all scripts */, "console");
    379378    if (m_domAgent)
    380379        m_domAgent->releaseDanglingNodes();
     
    501500    if (!enabled() || !m_frontend || frame != m_inspectedPage->mainFrame())
    502501        return;
    503     resetInjectedScript();
     502    m_injectedScriptHost->discardInjectedScripts();
    504503}
    505504
     
    514513    ScriptGlobalObject::set(m_scriptState, "InspectorBackend", m_inspectorBackend.get());
    515514    ScriptGlobalObject::set(m_scriptState, "InspectorFrontendHost", m_inspectorFrontendHost.get());
    516     ScriptGlobalObject::set(m_scriptState, "InjectedScriptHost", m_injectedScriptHost.get());
    517515}
    518516
     
    527525        return;
    528526    ScriptObject injectedScriptObj;
    529     if (!ScriptGlobalObject::get(m_scriptState, "InjectedScript", injectedScriptObj))
    530         return;
    531527    setFrontendProxyObject(m_scriptState, webInspectorObj, injectedScriptObj);
    532528
     
    546542}
    547543
    548 void InspectorController::setFrontendProxyObject(ScriptState* scriptState, ScriptObject webInspectorObj, ScriptObject injectedScriptObj)
     544void InspectorController::setFrontendProxyObject(ScriptState* scriptState, ScriptObject webInspectorObj, ScriptObject)
    549545{
    550546    m_scriptState = scriptState;
    551     m_injectedScriptObj = injectedScriptObj;
    552547    m_frontend.set(new InspectorFrontend(this, scriptState, webInspectorObj));
    553548    releaseDOMAgent();
     
    607602    closeWindow();
    608603
    609     m_injectedScriptObj = ScriptObject();
    610604    releaseDOMAgent();
    611605    m_frontend.set(0);
     
    716710    m_frontend->reset();
    717711    m_domAgent->reset();
    718     m_objectGroups.clear();
    719     m_idToWrappedObject.clear();
    720712}
    721713
     
    15921584void InspectorController::didPause()
    15931585{
    1594     ScriptFunctionCall function(m_scriptState, m_injectedScriptObj, "getCallFrames");
    1595     ScriptValue callFrames = function.call();
     1586    JavaScriptCallFrame* callFrame = m_injectedScriptHost->currentCallFrame();
     1587    ScriptState* scriptState = callFrame->scopeChain()->globalObject->globalExec();
     1588    ASSERT(scriptState);
     1589    ScriptObject injectedScriptObj = m_injectedScriptHost->injectedScriptFor(scriptState);
     1590    ScriptFunctionCall function(scriptState, injectedScriptObj, "getCallFrames");
     1591    ScriptValue callFramesValue = function.call();
     1592    String callFrames = callFramesValue.toString(scriptState);
     1593
    15961594    m_frontend->pausedScript(callFrames);
    15971595}
     
    18211819}
    18221820
    1823 ScriptValue InspectorController::wrapObject(const ScriptValue& quarantinedObject, const String& objectGroup)
    1824 {
    1825     ScriptFunctionCall function(m_scriptState, m_injectedScriptObj, "createProxyObject");
    1826     function.appendArgument(quarantinedObject);
    1827     if (quarantinedObject.isObject()) {
    1828         long id = m_lastBoundObjectId++;
    1829         String objectId = String::format("object#%ld", id);
    1830         m_idToWrappedObject.set(objectId, quarantinedObject);
    1831         ObjectGroupsMap::iterator it = m_objectGroups.find(objectGroup);
    1832         if (it == m_objectGroups.end())
    1833             it = m_objectGroups.set(objectGroup, Vector<String>()).first;
    1834         it->second.append(objectId);
    1835         function.appendArgument(objectId);
    1836     }
    1837     ScriptValue wrapper = function.call();
    1838     return wrapper;
    1839 }
    1840 
    1841 ScriptValue InspectorController::unwrapObject(const String& objectId)
    1842 {
    1843     HashMap<String, ScriptValue>::iterator it = m_idToWrappedObject.find(objectId);
    1844     if (it != m_idToWrappedObject.end())
    1845         return it->second;
    1846     return ScriptValue();
    1847 }
    1848 
    1849 void InspectorController::releaseWrapperObjectGroup(const String& objectGroup)
    1850 {
    1851     ObjectGroupsMap::iterator groupIt = m_objectGroups.find(objectGroup);
    1852     if (groupIt == m_objectGroups.end())
    1853         return;
    1854 
    1855     Vector<String>& groupIds = groupIt->second;
    1856     for (Vector<String>::iterator it = groupIds.begin(); it != groupIds.end(); ++it)
    1857         m_idToWrappedObject.remove(*it);
    1858     m_objectGroups.remove(groupIt);
    1859 }
    1860 
    1861 void InspectorController::resetInjectedScript()
    1862 {
    1863     ScriptFunctionCall function(m_scriptState, m_injectedScriptObj, "reset");
    1864     function.call();
    1865 }
    1866 
    18671821void InspectorController::deleteCookie(const String& cookieName, const String& domain)
    18681822{
     
    18931847}
    18941848
    1895 }  // namespace WebCore
     1849ScriptObject InspectorController::injectedScriptForNodeId(long id)
     1850{
     1851
     1852    Frame* frame = 0;
     1853    if (id) {
     1854        ASSERT(m_domAgent);
     1855        Node* node = m_domAgent->nodeForId(id);
     1856        if (node) {
     1857            Document* document = node->ownerDocument();
     1858            if (document)
     1859                frame = document->frame();
     1860        }
     1861    } else
     1862        frame = m_inspectedPage->mainFrame();
     1863
     1864    if (frame)
     1865        return m_injectedScriptHost->injectedScriptFor(frame->script()->mainWorldScriptState());
     1866
     1867    return ScriptObject();
     1868}
     1869
     1870} // namespace WebCore
    18961871   
    18971872#endif // ENABLE(INSPECTOR)
  • trunk/WebCore/inspector/InspectorController.h

    r53080 r53467  
    101101    typedef HashMap<int, RefPtr<InspectorDatabaseResource> > DatabaseResourcesMap;
    102102    typedef HashMap<int, RefPtr<InspectorDOMStorageResource> > DOMStorageResourcesMap;
    103     typedef HashMap<String, Vector<String> > ObjectGroupsMap;
    104103
    105104    typedef enum {
     
    249248
    250249    void evaluateForTestInFrontend(long callId, const String& script);
     250
     251    ScriptObject injectedScriptForNodeId(long id);
    251252
    252253private:
     
    265266    void releaseDOMAgent();
    266267
    267     friend class InspectorFrontend;
    268     // Following are used from InspectorFrontend only. We don't want to expose them to the
    269     // rest of the InspectorController clients.
    270     // TODO: extract these into a separate interface.
    271     ScriptValue wrapObject(const ScriptValue& object, const String& objectGroup);
    272     ScriptValue unwrapObject(const String& objectId);
    273     void releaseWrapperObjectGroup(const String& objectGroup);
    274    
    275     void resetInjectedScript();
    276 
    277268    void deleteCookie(const String& cookieName, const String& domain);
    278269
     
    322313    RefPtr<InspectorDOMAgent> m_domAgent;
    323314    OwnPtr<InspectorTimelineAgent> m_timelineAgent;
    324     ScriptObject m_injectedScriptObj;
    325315    Page* m_page;
    326316    RefPtr<Node> m_nodeToFocus;
     
    351341    RefPtr<InspectorFrontendHost> m_inspectorFrontendHost;
    352342    RefPtr<InjectedScriptHost> m_injectedScriptHost;
    353     HashMap<String, ScriptValue> m_idToWrappedObject;
    354     ObjectGroupsMap m_objectGroups;
    355     long m_lastBoundObjectId;
    356343
    357344    typedef HashMap<String, String> Settings;
  • trunk/WebCore/inspector/InspectorFrontend.cpp

    r52547 r53467  
    3535#include "ConsoleMessage.h"
    3636#include "Frame.h"
     37#include "InjectedScriptHost.h"
    3738#include "InspectorController.h"
    3839#include "Node.h"
     
    9495}
    9596
    96 void InspectorFrontend::addConsoleMessage(const ScriptObject& messageObj, const Vector<ScriptString>& frames, const Vector<ScriptValue> wrappedArguments, const String& message)
     97void InspectorFrontend::addConsoleMessage(const ScriptObject& messageObj, const Vector<ScriptString>& frames, ScriptState* scriptState, const Vector<ScriptValue> arguments, const String& message)
    9798{
    9899    ScriptFunctionCall function(m_scriptState, m_webInspector, "dispatch");
     
    100101    function.appendArgument(messageObj);
    101102    if (!frames.isEmpty()) {
     103        function.appendArgument(false);
    102104        for (unsigned i = 0; i < frames.size(); ++i)
    103105            function.appendArgument(frames[i]);
    104     } else if (!wrappedArguments.isEmpty()) {
    105         for (unsigned i = 0; i < wrappedArguments.size(); ++i)
    106             function.appendArgument(m_inspectorController->wrapObject(wrappedArguments[i], "console"));
    107     } else
     106    } else if (!arguments.isEmpty()) {
     107        function.appendArgument(true);
     108        ScriptObject injectedScript = m_inspectorController->injectedScriptHost()->injectedScriptFor(scriptState);
     109        for (unsigned i = 0; i < arguments.size(); ++i) {
     110            ScriptFunctionCall wrapFunction(scriptState, injectedScript, "wrapAndStringifyObject");
     111            wrapFunction.appendArgument(arguments[i]);
     112            wrapFunction.appendArgument("console");
     113            ScriptValue r = wrapFunction.call();
     114            if (r.hasNoValue())
     115                return;
     116            String s = r.toString(scriptState);
     117            function.appendArgument(s);
     118        }
     119    } else {
     120        function.appendArgument(false);
    108121        function.appendArgument(message);
     122    }
    109123    function.call();
    110124}
     
    313327}
    314328
    315 void InspectorFrontend::pausedScript(const ScriptValue& callFrames)
     329void InspectorFrontend::pausedScript(const String& callFrames)
    316330{
    317331    ScriptFunctionCall function(m_scriptState, m_webInspector, "dispatch");
  • trunk/WebCore/inspector/InspectorFrontend.h

    r52547 r53467  
    6868
    6969        void updateConsoleMessageExpiredCount(unsigned count);
    70         void addConsoleMessage(const ScriptObject& messageObj, const Vector<ScriptString>& frames, const Vector<ScriptValue> wrappedArguments, const String& message);
     70        void addConsoleMessage(const ScriptObject& messageObj, const Vector<ScriptString>& frames, ScriptState*, const Vector<ScriptValue> arguments, const String& message);
    7171        void updateConsoleMessageRepeatCount(unsigned count);
    7272        void clearConsoleMessages();
     
    9696        void didGetProfileHeaders(int callId, const ScriptArray& headers);
    9797        void didGetProfile(int callId, const ScriptValue& profile);
    98         void pausedScript(const ScriptValue& callFrames);
     98        void pausedScript(const String& callFrames);
    9999        void resumedScript();
    100100#endif
  • trunk/WebCore/inspector/front-end/AuditsPanel.js

    r52558 r53467  
    194194            this._updateLauncherViewControls();
    195195        } else
    196             InjectedScriptAccess.evaluate("window.location.reload()", nullCallback);
     196            InjectedScriptAccess.getDefault().evaluate("window.location.reload()", nullCallback);
    197197    },
    198198
  • trunk/WebCore/inspector/front-end/ConsoleView.js

    r52545 r53467  
    293293    requestClearMessages: function()
    294294    {
    295         InjectedScriptAccess.clearConsoleMessages(function() {});
     295        InjectedScriptAccess.getDefault().clearConsoleMessages(function() {});
    296296    },
    297297
     
    335335
    336336        var includeInspectorCommandLineAPI = (!dotNotation && !bracketNotation);
    337         if (WebInspector.panels.scripts && WebInspector.panels.scripts.paused)
    338             var callFrameId = WebInspector.panels.scripts.selectedCallFrameId();
    339         InjectedScriptAccess.getCompletions(expressionString, includeInspectorCommandLineAPI, callFrameId, reportCompletions);
     337        var callFrameId = WebInspector.panels.scripts.selectedCallFrameId();
     338        var injectedScriptAccess;
     339        if (WebInspector.panels.scripts && WebInspector.panels.scripts.paused) {
     340            var selectedCallFrame = WebInspector.panels.scripts.sidebarPanes.callstack.selectedCallFrame;
     341            injectedScriptAccess = InjectedScriptAccess.get(selectedCallFrame.injectedScriptId);
     342        } else
     343            injectedScriptAccess = InjectedScriptAccess.getDefault();
     344        injectedScriptAccess.getCompletions(expressionString, includeInspectorCommandLineAPI, callFrameId, reportCompletions);
    340345    },
    341346
     
    461466            callback(result.value, result.isException);
    462467        };
    463         InjectedScriptAccess.evaluate(expression, objectGroup, evalCallback);
     468        InjectedScriptAccess.getDefault().evaluate(expression, objectGroup, evalCallback);
    464469    },
    465470
     
    534539        }
    535540
    536         InjectedScriptAccess.pushNodeToFrontend(object, printNode);
     541        InjectedScriptAccess.get(object.injectedScriptId).pushNodeToFrontend(object, printNode);
    537542    },
    538543
    539544    _formatarray: function(arr, elem)
    540545    {
    541         InjectedScriptAccess.getProperties(arr, false, false, this._printArray.bind(this, elem));
     546        InjectedScriptAccess.get(arr.injectedScriptId).getProperties(arr, false, false, this._printArray.bind(this, elem));
    542547    },
    543548
  • trunk/WebCore/inspector/front-end/DOMAgent.js

    r53232 r53467  
    3434
    3535    this.id = payload.id;
     36    // injectedScriptId is a node is for DOM nodes which should be converted
     37    // to corresponding InjectedScript by the inspector backend. We indicate
     38    // this by making injectedScriptId negative.
     39    this.injectedScriptId = -payload.id;
    3640    this.nodeType = payload.nodeType;
    3741    this.nodeName = payload.nodeName;
     
    517521{
    518522    this.id = payload.id;
     523    this.injectedScriptId = payload.injectedScriptId;
    519524    this.width = payload.width;
    520525    this.height = payload.height;
     
    559564    var rule = {};
    560565    rule.id = payload.id;
     566    rule.injectedScriptId = payload.injectedScriptId;
    561567    rule.selectorText = payload.selectorText;
    562568    rule.style = new WebInspector.CSSStyleDeclaration(payload.style);
  • trunk/WebCore/inspector/front-end/Database.js

    r51528 r53467  
    9696            onSuccess(result);
    9797        }
    98         InjectedScriptAccess.executeSql(this._id, query, callback);
     98        // FIXME: execute the query in the frame the DB comes from.
     99        InjectedScriptAccess.getDefault().executeSql(this._id, query, callback);
    99100    }
    100101}
  • trunk/WebCore/inspector/front-end/ElementsPanel.js

    r53366 r53467  
    6464        }
    6565        if (this._focusedDOMNode)
    66             InjectedScriptAccess.addInspectedNode(this._focusedDOMNode.id, function() {});
     66            InjectedScriptAccess.get(this._focusedDOMNode.injectedScriptId).addInspectedNode(this._focusedDOMNode.id, function() {});
    6767    };
    6868
     
    238238
    239239        if (this._selectedPathOnReset)
    240             InjectedScriptAccess.nodeByPath(this._selectedPathOnReset, selectLastSelectedNode.bind(this));
     240            InjectedScriptAccess.getDefault().nodeByPath(this._selectedPathOnReset, selectLastSelectedNode.bind(this));
    241241        else
    242242            selectNode.call(this);
     
    258258        this._currentSearchResultIndex = 0;
    259259        this._searchResults = [];
    260         InjectedScriptAccess.searchCanceled(function() {});
     260        InjectedScriptAccess.getDefault().searchCanceled(function() {});
    261261    },
    262262
     
    273273        this._matchesCountUpdateTimeout = null;
    274274
    275         InjectedScriptAccess.performSearch(whitespaceTrimmedQuery, function() {});
     275        InjectedScriptAccess.getDefault().performSearch(whitespaceTrimmedQuery, function() {});
    276276    },
    277277
  • trunk/WebCore/inspector/front-end/ElementsTreeOutline.js

    r53232 r53467  
    358358            callback(tooltipText);
    359359        }
    360         var objectProxy = new WebInspector.ObjectProxy(node.id);
     360        var objectProxy = new WebInspector.ObjectProxy(node.injectedScriptId, node.id);
    361361        WebInspector.ObjectProxy.getPropertiesAsync(objectProxy, ["naturalHeight", "naturalWidth", "offsetHeight", "offsetWidth"], createTooltipThenCallback);
    362362    },
     
    10761076        function commitChange(value)
    10771077        {
    1078             InjectedScriptAccess.setOuterHTML(node.id, value, wasExpanded, selectNode.bind(this));
    1079         }
    1080 
    1081         InjectedScriptAccess.getNodePropertyValue(node.id, "outerHTML", this._startEditingAsHTML.bind(this, commitChange));
     1078            InjectedScriptAccess.get(node.injectedScriptId).setOuterHTML(node.id, value, wasExpanded, selectNode.bind(this));
     1079        }
     1080
     1081        InjectedScriptAccess.get(node.injectedScriptId).getNodePropertyValue(node.id, "outerHTML", this._startEditingAsHTML.bind(this, commitChange));
    10821082    },
    10831083
  • trunk/WebCore/inspector/front-end/EventListenersSidebarPane.js

    r52547 r53467  
    192192            var value = this.eventListener[propertyName];
    193193            if (value instanceof WebInspector.DOMNode)
    194                 value = new WebInspector.ObjectProxy(value.id, [], 0, appropriateSelectorForNode(value), true);
     194                value = new WebInspector.ObjectProxy(value.injectedScriptId, value.id, [], 0, appropriateSelectorForNode(value), true);
    195195            else
    196196                value = WebInspector.ObjectProxy.wrapPrimitiveValue(value);
  • trunk/WebCore/inspector/front-end/InjectedScript.js

    r53192 r53467  
    2727 */
    2828
     29var injectedScriptConstructor = (function (InjectedScriptHost, inspectedWindow, injectedScriptId) {
     30
    2931var InjectedScript = {};
     32
     33InjectedScript.lastBoundObjectId = 1;
     34InjectedScript.idToWrappedObject = {};
     35InjectedScript.objectGroups = {};
     36InjectedScript.wrapObject = function(object, objectGroupName)
     37{
     38    var objectId;
     39    if (typeof object === "object" || typeof object === "function" ||
     40        (typeof object === "undefined" && object instanceof inspectedWindow.HTMLAllCollection)) { // FIXME(33716)
     41        var id = InjectedScript.lastBoundObjectId++;
     42        objectId = "object#" + id;
     43        InjectedScript.idToWrappedObject[objectId] = object;
     44
     45        var group = InjectedScript.objectGroups[objectGroupName];
     46        if (!group) {
     47            group = [];
     48            InjectedScript.objectGroups[objectGroupName] = group;
     49        }
     50        group.push(objectId);
     51    }
     52    return InjectedScript.createProxyObject(object, objectId);
     53};
     54
     55InjectedScript.wrapAndStringifyObject = function(object, objectGroupName) {
     56    var r = InjectedScript.wrapObject(object, objectGroupName);
     57    return InjectedScript.JSON.stringify(r);
     58};
     59
     60InjectedScript.unwrapObject = function(objectId) {
     61    return InjectedScript.idToWrappedObject[objectId];
     62};
     63
     64InjectedScript.releaseWrapperObjectGroup = function(objectGroupName) {
     65    delete InjectedScript.objectGroups[objectGroupName];
     66};
    3067
    3168// Called from within InspectorController on the 'inspected page' side.
     
    5289        result = null;
    5390    }
    54     return JSON.stringify(result);
     91    return InjectedScript.JSON.stringify(result);
    5592}
    5693
     
    170207    if (disabled) {
    171208        if (!style.__disabledPropertyValues || !style.__disabledPropertyPriorities) {
    172             var inspectedWindow = InjectedScript._window();
    173             style.__disabledProperties = new inspectedWindow.Object;
    174             style.__disabledPropertyValues = new inspectedWindow.Object;
    175             style.__disabledPropertyPriorities = new inspectedWindow.Object;
     209            style.__disabledProperties = {};
     210            style.__disabledPropertyValues = {};
     211            style.__disabledPropertyPriorities = {};
    176212        }
    177213
     
    307343        }
    308344        ruleValue.id = rule.id;
     345        ruleValue.injectedScriptId = injectedScriptId;
    309346    }
    310347    return ruleValue;
     
    345382        }
    346383        result.id = style.id;
     384        result.injectedScriptId = injectedScriptId;
    347385    }
    348386    return result;
     
    446484{
    447485    var object = InjectedScript._resolveObject(objectProxy);
    448     if (!object)
     486    if (!InjectedScript._isDefined(object))
    449487        return false;
    450488
     
    480518{
    481519    var object = InjectedScript._resolveObject(objectProxy);
    482     if (!object)
     520    if (!InjectedScript._isDefined(object))
    483521        return false;
    484522
     
    589627    var result = {};
    590628    try {
    591         result.value = InjectedScriptHost.wrapObject(InjectedScript._evaluateOn(evalFunction, object, expression), objectGroup);
     629        result.value = InjectedScript.wrapObject(InjectedScript._evaluateOn(evalFunction, object, expression), objectGroup);
     630
    592631        // Handle error that might have happened while describing result.
    593632        if (result.value.errorText) {
     
    886925        callFrame = callFrame.caller;
    887926    } while (callFrame);
    888     return result;
     927    return InjectedScript.JSON.stringify(result);
    889928}
    890929
     
    916955        return;
    917956
    918     var inspectedWindow = InjectedScript._window();
    919957    inspectedWindow.console.log(o);
    920958    if (Object.type(o) === "node") {
     
    10151053    };");
    10161054
    1017     inspectorCommandLineAPI.clear = InjectedScriptHost.wrapCallback(InjectedScript.clearConsoleMessages);
    1018     inspectorCommandLineAPI.inspect = InjectedScriptHost.wrapCallback(InjectedScript._inspectObject);
    1019     inspectorCommandLineAPI.copy = InjectedScriptHost.wrapCallback(InjectedScript._copy);
     1055    inspectorCommandLineAPI.clear = InjectedScript.clearConsoleMessages;
     1056    inspectorCommandLineAPI.inspect = InjectedScript._inspectObject;
     1057    inspectorCommandLineAPI.copy = InjectedScript._copy;
    10201058}
    10211059
     
    10271065
    10281066    // Follow the property path.
    1029     for (var i = 0; object && path && i < path.length; ++i)
     1067    for (var i = 0; InjectedScript._isDefined(object) && path && i < path.length; ++i)
    10301068        object = object[path[i]];
    10311069
    10321070    // Get to the necessary proto layer.
    1033     for (var i = 0; object && protoDepth && i < protoDepth; ++i)
     1071    for (var i = 0; InjectedScript._isDefined(object) && protoDepth && i < protoDepth; ++i)
    10341072        object = object.__proto__;
    10351073
     
    10411079    // TODO: replace with 'return window;' once this script is injected into
    10421080    // the page's context.
    1043     return InjectedScriptHost.inspectedWindow();
     1081    return inspectedWindow;
    10441082}
    10451083
     
    10601098        return InjectedScript._nodeForId(objectId);
    10611099    } else if (typeof objectId === "string") {
    1062         return InjectedScriptHost.unwrapObject(objectId);
     1100        return InjectedScript.unwrapObject(objectId);
    10631101    } else if (typeof objectId === "object") {
    10641102        var callFrame = InjectedScript._callFrameForId(objectId.callFrame);
     
    10901128{
    10911129    var result = {};
     1130    result.injectedScriptId = injectedScriptId;
    10921131    result.objectId = objectId;
    10931132    result.type = Object.type(object);
     
    11711210            }
    11721211        }
    1173         InjectedScriptHost.reportDidDispatchOnInjectedScript(callId, JSON.stringify(result), false);
     1212        InjectedScriptHost.reportDidDispatchOnInjectedScript(callId, InjectedScript.JSON.stringify(result), false);
    11741213    }
    11751214
    11761215    function errorCallback(tx, error)
    11771216    {
    1178         InjectedScriptHost.reportDidDispatchOnInjectedScript(callId, JSON.stringify(error), false);
     1217        InjectedScriptHost.reportDidDispatchOnInjectedScript(callId, InjectedScript.JSON.stringify(error), false);
    11791218    }
    11801219
    11811220    function queryTransaction(tx)
    11821221    {
    1183         tx.executeSql(query, null, InjectedScriptHost.wrapCallback(successCallback), InjectedScriptHost.wrapCallback(errorCallback));
     1222        tx.executeSql(query, null, successCallback, errorCallback);
    11841223    }
    11851224
     
    11871226    if (!database)
    11881227        errorCallback(null, { code : 2 });  // Return as unexpected version.
    1189     database.transaction(InjectedScriptHost.wrapCallback(queryTransaction), InjectedScriptHost.wrapCallback(errorCallback));
     1228    database.transaction(queryTransaction, errorCallback);
    11901229    return true;
     1230}
     1231
     1232InjectedScript._isDefined = function(object)
     1233{
     1234    return object || object instanceof inspectedWindow.HTMLAllCollection;
    11911235}
    11921236
     
    11951239    if (obj === null)
    11961240        return "null";
     1241
     1242    // FIXME(33716): typeof document.all is always 'undefined'.
     1243    if (obj instanceof inspectedWindow.HTMLAllCollection)
     1244        return "array";
    11971245
    11981246    var type = typeof obj;
     
    12991347    return result;
    13001348}
     1349
     1350InjectedScript.JSON = {};
     1351
     1352// The following code is a slightly modified version of http://www.json.org/json2.js last modified on 2009-09-29.
     1353// Compared to the original version it ignores toJSON method on objects it serializes.
     1354// It's done to avoid weird behaviour when inspected application provides it's own implementation
     1355// of toJSON methods to the Object and other intrinsic types. We use InjectedScript.JSON implementation
     1356// instead of global JSON object since it can have been modified by the inspected code.
     1357(function() {
     1358
     1359    function f(n) {
     1360        // Format integers to have at least two digits.
     1361        return n < 10 ? '0' + n : n;
     1362    }
     1363
     1364    var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
     1365        escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
     1366        gap,
     1367        indent,
     1368        meta = {    // table of character substitutions
     1369            '\b': '\\b',
     1370            '\t': '\\t',
     1371            '\n': '\\n',
     1372            '\f': '\\f',
     1373            '\r': '\\r',
     1374            '"' : '\\"',
     1375            '\\': '\\\\'
     1376        },
     1377        rep;
     1378
     1379
     1380    function quote(string) {
     1381
     1382// If the string contains no control characters, no quote characters, and no
     1383// backslash characters, then we can safely slap some quotes around it.
     1384// Otherwise we must also replace the offending characters with safe escape
     1385// sequences.
     1386
     1387        escapable.lastIndex = 0;
     1388        return escapable.test(string) ?
     1389            '"' + string.replace(escapable, function (a) {
     1390                var c = meta[a];
     1391                return typeof c === 'string' ? c :
     1392                    '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
     1393            }) + '"' :
     1394            '"' + string + '"';
     1395    }
     1396
     1397
     1398    function str(key, holder) {
     1399
     1400// Produce a string from holder[key].
     1401
     1402        var i,          // The loop counter.
     1403            k,          // The member key.
     1404            v,          // The member value.
     1405            length,
     1406            mind = gap,
     1407            partial,
     1408            value = holder[key];
     1409
     1410// If we were called with a replacer function, then call the replacer to
     1411// obtain a replacement value.
     1412
     1413        if (typeof rep === 'function') {
     1414            value = rep.call(holder, key, value);
     1415        }
     1416
     1417// What happens next depends on the value's type.
     1418
     1419        switch (typeof value) {
     1420        case 'string':
     1421            return quote(value);
     1422
     1423        case 'number':
     1424
     1425// JSON numbers must be finite. Encode non-finite numbers as null.
     1426
     1427            return isFinite(value) ? String(value) : 'null';
     1428
     1429        case 'boolean':
     1430        case 'null':
     1431
     1432// If the value is a boolean or null, convert it to a string. Note:
     1433// typeof null does not produce 'null'. The case is included here in
     1434// the remote chance that this gets fixed someday.
     1435
     1436            return String(value);
     1437
     1438// If the type is 'object', we might be dealing with an object or an array or
     1439// null.
     1440
     1441        case 'object':
     1442
     1443// Due to a specification blunder in ECMAScript, typeof null is 'object',
     1444// so watch out for that case.
     1445
     1446            if (!value) {
     1447                return 'null';
     1448            }
     1449
     1450// Make an array to hold the partial results of stringifying this object value.
     1451
     1452            gap += indent;
     1453            partial = [];
     1454
     1455// Is the value an array?
     1456
     1457            if (Object.prototype.toString.apply(value) === '[object Array]') {
     1458
     1459// The value is an array. Stringify every element. Use null as a placeholder
     1460// for non-JSON values.
     1461
     1462                length = value.length;
     1463                for (i = 0; i < length; i += 1) {
     1464                    partial[i] = str(i, value) || 'null';
     1465                }
     1466
     1467// Join all of the elements together, separated with commas, and wrap them in
     1468// brackets.
     1469
     1470                v = partial.length === 0 ? '[]' :
     1471                    gap ? '[\n' + gap +
     1472                            partial.join(',\n' + gap) + '\n' +
     1473                                mind + ']' :
     1474                          '[' + partial.join(',') + ']';
     1475                gap = mind;
     1476                return v;
     1477            }
     1478
     1479// If the replacer is an array, use it to select the members to be stringified.
     1480
     1481            if (rep && typeof rep === 'object') {
     1482                length = rep.length;
     1483                for (i = 0; i < length; i += 1) {
     1484                    k = rep[i];
     1485                    if (typeof k === 'string') {
     1486                        v = str(k, value);
     1487                        if (v) {
     1488                            partial.push(quote(k) + (gap ? ': ' : ':') + v);
     1489                        }
     1490                    }
     1491                }
     1492            } else {
     1493
     1494// Otherwise, iterate through all of the keys in the object.
     1495
     1496                for (k in value) {
     1497                    if (Object.hasOwnProperty.call(value, k)) {
     1498                        v = str(k, value);
     1499                        if (v) {
     1500                            partial.push(quote(k) + (gap ? ': ' : ':') + v);
     1501                        }
     1502                    }
     1503                }
     1504            }
     1505
     1506// Join all of the member texts together, separated with commas,
     1507// and wrap them in braces.
     1508
     1509            v = partial.length === 0 ? '{}' :
     1510                gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' +
     1511                        mind + '}' : '{' + partial.join(',') + '}';
     1512            gap = mind;
     1513            return v;
     1514        }
     1515    }
     1516
     1517        InjectedScript.JSON.stringify = function (value, replacer, space) {
     1518
     1519// The stringify method takes a value and an optional replacer, and an optional
     1520// space parameter, and returns a JSON text. The replacer can be a function
     1521// that can replace values, or an array of strings that will select the keys.
     1522// A default replacer method can be provided. Use of the space parameter can
     1523// produce text that is more easily readable.
     1524
     1525            var i;
     1526            gap = '';
     1527            indent = '';
     1528
     1529// If the space parameter is a number, make an indent string containing that
     1530// many spaces.
     1531
     1532            if (typeof space === 'number') {
     1533                for (i = 0; i < space; i += 1) {
     1534                    indent += ' ';
     1535                }
     1536
     1537// If the space parameter is a string, it will be used as the indent string.
     1538
     1539            } else if (typeof space === 'string') {
     1540                indent = space;
     1541            }
     1542
     1543// If there is a replacer, it must be a function or an array.
     1544// Otherwise, throw an error.
     1545
     1546            rep = replacer;
     1547            if (replacer && typeof replacer !== 'function' &&
     1548                    (typeof replacer !== 'object' ||
     1549                     typeof replacer.length !== 'number')) {
     1550                throw new Error('JSON.stringify');
     1551            }
     1552
     1553// Make a fake root object containing our value under the key of ''.
     1554// Return the result of stringifying the value.
     1555
     1556            return str('', {'': value});
     1557        };
     1558
     1559
     1560// If the JSON object does not yet have a parse method, give it one.
     1561
     1562    InjectedScript.JSON.parse = function (text, reviver) {
     1563
     1564// The parse method takes a text and an optional reviver function, and returns
     1565// a JavaScript value if the text is a valid JSON text.
     1566
     1567            var j;
     1568
     1569            function walk(holder, key) {
     1570
     1571// The walk method is used to recursively walk the resulting structure so
     1572// that modifications can be made.
     1573
     1574                var k, v, value = holder[key];
     1575                if (value && typeof value === 'object') {
     1576                    for (k in value) {
     1577                        if (Object.hasOwnProperty.call(value, k)) {
     1578                            v = walk(value, k);
     1579                            if (v !== undefined) {
     1580                                value[k] = v;
     1581                            } else {
     1582                                delete value[k];
     1583                            }
     1584                        }
     1585                    }
     1586                }
     1587                return reviver.call(holder, key, value);
     1588            }
     1589
     1590
     1591// Parsing happens in four stages. In the first stage, we replace certain
     1592// Unicode characters with escape sequences. JavaScript handles many characters
     1593// incorrectly, either silently deleting them, or treating them as line endings.
     1594
     1595            cx.lastIndex = 0;
     1596            if (cx.test(text)) {
     1597                text = text.replace(cx, function (a) {
     1598                    return '\\u' +
     1599                        ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
     1600                });
     1601            }
     1602
     1603// In the second stage, we run the text against regular expressions that look
     1604// for non-JSON patterns. We are especially concerned with '()' and 'new'
     1605// because they can cause invocation, and '=' because it can cause mutation.
     1606// But just to be safe, we want to reject all unexpected forms.
     1607
     1608// We split the second stage into 4 regexp operations in order to work around
     1609// crippling inefficiencies in IE's and Safari's regexp engines. First we
     1610// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
     1611// replace all simple value tokens with ']' characters. Third, we delete all
     1612// open brackets that follow a colon or comma or that begin the text. Finally,
     1613// we look to see that the remaining characters are only whitespace or ']' or
     1614// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
     1615
     1616            if (/^[\],:{}\s]*$/.
     1617test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').
     1618replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
     1619replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
     1620
     1621// In the third stage we use the eval function to compile the text into a
     1622// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
     1623// in JavaScript: it can begin a block or an object literal. We wrap the text
     1624// in parens to eliminate the ambiguity.
     1625
     1626                j = eval('(' + text + ')');
     1627
     1628// In the optional fourth stage, we recursively walk the new structure, passing
     1629// each name/value pair to a reviver function for possible transformation.
     1630
     1631                return typeof reviver === 'function' ?
     1632                    walk({'': j}, '') : j;
     1633            }
     1634
     1635// If the text is not JSON parseable, then a SyntaxError is thrown.
     1636
     1637            throw new SyntaxError('JSON.parse');
     1638        };
     1639}());
     1640
     1641return InjectedScript;
     1642});
  • trunk/WebCore/inspector/front-end/InjectedScriptAccess.js

    r52556 r53467  
    3030 */
    3131
    32 var InjectedScriptAccess = {};
     32function InjectedScriptAccess(injectedScriptId) {
     33    this._injectedScriptId = injectedScriptId;
     34}
     35
     36InjectedScriptAccess.get = function(injectedScriptId)
     37{
     38    return new InjectedScriptAccess(injectedScriptId);
     39}
     40
     41InjectedScriptAccess.getDefault = function()
     42{
     43    return InjectedScriptAccess.get(0);
     44}
     45
     46InjectedScriptAccess.prototype = {};
    3347
    3448InjectedScriptAccess._installHandler = function(methodName, async)
    3549{
    36     InjectedScriptAccess[methodName] = function()
     50    InjectedScriptAccess.prototype[methodName] = function()
    3751    {
    3852        var allArgs = Array.prototype.slice.call(arguments);
     
    4862        }
    4963        var callId = WebInspector.Callback.wrap(myCallback);
    50         InspectorBackend.dispatchOnInjectedScript(callId, methodName, argsString, !!async);
     64
     65        InspectorBackend.dispatchOnInjectedScript(callId, this._injectedScriptId, methodName, argsString, !!async);
    5166    };
    5267}
  • trunk/WebCore/inspector/front-end/MetricsSidebarPane.js

    r51121 r53467  
    3131    WebInspector.SidebarPane.call(this, WebInspector.UIString("Metrics"));
    3232    this._inlineStyleId = null;
     33    this._inlineStyleInjectedScriptId = null;
    3334}
    3435
     
    5354            self._update(style);
    5455        };
    55         InjectedScriptAccess.getComputedStyle(node.id, callback);
     56        InjectedScriptAccess.get(node.injectedScriptId).getComputedStyle(node.id, callback);
    5657
    5758        var inlineStyleCallback = function(stylePayload) {
     
    5960                return;
    6061            self._inlineStyleId = stylePayload.id;
    61         };
    62         InjectedScriptAccess.getInlineStyle(node.id, inlineStyleCallback);
     62            self._inlineStyleInjectedScriptId = stylePayload.injectedScriptId;
     63        };
     64        InjectedScriptAccess.get(node.injectedScriptId).getInlineStyle(node.id, inlineStyleCallback);
    6365    },
    6466
     
    205207            self.update();
    206208        };
    207         InjectedScriptAccess.setStyleProperty(this._inlineStyleId, context.styleProperty, userInput, callback);
     209        InjectedScriptAccess.get(this._inlineStyleInjectedScriptId).setStyleProperty(this._inlineStyleId, context.styleProperty, userInput, callback);
    208210    }
    209211}
  • trunk/WebCore/inspector/front-end/ObjectPropertiesSection.js

    r53366 r53467  
    5151            self.updateProperties(properties);
    5252        };
    53         InjectedScriptAccess.getProperties(this.object, this.ignoreHasOwnProperty, true, callback);
     53        InjectedScriptAccess.get(this.object.injectedScriptId).getProperties(this.object, this.ignoreHasOwnProperty, true, callback);
    5454    },
    5555
     
    148148            }
    149149        };
    150         InjectedScriptAccess.getProperties(this.property.value, false, true, callback.bind(this));
     150        InjectedScriptAccess.get(this.property.value.injectedScriptId).getProperties(this.property.value, false, true, callback.bind(this));
    151151    },
    152152
     
    252252            }
    253253        };
    254         InjectedScriptAccess.setPropertyValue(this.property.parentObjectProxy, this.property.name, expression.trim(), callback);
     254        InjectedScriptAccess.get(this.property.parentObjectProxy.injectedScriptId).setPropertyValue(this.property.parentObjectProxy, this.property.name, expression.trim(), callback);
    255255    }
    256256}
  • trunk/WebCore/inspector/front-end/ObjectProxy.js

    r52544 r53467  
    2929 */
    3030
    31 WebInspector.ObjectProxy = function(objectId, path, protoDepth, description, hasChildren)
     31WebInspector.ObjectProxy = function(injectedScriptId, objectId, path, protoDepth, description, hasChildren)
    3232{
    3333    this.objectId = objectId;
     34    this.injectedScriptId = injectedScriptId;
    3435    this.path = path || [];
    3536    this.protoDepth = protoDepth || 0;
     
    6162        callback(result);
    6263    };
    63     InjectedScriptAccess.getProperties(objectProxy, true, false, createPropertiesMapThenCallback);
     64    InjectedScriptAccess.get(objectProxy.injectedScriptId).getProperties(objectProxy, true, false, createPropertiesMapThenCallback);
    6465}
    6566
  • trunk/WebCore/inspector/front-end/PropertiesSidebarPane.js

    r51121 r53467  
    5151            // Get array of prototype user-friendly names.
    5252            for (var i = 0; i < prototypes.length; ++i) {
    53                 var prototype = new WebInspector.ObjectProxy(node.id, [], i);
     53                var prototype = new WebInspector.ObjectProxy(node.injectedScriptId, node.id, [], i);
    5454                var section = new WebInspector.ObjectPropertiesSection(prototype, prototypes[i], WebInspector.UIString("Prototype"));
    5555                self.sections.push(section);
     
    5757            }
    5858        };
    59         InjectedScriptAccess.getPrototypes(node.id, callback);
     59        InjectedScriptAccess.get(node.injectedScriptId).getPrototypes(node.id, callback);
    6060    }
    6161}
  • trunk/WebCore/inspector/front-end/ResourcesPanel.js

    r53405 r53467  
    985985    ondblclick: function(event)
    986986    {
    987         InjectedScriptAccess.openInInspectedWindow(this.resource.url, function() {});
     987        InjectedScriptAccess.getDefault().openInInspectedWindow(this.resource.url, function() {});
    988988    },
    989989
  • trunk/WebCore/inspector/front-end/ScriptsPanel.js

    r52547 r53467  
    401401                callback(result.value, result.isException);
    402402        }
    403         InjectedScriptAccess.evaluateInCallFrame(callFrame.id, code, objectGroup, evalCallback);
     403        InjectedScriptAccess.get(callFrame.injectedScriptId).evaluateInCallFrame(callFrame.id, code, objectGroup, evalCallback);
    404404    },
    405405
  • trunk/WebCore/inspector/front-end/StylesSidebarPane.js

    r53366 r53467  
    116116        }
    117117
    118         InjectedScriptAccess.getStyles(node.id, !WebInspector.settings.showUserAgentStyles, callback);
     118        InjectedScriptAccess.get(node.injectedScriptId).getStyles(node.id, !WebInspector.settings.showUserAgentStyles, callback);
    119119    },
    120120
     
    693693        }
    694694
    695         InjectedScriptAccess.applyStyleRuleText(this.rule.id, newContent, this.pane.node.id, callback);
     695        InjectedScriptAccess.get(this.rule.injectedScriptId).applyStyleRuleText(this.rule.id, newContent, this.pane.node.id, callback);
    696696    },
    697697
     
    747747        }
    748748
    749         InjectedScriptAccess.addStyleSelector(newContent, this.pane.node.id, callback);
     749        InjectedScriptAccess.get(this.pane.node.injectedScriptId).addStyleSelector(newContent, this.pane.node.id, callback);
    750750    },
    751751
     
    10541054        }
    10551055
    1056         InjectedScriptAccess.toggleStyleEnabled(this.style.id, this.name, disabled, callback);
     1056        InjectedScriptAccess.get(this.style.injectedScriptId).toggleStyleEnabled(this.style.id, this.name, disabled, callback);
    10571057    },
    10581058
     
    12171217            // Restore the original CSS text before applying user changes. This is needed to prevent
    12181218            // new properties from sticking around if the user adds one, then removes it.
    1219             InjectedScriptAccess.setStyleText(this.style.id, this.originalCSSText);
     1219            InjectedScriptAccess.get(this.style.injectedScriptId).setStyleText(this.style.id, this.originalCSSText);
    12201220        }
    12211221
     
    12371237            this.treeOutline.removeChild(this);
    12381238        else if (this.originalCSSText) {
    1239             InjectedScriptAccess.setStyleText(this.style.id, this.originalCSSText);
     1239            InjectedScriptAccess.get(this.style.injectedScriptId).setStyleText(this.style.id, this.originalCSSText);
    12401240
    12411241            if (this.treeOutline.section && this.treeOutline.section.pane)
     
    13621362        }
    13631363
    1364         InjectedScriptAccess.applyStyleText(this.style.id, styleText.trim(), this.name, callback);
     1364        InjectedScriptAccess.get(this.style.injectedScriptId).applyStyleText(this.style.id, styleText.trim(), this.name, callback);
    13651365    }
    13661366}
  • trunk/WebCore/inspector/front-end/WatchExpressionsSidebarPane.js

    r53366 r53467  
    132132        }
    133133
    134         InspectorBackend.releaseWrapperObjectGroup(this._watchObjectGroupId)
     134        // TODO: pass exact injected script id.
     135        InspectorBackend.releaseWrapperObjectGroup(0, this._watchObjectGroupId)
    135136        var properties = [];
    136137
  • trunk/WebCore/inspector/front-end/inspector.js

    r53100 r53467  
    390390WebInspector.loaded = function()
    391391{
     392    InspectorBackend.setInjectedScriptSource("(" + injectedScriptConstructor + ");");
     393
    392394    var platform = WebInspector.platform;
    393395    document.body.addStyleClass("platform-" + platform);
     
    11481150WebInspector.pausedScript = function(callFrames)
    11491151{
     1152    callFrames = JSON.parse(callFrames);
    11501153    this.panels.scripts.debuggerPaused(callFrames);
    11511154}
     
    12041207}
    12051208
    1206 WebInspector.addConsoleMessage = function(payload)
     1209WebInspector.addConsoleMessage = function(payload, argumentsStringified, opt_args)
    12071210{
    12081211    var consoleMessage = new WebInspector.ConsoleMessage(
     
    12141217        payload.groupLevel,
    12151218        payload.repeatCount);
    1216     consoleMessage.setMessageBody(Array.prototype.slice.call(arguments, 1));
     1219    var parsedArguments = [];
     1220    for (var i = 2; i < arguments.length; i++) {
     1221        if (argumentsStringified)
     1222            parsedArguments.push(JSON.parse(arguments[i]));
     1223        else
     1224            parsedArguments.push(arguments[i]);
     1225    }
     1226    consoleMessage.setMessageBody(parsedArguments);
    12171227    this.console.addMessage(consoleMessage);
    12181228}
     
    12711281
    12721282        // ConsoleMessage expects a proxy object
    1273         message = new WebInspector.ObjectProxy(null, [], 0, message, false);
     1283        message = new WebInspector.ObjectProxy(null, null, [], 0, message, false);
    12741284
    12751285        // post the message
Note: See TracChangeset for help on using the changeset viewer.