Diff
Modified: trunk/LayoutTests/ChangeLog (100432 => 100433)
--- trunk/LayoutTests/ChangeLog 2011-11-16 12:52:06 UTC (rev 100432)
+++ trunk/LayoutTests/ChangeLog 2011-11-16 12:56:21 UTC (rev 100433)
@@ -1,3 +1,17 @@
+2011-11-15 Andrey Kosyakov <[email protected]>
+
+ Web Inspector: [Extensions API] drop ExtensionSidebarPane.onUpdated, use callbacks instead
+ https://bugs.webkit.org/show_bug.cgi?id=72388
+
+ Reviewed by Pavel Feldman.
+
+ - split LayoutTests/inspector/extensions.html into extensions-panel.html & extensions-sidebar.html.
+
+ * inspector/extensions/extensions-panel-expected.txt: Added.
+ * inspector/extensions/extensions-panel.html: Added.
+ * inspector/extensions/extensions-sidebar-expected.txt: Renamed from LayoutTests/inspector/extensions/extensions-expected.txt.
+ * inspector/extensions/extensions-sidebar.html: Renamed from LayoutTests/inspector/extensions/extensions.html.
+
2011-11-16 Gabor Rapcsanyi <[email protected]>
[Qt] Update Qt specific expected results.
Deleted: trunk/LayoutTests/inspector/extensions/extensions-expected.txt (100432 => 100433)
--- trunk/LayoutTests/inspector/extensions/extensions-expected.txt 2011-11-16 12:52:06 UTC (rev 100432)
+++ trunk/LayoutTests/inspector/extensions/extensions-expected.txt 2011-11-16 12:56:21 UTC (rev 100433)
@@ -1,68 +0,0 @@
-Tests WebInspector extension API
-
-Started extension.
-Running tests...
-RUNNING TEST: extension_testCreatePanel
-Panel created
-{
- onShown : {
- addListener : <function>
- removeListener : <function>
- }
- onHidden : {
- addListener : <function>
- removeListener : <function>
- }
- onSearch : {
- addListener : <function>
- removeListener : <function>
- }
-}
-Extension panel size correct
-RUNNING TEST: extension_testSidebarPage
-Sidebar created
-{
- onShown : {
- addListener : <function>
- removeListener : <function>
- }
- onHidden : {
- addListener : <function>
- removeListener : <function>
- }
- onUpdated : {
- addListener : <function>
- removeListener : <function>
- }
- setHeight : <function>
- setExpression : <function>
- setObject : <function>
- setPage : <function>
-}
-RUNNING TEST: extension_testSidebarWatchExpression
-Sidebar content: titlef0: "_expression_"f1: undefinedf2: nullf3: Objectf4: Array[0]f5: Array[3]f6: Objectf7: 42f8: Locationf9: HTMLCollection[2]f10: function () {}f11: "foo"__proto__: Object
-RUNNING TEST: extension_testSidebarWatchObject
-Watch sidebar created, callback arguments dump follows:
-{
- 0 : {
- onShown : {
- addListener : <function>
- removeListener : <function>
- }
- onHidden : {
- addListener : <function>
- removeListener : <function>
- }
- onUpdated : {
- addListener : <function>
- removeListener : <function>
- }
- setHeight : <function>
- setExpression : <function>
- setObject : <function>
- setPage : <function>
- }
-}
-Sidebar content: f0: "object"f1: undefinedf2: nullf3: {}f4: []f5: [aa, bb, cc]f6: {f60:42, f61:foo, f62:[]}f7: 42
-All tests done.
-
Added: trunk/LayoutTests/inspector/extensions/extensions-panel-expected.txt (0 => 100433)
--- trunk/LayoutTests/inspector/extensions/extensions-panel-expected.txt (rev 0)
+++ trunk/LayoutTests/inspector/extensions/extensions-panel-expected.txt 2011-11-16 12:56:21 UTC (rev 100433)
@@ -0,0 +1,23 @@
+Tests WebInspector extension API
+
+Started extension.
+Running tests...
+RUNNING TEST: extension_testCreatePanel
+Panel created
+{
+ onShown : {
+ addListener : <function>
+ removeListener : <function>
+ }
+ onHidden : {
+ addListener : <function>
+ removeListener : <function>
+ }
+ onSearch : {
+ addListener : <function>
+ removeListener : <function>
+ }
+}
+Extension panel size correct
+All tests done.
+
Property changes on: trunk/LayoutTests/inspector/extensions/extensions-panel-expected.txt
___________________________________________________________________
Added: svn:eol-style
Added: trunk/LayoutTests/inspector/extensions/extensions-panel.html (0 => 100433)
--- trunk/LayoutTests/inspector/extensions/extensions-panel.html (rev 0)
+++ trunk/LayoutTests/inspector/extensions/extensions-panel.html 2011-11-16 12:56:21 UTC (rev 100433)
@@ -0,0 +1,56 @@
+<html>
+<head>
+<script src=""
+<script src=""
+<script type="text/_javascript_">
+
+function initialize_extensionsPanelTest()
+{
+ InspectorTest.panelCallback = function(width, height)
+ {
+ InspectorTest.checkPanelSize(width, height);
+ var callback = InspectorTest._pendingPanelSizeTestCallback;
+ if (callback) {
+ delete InspectorTest._pendingPanelSizeTestCallback;
+ callback();
+ }
+ }
+
+ InspectorTest.waitForPanel = function(callback)
+ {
+ InspectorTest._pendingPanelSizeTestCallback = callback;
+ }
+
+ InspectorTest.checkPanelSize = function(width, height)
+ {
+ var extensionPanel = WebInspector.inspectorView._panelOrder[WebInspector.inspectorView._panelOrder.length - 1];
+ var boundingRect = document.getElementById("main-panels").getBoundingClientRect();
+ InspectorTest.assertEquals(boundingRect.width, width, "panel width mismatch");
+ InspectorTest.assertEquals(boundingRect.height, height, "panel height mismatch");
+ InspectorTest.addResult("Extension panel size correct");
+ }
+}
+
+function extension_testCreatePanel(nextTest)
+{
+ var callbackCount = 0;
+
+ function onPanelCreated(panel)
+ {
+ output("Panel created");
+ dumpObject(panel);
+ // This will force extension iframe to be really loaded and will cause waitForPanel() callback below.
+ extension_showPanel("extension");
+ }
+ // The panel code is expected to report its size via InspectorTest.panelCallback()
+ evaluateOnFrontend("InspectorTest.waitForPanel(reply);", nextTest);
+ var basePath = location.pathname.replace(/\/[^/]*$/, "/");
+ webInspector.panels.create("Test Panel", basePath + "extension-panel.png", basePath + "extension-panel.html", onPanelCreated);
+}
+
+</script>
+</head>
+<body _onload_="runTest()">
+<p>Tests WebInspector extension API</p>
+</body>
+</html>
Property changes on: trunk/LayoutTests/inspector/extensions/extensions-panel.html
___________________________________________________________________
Added: svn:eol-style
Copied: trunk/LayoutTests/inspector/extensions/extensions-sidebar-expected.txt (from rev 100432, trunk/LayoutTests/inspector/extensions/extensions-expected.txt) (0 => 100433)
--- trunk/LayoutTests/inspector/extensions/extensions-sidebar-expected.txt (rev 0)
+++ trunk/LayoutTests/inspector/extensions/extensions-sidebar-expected.txt 2011-11-16 12:56:21 UTC (rev 100433)
@@ -0,0 +1,46 @@
+Tests sidebars in WebInspector extensions API
+
+Started extension.
+Running tests...
+RUNNING TEST: extension_testSidebarPageReplacedWithObject
+Got onShown(), frame defined
+Got onShown(), frame not defined
+RUNNING TEST: extension_testSidebarSetExpression
+Sidebar content: titlef0: "_expression_"f1: undefinedf2: nullf3: Objectf4: Array[0]f5: Array[3]f6: Objectf7: 42f8: Locationf9: HTMLCollection[2]f10: function () {}f11: "foo"__proto__: Object
+RUNNING TEST: extension_testSidebarSetObject
+Watch sidebar created, callback arguments dump follows:
+{
+ 0 : {
+ onShown : {
+ addListener : <function>
+ removeListener : <function>
+ }
+ onHidden : {
+ addListener : <function>
+ removeListener : <function>
+ }
+ setHeight : <function>
+ setExpression : <function>
+ setObject : <function>
+ setPage : <function>
+ }
+}
+Sidebar content: f0: "object"f1: undefinedf2: nullf3: {}f4: []f5: [aa, bb, cc]f6: {f60:42, f61:foo, f62:[]}f7: 42
+RUNNING TEST: extension_testSidebarSetPage
+Sidebar created
+{
+ onShown : {
+ addListener : <function>
+ removeListener : <function>
+ }
+ onHidden : {
+ addListener : <function>
+ removeListener : <function>
+ }
+ setHeight : <function>
+ setExpression : <function>
+ setObject : <function>
+ setPage : <function>
+}
+All tests done.
+
Property changes: trunk/LayoutTests/inspector/extensions/extensions-sidebar-expected.txt
Added: svn:eol-style
Copied: trunk/LayoutTests/inspector/extensions/extensions-sidebar.html (from rev 100432, trunk/LayoutTests/inspector/extensions/extensions.html) (0 => 100433)
--- trunk/LayoutTests/inspector/extensions/extensions-sidebar.html (rev 0)
+++ trunk/LayoutTests/inspector/extensions/extensions-sidebar.html 2011-11-16 12:56:21 UTC (rev 100433)
@@ -0,0 +1,130 @@
+<html>
+<head>
+<script src=""
+<script src=""
+<script type="text/_javascript_">
+
+function initialize_extensionsSidebarTest()
+{
+ InspectorTest.dumpSidebarContent = function(callback)
+ {
+ var sidebarPanes = WebInspector.panels.elements.sidebarPanes;
+ // the sidebar of interest is presumed to always be last.
+ var sidebar = sidebarPanes[Object.keys(sidebarPanes).pop()];
+ InspectorTest.runAfterPendingDispatches(function() {
+ InspectorTest.addResult("Sidebar content: " + sidebar.bodyElement.textContent);
+ callback();
+ });
+ }
+}
+
+function extension_testSidebarSetPage(nextTest)
+{
+ function onSidebarCreated(sidebar)
+ {
+ output("Sidebar created");
+ dumpObject(sidebar);
+ function onShown()
+ {
+ sidebar.onShown.removeListener(onShown);
+ nextTest();
+ }
+ sidebar.onShown.addListener(onShown);
+ var basePath = location.pathname.replace(/\/[^/]*$/, "/");
+ sidebar.setPage(basePath + "extension-sidebar.html");
+ extension_showPanel("elements");
+ }
+ webInspector.panels.elements.createSidebarPane("Test Sidebar", onSidebarCreated);
+}
+
+function extension_dumpSidebarContent(nextTest)
+{
+ evaluateOnFrontend("InspectorTest.dumpSidebarContent(reply);", nextTest);
+}
+
+function extension_testSidebarSetObject(nextTest)
+{
+ function onSidebarCreated(sidebar)
+ {
+ output("Watch sidebar created, callback arguments dump follows:");
+ dumpObject(Array.prototype.slice.call(arguments));
+ sidebar.setObject({
+ f0: "object",
+ f1: undefined,
+ f2: null,
+ f3: {},
+ f4: [],
+ f5: ["aa", "bb", "cc"],
+ f6: { f60: 42, f61: "foo", f62: [] },
+ f7: 42
+ }, null, extension_dumpSidebarContent.bind(this, nextTest));
+ }
+ webInspector.panels.elements.createSidebarPane("Watch Test: Object", onSidebarCreated);
+}
+
+function extension_testSidebarSetExpression(nextTest)
+{
+ function onSidebarCreated(sidebar)
+ {
+ function _expression_()
+ {
+ document.body.testProperty = 'foo';
+ 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() {},
+ f11: $0.testProperty
+ };
+ }
+ // Do an extra round-trip to the inspected page to assure inspect()'s round-trip to
+ // front-end is complete and $0 is properly updated with currently inspected node.
+ webInspector.inspectedWindow.eval("", function() {
+ sidebar.setExpression("(" + _expression_.toString() + ")();", "title", extension_dumpSidebarContent.bind(this, nextTest));
+ });
+ }
+ webInspector.inspectedWindow.eval("inspect(document.body)", function() {
+ webInspector.panels.elements.createSidebarPane("Watch Test: _expression_", onSidebarCreated);
+ });
+}
+
+function extension_testSidebarPageReplacedWithObject(nextTest)
+{
+ var basePath = location.pathname.replace(/\/[^/]*$/, "/");
+ var sidebar;
+
+ function onSidebarCreated(aSidebar)
+ {
+ sidebar = aSidebar;
+ sidebar.onShown.addListener(onShown);
+ sidebar.setPage(basePath + "extension-sidebar.html");
+ extension_showPanel("elements");
+ }
+ var didSetObject = false;
+ function onShown(frame)
+ {
+ output("Got onShown(), frame " + (frame ? "defined" : "not defined"));
+ if (!didSetObject) {
+ didSetObject = true;
+ sidebar.setObject({ foo: 'bar' });
+ } else {
+ sidebar.onShown.removeListener(onShown);
+ nextTest();
+ }
+ }
+ webInspector.panels.elements.createSidebarPane("Sidebar Test: replace page with object", onSidebarCreated);
+}
+
+</script>
+</head>
+<body _onload_="runTest()">
+<p>Tests sidebars in WebInspector extensions API</p>
+</body>
+</html>
Property changes: trunk/LayoutTests/inspector/extensions/extensions-sidebar.html
Added: svn:eol-style
Deleted: trunk/LayoutTests/inspector/extensions/extensions.html (100432 => 100433)
--- trunk/LayoutTests/inspector/extensions/extensions.html 2011-11-16 12:52:06 UTC (rev 100432)
+++ trunk/LayoutTests/inspector/extensions/extensions.html 2011-11-16 12:56:21 UTC (rev 100433)
@@ -1,140 +0,0 @@
-<html>
-<head>
-<script src=""
-<script src=""
-<script type="text/_javascript_">
-
-function initialize_extensionsUITest()
-{
- InspectorTest.dumpSidebarContent = function(callback)
- {
- var sidebarPanes = WebInspector.panels.elements.sidebarPanes;
- // the sidebar of interest is presumed to always be last.
- var sidebar = sidebarPanes[Object.keys(sidebarPanes).pop()];
- InspectorTest.runAfterPendingDispatches(function() {
- InspectorTest.addResult("Sidebar content: " + sidebar.bodyElement.textContent);
- callback();
- });
- }
-
- InspectorTest.panelCallback = function(width, height)
- {
- InspectorTest.checkPanelSize(width, height);
- var callback = InspectorTest._pendingPanelSizeTestCallback;
- if (callback) {
- delete InspectorTest._pendingPanelSizeTestCallback;
- callback();
- }
- }
-
- InspectorTest.waitForPanel = function(callback)
- {
- InspectorTest._pendingPanelSizeTestCallback = callback;
- }
-
- InspectorTest.checkPanelSize = function(width, height)
- {
- var extensionPanel = WebInspector.inspectorView._panelOrder[WebInspector.inspectorView._panelOrder.length - 1];
- var boundingRect = document.getElementById("main-panels").getBoundingClientRect();
- InspectorTest.assertEquals(boundingRect.width, width, "panel width mismatch");
- InspectorTest.assertEquals(boundingRect.height, height, "panel height mismatch");
- InspectorTest.addResult("Extension panel size correct");
- }
-}
-
-function extension_testCreatePanel(nextTest)
-{
- var callbackCount = 0;
-
- function onPanelCreated(panel)
- {
- output("Panel created");
- dumpObject(panel);
- // This will force extension iframe to be really loaded and will cause waitForPanel() callback below.
- extension_showPanel("extension");
- }
- // The panel code is expected to report its size via InspectorTest.panelCallback()
- evaluateOnFrontend("InspectorTest.waitForPanel(reply);", nextTest);
- var basePath = location.pathname.replace(/\/[^/]*$/, "/");
- webInspector.panels.create("Test Panel", basePath + "extension-panel.png", basePath + "extension-panel.html", onPanelCreated);
-}
-
-function extension_testSidebarPage(nextTest)
-{
- function onSidebarCreated(sidebar)
- {
- output("Sidebar created");
- dumpObject(sidebar);
- sidebar.onUpdated.addListener(nextTest);
- var basePath = location.pathname.replace(/\/[^/]*$/, "/");
- sidebar.setPage(basePath + "extension-sidebar.html");
- }
- webInspector.panels.elements.createSidebarPane("Test Sidebar", onSidebarCreated);
-}
-
-function extension_dumpSidebarContent(nextTest)
-{
- evaluateOnFrontend("InspectorTest.dumpSidebarContent(reply);", nextTest);
-}
-
-function extension_testSidebarWatchObject(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.elements.createSidebarPane("Watch Test: Object", onSidebarCreated);
-}
-
-function extension_testSidebarWatchExpression(nextTest)
-{
- function onSidebarCreated(sidebar)
- {
- sidebar.onUpdated.addListener(bind(extension_dumpSidebarContent, this, nextTest));
- function _expression_()
- {
- document.body.testProperty = 'foo';
- 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() {},
- f11: $0.testProperty
- };
- }
- // Do an extra round-trip to the inspected page to assure inspect()'s round-trip to
- // front-end is complete and $0 is properly updated with currently inspected node.
- webInspector.inspectedWindow.eval("", function() {
- sidebar.setExpression("(" + _expression_.toString() + ")();", "title");
- });
- }
- webInspector.inspectedWindow.eval("inspect(document.body)", function() {
- webInspector.panels.elements.createSidebarPane("Watch Test: _expression_", onSidebarCreated);
- });
-}
-
-</script>
-</head>
-<body _onload_="runTest()">
-<p>Tests WebInspector extension API</p>
-</body>
-</html>
Modified: trunk/Source/WebCore/ChangeLog (100432 => 100433)
--- trunk/Source/WebCore/ChangeLog 2011-11-16 12:52:06 UTC (rev 100432)
+++ trunk/Source/WebCore/ChangeLog 2011-11-16 12:56:21 UTC (rev 100433)
@@ -1,3 +1,38 @@
+2011-11-15 Andrey Kosyakov <[email protected]>
+
+ Web Inspector: [Extensions API] drop ExtensionSidebarPane.onUpdated, use callbacks instead
+ https://bugs.webkit.org/show_bug.cgi?id=72388
+
+ Reviewed by Pavel Feldman.
+
+ Tests: inspector/extensions/extensions-panel.html
+ inspector/extensions/extensions-sidebar.html
+
+ - fire ExtensionSidebarPane.on{Hidden,Shown} for non-iframe content (experssions/objects);
+ - drop ExtensionsSidebarPane.onUpdated, provide callback for setObject()/setExpression() instead;
+ - fix an exception when a page is replaced with object/_expression_.
+
+ inspector/front-end/ExtensionAPI.js:
+ (injectedExtensionAPI.ExtensionSidebarPaneImpl):
+ (injectedExtensionAPI.ExtensionSidebarPaneImpl.prototype.setExpression):
+ (injectedExtensionAPI.ExtensionSidebarPaneImpl.prototype.setObject):
+ * inspector/front-end/ExtensionPanel.js:
+ (WebInspector.ExtensionNotifierView):
+ (WebInspector.ExtensionNotifierView.prototype.wasShown):
+ (WebInspector.ExtensionNotifierView.prototype.willHide):
+ (WebInspector.ExtensionSidebarPane.prototype.setObject):
+ (WebInspector.ExtensionSidebarPane.prototype.setExpression):
+ (WebInspector.ExtensionSidebarPane.prototype.setPage):
+ (WebInspector.ExtensionSidebarPane.prototype._onEvaluate):
+ (WebInspector.ExtensionSidebarPane.prototype._makeObjectPropertiesView):
+ (WebInspector.ExtensionSidebarPane.prototype._setObject):
+ * inspector/front-end/ExtensionServer.js:
+ (WebInspector.ExtensionServer.prototype._onSetSidebarContent.callback):
+ (WebInspector.ExtensionServer.prototype._onSetSidebarContent):
+ (WebInspector.ExtensionServer.prototype._dispatchCallback):
+ * inspector/front-end/View.js:
+ (WebInspector.View.prototype.detach):
+
2011-11-16 Simon Hausmann <[email protected]>
Unreviewed, rolling out r100266.
Modified: trunk/Source/WebCore/inspector/front-end/ExtensionAPI.js (100432 => 100433)
--- trunk/Source/WebCore/inspector/front-end/ExtensionAPI.js 2011-11-16 12:52:06 UTC (rev 100432)
+++ trunk/Source/WebCore/inspector/front-end/ExtensionAPI.js 2011-11-16 12:56:21 UTC (rev 100433)
@@ -345,7 +345,6 @@
function ExtensionSidebarPaneImpl(id)
{
ExtensionViewImpl.call(this, id);
- this._onUpdated_ = new EventSink("sidebar-updated-" + id);
}
ExtensionSidebarPaneImpl.prototype = {
@@ -354,14 +353,14 @@
extensionServer.sendRequest({ command: "setSidebarHeight", id: this._id, height: height });
},
- setExpression: function(_expression_, rootTitle)
+ setExpression: function(_expression_, rootTitle, callback)
{
- extensionServer.sendRequest({ command: "setSidebarContent", id: this._id, _expression_: _expression_, rootTitle: rootTitle, evaluateOnPage: true });
+ extensionServer.sendRequest({ command: "setSidebarContent", id: this._id, _expression_: _expression_, rootTitle: rootTitle, evaluateOnPage: true }, callback);
},
- setObject: function(jsonObject, rootTitle)
+ setObject: function(jsonObject, rootTitle, callback)
{
- extensionServer.sendRequest({ command: "setSidebarContent", id: this._id, _expression_: jsonObject, rootTitle: rootTitle });
+ extensionServer.sendRequest({ command: "setSidebarContent", id: this._id, _expression_: jsonObject, rootTitle: rootTitle }, callback);
},
setPage: function(page)
Modified: trunk/Source/WebCore/inspector/front-end/ExtensionPanel.js (100432 => 100433)
--- trunk/Source/WebCore/inspector/front-end/ExtensionPanel.js 2011-11-16 12:52:06 UTC (rev 100432)
+++ trunk/Source/WebCore/inspector/front-end/ExtensionPanel.js 2011-11-16 12:56:21 UTC (rev 100433)
@@ -31,16 +31,14 @@
/**
* @constructor
* @extends {WebInspector.View}
- * @param {number} id
+ * @param {string} id
* @param {Element} parent
* @param {string} src
* @param {string} className
*/
-
WebInspector.ExtensionView = function(id, parent, src, className)
{
WebInspector.View.call(this);
- this.element.className = "fill";
this._id = id;
this._iframe = document.createElement("iframe");
@@ -77,6 +75,32 @@
/**
* @constructor
+ * @extends {WebInspector.View}
+ * @param {string} id
+ */
+WebInspector.ExtensionNotifierView = function(id)
+{
+ WebInspector.View.call(this);
+
+ this._id = id;
+}
+
+WebInspector.ExtensionNotifierView.prototype = {
+ wasShown: function()
+ {
+ WebInspector.extensionServer.notifyViewShown(this._id);
+ },
+
+ willHide: function()
+ {
+ WebInspector.extensionServer.notifyViewHidden(this._id);
+ }
+}
+
+WebInspector.ExtensionNotifierView.prototype.__proto__ = WebInspector.View.prototype;
+
+/**
+ * @constructor
* @extends {WebInspector.Panel}
* @param {string} id
* @param {string} label
@@ -152,40 +176,98 @@
}
WebInspector.ExtensionSidebarPane.prototype = {
- setObject: function(object, title)
+ /**
+ * @param {Object} object
+ * @param {string} title
+ * @param {function(?string=)} callback
+ */
+ setObject: function(object, title, callback)
{
- this._setObject(WebInspector.RemoteObject.fromLocalObject(object), title);
+ this._createObjectPropertiesView();
+ this._setObject(WebInspector.RemoteObject.fromLocalObject(object), title, callback);
},
- setExpression: function(_expression_, title)
+ /**
+ * @param {string} _expression_
+ * @param {string} title
+ * @param {function(?string=)} callback
+ */
+ setExpression: function(_expression_, title, callback)
{
- RuntimeAgent.evaluate(_expression_, "extension-watch", true, undefined, undefined, undefined, this._onEvaluate.bind(this, title));
+ this._createObjectPropertiesView();
+ RuntimeAgent.evaluate(_expression_, "extension-watch", true, undefined, undefined, undefined, this._onEvaluate.bind(this, title, callback));
},
+ /**
+ * @param {string} url
+ */
setPage: function(url)
{
- this.bodyElement.removeChildren();
- var view = new WebInspector.ExtensionView(this._id, this.bodyElement, url, "extension");
- // TODO: Consider doing this upon load event.
- WebInspector.extensionServer.notifyExtensionSidebarUpdated(this._id);
+ if (this._objectPropertiesView) {
+ this._objectPropertiesView.detach();
+ delete this._objectPropertiesView;
+ }
+ if (this._extensionView)
+ this._extensionView.detach(true);
+
+ this._extensionView = new WebInspector.ExtensionView(this._id, this.bodyElement, url, "extension");
},
- _onEvaluate: function(title, error, result, wasThrown)
+ /**
+ * @param {string} height
+ */
+ setHeight: function(height)
{
- if (!error)
- this._setObject(WebInspector.RemoteObject.fromPayload(result), title);
+ this.bodyElement.style.height = height;
},
- _setObject: function(object, title)
+ /**
+ * @param {string} title
+ * @param {function(?string=)} callback
+ * @param {Protocol.Error} error
+ * @param {Object} result
+ * @param {boolean} wasThrown
+ */
+ _onEvaluate: function(title, callback, error, result, wasThrown)
{
- this.bodyElement.removeChildren();
+ if (error)
+ callback(error.toString());
+ else
+ this._setObject(WebInspector.RemoteObject.fromPayload(result), title, callback);
+ },
+
+ _createObjectPropertiesView: function()
+ {
+ if (this._objectPropertiesView)
+ return;
+ if (this._extensionView) {
+ this._extensionView.detach(true);
+ delete this._extensionView;
+ }
+ this._objectPropertiesView = new WebInspector.ExtensionNotifierView(this._id);
+ this._objectPropertiesView.show(this.bodyElement);
+ },
+
+ /**
+ * @param {Object} object
+ * @param {string} title
+ * @param {function(?string=)} callback
+ */
+ _setObject: function(object, title, callback)
+ {
+ // This may only happen if setPage() was called while we were evaluating the _expression_.
+ if (!this._objectPropertiesView) {
+ callback("operation cancelled");
+ return;
+ }
+ this._objectPropertiesView.element.removeChildren();
var section = new WebInspector.ObjectPropertiesSection(object, title);
if (!title)
section.headerElement.addStyleClass("hidden");
section.expanded = true;
section.editable = false;
- this.bodyElement.appendChild(section.element);
- WebInspector.extensionServer.notifyExtensionSidebarUpdated(this._id);
+ this._objectPropertiesView.element.appendChild(section.element);
+ callback();
}
}
Modified: trunk/Source/WebCore/inspector/front-end/ExtensionServer.js (100432 => 100433)
--- trunk/Source/WebCore/inspector/front-end/ExtensionServer.js 2011-11-16 12:52:06 UTC (rev 100432)
+++ trunk/Source/WebCore/inspector/front-end/ExtensionServer.js 2011-11-16 12:56:21 UTC (rev 100433)
@@ -103,11 +103,6 @@
this._postNotification("reset");
},
- notifyExtensionSidebarUpdated: function(id)
- {
- this._postNotification("sidebar-updated-" + id);
- },
-
startAuditRun: function(category, auditRun)
{
this._clientObjects[auditRun.id] = auditRun;
@@ -226,18 +221,24 @@
var sidebar = this._clientObjects[message.id];
if (!sidebar)
return this._status.E_NOTFOUND(message.id);
- sidebar.bodyElement.firstChild.style.height = message.height;
+ sidebar.setHeight(message.height);
+ return this._status.OK();
},
- _onSetSidebarContent: function(message)
+ _onSetSidebarContent: function(message, port)
{
var sidebar = this._clientObjects[message.id];
if (!sidebar)
return this._status.E_NOTFOUND(message.id);
+ function callback(error)
+ {
+ var result = error ? this._status.E_FAILED(error) : this._status.OK();
+ this._dispatchCallback(message.requestId, port, result);
+ }
if (message.evaluateOnPage)
- sidebar.setExpression(message._expression_, message.rootTitle);
+ sidebar.setExpression(message._expression_, message.rootTitle, callback.bind(this));
else
- sidebar.setObject(message._expression_, message.rootTitle);
+ sidebar.setObject(message._expression_, message.rootTitle, callback.bind(this));
},
_onSetSidebarPage: function(message, port)
@@ -491,7 +492,8 @@
_dispatchCallback: function(requestId, port, result)
{
- port.postMessage({ command: "callback", requestId: requestId, result: result });
+ if (requestId)
+ port.postMessage({ command: "callback", requestId: requestId, result: result });
},
initExtensions: function()
Modified: trunk/Source/WebCore/inspector/front-end/View.js (100432 => 100433)
--- trunk/Source/WebCore/inspector/front-end/View.js 2011-11-16 12:52:06 UTC (rev 100432)
+++ trunk/Source/WebCore/inspector/front-end/View.js 2011-11-16 12:56:21 UTC (rev 100433)
@@ -167,7 +167,10 @@
this._processWasShown();
},
- detach: function()
+ /**
+ * @param {boolean=} overrideHideOnDetach
+ */
+ detach: function(overrideHideOnDetach)
{
var parentElement = this.element.parentElement;
if (!parentElement)
@@ -176,7 +179,7 @@
if (this._parentIsShowing())
this._processWillHide();
- if (this._hideOnDetach) {
+ if (this._hideOnDetach && !overrideHideOnDetach) {
this.element.removeStyleClass("visible");
this._visible = false;
if (this._parentIsShowing())