Changeset 120311 in webkit


Ignore:
Timestamp:
Jun 14, 2012 3:34:26 AM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Web Inspector: Implement ExtensionPanel.show() method
https://bugs.webkit.org/show_bug.cgi?id=88473

Source/WebCore:

Implemented ExtensionPanel.show() API method to allow extension
developers to show their panel when needed.

Patch by Jan Keromnes <janx@linux.com> on 2012-06-14
Reviewed by Pavel Feldman.

Tests for this method are in:
LayoutTests/inspector/extensions/extensions-panel.html

  • inspector/front-end/ExtensionAPI.js:

(defineCommonExtensionSymbols):
(injectedExtensionAPI.ExtensionPanelImpl.prototype.createStatusBarButton):
(injectedExtensionAPI.ExtensionPanelImpl.prototype.show):

  • inspector/front-end/ExtensionServer.js:

(WebInspector.ExtensionServer):
(WebInspector.ExtensionServer.prototype._onShowPanel):

LayoutTests:

Add output for ExtensionPanel callbacks, and use ExtensionPanel.show()
to show the panel. Fix expected.

Patch by Jan Keromnes <janx@linux.com> on 2012-06-14
Reviewed by Pavel Feldman.

  • inspector/extensions/extensions-panel-expected.txt:
  • inspector/extensions/extensions-panel.html:
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r120308 r120311  
     12012-06-14  Jan Keromnes  <janx@linux.com>
     2
     3        Web Inspector: Implement ExtensionPanel.show() method
     4        https://bugs.webkit.org/show_bug.cgi?id=88473
     5
     6        Add output for ExtensionPanel callbacks, and use ExtensionPanel.show()
     7        to show the panel. Fix expected.
     8
     9        Reviewed by Pavel Feldman.
     10
     11        * inspector/extensions/extensions-panel-expected.txt:
     12        * inspector/extensions/extensions-panel.html:
     13
    1142012-06-14  David Barr  <davidbarr@chromium.org>
    215
  • trunk/LayoutTests/inspector/extensions/extensions-panel-expected.txt

    r100735 r120311  
     1CONSOLE MESSAGE: line 8: hello
    12Tests WebInspector extension API
    23
     
    1920    }
    2021    createStatusBarButton : <function>
     22    show : <function>
    2123}
    2224Extension panel size correct
     25Panel shown
    2326RUNNING TEST: extension_testStatusBarButtons
    2427Created a status bar button, dump follows:
     
    3033    update : <function>
    3134}
     35Panel hidden
    3236button1 clicked
    3337Status bar buttons state:
  • trunk/LayoutTests/inspector/extensions/extensions-panel.html

    r100735 r120311  
    44<script src="../../http/tests/inspector/extensions-test.js"></script>
    55<script type="text/javascript">
     6function logMessage()
     7{
     8    console.log("hello");
     9}
    610
    711function initialize_extensionsPanelTest()
     
    5357        panel.statusBarItems[index].click();
    5458    }
     59
     60    InspectorTest.clickOnURL = function()
     61    {
     62        WebInspector.showPanel("console");
     63        var xpathResult = document.evaluate("//a[starts-with(., 'extensions-panel.html')]",
     64                                            WebInspector.panels.console.element, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null);
     65        var click = document.createEvent("MouseEvent");
     66        click.initMouseEvent("click", true, true);
     67        xpathResult.singleNodeValue.dispatchEvent(click);
     68    }
    5569}
    5670
     
    6377        output("Panel created");
    6478        dumpObject(panel);
    65         // This will force extension iframe to be really loaded and will cause waitForPanel() callback below.
    66         extension_showPanel("extension");
     79        panel.onHidden.addListener(function() {
     80            output("Panel hidden");
     81        });
     82        panel.onShown.addListener(function(window) {
     83            output("Panel shown");
     84        });
     85
     86        // This is not authorized and therefore should not produce any output
     87        panel.show();
     88        extension_showPanel("console");
     89
     90        function handleOpenResource(resource, lineNumber)
     91        {
     92            // This will force extension iframe to be really loaded and will cause waitForPanel() callback below.
     93            panel.show();
     94        }
     95        webInspector.panels.setOpenResourceHandler(handleOpenResource);
     96        evaluateOnFrontend("WebInspector.openAnchorLocationRegistry._activeHandler = 'test extension'");
     97        webInspector.inspectedWindow.eval("logMessage()", function() {
     98            evaluateOnFrontend("InspectorTest.clickOnURL();");
     99        });
    67100    }
    68101    // The panel code is expected to report its size via InspectorTest.panelCallback()
  • trunk/Source/WebCore/ChangeLog

    r120309 r120311  
     12012-06-14  Jan Keromnes  <janx@linux.com>
     2
     3        Web Inspector: Implement ExtensionPanel.show() method
     4        https://bugs.webkit.org/show_bug.cgi?id=88473
     5
     6        Implemented ExtensionPanel.show() API method to allow extension
     7        developers to show their panel when needed.
     8
     9        Reviewed by Pavel Feldman.
     10
     11        Tests for this method are in:
     12        LayoutTests/inspector/extensions/extensions-panel.html
     13
     14        * inspector/front-end/ExtensionAPI.js:
     15        (defineCommonExtensionSymbols):
     16        (injectedExtensionAPI.ExtensionPanelImpl.prototype.createStatusBarButton):
     17        (injectedExtensionAPI.ExtensionPanelImpl.prototype.show):
     18        * inspector/front-end/ExtensionServer.js:
     19        (WebInspector.ExtensionServer):
     20        (WebInspector.ExtensionServer.prototype._onShowPanel):
     21
    1222012-06-14  Kent Tamura  <tkent@chromium.org>
    223
  • trunk/Source/WebCore/inspector/front-end/ExtensionAPI.js

    r118492 r120311  
    8585        SetSidebarHeight: "setSidebarHeight",
    8686        SetSidebarPage: "setSidebarPage",
     87        ShowPanel: "showPanel",
    8788        StopAuditCategoryRun: "stopAuditCategoryRun",
    8889        Unsubscribe: "unsubscribe",
     
    101102var commands = apiPrivate.Commands;
    102103var events = apiPrivate.Events;
     104var userAction = false;
    103105
    104106// Here and below, all constructors are private to API implementation.
     
    306308            function callbackWrapper(message)
    307309            {
    308                 callback.call(null, new Resource(message.resource), message.lineNumber);
     310                // Allow the panel to show itself when handling the event.
     311                userAction = true;
     312                try {
     313                    callback.call(null, new Resource(message.resource), message.lineNumber);
     314                } finally {
     315                    userAction = false;
     316                }
    309317            }
    310318            extensionServer.registerHandler(events.OpenResource, callbackWrapper);
     
    395403        extensionServer.sendRequest(request);
    396404        return new Button(id);
     405    },
     406
     407    show: function()
     408    {
     409        if (!userAction)
     410            return;
     411
     412        var request = {
     413            command: commands.ShowPanel,
     414            id: this._id
     415        };
     416        extensionServer.sendRequest(request);
    397417    }
    398418};
  • trunk/Source/WebCore/inspector/front-end/ExtensionServer.js

    r117293 r120311  
    6767    this._registerHandler(commands.SetSidebarContent, this._onSetSidebarContent.bind(this));
    6868    this._registerHandler(commands.SetSidebarPage, this._onSetSidebarPage.bind(this));
     69    this._registerHandler(commands.ShowPanel, this._onShowPanel.bind(this));
    6970    this._registerHandler(commands.StopAuditCategoryRun, this._onStopAuditCategoryRun.bind(this));
    7071    this._registerHandler(commands.Subscribe, this._onSubscribe.bind(this));
     
    203204        WebInspector.addPanel(panel);
    204205        return this._status.OK();
     206    },
     207
     208    _onShowPanel: function(message)
     209    {
     210        // Note: WebInspector.showPanel already sanitizes input.
     211        WebInspector.showPanel(message.id);
    205212    },
    206213
Note: See TracChangeset for help on using the changeset viewer.