OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // A general-purpose engine for sending a sequence of protocol commands. | 5 // A general-purpose engine for sending a sequence of protocol commands. |
6 // The clients provide requests and response handlers, while the engine catches | 6 // The clients provide requests and response handlers, while the engine catches |
7 // errors and makes sure that once there's nothing to do completeTest() is calle
d. | 7 // errors and makes sure that once there's nothing to do completeTest() is calle
d. |
8 // @param step is an object with command, params and callback fields | 8 // @param step is an object with command, params and callback fields |
9 function runRequestSeries(step) | 9 function runRequestSeries(step) |
10 { | 10 { |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 var id = result.result.objectId; | 169 var id = result.result.objectId; |
170 if (id === undefined) | 170 if (id === undefined) |
171 throw new Error("objectId is expected"); | 171 throw new Error("objectId is expected"); |
172 return { | 172 return { |
173 command: "Runtime.getProperties", params: {objectId: id, ownProperties: true
}, callback: callbackPropertiesBound | 173 command: "Runtime.getProperties", params: {objectId: id, ownProperties: true
}, callback: callbackPropertiesBound |
174 }; | 174 }; |
175 } | 175 } |
176 function callbackPropertiesBound(result) | 176 function callbackPropertiesBound(result) |
177 { | 177 { |
178 logGetPropertiesResult("Bound function", result); | 178 logGetPropertiesResult("Bound function", result); |
| 179 return { callback: callbackStartObjectThrowsLength }; |
| 180 } |
| 181 |
| 182 |
| 183 // Object throws on length access |
| 184 |
| 185 function callbackStartObjectThrowsLength() { |
| 186 var expression = "({get length() { throw 'Length called'; }})"; |
| 187 return { command: "Runtime.evaluate", params: {expression: expression}, callba
ck: callbackEvalObjectThrowsLength }; |
| 188 } |
| 189 function callbackEvalObjectThrowsLength(result) { |
| 190 var id = result.result.objectId; |
| 191 if (id === undefined) |
| 192 throw new Error("objectId is expected"); |
| 193 return { |
| 194 command: "Runtime.getProperties", params: {objectId: id, ownProperties: true
}, callback: callbackPropertiesObjectThrowsLength |
| 195 }; |
| 196 } |
| 197 function callbackPropertiesObjectThrowsLength(result) { |
| 198 logGetPropertiesResult("Object that throws on length access", result); |
| 199 return { callback: callbackStartTypedArrayWithoutLength }; |
| 200 } |
| 201 |
| 202 |
| 203 // Typed array without length |
| 204 |
| 205 function callbackStartTypedArrayWithoutLength() { |
| 206 var expression = "({__proto__: Uint8Array.prototype})"; |
| 207 return { command: "Runtime.evaluate", params: {expression: expression}, callba
ck: callbackEvalTypedArrayWithoutLength }; |
| 208 } |
| 209 function callbackEvalTypedArrayWithoutLength(result) { |
| 210 var id = result.result.objectId; |
| 211 if (id === undefined) |
| 212 throw new Error("objectId is expected"); |
| 213 return { |
| 214 command: "Runtime.getProperties", params: {objectId: id, ownProperties: true
}, callback: callbackPropertiesTypedArrayWithoutLength |
| 215 }; |
| 216 } |
| 217 function callbackPropertiesTypedArrayWithoutLength(result) { |
| 218 logGetPropertiesResult("TypedArray without length", result); |
179 return; // End of test | 219 return; // End of test |
180 } | 220 } |
181 | 221 |
182 // A helper function that dumps object properties and internal properties in sor
ted order. | 222 // A helper function that dumps object properties and internal properties in sor
ted order. |
183 function logGetPropertiesResult(title, protocolResult) | 223 function logGetPropertiesResult(title, protocolResult) |
184 { | 224 { |
185 function hasGetterSetter(property, fieldName) | 225 function hasGetterSetter(property, fieldName) |
186 { | 226 { |
187 var v = property[fieldName]; | 227 var v = property[fieldName]; |
188 if (!v) | 228 if (!v) |
(...skipping 23 matching lines...) Expand all Loading... |
212 var v = p.value; | 252 var v = p.value; |
213 InspectorTest.log(" " + p.name + " " + v.type + " " + v.value); | 253 InspectorTest.log(" " + p.name + " " + v.type + " " + v.value); |
214 } | 254 } |
215 } | 255 } |
216 | 256 |
217 function NamedThingComparator(o1, o2) | 257 function NamedThingComparator(o1, o2) |
218 { | 258 { |
219 return o1.name === o2.name ? 0 : (o1.name < o2.name ? -1 : 1); | 259 return o1.name === o2.name ? 0 : (o1.name < o2.name ? -1 : 1); |
220 } | 260 } |
221 } | 261 } |
OLD | NEW |