OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 var mouseUpEvent = new MouseEvent('mouseup', {bubbles: true, detail: 1}); | 403 var mouseUpEvent = new MouseEvent('mouseup', {bubbles: true, detail: 1}); |
404 var resultMouseUp = test.util.sync.sendEvent( | 404 var resultMouseUp = test.util.sync.sendEvent( |
405 contentWindow, targetQuery, mouseUpEvent, opt_iframeQuery); | 405 contentWindow, targetQuery, mouseUpEvent, opt_iframeQuery); |
406 var clickEvent = new MouseEvent('click', {bubbles: true, detail: 1}); | 406 var clickEvent = new MouseEvent('click', {bubbles: true, detail: 1}); |
407 var resultClick = test.util.sync.sendEvent( | 407 var resultClick = test.util.sync.sendEvent( |
408 contentWindow, targetQuery, clickEvent, opt_iframeQuery); | 408 contentWindow, targetQuery, clickEvent, opt_iframeQuery); |
409 return resultMouseOver && resultMouseDown && resultMouseUp && resultClick; | 409 return resultMouseOver && resultMouseDown && resultMouseUp && resultClick; |
410 }; | 410 }; |
411 | 411 |
412 /** | 412 /** |
| 413 * Simulates a fake mouse click (right button, single click) on the element |
| 414 * specified by |targetQuery|. |
| 415 * |
| 416 * @param {Window} contentWindow Window to be tested. |
| 417 * @param {string} targetQuery Query to specify the element. |
| 418 * @param {string=} opt_iframeQuery Optional iframe selector. |
| 419 * @return {boolean} True if the event is sent to the target, false |
| 420 * otherwise. |
| 421 */ |
| 422 test.util.sync.fakeMouseRightClick = function( |
| 423 contentWindow, targetQuery, opt_iframeQuery) { |
| 424 var contextMenuEvent = new MouseEvent('contextmenu', {bubbles: true}); |
| 425 var result = test.util.sync.sendEvent( |
| 426 contentWindow, targetQuery, contextMenuEvent, opt_iframeQuery); |
| 427 return result; |
| 428 }; |
| 429 |
| 430 /** |
413 * Simulates a fake double click event (left button) to the element specified by | 431 * Simulates a fake double click event (left button) to the element specified by |
414 * |targetQuery|. | 432 * |targetQuery|. |
415 * | 433 * |
416 * @param {Window} contentWindow Window to be tested. | 434 * @param {Window} contentWindow Window to be tested. |
417 * @param {string} targetQuery Query to specify the element. | 435 * @param {string} targetQuery Query to specify the element. |
418 * @param {string=} opt_iframeQuery Optional iframe selector. | 436 * @param {string=} opt_iframeQuery Optional iframe selector. |
419 * @return {boolean} True if the event is sent to the target, false otherwise. | 437 * @return {boolean} True if the event is sent to the target, false otherwise. |
420 */ | 438 */ |
421 test.util.sync.fakeMouseDoubleClick = function( | 439 test.util.sync.fakeMouseDoubleClick = function( |
422 contentWindow, targetQuery, opt_iframeQuery) { | 440 contentWindow, targetQuery, opt_iframeQuery) { |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 return false; | 687 return false; |
670 } else { | 688 } else { |
671 console.error('Invalid function name.'); | 689 console.error('Invalid function name.'); |
672 return false; | 690 return false; |
673 } | 691 } |
674 }); | 692 }); |
675 }; | 693 }; |
676 | 694 |
677 // Register the test utils. | 695 // Register the test utils. |
678 test.util.registerRemoteTestUtils(); | 696 test.util.registerRemoteTestUtils(); |
OLD | NEW |