Changeset 53469 in webkit


Ignore:
Timestamp:
Jan 19, 2010 9:00:49 AM (14 years ago)
Author:
yurys@chromium.org
Message:

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

Reviewed by NOBODY (build fix).

Revert r53467. Browser crashes on opening inspector if there
are messages in console.

  • bindings/js/JSInjectedScriptHostCustom.cpp: (WebCore::JSInjectedScriptHost::databaseForId): (WebCore::JSInjectedScriptHost::inspectedWindow): (WebCore::JSInjectedScriptHost::wrapCallback): (WebCore::JSInjectedScriptHost::currentCallFrame): (WebCore::JSInjectedScriptHost::nodeForId): (WebCore::JSInjectedScriptHost::wrapObject): (WebCore::JSInjectedScriptHost::unwrapObject): (WebCore::JSInjectedScriptHost::pushNodePathToFrontend): (WebCore::JSInjectedScriptHost::selectDatabase): (WebCore::JSInjectedScriptHost::selectDOMStorage):
  • bindings/js/ScriptController.cpp:
  • bindings/js/ScriptController.h:
  • bindings/js/ScriptObject.h:
  • bindings/js/ScriptValue.cpp: (WebCore::ScriptValue::quarantineValue):
  • bindings/js/ScriptValue.h:
  • bindings/v8/ScriptObject.h:
  • bindings/v8/ScriptValue.h: (WebCore::ScriptValue::quarantineValue):
  • bindings/v8/custom/V8InjectedScriptHostCustom.cpp: (WebCore::V8InjectedScriptHost::inspectedWindowCallback): (WebCore::V8InjectedScriptHost::wrapCallbackCallback): (WebCore::V8InjectedScriptHost::wrapObjectCallback): (WebCore::V8InjectedScriptHost::unwrapObjectCallback):
  • inspector/ConsoleMessage.cpp: (WebCore::ConsoleMessage::ConsoleMessage): (WebCore::ConsoleMessage::addToConsole): (WebCore::ConsoleMessage::isEqual):
  • inspector/ConsoleMessage.h:
  • inspector/InjectedScriptHost.cpp: (WebCore::InjectedScriptHost::wrapObject): (WebCore::InjectedScriptHost::unwrapObject):
  • inspector/InjectedScriptHost.h:
  • inspector/InjectedScriptHost.idl:
  • inspector/InspectorBackend.cpp: (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::wrapObject): (WebCore::InspectorController::unwrapObject): (WebCore::InspectorController::releaseWrapperObjectGroup): (WebCore::InspectorController::resetInjectedScript):
  • 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.completions): (WebInspector.ConsoleView.prototype.doEvalInWindow): (WebInspector.ConsoleView.prototype._formatnode): (WebInspector.ConsoleView.prototype._formatarray):
  • 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): (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: (InjectedScript.dispatch): (InjectedScript.toggleStyleEnabled): (InjectedScript._serializeRule): (InjectedScript._serializeStyle): (InjectedScript.getProperties): (InjectedScript.setPropertyValue): (InjectedScript._evaluateAndWrap): (InjectedScript.getCallFrames): (InjectedScript._inspectObject): (InjectedScript._ensureCommandLineAPIInstalled): (InjectedScript._resolveObject): (InjectedScript._window): (InjectedScript._objectForId): (InjectedScript.createProxyObject): (InjectedScript.executeSql): (InjectedScript.executeSql.errorCallback): (InjectedScript.executeSql.queryTransaction): (Object.type): (String.prototype.escapeCharacters):
  • inspector/front-end/InjectedScriptAccess.js: (InjectedScriptAccess._installHandler.InjectedScriptAccess.methodName): (InjectedScriptAccess._installHandler):
  • inspector/front-end/MetricsSidebarPane.js: (WebInspector.MetricsSidebarPane): (WebInspector.MetricsSidebarPane.prototype.update.inlineStyleCallback): (WebInspector.MetricsSidebarPane.prototype.update): (WebInspector.MetricsSidebarPane.prototype.editingCommitted):
  • inspector/front-end/ObjectPropertiesSection.js: (WebInspector.ObjectPropertiesSection.prototype.update): (WebInspector.ObjectPropertyTreeElement.prototype.onpopulate): (WebInspector.ObjectPropertyTreeElement.prototype.applyExpression):
  • inspector/front-end/ObjectProxy.js: (WebInspector.ObjectProxy): (WebInspector.ObjectProxy.getPropertiesAsync):
  • inspector/front-end/PropertiesSidebarPane.js: (WebInspector.PropertiesSidebarPane.prototype.update.callback): (WebInspector.PropertiesSidebarPane.prototype.update):
  • inspector/front-end/ResourcesPanel.js: (WebInspector.ResourceSidebarTreeElement.prototype.ondblclick):
  • inspector/front-end/ScriptsPanel.js: (WebInspector.ScriptsPanel.prototype.doEvalInCallFrame):
  • inspector/front-end/StylesSidebarPane.js: (WebInspector.StylesSidebarPane.prototype.update): (WebInspector.StylePropertiesSection.prototype.editingSelectorCommitted): (WebInspector.BlankStylePropertiesSection.prototype.editingSelectorCommitted): (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 NOBODY (build fix).

Revert r53467. Browser crashes on opening inspector if there
are messages in console.

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

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r53467 r53469  
     12010-01-19  Yury Semikhatsky  <yurys@chromium.org>
     2
     3        Reviewed by NOBODY (build fix).
     4
     5        Revert r53467. Browser crashes on opening inspector if there
     6        are messages in console.
     7
     8        * inspector/styles-iframe.html:
     9
    1102010-01-19  Yury Semikhatsky  <yurys@chromium.org>
    211
  • trunk/LayoutTests/inspector/styles-iframe.html

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

    r53467 r53469  
     12010-01-19  Yury Semikhatsky  <yurys@chromium.org>
     2
     3        Reviewed by NOBODY (build fix).
     4
     5        Revert r53467. Browser crashes on opening inspector if there
     6        are messages in console.
     7
     8        * bindings/js/JSInjectedScriptHostCustom.cpp:
     9        (WebCore::JSInjectedScriptHost::databaseForId):
     10        (WebCore::JSInjectedScriptHost::inspectedWindow):
     11        (WebCore::JSInjectedScriptHost::wrapCallback):
     12        (WebCore::JSInjectedScriptHost::currentCallFrame):
     13        (WebCore::JSInjectedScriptHost::nodeForId):
     14        (WebCore::JSInjectedScriptHost::wrapObject):
     15        (WebCore::JSInjectedScriptHost::unwrapObject):
     16        (WebCore::JSInjectedScriptHost::pushNodePathToFrontend):
     17        (WebCore::JSInjectedScriptHost::selectDatabase):
     18        (WebCore::JSInjectedScriptHost::selectDOMStorage):
     19        * bindings/js/ScriptController.cpp:
     20        * bindings/js/ScriptController.h:
     21        * bindings/js/ScriptObject.h:
     22        * bindings/js/ScriptValue.cpp:
     23        (WebCore::ScriptValue::quarantineValue):
     24        * bindings/js/ScriptValue.h:
     25        * bindings/v8/ScriptObject.h:
     26        * bindings/v8/ScriptValue.h:
     27        (WebCore::ScriptValue::quarantineValue):
     28        * bindings/v8/custom/V8InjectedScriptHostCustom.cpp:
     29        (WebCore::V8InjectedScriptHost::inspectedWindowCallback):
     30        (WebCore::V8InjectedScriptHost::wrapCallbackCallback):
     31        (WebCore::V8InjectedScriptHost::wrapObjectCallback):
     32        (WebCore::V8InjectedScriptHost::unwrapObjectCallback):
     33        * inspector/ConsoleMessage.cpp:
     34        (WebCore::ConsoleMessage::ConsoleMessage):
     35        (WebCore::ConsoleMessage::addToConsole):
     36        (WebCore::ConsoleMessage::isEqual):
     37        * inspector/ConsoleMessage.h:
     38        * inspector/InjectedScriptHost.cpp:
     39        (WebCore::InjectedScriptHost::wrapObject):
     40        (WebCore::InjectedScriptHost::unwrapObject):
     41        * inspector/InjectedScriptHost.h:
     42        * inspector/InjectedScriptHost.idl:
     43        * inspector/InspectorBackend.cpp:
     44        (WebCore::InspectorBackend::dispatchOnInjectedScript):
     45        (WebCore::InspectorBackend::releaseWrapperObjectGroup):
     46        * inspector/InspectorBackend.h:
     47        * inspector/InspectorBackend.idl:
     48        * inspector/InspectorController.cpp:
     49        (WebCore::InspectorController::InspectorController):
     50        (WebCore::InspectorController::clearConsoleMessages):
     51        (WebCore::InspectorController::inspectedWindowScriptObjectCleared):
     52        (WebCore::InspectorController::windowScriptObjectAvailable):
     53        (WebCore::InspectorController::scriptObjectReady):
     54        (WebCore::InspectorController::setFrontendProxyObject):
     55        (WebCore::InspectorController::close):
     56        (WebCore::InspectorController::resetScriptObjects):
     57        (WebCore::InspectorController::didPause):
     58        (WebCore::InspectorController::wrapObject):
     59        (WebCore::InspectorController::unwrapObject):
     60        (WebCore::InspectorController::releaseWrapperObjectGroup):
     61        (WebCore::InspectorController::resetInjectedScript):
     62        * inspector/InspectorController.h:
     63        * inspector/InspectorFrontend.cpp:
     64        (WebCore::InspectorFrontend::addConsoleMessage):
     65        (WebCore::InspectorFrontend::pausedScript):
     66        * inspector/InspectorFrontend.h:
     67        * inspector/front-end/AuditsPanel.js:
     68        (WebInspector.AuditsPanel.prototype._reloadResources):
     69        * inspector/front-end/ConsoleView.js:
     70        (WebInspector.ConsoleView.prototype.requestClearMessages):
     71        (WebInspector.ConsoleView.prototype.completions):
     72        (WebInspector.ConsoleView.prototype.doEvalInWindow):
     73        (WebInspector.ConsoleView.prototype._formatnode):
     74        (WebInspector.ConsoleView.prototype._formatarray):
     75        * inspector/front-end/DOMAgent.js:
     76        (WebInspector.DOMNode):
     77        (WebInspector.CSSStyleDeclaration):
     78        (WebInspector.CSSStyleDeclaration.parseRule):
     79        * inspector/front-end/Database.js:
     80        (WebInspector.Database.prototype.executeSql):
     81        * inspector/front-end/ElementsPanel.js:
     82        (WebInspector.ElementsPanel.this.treeOutline.focusedNodeChanged):
     83        (WebInspector.ElementsPanel.prototype.setDocument):
     84        (WebInspector.ElementsPanel.prototype.searchCanceled):
     85        (WebInspector.ElementsPanel.prototype.performSearch):
     86        * inspector/front-end/ElementsTreeOutline.js:
     87        (WebInspector.ElementsTreeElement.prototype.createTooltipForImageNode):
     88        * inspector/front-end/EventListenersSidebarPane.js:
     89        ():
     90        * inspector/front-end/InjectedScript.js:
     91        (InjectedScript.dispatch):
     92        (InjectedScript.toggleStyleEnabled):
     93        (InjectedScript._serializeRule):
     94        (InjectedScript._serializeStyle):
     95        (InjectedScript.getProperties):
     96        (InjectedScript.setPropertyValue):
     97        (InjectedScript._evaluateAndWrap):
     98        (InjectedScript.getCallFrames):
     99        (InjectedScript._inspectObject):
     100        (InjectedScript._ensureCommandLineAPIInstalled):
     101        (InjectedScript._resolveObject):
     102        (InjectedScript._window):
     103        (InjectedScript._objectForId):
     104        (InjectedScript.createProxyObject):
     105        (InjectedScript.executeSql):
     106        (InjectedScript.executeSql.errorCallback):
     107        (InjectedScript.executeSql.queryTransaction):
     108        (Object.type):
     109        (String.prototype.escapeCharacters):
     110        * inspector/front-end/InjectedScriptAccess.js:
     111        (InjectedScriptAccess._installHandler.InjectedScriptAccess.methodName):
     112        (InjectedScriptAccess._installHandler):
     113        * inspector/front-end/MetricsSidebarPane.js:
     114        (WebInspector.MetricsSidebarPane):
     115        (WebInspector.MetricsSidebarPane.prototype.update.inlineStyleCallback):
     116        (WebInspector.MetricsSidebarPane.prototype.update):
     117        (WebInspector.MetricsSidebarPane.prototype.editingCommitted):
     118        * inspector/front-end/ObjectPropertiesSection.js:
     119        (WebInspector.ObjectPropertiesSection.prototype.update):
     120        (WebInspector.ObjectPropertyTreeElement.prototype.onpopulate):
     121        (WebInspector.ObjectPropertyTreeElement.prototype.applyExpression):
     122        * inspector/front-end/ObjectProxy.js:
     123        (WebInspector.ObjectProxy):
     124        (WebInspector.ObjectProxy.getPropertiesAsync):
     125        * inspector/front-end/PropertiesSidebarPane.js:
     126        (WebInspector.PropertiesSidebarPane.prototype.update.callback):
     127        (WebInspector.PropertiesSidebarPane.prototype.update):
     128        * inspector/front-end/ResourcesPanel.js:
     129        (WebInspector.ResourceSidebarTreeElement.prototype.ondblclick):
     130        * inspector/front-end/ScriptsPanel.js:
     131        (WebInspector.ScriptsPanel.prototype.doEvalInCallFrame):
     132        * inspector/front-end/StylesSidebarPane.js:
     133        (WebInspector.StylesSidebarPane.prototype.update):
     134        (WebInspector.StylePropertiesSection.prototype.editingSelectorCommitted):
     135        (WebInspector.BlankStylePropertiesSection.prototype.editingSelectorCommitted):
     136        (WebInspector.StylePropertyTreeElement.prototype):
     137        * inspector/front-end/WatchExpressionsSidebarPane.js:
     138        (WebInspector.WatchExpressionsSection.prototype.update):
     139        * inspector/front-end/inspector.js:
     140        (WebInspector.loaded):
     141        (WebInspector.pausedScript):
     142        (WebInspector.addConsoleMessage):
     143        (WebInspector.log.logMessage):
     144        (WebInspector.log):
     145
    11462010-01-19  Yury Semikhatsky  <yurys@chromium.org>
    2147
  • trunk/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp

    r53467 r53469  
    4848#include "InspectorResource.h"
    4949#include "JSDOMWindow.h"
     50#include "JSInspectedObjectWrapper.h"
     51#include "JSInspectorCallbackWrapper.h"
    5052#include "JSNode.h"
    5153#include "JSRange.h"
     
    111113    if (!database)
    112114        return jsUndefined();
    113     return toJS(exec, database);
    114 }
    115 #endif
     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
     121JSValue JSInjectedScriptHost::inspectedWindow(ExecState*, const ArgList&)
     122{
     123    InspectorController* ic = impl()->inspectorController();
     124    if (!ic)
     125        return jsUndefined();
     126    JSDOMWindow* inspectedWindow = toJSDOMWindow(ic->inspectedPage()->mainFrame(), debuggerWorld());
     127    return JSInspectedObjectWrapper::wrap(inspectedWindow->globalExec(), inspectedWindow);
     128}
     129
     130JSValue 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}
    116137
    117138#if ENABLE(JAVASCRIPT_DEBUGGER)
     
    123144        return jsUndefined();
    124145
    125     JSLock lock(SilenceAssertionsOnly);
    126     return toJS(exec, callFrame);
     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));
    127151}
    128152
     
    143167
    144168    JSLock lock(SilenceAssertionsOnly);
    145     return toJS(exec, node);
     169    JSDOMWindow* inspectedWindow = toJSDOMWindow(ic->inspectedPage()->mainFrame(), debuggerWorld());
     170    return JSInspectedObjectWrapper::wrap(inspectedWindow->globalExec(), toJS(exec, deprecatedGlobalObjectForPrototype(inspectedWindow->globalExec()), node));
     171}
     172
     173JSValue 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
     181JSValue 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();
    146187}
    147188
     
    151192        return jsUndefined();
    152193
    153     Node* node = toNode(args.at(0));
     194    JSQuarantinedObjectWrapper* wrapper = JSQuarantinedObjectWrapper::asWrapper(args.at(0));
     195    if (!wrapper)
     196        return jsUndefined();
     197
     198    Node* node = toNode(wrapper->unwrappedObject());
    154199    if (!node)
    155200        return jsUndefined();
     
    166211        return jsUndefined();
    167212
    168     Database* database = toDatabase(args.at(0));
     213    JSQuarantinedObjectWrapper* wrapper = JSQuarantinedObjectWrapper::asWrapper(args.at(0));
     214    if (!wrapper)
     215        return jsUndefined();
     216
     217    Database* database = toDatabase(wrapper->unwrappedObject());
    169218    if (database)
    170219        impl()->selectDatabase(database);
     
    182231        return jsUndefined();
    183232
    184     Storage* storage = toStorage(args.at(0));
     233    JSQuarantinedObjectWrapper* wrapper = JSQuarantinedObjectWrapper::asWrapper(args.at(0));
     234    if (!wrapper)
     235        return jsUndefined();
     236
     237    Storage* storage = toStorage(wrapper->unwrappedObject());
    185238    if (storage)
    186239        impl()->selectDOMStorage(storage);
  • trunk/WebCore/bindings/js/ScriptController.cpp

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

    r53467 r53469  
    2525#include "JSDOMWindowShell.h"
    2626#include "ScriptInstance.h"
    27 #include "ScriptState.h"
    2827#include <runtime/Protect.h>
    2928#include <wtf/RefPtr.h>
     
    161160    XSSAuditor* xssAuditor() { return m_XSSAuditor.get(); }
    162161
    163     ScriptState* mainWorldScriptState();
    164 
    165162private:
    166163    JSDOMWindowShell* initScript(DOMWrapperWorld* world);
  • trunk/WebCore/bindings/js/ScriptObject.h

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

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

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

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

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

    r53467 r53469  
    115115}
    116116
     117v8::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
     128v8::Handle<v8::Value> V8InjectedScriptHost::wrapCallbackCallback(const v8::Arguments& args)
     129{
     130    INC_STATS("InjectedScriptHost.wrapCallback()");
     131    return args[0];
     132}
     133
    117134v8::Handle<v8::Value> V8InjectedScriptHost::nodeForIdCallback(const v8::Arguments& args)
    118135{
     
    132149
    133150    return V8DOMWrapper::convertToV8Object(V8ClassIndex::NODE, node);
     151}
     152
     153v8::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
     163v8::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();
    134171}
    135172
  • trunk/WebCore/inspector/ConsoleMessage.cpp

    r53467 r53469  
    5555    , m_level(l)
    5656#if ENABLE(INSPECTOR)
    57     , m_arguments(callStack->at(0).argumentCount())
    58     , m_scriptState(callStack->state())
     57    , m_wrappedArguments(callStack->at(0).argumentCount())
    5958#endif
    6059    , m_frames(storeTrace ? callStack->size() : 0)
     
    7675#if ENABLE(INSPECTOR)
    7776    for (unsigned i = 0; i < lastCaller.argumentCount(); ++i)
    78         m_arguments[i] = lastCaller.argumentAt(i);
     77        m_wrappedArguments[i] = ScriptObject::quarantineValue(callStack->state(), lastCaller.argumentAt(i));
    7978#endif
    8079}
     
    9190    jsonObj.set("groupLevel", static_cast<int>(m_groupLevel));
    9291    jsonObj.set("repeatCount", static_cast<int>(m_repeatCount));
    93     frontend->addConsoleMessage(jsonObj, m_frames, m_scriptState, m_arguments,  m_message);
     92    frontend->addConsoleMessage(jsonObj, m_frames, m_wrappedArguments,  m_message);
    9493}
    9594
     
    103102{
    104103#if ENABLE(INSPECTOR)
    105     if (msg->m_arguments.size() != m_arguments.size())
     104    if (msg->m_wrappedArguments.size() != m_wrappedArguments.size())
    106105        return false;
    107     if (!state && msg->m_arguments.size())
     106    if (!state && msg->m_wrappedArguments.size())
    108107        return false;
    109108
    110     ASSERT_ARG(state, state || msg->m_arguments.isEmpty());
     109    ASSERT_ARG(state, state || msg->m_wrappedArguments.isEmpty());
    111110
    112     for (size_t i = 0; i < msg->m_arguments.size(); ++i) {
    113         if (!m_arguments[i].isEqual(state, msg->m_arguments[i]))
     111    for (size_t i = 0; i < msg->m_wrappedArguments.size(); ++i) {
     112        if (!m_wrappedArguments[i].isEqual(state, msg->m_wrappedArguments[i]))
    114113            return false;
    115114    }
  • trunk/WebCore/inspector/ConsoleMessage.h

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

    r53467 r53469  
    9999}
    100100
     101ScriptValue 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
     108ScriptValue InjectedScriptHost::unwrapObject(const String& objectId)
     109{
     110    if (m_inspectorController)
     111        return m_inspectorController->unwrapObject(objectId);
     112    return ScriptValue();
     113}
     114
    101115long InjectedScriptHost::pushNodePathToFrontend(Node* node, bool withChildren, bool selectInUI)
    102116{
     
    178192}
    179193
    180 void 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 
    193194InspectorDOMAgent* InjectedScriptHost::inspectorDOMAgent()
    194195{
     
    205206}
    206207
    207 void 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 
    214208} // namespace WebCore
    215209
  • trunk/WebCore/inspector/InjectedScriptHost.h

    r53467 r53469  
    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);
    6971    long pushNodePathToFrontend(Node* node, bool withChildren, bool selectInUI);
    7072
     
    8789    ScriptObject injectedScriptForId(long);
    8890    void discardInjectedScripts();
    89     void releaseWrapperObjectGroup(long injectedScriptId, const String& objectGroup);
    9091
    9192private:
     
    9394    InspectorDOMAgent* inspectorDOMAgent();
    9495    InspectorFrontend* inspectorFrontend();
    95 
    96     void releaseWrapperObjectGroup(const ScriptObject& injectedScript, const String& objectGroup);
    9796
    9897    InspectorController* m_inspectorController;
  • trunk/WebCore/inspector/InjectedScriptHost.idl

    r53467 r53469  
    3333module core {
    3434    interface [Conditional=INSPECTOR] InjectedScriptHost {
     35        [Custom] DOMWindow inspectedWindow();
     36        [Custom] DOMObject wrapCallback(in DOMObject callback);
    3537        void clearConsoleMessages();
    3638
    3739        void copyText(in DOMString text);
    3840        [Custom] DOMObject nodeForId(in long nodeId);
     41        [Custom] long wrapObject(in DOMObject object, in DOMString objectGroup);
     42        [Custom] DOMObject unwrapObject(in long objectId);
    3943        [Custom] int pushNodePathToFrontend(in DOMObject node, in boolean withChildren, in boolean selectInUI);
    4044
  • trunk/WebCore/inspector/InspectorBackend.cpp

    r53467 r53469  
    4141#include "FrameLoader.h"
    4242#include "HTMLFrameOwnerElement.h"
    43 #include "InjectedScriptHost.h"
    4443#include "InspectorClient.h"
    4544#include "InspectorController.h"
     
    258257#endif
    259258
    260 void InspectorBackend::setInjectedScriptSource(const String& source)
    261 {
    262     if (m_inspectorController)
    263         m_inspectorController->injectedScriptHost()->setInjectedScriptSource(source);
    264 }
    265 
    266 void InspectorBackend::dispatchOnInjectedScript(long callId, long injectedScriptId, const String& methodName, const String& arguments, bool async)
     259void InspectorBackend::dispatchOnInjectedScript(long callId, const String& methodName, const String& arguments, bool async)
    267260{
    268261    InspectorFrontend* frontend = inspectorFrontend();
     
    270263        return;
    271264
    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");
     265    ScriptFunctionCall function(m_inspectorController->m_scriptState, m_inspectorController->m_injectedScriptObj, "dispatch");
    285266    function.appendArgument(methodName);
    286267    function.appendArgument(arguments);
     
    294275        frontend->didDispatchOnInjectedScript(callId, "", true);
    295276    else
    296         frontend->didDispatchOnInjectedScript(callId, result.toString(injectedScript.scriptState()), false);
     277        frontend->didDispatchOnInjectedScript(callId, result.toString(m_inspectorController->m_scriptState), false);
    297278}
    298279
     
    391372}
    392373
    393 void InspectorBackend::releaseWrapperObjectGroup(long injectedScriptId, const String& objectGroup)
    394 {
    395     if (!m_inspectorController)
    396         return;
    397     m_inspectorController->injectedScriptHost()->releaseWrapperObjectGroup(injectedScriptId, objectGroup);
     374void InspectorBackend::releaseWrapperObjectGroup(const String& objectGroup)
     375{
     376    if (m_inspectorController)
     377        m_inspectorController->releaseWrapperObjectGroup(objectGroup);
    398378}
    399379
  • trunk/WebCore/inspector/InspectorBackend.h

    r53467 r53469  
    105105#endif
    106106
    107     void setInjectedScriptSource(const String& source);
    108     void dispatchOnInjectedScript(long callId, long injectedScriptId, const String& methodName, const String& arguments, bool async);
     107    void dispatchOnInjectedScript(long callId, const String& methodName, const String& arguments, bool async);
    109108    void getChildNodes(long callId, long nodeId);
    110109    void setAttribute(long callId, long elementId, const String& name, const String& value);
     
    121120
    122121    // Generic code called from custom implementations.
    123     void releaseWrapperObjectGroup(long injectedScriptId, const String& objectGroup);
     122    void releaseWrapperObjectGroup(const String& objectGroup);
    124123    void didEvaluateForTestInFrontend(long callId, const String& jsonResult);
    125124
  • trunk/WebCore/inspector/InspectorBackend.idl

    r53467 r53469  
    7676        void getProfile(in long callId, in unsigned long uid);
    7777#endif
    78         void setInjectedScriptSource(in DOMString scriptSource);
    79         void dispatchOnInjectedScript(in long callId, in long injectedScriptId, in DOMString methodName, in DOMString arguments, in boolean async);
     78        void dispatchOnInjectedScript(in long callId, in DOMString methodName, in DOMString arguments, in boolean async);
    8079        void getChildNodes(in long callId, in long nodeId);
    8180        void setAttribute(in long callId, in long elementId, in DOMString name, in DOMString value);
     
    9190        void deleteCookie(in DOMString cookieName, in DOMString domain);
    9291
    93         void releaseWrapperObjectGroup(in long injectedScriptId, in DOMString objectGroup);
     92        void releaseWrapperObjectGroup(in DOMString objectGroup);
    9493        void didEvaluateForTestInFrontend(in long callId, in DOMString jsonResult);
    9594
  • trunk/WebCore/inspector/InspectorController.cpp

    r53467 r53469  
    144144    , m_inspectorFrontendHost(InspectorFrontendHost::create(this, client))
    145145    , m_injectedScriptHost(InjectedScriptHost::create(this))
     146    , m_lastBoundObjectId(1)
    146147#if ENABLE(JAVASCRIPT_DEBUGGER)
    147148    , m_debuggerEnabled(false)
     
    375376    m_previousMessage = 0;
    376377    m_groupLevel = 0;
    377     m_injectedScriptHost->releaseWrapperObjectGroup(0 /* release the group in all scripts */, "console");
     378    releaseWrapperObjectGroup("console");
    378379    if (m_domAgent)
    379380        m_domAgent->releaseDanglingNodes();
     
    500501    if (!enabled() || !m_frontend || frame != m_inspectedPage->mainFrame())
    501502        return;
    502     m_injectedScriptHost->discardInjectedScripts();
     503    resetInjectedScript();
    503504}
    504505
     
    513514    ScriptGlobalObject::set(m_scriptState, "InspectorBackend", m_inspectorBackend.get());
    514515    ScriptGlobalObject::set(m_scriptState, "InspectorFrontendHost", m_inspectorFrontendHost.get());
     516    ScriptGlobalObject::set(m_scriptState, "InjectedScriptHost", m_injectedScriptHost.get());
    515517}
    516518
     
    525527        return;
    526528    ScriptObject injectedScriptObj;
     529    if (!ScriptGlobalObject::get(m_scriptState, "InjectedScript", injectedScriptObj))
     530        return;
    527531    setFrontendProxyObject(m_scriptState, webInspectorObj, injectedScriptObj);
    528532
     
    542546}
    543547
    544 void InspectorController::setFrontendProxyObject(ScriptState* scriptState, ScriptObject webInspectorObj, ScriptObject)
     548void InspectorController::setFrontendProxyObject(ScriptState* scriptState, ScriptObject webInspectorObj, ScriptObject injectedScriptObj)
    545549{
    546550    m_scriptState = scriptState;
     551    m_injectedScriptObj = injectedScriptObj;
    547552    m_frontend.set(new InspectorFrontend(this, scriptState, webInspectorObj));
    548553    releaseDOMAgent();
     
    602607    closeWindow();
    603608
     609    m_injectedScriptObj = ScriptObject();
    604610    releaseDOMAgent();
    605611    m_frontend.set(0);
     
    710716    m_frontend->reset();
    711717    m_domAgent->reset();
     718    m_objectGroups.clear();
     719    m_idToWrappedObject.clear();
    712720}
    713721
     
    15841592void InspectorController::didPause()
    15851593{
    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 
     1594    ScriptFunctionCall function(m_scriptState, m_injectedScriptObj, "getCallFrames");
     1595    ScriptValue callFrames = function.call();
    15941596    m_frontend->pausedScript(callFrames);
    15951597}
     
    18191821}
    18201822
     1823ScriptValue 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
     1841ScriptValue 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
     1849void 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
     1861void InspectorController::resetInjectedScript()
     1862{
     1863    ScriptFunctionCall function(m_scriptState, m_injectedScriptObj, "reset");
     1864    function.call();
     1865}
     1866
    18211867void InspectorController::deleteCookie(const String& cookieName, const String& domain)
    18221868{
     
    18471893}
    18481894
    1849 ScriptObject 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
     1895}  // namespace WebCore
    18711896   
    18721897#endif // ENABLE(INSPECTOR)
  • trunk/WebCore/inspector/InspectorController.h

    r53467 r53469  
    101101    typedef HashMap<int, RefPtr<InspectorDatabaseResource> > DatabaseResourcesMap;
    102102    typedef HashMap<int, RefPtr<InspectorDOMStorageResource> > DOMStorageResourcesMap;
     103    typedef HashMap<String, Vector<String> > ObjectGroupsMap;
    103104
    104105    typedef enum {
     
    248249
    249250    void evaluateForTestInFrontend(long callId, const String& script);
    250 
    251     ScriptObject injectedScriptForNodeId(long id);
    252251
    253252private:
     
    266265    void releaseDOMAgent();
    267266
     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
    268277    void deleteCookie(const String& cookieName, const String& domain);
    269278
     
    313322    RefPtr<InspectorDOMAgent> m_domAgent;
    314323    OwnPtr<InspectorTimelineAgent> m_timelineAgent;
     324    ScriptObject m_injectedScriptObj;
    315325    Page* m_page;
    316326    RefPtr<Node> m_nodeToFocus;
     
    341351    RefPtr<InspectorFrontendHost> m_inspectorFrontendHost;
    342352    RefPtr<InjectedScriptHost> m_injectedScriptHost;
     353    HashMap<String, ScriptValue> m_idToWrappedObject;
     354    ObjectGroupsMap m_objectGroups;
     355    long m_lastBoundObjectId;
    343356
    344357    typedef HashMap<String, String> Settings;
  • trunk/WebCore/inspector/InspectorFrontend.cpp

    r53467 r53469  
    3535#include "ConsoleMessage.h"
    3636#include "Frame.h"
    37 #include "InjectedScriptHost.h"
    3837#include "InspectorController.h"
    3938#include "Node.h"
     
    9594}
    9695
    97 void InspectorFrontend::addConsoleMessage(const ScriptObject& messageObj, const Vector<ScriptString>& frames, ScriptState* scriptState, const Vector<ScriptValue> arguments, const String& message)
     96void InspectorFrontend::addConsoleMessage(const ScriptObject& messageObj, const Vector<ScriptString>& frames, const Vector<ScriptValue> wrappedArguments, const String& message)
    9897{
    9998    ScriptFunctionCall function(m_scriptState, m_webInspector, "dispatch");
     
    101100    function.appendArgument(messageObj);
    102101    if (!frames.isEmpty()) {
    103         function.appendArgument(false);
    104102        for (unsigned i = 0; i < frames.size(); ++i)
    105103            function.appendArgument(frames[i]);
    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);
     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
    121108        function.appendArgument(message);
    122     }
    123109    function.call();
    124110}
     
    327313}
    328314
    329 void InspectorFrontend::pausedScript(const String& callFrames)
     315void InspectorFrontend::pausedScript(const ScriptValue& callFrames)
    330316{
    331317    ScriptFunctionCall function(m_scriptState, m_webInspector, "dispatch");
  • trunk/WebCore/inspector/InspectorFrontend.h

    r53467 r53469  
    6868
    6969        void updateConsoleMessageExpiredCount(unsigned count);
    70         void addConsoleMessage(const ScriptObject& messageObj, const Vector<ScriptString>& frames, ScriptState*, const Vector<ScriptValue> arguments, const String& message);
     70        void addConsoleMessage(const ScriptObject& messageObj, const Vector<ScriptString>& frames, const Vector<ScriptValue> wrappedArguments, 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 String& callFrames);
     98        void pausedScript(const ScriptValue& callFrames);
    9999        void resumedScript();
    100100#endif
  • trunk/WebCore/inspector/front-end/AuditsPanel.js

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

    r53467 r53469  
    293293    requestClearMessages: function()
    294294    {
    295         InjectedScriptAccess.getDefault().clearConsoleMessages(function() {});
     295        InjectedScriptAccess.clearConsoleMessages(function() {});
    296296    },
    297297
     
    335335
    336336        var includeInspectorCommandLineAPI = (!dotNotation && !bracketNotation);
    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);
     337        if (WebInspector.panels.scripts && WebInspector.panels.scripts.paused)
     338            var callFrameId = WebInspector.panels.scripts.selectedCallFrameId();
     339        InjectedScriptAccess.getCompletions(expressionString, includeInspectorCommandLineAPI, callFrameId, reportCompletions);
    345340    },
    346341
     
    466461            callback(result.value, result.isException);
    467462        };
    468         InjectedScriptAccess.getDefault().evaluate(expression, objectGroup, evalCallback);
     463        InjectedScriptAccess.evaluate(expression, objectGroup, evalCallback);
    469464    },
    470465
     
    539534        }
    540535
    541         InjectedScriptAccess.get(object.injectedScriptId).pushNodeToFrontend(object, printNode);
     536        InjectedScriptAccess.pushNodeToFrontend(object, printNode);
    542537    },
    543538
    544539    _formatarray: function(arr, elem)
    545540    {
    546         InjectedScriptAccess.get(arr.injectedScriptId).getProperties(arr, false, false, this._printArray.bind(this, elem));
     541        InjectedScriptAccess.getProperties(arr, false, false, this._printArray.bind(this, elem));
    547542    },
    548543
  • trunk/WebCore/inspector/front-end/DOMAgent.js

    r53467 r53469  
    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;
    4036    this.nodeType = payload.nodeType;
    4137    this.nodeName = payload.nodeName;
     
    521517{
    522518    this.id = payload.id;
    523     this.injectedScriptId = payload.injectedScriptId;
    524519    this.width = payload.width;
    525520    this.height = payload.height;
     
    564559    var rule = {};
    565560    rule.id = payload.id;
    566     rule.injectedScriptId = payload.injectedScriptId;
    567561    rule.selectorText = payload.selectorText;
    568562    rule.style = new WebInspector.CSSStyleDeclaration(payload.style);
  • trunk/WebCore/inspector/front-end/Database.js

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

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

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

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

    r53467 r53469  
    2727 */
    2828
    29 var injectedScriptConstructor = (function (InjectedScriptHost, inspectedWindow, injectedScriptId) {
    30 
    3129var InjectedScript = {};
    32 
    33 InjectedScript.lastBoundObjectId = 1;
    34 InjectedScript.idToWrappedObject = {};
    35 InjectedScript.objectGroups = {};
    36 InjectedScript.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 
    55 InjectedScript.wrapAndStringifyObject = function(object, objectGroupName) {
    56     var r = InjectedScript.wrapObject(object, objectGroupName);
    57     return InjectedScript.JSON.stringify(r);
    58 };
    59 
    60 InjectedScript.unwrapObject = function(objectId) {
    61     return InjectedScript.idToWrappedObject[objectId];
    62 };
    63 
    64 InjectedScript.releaseWrapperObjectGroup = function(objectGroupName) {
    65     delete InjectedScript.objectGroups[objectGroupName];
    66 };
    6730
    6831// Called from within InspectorController on the 'inspected page' side.
     
    8952        result = null;
    9053    }
    91     return InjectedScript.JSON.stringify(result);
     54    return JSON.stringify(result);
    9255}
    9356
     
    207170    if (disabled) {
    208171        if (!style.__disabledPropertyValues || !style.__disabledPropertyPriorities) {
    209             style.__disabledProperties = {};
    210             style.__disabledPropertyValues = {};
    211             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;
    212176        }
    213177
     
    343307        }
    344308        ruleValue.id = rule.id;
    345         ruleValue.injectedScriptId = injectedScriptId;
    346309    }
    347310    return ruleValue;
     
    382345        }
    383346        result.id = style.id;
    384         result.injectedScriptId = injectedScriptId;
    385347    }
    386348    return result;
     
    484446{
    485447    var object = InjectedScript._resolveObject(objectProxy);
    486     if (!InjectedScript._isDefined(object))
     448    if (!object)
    487449        return false;
    488450
     
    518480{
    519481    var object = InjectedScript._resolveObject(objectProxy);
    520     if (!InjectedScript._isDefined(object))
     482    if (!object)
    521483        return false;
    522484
     
    627589    var result = {};
    628590    try {
    629         result.value = InjectedScript.wrapObject(InjectedScript._evaluateOn(evalFunction, object, expression), objectGroup);
    630 
     591        result.value = InjectedScriptHost.wrapObject(InjectedScript._evaluateOn(evalFunction, object, expression), objectGroup);
    631592        // Handle error that might have happened while describing result.
    632593        if (result.value.errorText) {
     
    925886        callFrame = callFrame.caller;
    926887    } while (callFrame);
    927     return InjectedScript.JSON.stringify(result);
     888    return result;
    928889}
    929890
     
    955916        return;
    956917
     918    var inspectedWindow = InjectedScript._window();
    957919    inspectedWindow.console.log(o);
    958920    if (Object.type(o) === "node") {
     
    10531015    };");
    10541016
    1055     inspectorCommandLineAPI.clear = InjectedScript.clearConsoleMessages;
    1056     inspectorCommandLineAPI.inspect = InjectedScript._inspectObject;
    1057     inspectorCommandLineAPI.copy = InjectedScript._copy;
     1017    inspectorCommandLineAPI.clear = InjectedScriptHost.wrapCallback(InjectedScript.clearConsoleMessages);
     1018    inspectorCommandLineAPI.inspect = InjectedScriptHost.wrapCallback(InjectedScript._inspectObject);
     1019    inspectorCommandLineAPI.copy = InjectedScriptHost.wrapCallback(InjectedScript._copy);
    10581020}
    10591021
     
    10651027
    10661028    // Follow the property path.
    1067     for (var i = 0; InjectedScript._isDefined(object) && path && i < path.length; ++i)
     1029    for (var i = 0; object && path && i < path.length; ++i)
    10681030        object = object[path[i]];
    10691031
    10701032    // Get to the necessary proto layer.
    1071     for (var i = 0; InjectedScript._isDefined(object) && protoDepth && i < protoDepth; ++i)
     1033    for (var i = 0; object && protoDepth && i < protoDepth; ++i)
    10721034        object = object.__proto__;
    10731035
     
    10791041    // TODO: replace with 'return window;' once this script is injected into
    10801042    // the page's context.
    1081     return inspectedWindow;
     1043    return InjectedScriptHost.inspectedWindow();
    10821044}
    10831045
     
    10981060        return InjectedScript._nodeForId(objectId);
    10991061    } else if (typeof objectId === "string") {
    1100         return InjectedScript.unwrapObject(objectId);
     1062        return InjectedScriptHost.unwrapObject(objectId);
    11011063    } else if (typeof objectId === "object") {
    11021064        var callFrame = InjectedScript._callFrameForId(objectId.callFrame);
     
    11281090{
    11291091    var result = {};
    1130     result.injectedScriptId = injectedScriptId;
    11311092    result.objectId = objectId;
    11321093    result.type = Object.type(object);
     
    12101171            }
    12111172        }
    1212         InjectedScriptHost.reportDidDispatchOnInjectedScript(callId, InjectedScript.JSON.stringify(result), false);
     1173        InjectedScriptHost.reportDidDispatchOnInjectedScript(callId, JSON.stringify(result), false);
    12131174    }
    12141175
    12151176    function errorCallback(tx, error)
    12161177    {
    1217         InjectedScriptHost.reportDidDispatchOnInjectedScript(callId, InjectedScript.JSON.stringify(error), false);
     1178        InjectedScriptHost.reportDidDispatchOnInjectedScript(callId, JSON.stringify(error), false);
    12181179    }
    12191180
    12201181    function queryTransaction(tx)
    12211182    {
    1222         tx.executeSql(query, null, successCallback, errorCallback);
     1183        tx.executeSql(query, null, InjectedScriptHost.wrapCallback(successCallback), InjectedScriptHost.wrapCallback(errorCallback));
    12231184    }
    12241185
     
    12261187    if (!database)
    12271188        errorCallback(null, { code : 2 });  // Return as unexpected version.
    1228     database.transaction(queryTransaction, errorCallback);
     1189    database.transaction(InjectedScriptHost.wrapCallback(queryTransaction), InjectedScriptHost.wrapCallback(errorCallback));
    12291190    return true;
    1230 }
    1231 
    1232 InjectedScript._isDefined = function(object)
    1233 {
    1234     return object || object instanceof inspectedWindow.HTMLAllCollection;
    12351191}
    12361192
     
    12391195    if (obj === null)
    12401196        return "null";
    1241 
    1242     // FIXME(33716): typeof document.all is always 'undefined'.
    1243     if (obj instanceof inspectedWindow.HTMLAllCollection)
    1244         return "array";
    12451197
    12461198    var type = typeof obj;
     
    13471299    return result;
    13481300}
    1349 
    1350 InjectedScript.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]*$/.
    1617 test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').
    1618 replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
    1619 replace(/(?:^|:|,)(?:\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 
    1641 return InjectedScript;
    1642 });
  • trunk/WebCore/inspector/front-end/InjectedScriptAccess.js

    r53467 r53469  
    3030 */
    3131
    32 function InjectedScriptAccess(injectedScriptId) {
    33     this._injectedScriptId = injectedScriptId;
    34 }
    35 
    36 InjectedScriptAccess.get = function(injectedScriptId)
    37 {
    38     return new InjectedScriptAccess(injectedScriptId);
    39 }
    40 
    41 InjectedScriptAccess.getDefault = function()
    42 {
    43     return InjectedScriptAccess.get(0);
    44 }
    45 
    46 InjectedScriptAccess.prototype = {};
     32var InjectedScriptAccess = {};
    4733
    4834InjectedScriptAccess._installHandler = function(methodName, async)
    4935{
    50     InjectedScriptAccess.prototype[methodName] = function()
     36    InjectedScriptAccess[methodName] = function()
    5137    {
    5238        var allArgs = Array.prototype.slice.call(arguments);
     
    6248        }
    6349        var callId = WebInspector.Callback.wrap(myCallback);
    64 
    65         InspectorBackend.dispatchOnInjectedScript(callId, this._injectedScriptId, methodName, argsString, !!async);
     50        InspectorBackend.dispatchOnInjectedScript(callId, methodName, argsString, !!async);
    6651    };
    6752}
  • trunk/WebCore/inspector/front-end/MetricsSidebarPane.js

    r53467 r53469  
    3131    WebInspector.SidebarPane.call(this, WebInspector.UIString("Metrics"));
    3232    this._inlineStyleId = null;
    33     this._inlineStyleInjectedScriptId = null;
    3433}
    3534
     
    5453            self._update(style);
    5554        };
    56         InjectedScriptAccess.get(node.injectedScriptId).getComputedStyle(node.id, callback);
     55        InjectedScriptAccess.getComputedStyle(node.id, callback);
    5756
    5857        var inlineStyleCallback = function(stylePayload) {
     
    6059                return;
    6160            self._inlineStyleId = stylePayload.id;
    62             self._inlineStyleInjectedScriptId = stylePayload.injectedScriptId;
    63         };
    64         InjectedScriptAccess.get(node.injectedScriptId).getInlineStyle(node.id, inlineStyleCallback);
     61        };
     62        InjectedScriptAccess.getInlineStyle(node.id, inlineStyleCallback);
    6563    },
    6664
     
    207205            self.update();
    208206        };
    209         InjectedScriptAccess.get(this._inlineStyleInjectedScriptId).setStyleProperty(this._inlineStyleId, context.styleProperty, userInput, callback);
     207        InjectedScriptAccess.setStyleProperty(this._inlineStyleId, context.styleProperty, userInput, callback);
    210208    }
    211209}
  • trunk/WebCore/inspector/front-end/ObjectPropertiesSection.js

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

    r53467 r53469  
    2929 */
    3030
    31 WebInspector.ObjectProxy = function(injectedScriptId, objectId, path, protoDepth, description, hasChildren)
     31WebInspector.ObjectProxy = function(objectId, path, protoDepth, description, hasChildren)
    3232{
    3333    this.objectId = objectId;
    34     this.injectedScriptId = injectedScriptId;
    3534    this.path = path || [];
    3635    this.protoDepth = protoDepth || 0;
     
    6261        callback(result);
    6362    };
    64     InjectedScriptAccess.get(objectProxy.injectedScriptId).getProperties(objectProxy, true, false, createPropertiesMapThenCallback);
     63    InjectedScriptAccess.getProperties(objectProxy, true, false, createPropertiesMapThenCallback);
    6564}
    6665
  • trunk/WebCore/inspector/front-end/PropertiesSidebarPane.js

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

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

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

    r53467 r53469  
    116116        }
    117117
    118         InjectedScriptAccess.get(node.injectedScriptId).getStyles(node.id, !WebInspector.settings.showUserAgentStyles, callback);
     118        InjectedScriptAccess.getStyles(node.id, !WebInspector.settings.showUserAgentStyles, callback);
    119119    },
    120120
     
    693693        }
    694694
    695         InjectedScriptAccess.get(this.rule.injectedScriptId).applyStyleRuleText(this.rule.id, newContent, this.pane.node.id, callback);
     695        InjectedScriptAccess.applyStyleRuleText(this.rule.id, newContent, this.pane.node.id, callback);
    696696    },
    697697
     
    747747        }
    748748
    749         InjectedScriptAccess.get(this.pane.node.injectedScriptId).addStyleSelector(newContent, this.pane.node.id, callback);
     749        InjectedScriptAccess.addStyleSelector(newContent, this.pane.node.id, callback);
    750750    },
    751751
     
    10541054        }
    10551055
    1056         InjectedScriptAccess.get(this.style.injectedScriptId).toggleStyleEnabled(this.style.id, this.name, disabled, callback);
     1056        InjectedScriptAccess.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.get(this.style.injectedScriptId).setStyleText(this.style.id, this.originalCSSText);
     1219            InjectedScriptAccess.setStyleText(this.style.id, this.originalCSSText);
    12201220        }
    12211221
     
    12371237            this.treeOutline.removeChild(this);
    12381238        else if (this.originalCSSText) {
    1239             InjectedScriptAccess.get(this.style.injectedScriptId).setStyleText(this.style.id, this.originalCSSText);
     1239            InjectedScriptAccess.setStyleText(this.style.id, this.originalCSSText);
    12401240
    12411241            if (this.treeOutline.section && this.treeOutline.section.pane)
     
    13621362        }
    13631363
    1364         InjectedScriptAccess.get(this.style.injectedScriptId).applyStyleText(this.style.id, styleText.trim(), this.name, callback);
     1364        InjectedScriptAccess.applyStyleText(this.style.id, styleText.trim(), this.name, callback);
    13651365    }
    13661366}
  • trunk/WebCore/inspector/front-end/WatchExpressionsSidebarPane.js

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

    r53467 r53469  
    390390WebInspector.loaded = function()
    391391{
    392     InspectorBackend.setInjectedScriptSource("(" + injectedScriptConstructor + ");");
    393 
    394392    var platform = WebInspector.platform;
    395393    document.body.addStyleClass("platform-" + platform);
     
    11501148WebInspector.pausedScript = function(callFrames)
    11511149{
    1152     callFrames = JSON.parse(callFrames);
    11531150    this.panels.scripts.debuggerPaused(callFrames);
    11541151}
     
    12071204}
    12081205
    1209 WebInspector.addConsoleMessage = function(payload, argumentsStringified, opt_args)
     1206WebInspector.addConsoleMessage = function(payload)
    12101207{
    12111208    var consoleMessage = new WebInspector.ConsoleMessage(
     
    12171214        payload.groupLevel,
    12181215        payload.repeatCount);
    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);
     1216    consoleMessage.setMessageBody(Array.prototype.slice.call(arguments, 1));
    12271217    this.console.addMessage(consoleMessage);
    12281218}
     
    12811271
    12821272        // ConsoleMessage expects a proxy object
    1283         message = new WebInspector.ObjectProxy(null, null, [], 0, message, false);
     1273        message = new WebInspector.ObjectProxy(null, [], 0, message, false);
    12841274
    12851275        // post the message
Note: See TracChangeset for help on using the changeset viewer.