OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 13 matching lines...) Expand all Loading... |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 /** | 31 /** |
32 * @constructor | 32 * @constructor |
33 * @implements {WebInspector.AuditCategory} | 33 * @implements {WebInspector.AuditCategory} |
34 * @param {!WebInspector.ExtensionServer} server | |
35 * @param {string} extensionOrigin | 34 * @param {string} extensionOrigin |
36 * @param {string} id | 35 * @param {string} id |
37 * @param {string} displayName | 36 * @param {string} displayName |
38 * @param {number=} ruleCount | 37 * @param {number=} ruleCount |
39 */ | 38 */ |
40 WebInspector.ExtensionAuditCategory = function(server, extensionOrigin, id, disp
layName, ruleCount) | 39 WebInspector.AuditExtensionCategory = function(extensionOrigin, id, displayName,
ruleCount) |
41 { | 40 { |
42 this._server = server; | |
43 this._extensionOrigin = extensionOrigin; | 41 this._extensionOrigin = extensionOrigin; |
44 this._id = id; | 42 this._id = id; |
45 this._displayName = displayName; | 43 this._displayName = displayName; |
46 this._ruleCount = ruleCount; | 44 this._ruleCount = ruleCount; |
47 } | 45 } |
48 | 46 |
49 WebInspector.ExtensionAuditCategory.prototype = { | 47 WebInspector.AuditExtensionCategory.prototype = { |
50 /** | 48 /** |
51 * @override | 49 * @override |
52 */ | 50 */ |
53 get id() | 51 get id() |
54 { | 52 { |
55 return this._id; | 53 return this._id; |
56 }, | 54 }, |
57 | 55 |
58 /** | 56 /** |
59 * @override | 57 * @override |
60 */ | 58 */ |
61 get displayName() | 59 get displayName() |
62 { | 60 { |
63 return this._displayName; | 61 return this._displayName; |
64 }, | 62 }, |
65 | 63 |
66 /** | 64 /** |
67 * @override | 65 * @override |
68 * @param {!WebInspector.Target} target | 66 * @param {!WebInspector.Target} target |
69 * @param {!Array.<!WebInspector.NetworkRequest>} requests | 67 * @param {!Array.<!WebInspector.NetworkRequest>} requests |
70 * @param {function(!WebInspector.AuditRuleResult)} ruleResultCallbac
k | 68 * @param {function(!WebInspector.AuditRuleResult)} ruleResultCallbac
k |
71 * @param {function()} categoryDoneCallback | 69 * @param {function()} categoryDoneCallback |
72 * @param {!WebInspector.Progress} progress | 70 * @param {!WebInspector.Progress} progress |
73 */ | 71 */ |
74 run: function(target, requests, ruleResultCallback, categoryDoneCallback, pr
ogress) | 72 run: function(target, requests, ruleResultCallback, categoryDoneCallback, pr
ogress) |
75 { | 73 { |
76 var results = new WebInspector.ExtensionAuditCategoryResults(this, targe
t, ruleResultCallback, categoryDoneCallback, progress); | 74 var results = new WebInspector.AuditExtensionCategoryResults(this, targe
t, ruleResultCallback, categoryDoneCallback, progress); |
77 this._server.startAuditRun(this, results); | 75 WebInspector.extensionServer.startAuditRun(this.id, results); |
78 } | 76 } |
79 } | 77 } |
80 | 78 |
81 /** | 79 /** |
82 * @constructor | 80 * @constructor |
83 * @param {!WebInspector.ExtensionAuditCategory} category | 81 * @implements {WebInspector.ExtensionAuditCategoryResults} |
| 82 * @param {!WebInspector.AuditExtensionCategory} category |
84 * @param {!WebInspector.Target} target | 83 * @param {!WebInspector.Target} target |
85 * @param {function(!WebInspector.AuditRuleResult)} ruleResultCallback | 84 * @param {function(!WebInspector.AuditRuleResult)} ruleResultCallback |
86 * @param {function()} categoryDoneCallback | 85 * @param {function()} categoryDoneCallback |
87 * @param {!WebInspector.Progress} progress | 86 * @param {!WebInspector.Progress} progress |
88 */ | 87 */ |
89 WebInspector.ExtensionAuditCategoryResults = function(category, target, ruleResu
ltCallback, categoryDoneCallback, progress) | 88 WebInspector.AuditExtensionCategoryResults = function(category, target, ruleResu
ltCallback, categoryDoneCallback, progress) |
90 { | 89 { |
91 this._target = target; | 90 this._target = target; |
92 this._category = category; | 91 this._category = category; |
93 this._ruleResultCallback = ruleResultCallback; | 92 this._ruleResultCallback = ruleResultCallback; |
94 this._categoryDoneCallback = categoryDoneCallback; | 93 this._categoryDoneCallback = categoryDoneCallback; |
95 this._progress = progress; | 94 this._progress = progress; |
96 this._progress.setTotalWork(1); | 95 this._progress.setTotalWork(1); |
97 this._expectedResults = category._ruleCount; | 96 this._expectedResults = category._ruleCount; |
98 this._actualResults = 0; | 97 this._actualResults = 0; |
99 | 98 |
100 this.id = category.id + "-" + ++WebInspector.ExtensionAuditCategoryResults._
lastId; | 99 this._id = category.id + "-" + ++WebInspector.AuditExtensionCategoryResults.
_lastId; |
101 } | 100 } |
102 | 101 |
103 WebInspector.ExtensionAuditCategoryResults.prototype = { | 102 WebInspector.AuditExtensionCategoryResults.prototype = { |
| 103 /** |
| 104 * @return {string} |
| 105 */ |
| 106 id: function() |
| 107 { |
| 108 return this._id; |
| 109 }, |
| 110 |
104 done: function() | 111 done: function() |
105 { | 112 { |
106 this._category._server.stopAuditRun(this); | 113 WebInspector.extensionServer.stopAuditRun(this); |
107 this._progress.done(); | 114 this._progress.done(); |
108 this._categoryDoneCallback(); | 115 this._categoryDoneCallback(); |
109 }, | 116 }, |
110 | 117 |
| 118 /** |
| 119 * @param {string} displayName |
| 120 * @param {string} description |
| 121 * @param {string} severity |
| 122 * @param {!Object} details |
| 123 */ |
111 addResult: function(displayName, description, severity, details) | 124 addResult: function(displayName, description, severity, details) |
112 { | 125 { |
113 var result = new WebInspector.AuditRuleResult(displayName); | 126 var result = new WebInspector.AuditRuleResult(displayName); |
114 result.addChild(description); | 127 result.addChild(description); |
115 result.severity = severity; | 128 result.severity = severity; |
116 if (details) | 129 if (details) |
117 this._addNode(result, details); | 130 this._addNode(result, details); |
118 this._addResult(result); | 131 this._addResult(result); |
119 }, | 132 }, |
120 | 133 |
121 _addNode: function(parent, node) | 134 _addNode: function(parent, node) |
122 { | 135 { |
123 var contents = WebInspector.auditFormatters.partiallyApply(WebInspector.
ExtensionAuditFormatters, this, node.contents); | 136 var contents = WebInspector.auditFormatters.partiallyApply(WebInspector.
AuditExtensionFormatters, this, node.contents); |
124 var addedNode = parent.addChild(contents, node.expanded); | 137 var addedNode = parent.addChild(contents, node.expanded); |
125 if (node.children) { | 138 if (node.children) { |
126 for (var i = 0; i < node.children.length; ++i) | 139 for (var i = 0; i < node.children.length; ++i) |
127 this._addNode(addedNode, node.children[i]); | 140 this._addNode(addedNode, node.children[i]); |
128 } | 141 } |
129 }, | 142 }, |
130 | 143 |
131 _addResult: function(result) | 144 _addResult: function(result) |
132 { | 145 { |
133 this._ruleResultCallback(result); | 146 this._ruleResultCallback(result); |
(...skipping 17 matching lines...) Expand all Loading... |
151 * @param {string} expression | 164 * @param {string} expression |
152 * @param {?Object} evaluateOptions | 165 * @param {?Object} evaluateOptions |
153 * @param {function(!WebInspector.RemoteObject)} callback | 166 * @param {function(!WebInspector.RemoteObject)} callback |
154 */ | 167 */ |
155 evaluate: function(expression, evaluateOptions, callback) | 168 evaluate: function(expression, evaluateOptions, callback) |
156 { | 169 { |
157 /** | 170 /** |
158 * @param {?string} error | 171 * @param {?string} error |
159 * @param {!RuntimeAgent.RemoteObject} result | 172 * @param {!RuntimeAgent.RemoteObject} result |
160 * @param {boolean=} wasThrown | 173 * @param {boolean=} wasThrown |
161 * @this {WebInspector.ExtensionAuditCategoryResults} | 174 * @this {WebInspector.AuditExtensionCategoryResults} |
162 */ | 175 */ |
163 function onEvaluate(error, result, wasThrown) | 176 function onEvaluate(error, result, wasThrown) |
164 { | 177 { |
165 if (wasThrown) | 178 if (wasThrown) |
166 return; | 179 return; |
167 var object = this._target.runtimeModel.createRemoteObject(result); | 180 var object = this._target.runtimeModel.createRemoteObject(result); |
168 callback(object); | 181 callback(object); |
169 } | 182 } |
170 this._category._server.evaluate(expression, false, false, evaluateOption
s, this._category._extensionOrigin, onEvaluate.bind(this)); | 183 WebInspector.extensionServer.evaluate(expression, false, false, evaluate
Options, this._category._extensionOrigin, onEvaluate.bind(this)); |
171 } | 184 } |
172 } | 185 } |
173 | 186 |
174 WebInspector.ExtensionAuditFormatters = { | 187 WebInspector.AuditExtensionFormatters = { |
175 /** | 188 /** |
176 * @this {WebInspector.ExtensionAuditCategoryResults} | 189 * @this {WebInspector.AuditExtensionCategoryResults} |
177 * @param {string} expression | 190 * @param {string} expression |
178 * @param {string} title | 191 * @param {string} title |
179 * @param {?Object} evaluateOptions | 192 * @param {?Object} evaluateOptions |
180 * @return {!Element} | 193 * @return {!Element} |
181 */ | 194 */ |
182 object: function(expression, title, evaluateOptions) | 195 object: function(expression, title, evaluateOptions) |
183 { | 196 { |
184 var parentElement = createElement("div"); | 197 var parentElement = createElement("div"); |
185 function onEvaluate(remoteObject) | 198 function onEvaluate(remoteObject) |
186 { | 199 { |
187 var section = new WebInspector.ObjectPropertiesSection(remoteObject,
title); | 200 var section = new WebInspector.ObjectPropertiesSection(remoteObject,
title); |
188 section.expanded = true; | 201 section.expanded = true; |
189 section.editable = false; | 202 section.editable = false; |
190 parentElement.appendChild(section.element); | 203 parentElement.appendChild(section.element); |
191 } | 204 } |
192 this.evaluate(expression, evaluateOptions, onEvaluate); | 205 this.evaluate(expression, evaluateOptions, onEvaluate); |
193 return parentElement; | 206 return parentElement; |
194 }, | 207 }, |
195 | 208 |
196 /** | 209 /** |
197 * @this {WebInspector.ExtensionAuditCategoryResults} | 210 * @this {WebInspector.AuditExtensionCategoryResults} |
198 * @param {string} expression | 211 * @param {string} expression |
199 * @param {?Object} evaluateOptions | 212 * @param {?Object} evaluateOptions |
200 * @return {!Element} | 213 * @return {!Element} |
201 */ | 214 */ |
202 node: function(expression, evaluateOptions) | 215 node: function(expression, evaluateOptions) |
203 { | 216 { |
204 var parentElement = createElement("div"); | 217 var parentElement = createElement("div"); |
205 this.evaluate(expression, evaluateOptions, onEvaluate); | 218 this.evaluate(expression, evaluateOptions, onEvaluate); |
206 | 219 |
207 /** | 220 /** |
208 * @param {!WebInspector.RemoteObject} remoteObject | 221 * @param {!WebInspector.RemoteObject} remoteObject |
209 */ | 222 */ |
210 function onEvaluate(remoteObject) | 223 function onEvaluate(remoteObject) |
211 { | 224 { |
212 WebInspector.Renderer.renderPromise(remoteObject).then(appendRendere
r).thenOrCatch(remoteObject.release.bind(remoteObject)).done(); | 225 WebInspector.Renderer.renderPromise(remoteObject).then(appendRendere
r).thenOrCatch(remoteObject.release.bind(remoteObject)).done(); |
213 | 226 |
214 /** | 227 /** |
215 * @param {!Element} element | 228 * @param {!Element} element |
216 */ | 229 */ |
217 function appendRenderer(element) | 230 function appendRenderer(element) |
218 { | 231 { |
219 parentElement.appendChild(element); | 232 parentElement.appendChild(element); |
220 } | 233 } |
221 } | 234 } |
222 return parentElement; | 235 return parentElement; |
223 } | 236 } |
224 } | 237 } |
225 | 238 |
226 WebInspector.ExtensionAuditCategoryResults._lastId = 0; | 239 WebInspector.AuditExtensionCategoryResults._lastId = 0; |
OLD | NEW |