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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/wpt/uievents/resources/eventrecorder.js

Issue 2446483002: Import wpt@c5a14f553cba5f197743b9af605a84eddd8692a2 (Closed)
Patch Set: Created 4 years, 2 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
OLDNEW
1 // interface EventRecorder { 1 // interface EventRecorder {
2 // static void start(); 2 // static void start();
3 // static void stop(); 3 // static void stop();
4 // static void clearRecords(); 4 // static void clearRecords();
5 // static sequence<EventRecord> getRecords(); 5 // static sequence<EventRecord> getRecords();
6 // static void configure(EventRecorderOptions options); 6 // static void configure(EventRecorderOptions options);
7 // }; 7 // };
8 // * getRecords 8 // * getRecords
9 // * returns an array of EventRecord objects; the array represents the sequenc e of events captured at anytime after the last clear() 9 // * returns an array of EventRecord objects; the array represents the sequenc e of events captured at anytime after the last clear()
10 // call, between when the recorder was started and stopped (includin g multiple start/stop pairs) 10 // call, between when the recorder was started and stopped (includin g multiple start/stop pairs)
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 }, 133 },
134 clearRecords: { 134 clearRecords: {
135 enumerable: true, configurable: true, writable: true, value: functio n clearRecords() { 135 enumerable: true, configurable: true, writable: true, value: functio n clearRecords() {
136 rawOrder = 1; 136 rawOrder = 1;
137 allRecords = []; 137 allRecords = [];
138 } 138 }
139 }, 139 },
140 getRecords: { 140 getRecords: {
141 enumerable: true, configurable: true, writable: true, value: functio n getRecords() { return allRecords; } 141 enumerable: true, configurable: true, writable: true, value: functio n getRecords() { return allRecords; }
142 }, 142 },
143 checkRecords: {
144 enumerable: true, configurable: true, writable: true, value: functio n checkRecords(expected) {
145 if (expected.length < allRecords.length) {
146 return false;
147 }
148 var j = 0;
149 for (var i = 0; i < expected.length; ++i) {
150 if (j >= allRecords.length) {
151 if (expected[i].optional) {
152 continue;
153 }
154 return false;
155 }
156 if (expected[i].type == allRecords[j].event.type && expected[i ].target == allRecords[j].event.currentTarget) {
157 ++j;
158 continue;
159 }
160 if (expected[i].optional) {
161 continue;
162 }
163 return false;
164 }
165 return true;
166 }
167 },
143 configure: { 168 configure: {
144 enumerable: true, configurable: true, writable: true, value: functio n configure(options) { 169 enumerable: true, configurable: true, writable: true, value: functio n configure(options) {
145 if (allRecords.length > 0) 170 if (allRecords.length > 0)
146 throw new Error("Wrong time to call me: EventRecorder.configur e must only be called when no recorded events are present. Try 'clearRecords' fi rst."); 171 throw new Error("Wrong time to call me: EventRecorder.configur e must only be called when no recorded events are present. Try 'clearRecords' fi rst.");
147 172
148 // Un-configure existing options by calling again with no options set... 173 // Un-configure existing options by calling again with no options set...
149 mergeTypesTruthMap = {}; 174 mergeTypesTruthMap = {};
150 knownObjectsMap = eventConstructorsNameMap; 175 knownObjectsMap = eventConstructorsNameMap;
151 176
152 if (!(options instanceof Object)) 177 if (!(options instanceof Object))
153 return; 178 return;
154 // Sanitize the passed object (tease-out getter functions) 179 // Sanitize the passed object (tease-out getter functions)
155 var sanitizedOptions = {}; 180 var sanitizedOptions = {};
156 for (var x in options) { 181 for (var x in options) {
157 sanitizedOptions[x] = options[x]; 182 sanitizedOptions[x] = options[x];
158 } 183 }
159 if (sanitizedOptions.mergeEventTypes && Array.isArray(sanitizedOp tions.mergeEventTypes)) { 184 if (sanitizedOptions.mergeEventTypes && Array.isArray(sanitizedOp tions.mergeEventTypes)) {
160 sanitizedOptions.mergeEventTypes.forEach(function (eventType) { 185 sanitizedOptions.mergeEventTypes.forEach(function (eventType) {
161 if (typeof eventType == "string") 186 if (typeof eventType == "string")
162 mergeTypesTruthMap[eventType] = true; 187 mergeTypesTruthMap[eventType] = true;
163 }); 188 });
164 } 189 }
165 if (sanitizedOptions.objectMap && (sanitizedOptions.objectMap ins tanceof Object)) { 190 if (sanitizedOptions.objectMap && (sanitizedOptions.objectMap ins tanceof Object)) {
166 for (var y in sanitizedOptions.objectMap) { 191 for (var y in sanitizedOptions.objectMap) {
167 knownObjectsMap.set(sanitizedOptions.objectMap[y], y); 192 knownObjectsMap.set(sanitizedOptions.objectMap[y], y);
168 } 193 }
169 } 194 }
170 } 195 }
196 },
197 addEventListenersForNodes: {
198 enumerable: true, configurable: true, writable: true, value: functio n addEventListenersForNodes(events, nodes, handler) {
199 for (var i = 0; i < nodes.length; ++i) {
200 for (var j = 0; j < events.length; ++j) {
201 nodes[i].addRecordedEventListener(events[j], handler);
202 }
203 }
204 }
171 } 205 }
172 }) 206 })
173 }); 207 });
174 208
175 function EventRecord(rawEvent) { 209 function EventRecord(rawEvent) {
176 this.chronologicalOrder = rawOrder++; 210 this.chronologicalOrder = rawOrder++;
177 this.sequentialOccurrences = 1; 211 this.sequentialOccurrences = 1;
178 this.nestedEvents = null; // potentially a [] 212 this.nestedEvents = null; // potentially a []
179 this.interfaceType = knownObjectsMap.get(rawEvent.constructor); 213 this.interfaceType = knownObjectsMap.get(rawEvent.constructor);
180 if (!this.interfaceType) // In case (somehow) this event's constructor is not named something with an 'Event' suffix... 214 if (!this.interfaceType) // In case (somehow) this event's constructor is not named something with an 'Event' suffix...
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 removeRecordedEventListener: { 308 removeRecordedEventListener: {
275 enumerable: true, writable: true, configurable: true, 309 enumerable: true, writable: true, configurable: true,
276 value: function addRecordedEventListener(type, handler, capture) { 310 value: function addRecordedEventListener(type, handler, capture) {
277 var alternateHandlerUsed = handlerMap.get(handler); 311 var alternateHandlerUsed = handlerMap.get(handler);
278 this.removeEventListenter(type, alternateHandlerUsed ? alternateHand lerUsed : recordedEventHandler, capture); 312 this.removeEventListenter(type, alternateHandlerUsed ? alternateHand lerUsed : recordedEventHandler, capture);
279 } 313 }
280 } 314 }
281 }); 315 });
282 316
283 })(window); 317 })(window);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698