Changeset 116739 in webkit


Ignore:
Timestamp:
May 11, 2012 1:29:08 AM (12 years ago)
Author:
caseq@chromium.org
Message:

Web Inspector: [Extensions API] add audit formatters for remote objects and DOM elements
https://bugs.webkit.org/show_bug.cgi?id=86108

Reviewed by Pavel Feldman.

Source/WebCore:

  • added two new formatters to AuditResults object of webInspector.audits API;
  • inspector/front-end/AuditFormatters.js:

(WebInspector.AuditFormatters.resourceLink):
(WebInspector.AuditFormatters.object.onEvaluate):
(WebInspector.AuditFormatters.object): format as a remote object property list;
(WebInspector.AuditFormatters.node.onNodeAvailable):
(WebInspector.AuditFormatters.node.onEvaluate):
(WebInspector.AuditFormatters.node): format as a DOM elements sub-tree;
(WebInspector.AuditFormatters.Utilities.evaluate): common expression evaluation logic for both new formatters;

  • inspector/front-end/ExtensionAPI.js:

(injectedExtensionAPI.AuditResultImpl):

  • inspector/front-end/auditsPanel.css:

(.audit-result-tree ol.outline-disclosure):
(.audit-result-tree .section .header):
(.audit-result-tree .section .header::before):

LayoutTests:

  • rebaselined tests to account for two new AuditResults method and their results;
  • inspector/extensions/extensions-audits-api-expected.txt:
  • inspector/extensions/extensions-audits-expected.txt:
  • inspector/extensions/extensions-audits-tests.js:

(initialize_ExtensionsAuditsTest.InspectorTest.startExtensionAudits.onAuditsDone):

  • inspector/extensions/extensions-audits.html:
Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r116737 r116739  
     12012-05-10  Andrey Kosyakov  <caseq@chromium.org>
     2
     3        Web Inspector: [Extensions API] add audit formatters for remote objects and DOM elements
     4        https://bugs.webkit.org/show_bug.cgi?id=86108
     5
     6        Reviewed by Pavel Feldman.
     7
     8        - rebaselined tests to account for two new AuditResults method and their results;
     9
     10        * inspector/extensions/extensions-audits-api-expected.txt:
     11        * inspector/extensions/extensions-audits-expected.txt:
     12        * inspector/extensions/extensions-audits-tests.js:
     13        (initialize_ExtensionsAuditsTest.InspectorTest.startExtensionAudits.onAuditsDone):
     14        * inspector/extensions/extensions-audits.html:
     15
    1162012-05-11  Csaba Osztrogonác  <ossy@webkit.org>
    217
  • trunk/LayoutTests/inspector/audits/audits-test.js

    r82713 r116739  
    2222            for (var i = 0; i < level; ++i)
    2323                nodeOutput += " ";
    24             nodeOutput += child.nodeValue;
     24            nodeOutput += child.nodeValue.replace("\u200B", "");
    2525        } else if (child.nodeType === Node.ELEMENT_NODE) {
    2626            if (nodeOutput !== "") {
  • trunk/LayoutTests/inspector/extensions/extensions-audits-api-expected.txt

    r101760 r116739  
    1111    }
    1212}
    13   Extension audits
    1413category.onAuditStarted fired, results dump follows:
    1514{
     
    1716    createSnippet : <function>
    1817    createText : <function>
     18    createObject : <function>
     19    createNode : <function>
    1920    addResult : <function>
    2021    createResult : <function>
     
    3637    addChild : <function>
    3738}
     39  Extension audits
    3840All tests done.
    3941
  • trunk/LayoutTests/inspector/extensions/extensions-audits-api.html

    r82713 r116739  
    1616        var node = results.createResult("Subtree");
    1717        dumpObject(node);
    18         results.done();
     18        // Make sure dumpObject() pushes stuff through before we continue.
     19        evaluateOnFrontend("InspectorTest.runAfterPendingDispatches(reply)", function() {
     20            results.done();
     21        });
    1922    }
    2023    var category = webInspector.audits.addCategory("Extension audits", 20);
  • trunk/LayoutTests/inspector/extensions/extensions-audits-expected.txt

    r101760 r116739  
    11Tests audits support in WebInspector Extensions API
    22
    3 Started extension.
     3 Started extension.
    44Running tests...
    55RUNNING TEST: extension_testAudits
     
    2020}
    2121         /path/to/error.html:10
     22            object details
     23             a
     24             :
     25             42
     26             b
     27             :
     28             "foo"
     29             __proto__
     30             :
     31             Object
     32            <
     33             span
     34             
     35              id
     36             ="
     37              test-element
     38             "
     39            >
     40           
    2241         extensions-audits.html:20
    2342    Passed rule
  • trunk/LayoutTests/inspector/extensions/extensions-audits-tests.js

    r89656 r116739  
    2121        function onAuditsDone()
    2222        {
    23             InspectorTest.collectAuditResults();
    24             callback();
     23            InspectorTest.runAfterPendingDispatches(function() {
     24                InspectorTest.collectAuditResults();
     25                callback();
     26            });
    2527        }
    2628        InspectorTest.addSniffer(WebInspector.panels.audits, "_auditFinishedCallback", onAuditsDone, true);
  • trunk/LayoutTests/inspector/extensions/extensions-audits.html

    r101760 r116739  
    2424        nestedNode.addChild(results.createSnippet("function rand()\n{\n    return 4;\n}"));
    2525        nestedNode.addChild(results.createResourceLink("file:///path/to/error.html", 10));
     26        nestedNode.addChild(results.createObject("({a: 42, b: 'foo'})", "object details"));
     27        nestedNode.addChild(results.createNode("document.getElementById('test-element')"));
     28
    2629        webInspector.inspectedWindow.eval("location.href", function(inspectedPageURL) {
    2730            nestedNode.addChild(results.createResourceLink(inspectedPageURL, 20));
     
    6972<body onload="runTest()">
    7073<p>Tests audits support in WebInspector Extensions API</p>
     74<span id="test-element"><b></b></span>
    7175</body>
    7276</html>
  • trunk/Source/WebCore/ChangeLog

    r116736 r116739  
     12012-05-10  Andrey Kosyakov  <caseq@chromium.org>
     2
     3        Web Inspector: [Extensions API] add audit formatters for remote objects and DOM elements
     4        https://bugs.webkit.org/show_bug.cgi?id=86108
     5
     6        Reviewed by Pavel Feldman.
     7
     8       - added two new formatters to AuditResults object of webInspector.audits API;
     9
     10        * inspector/front-end/AuditFormatters.js:
     11        (WebInspector.AuditFormatters.resourceLink):
     12        (WebInspector.AuditFormatters.object.onEvaluate):
     13        (WebInspector.AuditFormatters.object): format as a remote object property list;
     14        (WebInspector.AuditFormatters.node.onNodeAvailable):
     15        (WebInspector.AuditFormatters.node.onEvaluate):
     16        (WebInspector.AuditFormatters.node): format as a DOM elements sub-tree;
     17        (WebInspector.AuditFormatters.Utilities.evaluate): common expression evaluation logic for both new formatters;
     18        * inspector/front-end/ExtensionAPI.js:
     19        (injectedExtensionAPI.AuditResultImpl):
     20        * inspector/front-end/auditsPanel.css:
     21        (.audit-result-tree ol.outline-disclosure):
     22        (.audit-result-tree .section .header):
     23        (.audit-result-tree .section .header::before):
     24
    1252012-05-11  Sheriff Bot  <webkit.review.bot@gmail.com>
    226
  • trunk/Source/WebCore/inspector/front-end/AuditFormatters.js

    r101760 r116739  
    11/*
    2  * Copyright (C) 2010 Google Inc. All rights reserved.
     2 * Copyright (C) 2012 Google Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    9797        // FIXME: use WebInspector.DebuggerPresentationModel.Linkifier
    9898        return WebInspector.linkifyResourceAsNode(url, line, "console-message-url webkit-html-resource-link");
     99    },
     100
     101    /**
     102     * @param {string} expression
     103     * @param {string} title
     104     */
     105    object: function(expression, title)
     106    {
     107        var parentElement = document.createElement("div");
     108        function onEvaluate(remoteObject)
     109        {
     110            var section = new WebInspector.ObjectPropertiesSection(remoteObject, title);
     111            section.expanded = true;
     112            section.editable = false;
     113            parentElement.appendChild(section.element);
     114        }
     115        WebInspector.AuditFormatters.Utilities.evaluate(expression, onEvaluate);
     116        return parentElement;
     117    },
     118
     119    /**
     120     * @param {string} expression
     121     */
     122    node: function(expression)
     123    {
     124        var treeOutline = new WebInspector.ElementsTreeOutline(false, false, true);
     125        /**
     126         * @param {?number} nodeId
     127         */
     128        function onNodeAvailable(nodeId)
     129        {
     130            if (!nodeId)
     131                return;
     132            treeOutline.rootDOMNode = WebInspector.domAgent.nodeForId(nodeId);
     133            treeOutline.element.addStyleClass("outline-disclosure");
     134            treeOutline.setVisible(true);
     135        }
     136        /**
     137         * @param {WebInspector.RemoteObject} remoteObject
     138         */
     139        function onEvaluate(remoteObject)
     140        {
     141            remoteObject.pushNodeToFrontend(onNodeAvailable);
     142        }
     143        WebInspector.AuditFormatters.Utilities.evaluate(expression, onEvaluate);
     144        return treeOutline.element;
    99145    }
    100146};
     147
     148WebInspector.AuditFormatters.Utilities = {
     149    /**
     150     * @param {string} expression
     151     * @param {function(WebInspector.RemoteObject)} callback
     152     */
     153    evaluate: function(expression, callback)
     154    {
     155        /**
     156         * @param {?string} error
     157         * @param {?RuntimeAgent.RemoteObject} result
     158         * @param {boolean=} wasThrown
     159         */
     160        function onEvaluate(error, result, wasThrown)
     161        {
     162            if (wasThrown)
     163                return;
     164            var object = WebInspector.RemoteObject.fromPayload(result);
     165            callback(object);
     166        }
     167        RuntimeAgent.evaluate(expression, "extension-watch", true, undefined, undefined, undefined, onEvaluate);
     168    }
     169};
     170
  • trunk/Source/WebCore/inspector/front-end/ExtensionAPI.js

    r108972 r116739  
    11/*
    2  * Copyright (C) 2011 Google Inc. All rights reserved.
     2 * Copyright (C) 2012 Google Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    499499    this.createSnippet = this._nodeFactory.bind(null, "snippet");
    500500    this.createText = this._nodeFactory.bind(null, "text");
     501    this.createObject = this._nodeFactory.bind(null, "object");
     502    this.createNode = this._nodeFactory.bind(null, "node");
    501503}
    502504
  • trunk/Source/WebCore/inspector/front-end/auditsPanel.css

    r103765 r116739  
    179179}
    180180
     181.audit-result-tree ol.outline-disclosure {
     182    -webkit-padding-start: 0;
     183}
     184
     185.audit-result-tree .section .header {
     186    padding-left: 13px;
     187}
     188
     189.audit-result-tree .section .header::before {
     190    left: 2px;
     191}
     192
    181193.audit-result-tree li {
    182194    padding: 0 0 0 14px;
Note: See TracChangeset for help on using the changeset viewer.