Diff
Modified: trunk/LayoutTests/ChangeLog (117292 => 117293)
--- trunk/LayoutTests/ChangeLog 2012-05-16 15:27:10 UTC (rev 117292)
+++ trunk/LayoutTests/ChangeLog 2012-05-16 15:41:08 UTC (rev 117293)
@@ -1,3 +1,18 @@
+2012-05-16 Andrey Kosyakov <[email protected]>
+
+ Web Inspector: [Extensions API] expose evaluateOptions in audit formatters
+ https://bugs.webkit.org/show_bug.cgi?id=86617
+
+ Reviewed by Pavel Feldman.
+
+ * inspector/extensions/extensions-audits-content-script-expected.txt: Added.
+ * inspector/extensions/extensions-audits-content-script.html: Added.
+ * platform/gtk/test_expectations.txt:
+ * platform/mac/Skipped:
+ * platform/qt/Skipped:
+ * platform/win/Skipped:
+ * platform/wk2/Skipped:
+
2012-05-16 Rob Buis <[email protected]>
SVGSVGElement checkIntersection and checkEnclosure Mem corruption
Added: trunk/LayoutTests/inspector/extensions/extensions-audits-content-script-expected.txt (0 => 117293)
--- trunk/LayoutTests/inspector/extensions/extensions-audits-content-script-expected.txt (rev 0)
+++ trunk/LayoutTests/inspector/extensions/extensions-audits-content-script-expected.txt 2012-05-16 15:41:08 UTC (rev 117293)
@@ -0,0 +1,43 @@
+Tests audit formatters performing evals on content scripts in WebInspector Extensions API
+
+ Started extension.
+Running tests...
+RUNNING TEST: extension_testAudits
+ Extension audits
+ Rule with details subtree (1)
+ Test Formatters
+ main world object
+ whereAmI
+ :
+ "main world"
+ __proto__
+ :
+ Object
+ <
+ span
+
+ id
+ ="
+ test-element
+ "
+ >
+
+ content script object
+ whereAmI
+ :
+ "brave new world"
+ __proto__
+ :
+ Object
+ <
+ span
+
+ id
+ ="
+ test-element
+ "
+ >
+
+category.onAuditStarted fired
+All tests done.
+
Property changes on: trunk/LayoutTests/inspector/extensions/extensions-audits-content-script-expected.txt
___________________________________________________________________
Added: svn:eol-style
Added: trunk/LayoutTests/inspector/extensions/extensions-audits-content-script.html (0 => 117293)
--- trunk/LayoutTests/inspector/extensions/extensions-audits-content-script.html (rev 0)
+++ trunk/LayoutTests/inspector/extensions/extensions-audits-content-script.html 2012-05-16 15:41:08 UTC (rev 117293)
@@ -0,0 +1,51 @@
+<html>
+<head>
+<script src=""
+<script src=""
+<script src=""
+<script src=""
+
+<script type="text/_javascript_">
+
+window.whereAmI = "main world";
+
+layoutTestController.setIsolatedWorldSecurityOrigin(632, "file:///");
+layoutTestController.evaluateScriptInIsolatedWorld(632, "window.whereAmI = 'brave new world'");
+
+function extension_testAudits(nextTest)
+{
+ var pendingOutput = [];
+
+ function onStartAuditCategory(results)
+ {
+ pendingOutput.push("category.onAuditStarted fired");
+ var node = results.createResult("Test Formatters");
+ node.addChild(results.createObject("({whereAmI: window.whereAmI})", "main world object"));
+ node.addChild(results.createNode("document.getElementById('test-element')"));
+
+ node.addChild(results.createObject("({whereAmI: window.whereAmI})", "content script object", { useContentScriptContext: true }));
+ node.addChild(results.createNode("document.getElementById('test-element')", { useContentScriptContext: true }));
+
+ results.addResult("Rule with details subtree (1)", "", results.Severity.Warning, node);
+ results.done();
+ }
+ var category = webInspector.audits.addCategory("Extension audits", 20);
+ category.onAuditStarted.addListener(onStartAuditCategory);
+
+ function auditsDone()
+ {
+ pendingOutput.sort().forEach(output);
+ nextTest();
+ }
+ webInspector.inspectedWindow.eval("", function() {
+ extension_runAudits(auditsDone);
+ });
+}
+
+</script>
+</head>
+<body _onload_="runTest()">
+<p>Tests audit formatters performing evals on content scripts in WebInspector Extensions API</p>
+<span id="test-element"><b></b></span>
+</body>
+</html>
Property changes on: trunk/LayoutTests/inspector/extensions/extensions-audits-content-script.html
___________________________________________________________________
Added: svn:eol-style
Modified: trunk/LayoutTests/platform/gtk/test_expectations.txt (117292 => 117293)
--- trunk/LayoutTests/platform/gtk/test_expectations.txt 2012-05-16 15:27:10 UTC (rev 117292)
+++ trunk/LayoutTests/platform/gtk/test_expectations.txt 2012-05-16 15:41:08 UTC (rev 117293)
@@ -782,7 +782,6 @@
BUGWK82886 SKIP : inspector/styles/override-screen-size.html = FAIL
BUGWK72434 SKIP : inspector/styles/svg-style.xhtml = FAIL
BUGWK43034 SKIP : inspector/debugger/debugger-breakpoints-not-activated-on-reload.html = FAIL
-BUGWK81089 SKIP : inspector/debugger/snippets-model.html = FAIL
BUGWK43332 SKIP : inspector/debugger/dom-breakpoints.html = FAIL
BUGWK43332 SKIP : inspector/debugger/event-listener-breakpoints.html = FAIL
BUGWK43332 SKIP : inspector/debugger/step-through-event-listeners.html = FAIL
@@ -791,6 +790,7 @@
BUGWK50868 SKIP : inspector/debugger/debugger-step-out.html = FAIL
BUGWK50868 SKIP : inspector/styles/styles-source-lines-inline.html = FAIL
BUGWK85709 SKIP : inspector/extensions/extensions-eval-content-script.html = FAIL
+BUGWK85709 SKIP : inspector/extensions/extensions-audits-content-script.html = FAIL
// These inspector tests fell out of the radar after the transition to NRWT
// Some time out and some are flaky or present different baselines.
Modified: trunk/LayoutTests/platform/mac/Skipped (117292 => 117293)
--- trunk/LayoutTests/platform/mac/Skipped 2012-05-16 15:27:10 UTC (rev 117292)
+++ trunk/LayoutTests/platform/mac/Skipped 2012-05-16 15:41:08 UTC (rev 117293)
@@ -842,6 +842,7 @@
# Inspector only supports evaluation in content script world with v8, see https://bugs.webkit.org/show_bug.cgi?id=85709
inspector/extensions/extensions-eval-content-script.html
+inspector/extensions/extensions-audits-content-script.html
# https://bugs.webkit.org/show_bug.cgi?id=86480
plugins/npruntime/delete-plugin-within-setProperty.html
Modified: trunk/LayoutTests/platform/qt/Skipped (117292 => 117293)
--- trunk/LayoutTests/platform/qt/Skipped 2012-05-16 15:27:10 UTC (rev 117292)
+++ trunk/LayoutTests/platform/qt/Skipped 2012-05-16 15:41:08 UTC (rev 117293)
@@ -2488,6 +2488,7 @@
# Inspector only supports evaluation in content script world with v8, see https://bugs.webkit.org/show_bug.cgi?id=85709
inspector/extensions/extensions-eval-content-script.html
+inspector/extensions/extensions-audits-content-script.html
# [Qt][GTK] New fast/multicol/split-in-top-margin.html fails
# https://bugs.webkit.org/show_bug.cgi?id=86445
Modified: trunk/LayoutTests/platform/win/Skipped (117292 => 117293)
--- trunk/LayoutTests/platform/win/Skipped 2012-05-16 15:27:10 UTC (rev 117292)
+++ trunk/LayoutTests/platform/win/Skipped 2012-05-16 15:41:08 UTC (rev 117293)
@@ -1747,4 +1747,5 @@
# Inspector only supports evaluation in content script world with v8, see https://bugs.webkit.org/show_bug.cgi?id=85709
inspector/extensions/extensions-eval-content-script.html
+inspector/extensions/extensions-audits-content-script.html
Modified: trunk/LayoutTests/platform/wk2/Skipped (117292 => 117293)
--- trunk/LayoutTests/platform/wk2/Skipped 2012-05-16 15:27:10 UTC (rev 117292)
+++ trunk/LayoutTests/platform/wk2/Skipped 2012-05-16 15:41:08 UTC (rev 117293)
@@ -73,6 +73,7 @@
# Inspector only supports evaluation in content script world with v8, see https://bugs.webkit.org/show_bug.cgi?id=85709
inspector/extensions/extensions-eval-content-script.html
+inspector/extensions/extensions-audits-content-script.html
# A bunch of inspector tests time out on Lion Intel Debug WebKit2 testers.
# https://bugs.webkit.org/show_bug.cgi?id=81601
Modified: trunk/Source/WebCore/ChangeLog (117292 => 117293)
--- trunk/Source/WebCore/ChangeLog 2012-05-16 15:27:10 UTC (rev 117292)
+++ trunk/Source/WebCore/ChangeLog 2012-05-16 15:41:08 UTC (rev 117293)
@@ -1,3 +1,30 @@
+2012-05-16 Andrey Kosyakov <[email protected]>
+
+ Web Inspector: [Extensions API] expose evaluateOptions in audit formatters
+ https://bugs.webkit.org/show_bug.cgi?id=86617
+
+ Reviewed by Pavel Feldman.
+
+ Test: inspector/extensions/extensions-audits-content-script.html
+
+ - apply extension-specific audit formatters earlier (in ExtensionAduitCategory, not along with the rest in AuditFormatters);
+ - use ExtensionServer.evaluate() to handle evaluateOptions instead of PageAgent.evaluate();
+
+ * inspector/front-end/AuditFormatters.js: Move node and object formatters to ExtensionAuditCategory.
+ (WebInspector.partiallyApplyFormatters): Added a method to traverse formatters tree and apply formatters that are passed as input.
+ * inspector/front-end/ExtensionAuditCategory.js:
+ (WebInspector.ExtensionAuditCategory): Pass extensionOrigin.
+ (WebInspector.ExtensionAuditCategoryResults.prototype._addNode): Apply extensions formatters before adding the result.
+ (WebInspector.ExtensionAuditCategoryResults.prototype._addResult):
+ (WebInspector.ExtensionAuditCategoryResults.prototype.evaluate): moved from AuditFormatters.
+ (WebInspector.ExtensionAuditFormatters.object.onEvaluate):
+ (WebInspector.ExtensionAuditFormatters.object):
+ (WebInspector.ExtensionAuditFormatters.node.onNodeAvailable):
+ (WebInspector.ExtensionAuditFormatters.node.onEvaluate):
+ (WebInspector.ExtensionAuditFormatters.node):
+ * inspector/front-end/ExtensionServer.js:
+ (WebInspector.ExtensionServer.prototype._onAddAuditCategory): Plumb extensionOrigin through to audit category.
+
2012-05-16 Donald Carr <[email protected]>
Fixes the build with Qt 5 HEAD
Modified: trunk/Source/WebCore/inspector/front-end/AuditFormatters.js (117292 => 117293)
--- trunk/Source/WebCore/inspector/front-end/AuditFormatters.js 2012-05-16 15:27:10 UTC (rev 117292)
+++ trunk/Source/WebCore/inspector/front-end/AuditFormatters.js 2012-05-16 15:41:08 UTC (rev 117293)
@@ -28,38 +28,14 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-WebInspector.applyFormatters = function(value)
+/**
+ * @constructor
+ */
+WebInspector.AuditFormatters = function()
{
- var formatter;
- var type = typeof value;
- var args;
-
- switch (type) {
- case "string":
- case "boolean":
- case "number":
- formatter = WebInspector.AuditFormatters.text;
- args = [ value.toString() ];
- break;
-
- case "object":
- if (value instanceof Node)
- return value;
- if (value instanceof Array) {
- formatter = WebInspector.AuditFormatters.concat;
- args = value;
- } else if (value.type && value.arguments) {
- formatter = WebInspector.AuditFormatters[value.type];
- args = value.arguments;
- }
- }
- if (!formatter)
- throw "Invalid value or formatter: " + type + JSON.stringify(value);
-
- return formatter.apply(null, args);
}
-WebInspector.AuditFormatters = {
+WebInspector.AuditFormatters.Registry = {
text: function(text)
{
return document.createTextNode(text);
@@ -77,7 +53,7 @@
{
var parent = document.createElement("span");
for (var arg = 0; arg < arguments.length; ++arg)
- parent.appendChild(WebInspector.applyFormatters(arguments[arg]));
+ parent.appendChild(WebInspector.auditFormatters.apply(arguments[arg]));
return parent;
},
@@ -96,77 +72,57 @@
{
// FIXME: use WebInspector.Linkifier
return WebInspector.linkifyResourceAsNode(url, line, "console-message-url webkit-html-resource-link");
- },
+ }
+};
+WebInspector.AuditFormatters.prototype = {
/**
- * @param {string} _expression_
- * @param {string} title
+ * @param {string|boolean|number|Object} value
*/
- object: function(_expression_, title)
+ apply: function(value)
{
- var parentElement = document.createElement("div");
- function onEvaluate(remoteObject)
- {
- var section = new WebInspector.ObjectPropertiesSection(remoteObject, title);
- section.expanded = true;
- section.editable = false;
- parentElement.appendChild(section.element);
+ var formatter;
+ var type = typeof value;
+ var args;
+
+ switch (type) {
+ case "string":
+ case "boolean":
+ case "number":
+ formatter = WebInspector.AuditFormatters.Registry.text;
+ args = [ value.toString() ];
+ break;
+
+ case "object":
+ if (value instanceof Node)
+ return value;
+ if (value instanceof Array) {
+ formatter = WebInspector.AuditFormatters.Registry.concat;
+ args = value;
+ } else if (value.type && value.arguments) {
+ formatter = WebInspector.AuditFormatters.Registry[value.type];
+ args = value.arguments;
+ }
}
- WebInspector.AuditFormatters.Utilities.evaluate(_expression_, onEvaluate);
- return parentElement;
+ if (!formatter)
+ throw "Invalid value or formatter: " + type + JSON.stringify(value);
+
+ return formatter.apply(null, args);
},
/**
- * @param {string} _expression_
+ * @param {Object} formatters
+ * @param {Object} thisArgument
+ * @param {string|boolean|number|Object} value
*/
- node: function(_expression_)
+ partiallyApply: function(formatters, thisArgument, value)
{
- var parentElement = document.createElement("div");
- /**
- * @param {?number} nodeId
- */
- function onNodeAvailable(nodeId)
- {
- if (!nodeId)
- return;
- var treeOutline = new WebInspector.ElementsTreeOutline(false, false, true);
- treeOutline.rootDOMNode = WebInspector.domAgent.nodeForId(nodeId);
- treeOutline.element.addStyleClass("outline-disclosure");
- treeOutline.setVisible(true);
- parentElement.appendChild(treeOutline.element);
- }
- /**
- * @param {WebInspector.RemoteObject} remoteObject
- */
- function onEvaluate(remoteObject)
- {
- remoteObject.pushNodeToFrontend(onNodeAvailable);
- }
- WebInspector.AuditFormatters.Utilities.evaluate(_expression_, onEvaluate);
- return parentElement;
+ if (value instanceof Array)
+ return value.map(this.partiallyApply.bind(this, formatters, thisArgument));
+ if (typeof value === "object" && typeof formatters[value.type] === "function" && value.arguments)
+ return formatters[value.type].apply(thisArgument, value.arguments);
+ return value;
}
-};
+}
-WebInspector.AuditFormatters.Utilities = {
- /**
- * @param {string} _expression_
- * @param {function(WebInspector.RemoteObject)} callback
- */
- evaluate: function(_expression_, callback)
- {
- /**
- * @param {?string} error
- * @param {?RuntimeAgent.RemoteObject} result
- * @param {boolean=} wasThrown
- */
- function onEvaluate(error, result, wasThrown)
- {
- if (wasThrown)
- return;
- var object = WebInspector.RemoteObject.fromPayload(result);
- callback(object);
- }
- RuntimeAgent.evaluate(_expression_, "extension-watch", true, undefined, undefined, undefined, onEvaluate);
- }
-};
-
+WebInspector.auditFormatters = new WebInspector.AuditFormatters();
Modified: trunk/Source/WebCore/inspector/front-end/AuditResultView.js (117292 => 117293)
--- trunk/Source/WebCore/inspector/front-end/AuditResultView.js 2012-05-16 15:27:10 UTC (rev 117292)
+++ trunk/Source/WebCore/inspector/front-end/AuditResultView.js 2012-05-16 15:41:08 UTC (rev 117293)
@@ -114,7 +114,7 @@
if (result.className)
treeElement.listItemElement.addStyleClass(result.className);
if (typeof result.value !== "string")
- treeElement.listItemElement.appendChild(WebInspector.applyFormatters(result.value));
+ treeElement.listItemElement.appendChild(WebInspector.auditFormatters.apply(result.value));
if (result.children) {
for (var i = 0; i < result.children.length; ++i)
Modified: trunk/Source/WebCore/inspector/front-end/ExtensionAuditCategory.js (117292 => 117293)
--- trunk/Source/WebCore/inspector/front-end/ExtensionAuditCategory.js 2012-05-16 15:27:10 UTC (rev 117292)
+++ trunk/Source/WebCore/inspector/front-end/ExtensionAuditCategory.js 2012-05-16 15:41:08 UTC (rev 117293)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 Google Inc. All rights reserved.
+ * Copyright (C) 2012 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -30,9 +30,14 @@
/**
* @constructor
+ * @param {string} extensionOrigin
+ * @param {string} id
+ * @param {string} displayName
+ * @param {number} ruleCount
*/
-WebInspector.ExtensionAuditCategory = function(id, displayName, ruleCount)
+WebInspector.ExtensionAuditCategory = function(extensionOrigin, id, displayName, ruleCount)
{
+ this._extensionOrigin = extensionOrigin;
this._id = id;
this._displayName = displayName;
this._ruleCount = ruleCount;
@@ -63,6 +68,8 @@
/**
* @constructor
+ * @param {WebInspector.ExtensionAuditCategory} category
+ * @param {function(WebInspector.AuditRuleResult)} callback
*/
WebInspector.ExtensionAuditCategoryResults = function(category, callback)
{
@@ -98,7 +105,8 @@
_addNode: function(parent, node)
{
- var addedNode = parent.addChild(node.contents, node.expanded);
+ var contents = WebInspector.auditFormatters.partiallyApply(WebInspector.ExtensionAuditFormatters, this, node.contents);
+ var addedNode = parent.addChild(contents, node.expanded);
if (node.children) {
for (var i = 0; i < node.children.length; ++i)
this._addNode(addedNode, node.children[i]);
@@ -111,7 +119,82 @@
this._pendingRules--;
if (!this._pendingRules)
WebInspector.extensionServer.stopAuditRun(this);
+ },
+
+ /**
+ * @param {string} _expression_
+ * @param {function(WebInspector.RemoteObject)} callback
+ */
+ evaluate: function(_expression_, evaluateOptions, callback)
+ {
+ /**
+ * @param {?string} error
+ * @param {?RuntimeAgent.RemoteObject} result
+ * @param {boolean=} wasThrown
+ */
+ function onEvaluate(error, result, wasThrown)
+ {
+ if (wasThrown)
+ return;
+ var object = WebInspector.RemoteObject.fromPayload(result);
+ callback(object);
+ }
+ WebInspector.extensionServer.evaluate(_expression_, false, false, evaluateOptions, this._category._extensionOrigin, onEvaluate);
}
}
+WebInspector.ExtensionAuditFormatters = {
+ /**
+ * @this {WebInspector.ExtensionAuditCategoryResults}
+ * @param {string} _expression_
+ * @param {string} title
+ * @param {Object} evaluateOptions
+ */
+ object: function(_expression_, title, evaluateOptions)
+ {
+ var parentElement = document.createElement("div");
+ function onEvaluate(remoteObject)
+ {
+ var section = new WebInspector.ObjectPropertiesSection(remoteObject, title);
+ section.expanded = true;
+ section.editable = false;
+ parentElement.appendChild(section.element);
+ }
+ this.evaluate(_expression_, evaluateOptions, onEvaluate);
+ return parentElement;
+ },
+
+ /**
+ * @this {WebInspector.ExtensionAuditCategoryResults}
+ * @param {string} _expression_
+ * @param {Object} evaluateOptions
+ */
+ node: function(_expression_, evaluateOptions)
+ {
+ var parentElement = document.createElement("div");
+ /**
+ * @param {?number} nodeId
+ */
+ function onNodeAvailable(nodeId)
+ {
+ if (!nodeId)
+ return;
+ var treeOutline = new WebInspector.ElementsTreeOutline(false, false, true);
+ treeOutline.rootDOMNode = WebInspector.domAgent.nodeForId(nodeId);
+ treeOutline.element.addStyleClass("outline-disclosure");
+ treeOutline.setVisible(true);
+ parentElement.appendChild(treeOutline.element);
+ }
+ /**
+ * @param {WebInspector.RemoteObject} remoteObject
+ */
+ function onEvaluate(remoteObject)
+ {
+ remoteObject.pushNodeToFrontend(onNodeAvailable);
+ }
+ this.evaluate(_expression_, evaluateOptions, onEvaluate);
+ return parentElement;
+ }
+}
+
WebInspector.ExtensionAuditCategoryResults._lastId = 0;
Modified: trunk/Source/WebCore/inspector/front-end/ExtensionServer.js (117292 => 117293)
--- trunk/Source/WebCore/inspector/front-end/ExtensionServer.js 2012-05-16 15:27:10 UTC (rev 117292)
+++ trunk/Source/WebCore/inspector/front-end/ExtensionServer.js 2012-05-16 15:41:08 UTC (rev 117293)
@@ -500,9 +500,9 @@
return this._requests[id];
},
- _onAddAuditCategory: function(message)
+ _onAddAuditCategory: function(message, port)
{
- var category = new WebInspector.ExtensionAuditCategory(message.id, message.displayName, message.resultCount);
+ var category = new WebInspector.ExtensionAuditCategory(port._extensionOrigin, message.id, message.displayName, message.resultCount);
if (WebInspector.panels.audits.getCategory(category.id))
return this._status.E_EXISTS(category.id);
this._clientObjects[message.id] = category;