OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 print("Check internal properties reported in object preview."); | |
dgozman
2016/10/07 00:00:18
object-preview.js
kozy
2016/10/07 00:20:31
Done.
| |
6 | |
7 Protocol.Debugger.enable(); | |
8 Protocol.Runtime.enable(); | |
9 Protocol.Runtime.onConsoleAPICalled(dumpInternalPropertiesAndEntries); | |
10 | |
11 InspectorTest.runTestSuite([ | |
12 function boxedObjects(next) | |
13 { | |
14 checkExpression("new Number(239)") | |
15 .then(() => checkExpression("new Boolean(false)")) | |
16 .then(() => checkExpression("new String(\"abc\")")) | |
17 .then(() => checkExpression("Object(Symbol(42))")) | |
18 .then(next); | |
19 }, | |
20 | |
21 function promise(next) | |
22 { | |
23 checkExpression("Promise.resolve(42)") | |
24 .then(() => checkExpression("new Promise(() => undefined)")) | |
25 .then(next); | |
26 }, | |
27 | |
28 function generatorObject(next) | |
29 { | |
30 checkExpression("(function* foo() { yield 1 })()") | |
31 .then(next); | |
32 }, | |
33 | |
34 function entriesInMapAndSet(next) | |
35 { | |
36 checkExpression("new Map([[1,2]])") | |
37 .then(() => checkExpression("new Set([1])")) | |
38 .then(() => checkExpression("new WeakMap([[{}, 42]])")) | |
39 .then(() => checkExpression("new WeakSet([{}])")) | |
40 .then(next); | |
41 }, | |
42 | |
43 function iteratorObject(next) | |
44 { | |
45 checkExpression("(new Map([[1,2]])).entries()") | |
46 .then(() => checkExpression("(new Set([[1,2]])).entries()")) | |
47 .then(next); | |
48 }, | |
49 | |
50 function noPreviewForFunctionObject(next) | |
51 { | |
52 var expression = "(function foo(){})"; | |
53 InspectorTest.log(expression); | |
54 Protocol.Runtime.evaluate({ expression: expression, generatePreview: true}) | |
55 .then(message => InspectorTest.logMessage(message)) | |
56 .then(next); | |
57 }, | |
58 | |
59 function otherObjects(next) | |
60 { | |
61 checkExpression("[1,2,3]") | |
62 .then(() => checkExpression("/123/")) | |
63 .then(() => checkExpression("({})")) | |
64 .then(next); | |
65 } | |
66 ]); | |
67 | |
68 function checkExpression(expression) | |
69 { | |
70 InspectorTest.log(`expression: ${expression}`); | |
71 // console.table has higher limits for internal properties amount in preview. | |
72 return Protocol.Runtime.evaluate({ expression: `console.table(${expression})`, generatePreview: true }); | |
73 } | |
74 | |
75 function dumpInternalPropertiesAndEntries(message) | |
76 { | |
77 var properties; | |
78 var entries; | |
79 try { | |
80 var preview = message.params.args[0].preview; | |
81 properties = preview.properties; | |
82 entries = preview.entries; | |
83 } catch (e) { | |
84 InspectorTest.logMessage(message); | |
85 return; | |
86 } | |
87 if (!properties) { | |
88 InspectorTest.logMessage(message); | |
89 return; | |
90 } | |
91 for (var property of properties) { | |
92 if (property.name.startsWith("[[")) | |
93 InspectorTest.logMessage(property); | |
94 } | |
95 if (entries) { | |
96 InspectorTest.log("[[Entries]]:"); | |
97 InspectorTest.logMessage(entries); | |
98 } | |
99 InspectorTest.log(""); | |
100 } | |
OLD | NEW |