Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(516)

Side by Side Diff: third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-getProperties.html

Issue 1950303004: [DevTools] Add additional accessor check in InjectedScriptSource.js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-getProperties-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <html> 1 <html>
2 <head> 2 <head>
3 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspecto r-protocol-test.js"></script> 3 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspecto r-protocol-test.js"></script>
4 <script> 4 <script>
5 5
6 function test() 6 function test()
7 { 7 {
8 // A general-purpose engine for sending a sequence of protocol commands. 8 // A general-purpose engine for sending a sequence of protocol commands.
9 // The clients provide requests and response handlers, while the engine catc hes 9 // The clients provide requests and response handlers, while the engine catc hes
10 // errors and makes sure that once there's nothing to do completeTest() is c alled. 10 // errors and makes sure that once there's nothing to do completeTest() is c alled.
11 // @param step is an object with command, params and callback fields 11 // @param step is an object with command, params and callback fields
12 function runRequestSeries(step) 12 function runRequestSeries(step)
13 { 13 {
14 processStep(step); 14 processStep(step);
15 15
16 function processStep(s) 16 function processStep(s)
17 { 17 {
18 try { 18 try {
19 processStepOrFail(s); 19 processStepOrFail(s);
20 } catch (e) { 20 } catch (e) {
21 InspectorTest.log(e.stack); 21 InspectorTest.log(e.stack);
22 InspectorTest.completeTest(); 22 InspectorTest.completeTest();
23 } 23 }
24 } 24 }
25 25
26 function processStepOrFail(s) 26 function processStepOrFail(s)
27 { 27 {
28 if (!s) { 28 if (!s) {
29 InspectorTest.completeTest(); 29 InspectorTest.completeTest();
30 return; 30 return;
31 } 31 }
32 if (!s.command) { 32 if (!s.command) {
33 // A simple loopback step. 33 // A simple loopback step.
34 var next = s.callback(); 34 var next = s.callback();
35 processStep(next); 35 processStep(next);
(...skipping 13 matching lines...) Expand all
49 } catch (e) { 49 } catch (e) {
50 InspectorTest.log(e.stack); 50 InspectorTest.log(e.stack);
51 InspectorTest.completeTest(); 51 InspectorTest.completeTest();
52 return; 52 return;
53 } 53 }
54 processStep(next); 54 processStep(next);
55 } 55 }
56 InspectorTest.sendCommand(s.command, s.params, innerCallback); 56 InspectorTest.sendCommand(s.command, s.params, innerCallback);
57 } 57 }
58 } 58 }
59 59
60 var firstStep = { callback: callbackStart5 }; 60 var firstStep = { callback: callbackStart5 };
61 61
62 runRequestSeries(firstStep); 62 runRequestSeries(firstStep);
63 63
64 // 'Object5' section -- check properties of '5' wrapped as object (has an i nternal property). 64 // 'Object5' section -- check properties of '5' wrapped as object (has an i nternal property).
65 65
66 function callbackStart5() 66 function callbackStart5()
67 { 67 {
68 // Create an wrapper object with additional property. 68 // Create an wrapper object with additional property.
69 var expression = "(function(){var r = Object(5); r.foo = 'cat';return r; })()"; 69 var expression = "(function(){var r = Object(5); r.foo = 'cat';return r; })()";
70 70
71 return { command: "Runtime.evaluate", params: {expression: expression}, callback: callbackEval5 }; 71 return { command: "Runtime.evaluate", params: {expression: expression}, callback: callbackEval5 };
72 } 72 }
73 function callbackEval5(result) 73 function callbackEval5(result)
74 { 74 {
75 var id = result.result.objectId; 75 var id = result.result.objectId;
76 if (id === undefined) 76 if (id === undefined)
77 throw new Error("objectId is expected"); 77 throw new Error("objectId is expected");
78 return { 78 return {
79 command: "Runtime.getProperties", params: {objectId: id, ownProperti es: true}, callback: callbackProperties5 79 command: "Runtime.getProperties", params: {objectId: id, ownProperti es: true}, callback: callbackProperties5
80 }; 80 };
81 } 81 }
82 function callbackProperties5(result) 82 function callbackProperties5(result)
83 { 83 {
84 logGetPropertiesResult("Object(5)", result); 84 logGetPropertiesResult("Object(5)", result);
85 return { callback: callbackStartNotOwn }; 85 return { callback: callbackStartNotOwn };
86 } 86 }
87 87
88 88
89 // 'Not own' section -- check all properties of the object, including ones f rom it prototype chain. 89 // 'Not own' section -- check all properties of the object, including ones f rom it prototype chain.
90 90
91 function callbackStartNotOwn() 91 function callbackStartNotOwn()
92 { 92 {
93 // Create an wrapper object with additional property. 93 // Create an wrapper object with additional property.
94 var expression = "({ a: 2, set b(_) {}, get b() {return 5;}, __proto__: { a: 3, c: 4, get d() {return 6;} }})"; 94 var expression = "({ a: 2, set b(_) {}, get b() {return 5;}, __proto__: { a: 3, c: 4, get d() {return 6;} }})";
95 95
96 return { command: "Runtime.evaluate", params: {expression: expression}, callback: callbackEvalNotOwn }; 96 return { command: "Runtime.evaluate", params: {expression: expression}, callback: callbackEvalNotOwn };
97 } 97 }
98 function callbackEvalNotOwn(result) 98 function callbackEvalNotOwn(result)
99 { 99 {
100 var id = result.result.objectId; 100 var id = result.result.objectId;
101 if (id === undefined) 101 if (id === undefined)
102 throw new Error("objectId is expected"); 102 throw new Error("objectId is expected");
103 return { 103 return {
104 command: "Runtime.getProperties", params: {objectId: id, ownProperti es: false}, callback: callbackPropertiesNotOwn 104 command: "Runtime.getProperties", params: {objectId: id, ownProperti es: false}, callback: callbackPropertiesNotOwn
105 }; 105 };
106 } 106 }
107 function callbackPropertiesNotOwn(result) 107 function callbackPropertiesNotOwn(result)
108 { 108 {
109 logGetPropertiesResult("Not own properties", result); 109 logGetPropertiesResult("Not own properties", result);
110 return { callback: callbackStartAccessorsOnly }; 110 return { callback: callbackStartAccessorsOnly };
111 } 111 }
112 112
113 113
114 // 'Accessors only' section -- check only accessor properties of the object. 114 // 'Accessors only' section -- check only accessor properties of the object.
115 115
116 function callbackStartAccessorsOnly() 116 function callbackStartAccessorsOnly()
117 { 117 {
118 // Create an wrapper object with additional property. 118 // Create an wrapper object with additional property.
119 var expression = "({ a: 2, set b(_) {}, get b() {return 5;}, c: 'c', set d(_){} })"; 119 var expression = "({ a: 2, set b(_) {}, get b() {return 5;}, c: 'c', set d(_){} })";
120 120
121 return { command: "Runtime.evaluate", params: {expression: expression}, callback: callbackEvalAccessorsOnly }; 121 return { command: "Runtime.evaluate", params: {expression: expression}, callback: callbackEvalAccessorsOnly };
122 } 122 }
123 function callbackEvalAccessorsOnly(result) 123 function callbackEvalAccessorsOnly(result)
124 { 124 {
125 var id = result.result.objectId; 125 var id = result.result.objectId;
126 if (id === undefined) 126 if (id === undefined)
127 throw new Error("objectId is expected"); 127 throw new Error("objectId is expected");
128 return { 128 return {
129 command: "Runtime.getProperties", params: {objectId: id, ownProperti es: true, accessorPropertiesOnly: true}, callback: callbackPropertiesAccessorsOn ly 129 command: "Runtime.getProperties", params: {objectId: id, ownProperti es: true, accessorPropertiesOnly: true}, callback: callbackPropertiesAccessorsOn ly
130 }; 130 };
131 } 131 }
132 function callbackPropertiesAccessorsOnly(result) 132 function callbackPropertiesAccessorsOnly(result)
133 { 133 {
134 logGetPropertiesResult("Accessor only properties", result); 134 logGetPropertiesResult("Accessor only properties", result);
135 return { callback: callbackStartArray }; 135 return { callback: callbackStartArray };
136 } 136 }
137 137
138 138
139 // 'Array' section -- check properties of an array. 139 // 'Array' section -- check properties of an array.
140 140
141 function callbackStartArray() 141 function callbackStartArray()
142 { 142 {
143 var expression = "['red', 'green', 'blue']"; 143 var expression = "['red', 'green', 'blue']";
144 return { command: "Runtime.evaluate", params: {expression: expression}, callback: callbackEvalArray }; 144 return { command: "Runtime.evaluate", params: {expression: expression}, callback: callbackEvalArray };
145 } 145 }
146 function callbackEvalArray(result) 146 function callbackEvalArray(result)
147 { 147 {
148 var id = result.result.objectId; 148 var id = result.result.objectId;
149 if (id === undefined) 149 if (id === undefined)
150 throw new Error("objectId is expected"); 150 throw new Error("objectId is expected");
151 return { 151 return {
152 command: "Runtime.getProperties", params: {objectId: id, ownProperti es: true}, callback: callbackPropertiesArray 152 command: "Runtime.getProperties", params: {objectId: id, ownProperti es: true}, callback: callbackPropertiesArray
153 }; 153 };
154 } 154 }
155 function callbackPropertiesArray(result) 155 function callbackPropertiesArray(result)
156 { 156 {
157 logGetPropertiesResult("array", result); 157 logGetPropertiesResult("array", result);
158 return { callback: callbackStartBound }; 158 return { callback: callbackStartBound };
159 } 159 }
160 160
161 161
162 // 'Bound' section -- check properties of a bound function (has a bunch of i nternal properties). 162 // 'Bound' section -- check properties of a bound function (has a bunch of i nternal properties).
163 163
164 function callbackStartBound() 164 function callbackStartBound()
165 { 165 {
166 var expression = "Number.bind({}, 5)"; 166 var expression = "Number.bind({}, 5)";
167 return { command: "Runtime.evaluate", params: {expression: expression}, callback: callbackEvalBound }; 167 return { command: "Runtime.evaluate", params: {expression: expression}, callback: callbackEvalBound };
168 } 168 }
169 function callbackEvalBound(result) 169 function callbackEvalBound(result)
170 { 170 {
171 var id = result.result.objectId; 171 var id = result.result.objectId;
172 if (id === undefined) 172 if (id === undefined)
173 throw new Error("objectId is expected"); 173 throw new Error("objectId is expected");
174 return { 174 return {
175 command: "Runtime.getProperties", params: {objectId: id, ownProperti es: true}, callback: callbackPropertiesBound 175 command: "Runtime.getProperties", params: {objectId: id, ownProperti es: true}, callback: callbackPropertiesBound
176 }; 176 };
177 } 177 }
178 function callbackPropertiesBound(result) 178 function callbackPropertiesBound(result)
179 { 179 {
180 logGetPropertiesResult("Bound function", result); 180 logGetPropertiesResult("Bound function", result);
181 return { callback: callbackStartUserDefinedPropertyOnEvent };
182 }
183
184 function callbackStartUserDefinedPropertyOnEvent()
185 {
186 var expression = "var e = document.createEvent(\"Event\"); Object.define Property(e, \"eventPhase\", { get: function() { return 239; } })";
187 return { command: "Runtime.evaluate", params: {expression: expression}, callback: callbackEvalUserDefinedPropertyOnEvent };
188 }
189 function callbackEvalUserDefinedPropertyOnEvent(result)
190 {
191 var id = result.result.objectId;
192 if (id === undefined)
193 throw new Error("objectId is expected");
194 return {
195 command: "Runtime.getProperties", params: {objectId: id, ownProperti es: true}, callback: callbackPropertiesUserDefinedPropertyOnEvent
196 };
197 }
198 function callbackPropertiesUserDefinedPropertyOnEvent(result)
199 {
200 logGetPropertiesResult("Event with user defined property", result);
181 return; // End of test 201 return; // End of test
182 } 202 }
183
184 203
185 // A helper function that dumps object properties and internal properties in sorted order. 204
205 // A helper function that dumps object properties and internal properties in sorted order.
186 function logGetPropertiesResult(title, protocolResult) 206 function logGetPropertiesResult(title, protocolResult)
187 { 207 {
188 function hasGetterSetter(property, fieldName) 208 function hasGetterSetter(property, fieldName)
189 { 209 {
190 var v = property[fieldName]; 210 var v = property[fieldName];
191 if (!v) 211 if (!v)
192 return false; 212 return false;
193 return v.type !== "undefined" 213 return v.type !== "undefined"
194 } 214 }
195 215
196 InspectorTest.log("Properties of " + title); 216 InspectorTest.log("Properties of " + title);
197 var propertyArray = protocolResult.result; 217 var propertyArray = protocolResult.result;
198 propertyArray.sort(NamedThingComparator); 218 propertyArray.sort(NamedThingComparator);
199 for (var i = 0; i < propertyArray.length; i++) { 219 for (var i = 0; i < propertyArray.length; i++) {
200 var p = propertyArray[i]; 220 var p = propertyArray[i];
201 var v = p.value; 221 var v = p.value;
202 var own = p.isOwn ? "own" : "inherited"; 222 var own = p.isOwn ? "own" : "inherited";
203 if (v) 223 if (v)
204 InspectorTest.log(" " + p.name + " " + own + " " + v.type + " " + v.value ); 224 InspectorTest.log(" " + p.name + " " + own + " " + v.type + " " + v.value );
205 else 225 else
206 InspectorTest.log(" " + p.name + " " + own + " no value" + 226 InspectorTest.log(" " + p.name + " " + own + " no value" +
207 (hasGetterSetter(p, "get") ? ", getter" : "") + (hasGetterSe tter(p, "set") ? ", setter" : "")); 227 (hasGetterSetter(p, "get") ? ", getter" : "") + (hasGetterSe tter(p, "set") ? ", setter" : ""));
208 } 228 }
209 var internalPropertyArray = protocolResult.internalProperties; 229 var internalPropertyArray = protocolResult.internalProperties;
210 if (internalPropertyArray) { 230 if (internalPropertyArray) {
211 InspectorTest.log("Internal properties"); 231 InspectorTest.log("Internal properties");
212 internalPropertyArray.sort(NamedThingComparator); 232 internalPropertyArray.sort(NamedThingComparator);
213 for (var i = 0; i < internalPropertyArray.length; i++) { 233 for (var i = 0; i < internalPropertyArray.length; i++) {
214 var p = internalPropertyArray[i]; 234 var p = internalPropertyArray[i];
215 var v = p.value; 235 var v = p.value;
216 InspectorTest.log(" " + p.name + " " + v.type + " " + v.value); 236 InspectorTest.log(" " + p.name + " " + v.type + " " + v.value);
217 } 237 }
218 } 238 }
219 239
220 function NamedThingComparator(o1, o2) 240 function NamedThingComparator(o1, o2)
221 { 241 {
222 return o1.name === o2.name ? 0 : (o1.name < o2.name ? -1 : 1); 242 return o1.name === o2.name ? 0 : (o1.name < o2.name ? -1 : 1);
223 } 243 }
224 } 244 }
225 } 245 }
226 </script> 246 </script>
227 </head> 247 </head>
228 <body onLoad="runTest();"> 248 <body onLoad="runTest();">
229 </body> 249 </body>
230 </html> 250 </html>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-getProperties-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698