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

Side by Side Diff: ui/file_manager/file_manager/background/js/test_util_base.js

Issue 2046143002: Send 'key' from fake keyboard events generated by file_manager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix additional tests I missed Created 4 years, 6 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 // Copyright (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 The Chromium 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 /** 5 /**
6 * Namespace for test related things. 6 * Namespace for test related things.
7 */ 7 */
8 var test = test || {}; 8 var test = test || {};
9 9
10 /** 10 /**
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 return test.util.sync.sendEvent(contentWindow, targetQuery, event); 329 return test.util.sync.sendEvent(contentWindow, targetQuery, event);
330 }; 330 };
331 331
332 /** 332 /**
333 * Sends a fake key event to the element specified by |targetQuery| or active 333 * Sends a fake key event to the element specified by |targetQuery| or active
334 * element with the given |keyIdentifier| and optional |ctrl| modifier. 334 * element with the given |keyIdentifier| and optional |ctrl| modifier.
335 * 335 *
336 * @param {Window} contentWindow Window to be tested. 336 * @param {Window} contentWindow Window to be tested.
337 * @param {?string} targetQuery Query to specify the element. If this value is 337 * @param {?string} targetQuery Query to specify the element. If this value is
338 * null, key event is dispatched to active element of the document. 338 * null, key event is dispatched to active element of the document.
339 * @param {string} key DOM UI Events key value.
339 * @param {string} keyIdentifier Identifier of the emulated key. 340 * @param {string} keyIdentifier Identifier of the emulated key.
340 * @param {boolean} ctrl Whether CTRL should be pressed, or not. 341 * @param {boolean} ctrl Whether CTRL should be pressed, or not.
341 * @param {boolean} shift whether SHIFT should be pressed, or not. 342 * @param {boolean} shift whether SHIFT should be pressed, or not.
342 * @param {boolean} alt whether ALT should be pressed, or not. 343 * @param {boolean} alt whether ALT should be pressed, or not.
343 * @param {string=} opt_iframeQuery Optional iframe selector. 344 * @param {string=} opt_iframeQuery Optional iframe selector.
344 * @return {boolean} True if the event is sent to the target, false otherwise. 345 * @return {boolean} True if the event is sent to the target, false otherwise.
345 */ 346 */
346 test.util.sync.fakeKeyDown = function( 347 test.util.sync.fakeKeyDown = function(
347 contentWindow, targetQuery, keyIdentifier, ctrl, shift, alt, 348 contentWindow, targetQuery, key, keyIdentifier, ctrl, shift, alt,
348 opt_iframeQuery) { 349 opt_iframeQuery) {
349 var event = new KeyboardEvent('keydown', 350 var event = new KeyboardEvent('keydown',
350 { 351 {
351 bubbles: true, 352 bubbles: true,
353 key: key,
352 keyIdentifier: keyIdentifier, 354 keyIdentifier: keyIdentifier,
353 ctrlKey: ctrl, 355 ctrlKey: ctrl,
354 shiftKey: shift, 356 shiftKey: shift,
355 altKey: alt 357 altKey: alt
356 }); 358 });
357 return test.util.sync.sendEvent( 359 return test.util.sync.sendEvent(
358 contentWindow, targetQuery, event, opt_iframeQuery); 360 contentWindow, targetQuery, event, opt_iframeQuery);
359 }; 361 };
360 362
361 /** 363 /**
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 return true; 583 return true;
582 } else if (test.util.sync[request.func]) { 584 } else if (test.util.sync[request.func]) {
583 sendResponse(test.util.sync[request.func].apply(null, args)); 585 sendResponse(test.util.sync[request.func].apply(null, args));
584 return false; 586 return false;
585 } else { 587 } else {
586 console.error('Invalid function name.'); 588 console.error('Invalid function name.');
587 return false; 589 return false;
588 } 590 }
589 }); 591 });
590 }; 592 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698