[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

caseq at chromium.org caseq at chromium.org
Wed Dec 22 15:22:34 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit d321da6ff07ec8580304635faf2ccd23d9583258
Author: caseq at chromium.org <caseq at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Nov 2 10:29:02 2010 +0000

    2010-11-01  Andrey Kosyakov  <caseq at chromium.org>
    
            Reviewed by Pavel Feldman.
    
            Web Inspector: [Extensions API] expose API to create properties watch sidebar panes
            https://bugs.webkit.org/show_bug.cgi?id=48761
    
            * inspector/front-end/ExtensionAPI.js:
            (WebInspector.injectedExtensionAPI.PanelImpl.prototype.createSidebarPane):
            (WebInspector.injectedExtensionAPI.PanelImpl.prototype.createWatchExpressionSidebarPane.callbackWrapper):
            (WebInspector.injectedExtensionAPI.PanelImpl.prototype.createWatchExpressionSidebarPane):
            (WebInspector.injectedExtensionAPI):
            (WebInspector.injectedExtensionAPI.WatchExpressionSidebarPaneImpl):
            (WebInspector.injectedExtensionAPI.WatchExpressionSidebarPaneImpl.prototype.setExpression):
            (WebInspector.injectedExtensionAPI.WatchExpressionSidebarPaneImpl.prototype.setObject):
            * inspector/front-end/ExtensionPanel.js: Added ExtensionWatchSidebarPane
            (WebInspector.ExtensionWatchSidebarPane):
            (WebInspector.ExtensionWatchSidebarPane.prototype.setObject):
            (WebInspector.ExtensionWatchSidebarPane.prototype.setExpression):
            (WebInspector.ExtensionWatchSidebarPane.prototype._onEvaluate):
            (WebInspector.ExtensionWatchSidebarPane.prototype._setObject):
            * inspector/front-end/ExtensionServer.js:
            (WebInspector.ExtensionServer):
            (WebInspector.ExtensionServer.prototype.notifyExtensionWatchSidebarUpdated):
            (WebInspector.ExtensionServer.prototype._onCreateSidebar):
            (WebInspector.ExtensionServer.prototype._onCreateWatchExpressionSidebarPane):
            (WebInspector.ExtensionServer.prototype._createSidebar):
            (WebInspector.ExtensionServer.prototype._onSetWatchSidebarContent):
            * inspector/front-end/InjectedScript.js:
            (injectedScriptConstructor.):
            * inspector/front-end/RemoteObject.js: Added a wrapper for local JSON object to simulate RemoteObject interface.
            (WebInspector.RemoteObject.fromLocalObject):
            (WebInspector.LocalJSONObject):
            (WebInspector.LocalJSONObject.prototype.get description):
            (WebInspector.LocalJSONObject.prototype.get type):
            (WebInspector.LocalJSONObject.prototype.get hasChildren):
            (WebInspector.LocalJSONObject.prototype.getOwnProperties):
            (WebInspector.LocalJSONObject.prototype.getProperties):
            (WebInspector.LocalJSONObject.prototype.isError):
    
    2010-11-01  Andrey Kosyakov  <caseq at chromium.org>
    
            Reviewed by Pavel Feldman.
    
            Web Inspector: [Extensions API] expose API to create properties watch sidebar panes
            https://bugs.webkit.org/show_bug.cgi?id=48761
    
            * inspector/extensions-api-expected.txt:
            * inspector/extensions-events-expected.txt:
            * inspector/extensions-expected.txt:
            * inspector/extensions-test.js: Added generic way to dispatch messages to front-end and receive callbacks.
            (initialize_ExtensionsTest.InspectorTest.dispatchOnMessage):
            (initialize_ExtensionsTest.InspectorTest.dumpSidebarContent):
            * inspector/extensions.html:
            * inspector/resources/extension-main.js:
            (dispatchOnFrontend.callbackWrapper):
            (dispatchOnFrontend):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@71107 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index d20a0b5..09871f7 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,21 @@
+2010-11-01  Andrey Kosyakov  <caseq at chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        Web Inspector: [Extensions API] expose API to create properties watch sidebar panes
+        https://bugs.webkit.org/show_bug.cgi?id=48761
+
+        * inspector/extensions-api-expected.txt:
+        * inspector/extensions-events-expected.txt:
+        * inspector/extensions-expected.txt:
+        * inspector/extensions-test.js: Added generic way to dispatch messages to front-end and receive callbacks.
+        (initialize_ExtensionsTest.InspectorTest.dispatchOnMessage):
+        (initialize_ExtensionsTest.InspectorTest.dumpSidebarContent):
+        * inspector/extensions.html:
+        * inspector/resources/extension-main.js:
+        (dispatchOnFrontend.callbackWrapper):
+        (dispatchOnFrontend):
+
 2010-11-02  Philippe Normand  <pnormand at igalia.com>
 
         Unreviewed, unskip passing media test on the GTK+ port.
diff --git a/LayoutTests/inspector/extensions-api-expected.txt b/LayoutTests/inspector/extensions-api-expected.txt
index c7a7920..d886313 100644
--- a/LayoutTests/inspector/extensions-api-expected.txt
+++ b/LayoutTests/inspector/extensions-api-expected.txt
@@ -27,6 +27,7 @@ RUNNING TEST: extension_testAPI
     panels : {
         elements : {
             createSidebarPane : <function>
+            createWatchExpressionSidebarPane : <function>
             onSelectionChanged : {
                 addListener : <function>
                 removeListener : <function>
@@ -34,6 +35,7 @@ RUNNING TEST: extension_testAPI
         }
         scripts : {
             createSidebarPane : <function>
+            createWatchExpressionSidebarPane : <function>
             onSelectionChanged : {
                 addListener : <function>
                 removeListener : <function>
diff --git a/LayoutTests/inspector/extensions-events-expected.txt b/LayoutTests/inspector/extensions-events-expected.txt
index 8bcf000..ca143a8 100644
--- a/LayoutTests/inspector/extensions-events-expected.txt
+++ b/LayoutTests/inspector/extensions-events-expected.txt
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 670: [object HTMLParagraphElement]
+CONSOLE MESSAGE: line 669: [object HTMLParagraphElement]
 Tests WebInspector extension API
 
 Page reloaded.
diff --git a/LayoutTests/inspector/extensions-expected.txt b/LayoutTests/inspector/extensions-expected.txt
index bd5a952..15c6653 100644
--- a/LayoutTests/inspector/extensions-expected.txt
+++ b/LayoutTests/inspector/extensions-expected.txt
@@ -8,6 +8,7 @@ done createPanel
 Panel created
 {
     createSidebarPane : <function>
+    createWatchExpressionSidebarPane : <function>
     onSelectionChanged : {
         addListener : <function>
         removeListener : <function>
@@ -23,5 +24,22 @@ Sidebar created
     setHeight : <function>
     setExpanded : <function>
 }
+RUNNING TEST: extension_testExtensionWatchSidebarExpression
+Sidebar content: titlef0: "expression"f1: undefinedf2: nullf3: Objectf4: Array[0]f5: Array[3]f6: Objectf7: 42f8: Locationf9: HTMLCollection[26]f10: function () {}__proto__: Object
+RUNNING TEST: extension_testExtensionWatchSidebarObject
+Watch sidebar created, callback arguments dump follows:
+{
+    0 : {
+        setHeight : <function>
+        setExpanded : <function>
+        setExpression : <function>
+        setObject : <function>
+        onUpdated : {
+            addListener : <function>
+            removeListener : <function>
+        }
+    }
+}
+Sidebar content: f0: "object"f1: undefinedf2: nullf3: { }f4: [0]f5: [3]f6: {...}f7: 42
 All tests done.
 
diff --git a/LayoutTests/inspector/extensions-test.js b/LayoutTests/inspector/extensions-test.js
index 4dc2fb4..a51f712 100644
--- a/LayoutTests/inspector/extensions-test.js
+++ b/LayoutTests/inspector/extensions-test.js
@@ -17,14 +17,17 @@ function extensionFunctions()
 var initialize_ExtensionsTest = function()
 {
 
-InspectorTest.dispatchOnMessage = function(messageId, callback)
+InspectorTest.dispatchOnMessage = function(messageId, callback, recurring)
 {
     function onMessage(event)
     {
-        if (event.data === messageId) {
+        if (event.data !== messageId)
+            return;
+        if (!recurring)
             window.removeEventListener("message", onMessage, false);
-            callback();
-        }
+        callback();
+        if (event.ports && event.ports[0])
+            event.ports[0].postMessage("");
     }
     window.addEventListener("message", onMessage, false);
 }
@@ -46,6 +49,16 @@ InspectorTest.runExtensionTests = function()
     InspectorTest.reloadPageIfNeeded(addExtension);
 }
 
+InspectorTest.dumpSidebarContent = function()
+{
+    var sidebarPanes = WebInspector.panels.scripts.sidebarPanes;
+    // the sidebar of interest is presumed to always be last.
+    var sidebar = sidebarPanes[Object.keys(sidebarPanes).pop()];
+    InspectorTest.addResult("Sidebar content: " + sidebar.bodyElement.textContent);
+}
+
+InspectorTest.dispatchOnMessage("dump-sidebar-content", InspectorTest.dumpSidebarContent, true);
+
 }
 
 var test = function()
diff --git a/LayoutTests/inspector/extensions.html b/LayoutTests/inspector/extensions.html
index 1b5412a..08f0238 100644
--- a/LayoutTests/inspector/extensions.html
+++ b/LayoutTests/inspector/extensions.html
@@ -25,6 +25,58 @@ function extension_testCreateSidebar(nextTest)
     webInspector.panels.scripts.createSidebarPane("Test Sidebar", "extension-sidebar.html", callbackAndNextTest(onSidebarCreated, nextTest));
 }
 
+function extension_dumpSidebarContent(nextTest)
+{
+    dispatchOnFrontend("dump-sidebar-content", nextTest);
+}
+
+function extension_testExtensionWatchSidebarObject(nextTest)
+{
+    function onSidebarCreated(sidebar)
+    {
+        output("Watch sidebar created, callback arguments dump follows:");
+        dumpObject(Array.prototype.slice.call(arguments));
+        sidebar.onUpdated.addListener(bind(extension_dumpSidebarContent, this, nextTest));
+        sidebar.setObject({
+            f0: "object",
+            f1: undefined,
+            f2: null,
+            f3: {},
+            f4: [],
+            f5: ["aa", "bb", "cc"],
+            f6: { f60: 42, f61: "foo", f62: [] },
+            f7: 42
+        });
+    }
+    webInspector.panels.scripts.createWatchExpressionSidebarPane("Watch Test: Object", onSidebarCreated);
+}
+
+function extension_testExtensionWatchSidebarExpression(nextTest)
+{
+    function onSidebarCreated(sidebar)
+    {
+        sidebar.onUpdated.addListener(bind(extension_dumpSidebarContent, this, nextTest));
+        function expression()
+        {
+            return {
+                f0: 'expression',
+                f1: undefined,
+                f2: null,
+                f3: {},
+                f4: [],
+                f5: ["aa", "bb", "cc"],
+                f6: { f60: 42, f61: "foo", f62: [] },
+                f7: 42,
+                f8: window.location,
+                f9: document.body.children,
+                f10: function() {}
+            };
+        }
+        sidebar.setExpression("(" + expression.toString() + ")();", "title");
+    }
+    webInspector.panels.scripts.createWatchExpressionSidebarPane("Watch Test: Expression", onSidebarCreated);
+}
+
 </script>
 </head>
 <body onload="runTest()">
diff --git a/LayoutTests/inspector/resources/extension-main.js b/LayoutTests/inspector/resources/extension-main.js
index 1669733..d0f1c2e 100644
--- a/LayoutTests/inspector/resources/extension-main.js
+++ b/LayoutTests/inspector/resources/extension-main.js
@@ -40,6 +40,19 @@ function runTest(test, name)
     }
 }
 
+function dispatchOnFrontend(message, callback)
+{
+    function callbackWrapper()
+    {
+        channel.port1.removeEventListener("message", callbackWrapper, false);
+        callback();
+    }
+    var channel = new MessageChannel();
+    channel.port1.start();
+    channel.port1.addEventListener("message", callbackWrapper, false);
+    top.postMessage(message, [ channel.port2 ], "*");
+}
+
 function callbackAndNextTest(callback, nextTest)
 {
     function callbackWrapper()
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index da63c93..a8519ff 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,43 @@
+2010-11-01  Andrey Kosyakov  <caseq at chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        Web Inspector: [Extensions API] expose API to create properties watch sidebar panes
+        https://bugs.webkit.org/show_bug.cgi?id=48761
+
+        * inspector/front-end/ExtensionAPI.js:
+        (WebInspector.injectedExtensionAPI.PanelImpl.prototype.createSidebarPane):
+        (WebInspector.injectedExtensionAPI.PanelImpl.prototype.createWatchExpressionSidebarPane.callbackWrapper):
+        (WebInspector.injectedExtensionAPI.PanelImpl.prototype.createWatchExpressionSidebarPane):
+        (WebInspector.injectedExtensionAPI):
+        (WebInspector.injectedExtensionAPI.WatchExpressionSidebarPaneImpl):
+        (WebInspector.injectedExtensionAPI.WatchExpressionSidebarPaneImpl.prototype.setExpression):
+        (WebInspector.injectedExtensionAPI.WatchExpressionSidebarPaneImpl.prototype.setObject):
+        * inspector/front-end/ExtensionPanel.js: Added ExtensionWatchSidebarPane
+        (WebInspector.ExtensionWatchSidebarPane):
+        (WebInspector.ExtensionWatchSidebarPane.prototype.setObject):
+        (WebInspector.ExtensionWatchSidebarPane.prototype.setExpression):
+        (WebInspector.ExtensionWatchSidebarPane.prototype._onEvaluate):
+        (WebInspector.ExtensionWatchSidebarPane.prototype._setObject):
+        * inspector/front-end/ExtensionServer.js:
+        (WebInspector.ExtensionServer):
+        (WebInspector.ExtensionServer.prototype.notifyExtensionWatchSidebarUpdated):
+        (WebInspector.ExtensionServer.prototype._onCreateSidebar):
+        (WebInspector.ExtensionServer.prototype._onCreateWatchExpressionSidebarPane):
+        (WebInspector.ExtensionServer.prototype._createSidebar):
+        (WebInspector.ExtensionServer.prototype._onSetWatchSidebarContent):
+        * inspector/front-end/InjectedScript.js:
+        (injectedScriptConstructor.):
+        * inspector/front-end/RemoteObject.js: Added a wrapper for local JSON object to simulate RemoteObject interface.
+        (WebInspector.RemoteObject.fromLocalObject):
+        (WebInspector.LocalJSONObject):
+        (WebInspector.LocalJSONObject.prototype.get description):
+        (WebInspector.LocalJSONObject.prototype.get type):
+        (WebInspector.LocalJSONObject.prototype.get hasChildren):
+        (WebInspector.LocalJSONObject.prototype.getOwnProperties):
+        (WebInspector.LocalJSONObject.prototype.getProperties):
+        (WebInspector.LocalJSONObject.prototype.isError):
+
 2010-11-02  Ryuan Choi  <ryuan.choi at samsung.com>
 
         Unreviewed build fix for EFL build with libcurl
diff --git a/WebCore/inspector/front-end/ExtensionAPI.js b/WebCore/inspector/front-end/ExtensionAPI.js
index 5d090b0..7d6d76c 100644
--- a/WebCore/inspector/front-end/ExtensionAPI.js
+++ b/WebCore/inspector/front-end/ExtensionAPI.js
@@ -197,6 +197,19 @@ PanelImpl.prototype = {
                 callback(new ExtensionSidebarPane(id));
         }
         extensionServer.sendRequest({ command: "createSidebarPane", panel: this._id, id: id, title: title, url: expandURL(url) }, callback && callbackWrapper);
+    },
+
+    createWatchExpressionSidebarPane: function(title, callback)
+    {
+        var id = "watch-sidebar-" + extensionServer.nextObjectId();
+        function callbackWrapper(result)
+        {
+            if (result.isError)
+                callback(result);
+            else
+                callback(new WatchExpressionSidebarPane(id));
+        }
+        extensionServer.sendRequest({ command: "createWatchExpressionSidebarPane", panel: this._id, id: id, title: title }, callback && callbackWrapper);
     }
 }
 
@@ -204,6 +217,7 @@ function Panel(id)
 {
     var impl = new PanelImpl(id);
     this.createSidebarPane = bind(impl.createSidebarPane, impl);
+    this.createWatchExpressionSidebarPane = bind(impl.createWatchExpressionSidebarPane, impl);
     this.onSelectionChanged = new EventSink("panel-objectSelected-" + id);
 }
 
@@ -235,13 +249,40 @@ ExtensionSidebarPaneImpl.prototype = {
     }
 }
 
-function ExtensionSidebarPane(id)
+function ExtensionSidebarPane(id, impl)
 {
-    var impl = new ExtensionSidebarPaneImpl(id);
+    if (!impl)
+        impl = new ExtensionSidebarPaneImpl(id);
     this.setHeight = bind(impl.setHeight, impl);
     this.setExpanded = bind(impl.setExpanded, impl);
 }
 
+function WatchExpressionSidebarPaneImpl(id)
+{
+    ExtensionSidebarPaneImpl.call(this, id);
+}
+
+WatchExpressionSidebarPaneImpl.prototype = {
+    setExpression: function(expression, rootTitle)
+    {
+        extensionServer.sendRequest({ command: "setWatchSidebarContent", id: this._id, expression: expression, rootTitle: rootTitle, evaluateOnPage: true });
+    },
+
+    setObject: function(jsonObject, rootTitle)
+    {
+        extensionServer.sendRequest({ command: "setWatchSidebarContent", id: this._id, expression: jsonObject, rootTitle: rootTitle });
+    }
+}
+
+function WatchExpressionSidebarPane(id)
+{
+    var impl = new WatchExpressionSidebarPaneImpl(id);
+    ExtensionSidebarPane.call(this, id, impl);
+    this.setExpression = bind(impl.setExpression, impl);
+    this.setObject = bind(impl.setObject, impl);
+    this.onUpdated = new EventSink("watch-sidebar-updated-" + id);
+}
+
 function Audits()
 {
 }
diff --git a/WebCore/inspector/front-end/ExtensionPanel.js b/WebCore/inspector/front-end/ExtensionPanel.js
index ba5fa8e..4b42e68 100644
--- a/WebCore/inspector/front-end/ExtensionPanel.js
+++ b/WebCore/inspector/front-end/ExtensionPanel.js
@@ -80,3 +80,39 @@ WebInspector.ExtensionPanel.prototype = {
 }
 
 WebInspector.ExtensionPanel.prototype.__proto__ = WebInspector.Panel.prototype;
+
+WebInspector.ExtensionWatchSidebarPane = function(title, id)
+{
+    WebInspector.SidebarPane.call(this, title);
+    this._id = id;
+}
+
+WebInspector.ExtensionWatchSidebarPane.prototype = {
+    setObject: function(object, title)
+    {
+        this._setObject(WebInspector.RemoteObject.fromLocalObject(object), title);
+    },
+
+    setExpression: function(expression, title)
+    {
+        InjectedScriptAccess.getDefault().evaluate(expression, this._onEvaluate.bind(this, title));
+    },
+
+    _onEvaluate: function(title, result)
+    {
+        this._setObject(WebInspector.RemoteObject.fromPayload(result), title);
+    },
+
+    _setObject: function(object, title)
+    {
+        this.bodyElement.removeChildren();
+        var section = new WebInspector.ObjectPropertiesSection(object, title, null, true);
+        if (!title)
+            section.headerElement.addStyleClass("hidden");
+        section.expanded = true;
+        this.bodyElement.appendChild(section.element);
+        WebInspector.extensionServer.notifyExtensionWatchSidebarUpdated(this._id);
+    }
+}
+
+WebInspector.ExtensionWatchSidebarPane.prototype.__proto__ = WebInspector.SidebarPane.prototype;
diff --git a/WebCore/inspector/front-end/ExtensionServer.js b/WebCore/inspector/front-end/ExtensionServer.js
index 3ee8acc..729ab81 100644
--- a/WebCore/inspector/front-end/ExtensionServer.js
+++ b/WebCore/inspector/front-end/ExtensionServer.js
@@ -42,10 +42,12 @@ WebInspector.ExtensionServer = function()
     this._registerHandler("getPageTimings", this._onGetPageTimings.bind(this));
     this._registerHandler("createPanel", this._onCreatePanel.bind(this));
     this._registerHandler("createSidebarPane", this._onCreateSidebar.bind(this));
+    this._registerHandler("createWatchExpressionSidebarPane", this._onCreateWatchExpressionSidebarPane.bind(this));
     this._registerHandler("log", this._onLog.bind(this));
     this._registerHandler("evaluateOnInspectedPage", this._onEvaluateOnInspectedPage.bind(this));
     this._registerHandler("setSidebarHeight", this._onSetSidebarHeight.bind(this));
     this._registerHandler("setSidebarExpanded", this._onSetSidebarExpansion.bind(this));
+    this._registerHandler("setWatchSidebarContent", this._onSetWatchSidebarContent.bind(this));
 
     this._registerHandler("addAuditCategory", this._onAddAuditCategory.bind(this));
     this._registerHandler("addAuditResult", this._onAddAuditResult.bind(this));
@@ -90,6 +92,11 @@ WebInspector.ExtensionServer.prototype = {
         this._postNotification("reset");
     },
 
+    notifyExtensionWatchSidebarUpdated: function(id)
+    {
+        this._postNotification("watch-sidebar-updated-" + id);
+    },
+
     startAuditRun: function(category, auditRun)
     {
         this._clientObjects[auditRun.id] = auditRun;
@@ -161,7 +168,22 @@ WebInspector.ExtensionServer.prototype = {
         return this._status.OK();
     },
 
-    _onCreateSidebar: function(message, port)
+    _onCreateSidebar: function(message)
+    {
+        var sidebar = this._createSidebar(message, WebInspector.SidebarPane);
+        if (sidebar.isError)
+            return sidebar;
+        this._createClientIframe(sidebar.bodyElement, message.url);
+        return this._status.OK();
+    },
+
+    _onCreateWatchExpressionSidebarPane: function(message)
+    {
+        var sidebar = this._createSidebar(message, WebInspector.ExtensionWatchSidebarPane);
+        return sidebar.isError ? sidebar : this._status.OK();
+    },
+
+    _createSidebar: function(message, constructor)
     {
         var panel = WebInspector.panels[message.panel];
         if (!panel)
@@ -169,12 +191,12 @@ WebInspector.ExtensionServer.prototype = {
         if (!panel.sidebarElement || !panel.sidebarPanes)
             return this._status.E_NOTSUPPORTED();
         var id = message.id;
-        var sidebar = new WebInspector.SidebarPane(message.title);
+        var sidebar = new constructor(message.title, message.id);
         this._clientObjects[id] = sidebar;
         panel.sidebarPanes[id] = sidebar;
         panel.sidebarElement.appendChild(sidebar.element);
-        this._createClientIframe(sidebar.bodyElement, message.url);
-        return this._status.OK();
+
+        return sidebar;
     },
 
     _createClientIframe: function(parent, url, requestId, port)
@@ -205,6 +227,17 @@ WebInspector.ExtensionServer.prototype = {
             sidebar.collapse();
     },
 
+    _onSetWatchSidebarContent: function(message)
+    {
+        var sidebar = this._clientObjects[message.id];
+        if (!sidebar)
+            return this._status.E_NOTFOUND(message.id);
+        if (message.evaluateOnPage)
+            sidebar.setExpression(message.expression, message.rootTitle);
+        else
+            sidebar.setObject(message.expression, message.rootTitle);
+    },
+
     _onLog: function(message)
     {
         WebInspector.log(message.message);
diff --git a/WebCore/inspector/front-end/InjectedScript.js b/WebCore/inspector/front-end/InjectedScript.js
index 2d60f69..fff6680 100644
--- a/WebCore/inspector/front-end/InjectedScript.js
+++ b/WebCore/inspector/front-end/InjectedScript.js
@@ -52,7 +52,6 @@ InjectedScript.prototype = {
             var objectId;
             if (typeof object === "object" || typeof object === "function" || this._isHTMLAllCollection(object)) {
                 var id = this._lastBoundObjectId++;
-                objectId = id;
                 this._idToWrappedObject[id] = object;
     
                 var group = this._objectGroups[objectGroupName];
diff --git a/WebCore/inspector/front-end/RemoteObject.js b/WebCore/inspector/front-end/RemoteObject.js
index 003d483..4d6736c 100644
--- a/WebCore/inspector/front-end/RemoteObject.js
+++ b/WebCore/inspector/front-end/RemoteObject.js
@@ -41,6 +41,11 @@ WebInspector.RemoteObject.fromPrimitiveValue = function(value)
     return new WebInspector.RemoteObject(null, typeof value, value);
 }
 
+WebInspector.RemoteObject.fromLocalObject = function(value)
+{
+    return new WebInspector.LocalJSONObject(value);
+}
+
 WebInspector.RemoteObject.resolveNode = function(node, callback)
 {
     function mycallback(object)
@@ -136,3 +141,62 @@ WebInspector.RemoteObjectProperty = function(name, value)
     this.name = name;
     this.value = value;
 }
+
+// The below is a wrapper around a local object that provides an interface comaptible
+// with RemoteObject, to be used by the UI code (primarily ObjectPropertiesSection).
+// Note that only JSON-compliant objects are currently supported, as there's no provision
+// for traversing prototypes, extracting class names via constuctor, handling properties
+// or functions.
+
+WebInspector.LocalJSONObject = function(value)
+{
+    this._value = value;
+}
+
+WebInspector.LocalJSONObject.prototype = {
+    get description()
+    {
+        var type = this.type;
+        switch (type) {
+            case "array":
+                return "[" + this._value.length + "]";
+            case "object":
+                return this.hasChildren ? "{...}" : "{ }";
+            default:
+                return JSON.stringify(this._value);
+        }
+    },
+
+    get type()
+    {
+        if (this._value === null)
+            return "null";
+        if (this._value instanceof Array)
+            return "array";
+        return typeof this._value;
+    },
+
+    get hasChildren()
+    {
+        return typeof this._value === "object" && this._value !== null && Object.keys(this._value).length;
+    },
+
+    getOwnProperties: function(abbreviate, callback)
+    {
+        return this.getProperties(false, abbreviate, callback);
+    },
+
+    getProperties: function(ignoreHasOwnProperty, abbreviate, callback)
+    {
+        function buildProperty(propName)
+        {
+            return new WebInspector.RemoteObjectProperty(propName, new WebInspector.LocalJSONObject(this._value[propName]));
+        }
+        callback(Object.keys(this._value).map(buildProperty.bind(this)));
+    },
+
+    isError: function()
+    {
+        return false;
+    }
+}

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list