OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 } | 655 } |
656 | 656 |
657 function finish() { | 657 function finish() { |
658 test.releaseControl(); | 658 test.releaseControl(); |
659 } | 659 } |
660 | 660 |
661 test.takeControl(); | 661 test.takeControl(); |
662 step1(); | 662 step1(); |
663 }; | 663 }; |
664 | 664 |
| 665 TestSuite.prototype.testDispatchKeyEventShowsAutoFill = function() { |
| 666 var test = this; |
| 667 var receivedReady = false; |
| 668 |
| 669 function signalToShowAutofill() { |
| 670 SDK.targetManager.mainTarget().inputAgent().invoke_dispatchKeyEvent( |
| 671 {type: 'rawKeyDown', key: 'Down', windowsVirtualKeyCode: 40, nativeVir
tualKeyCode: 40}); |
| 672 SDK.targetManager.mainTarget().inputAgent().invoke_dispatchKeyEvent( |
| 673 {type: 'keyUp', key: 'Down', windowsVirtualKeyCode: 40, nativeVirtualK
eyCode: 40}); |
| 674 } |
| 675 |
| 676 function selectTopAutoFill() { |
| 677 SDK.targetManager.mainTarget().inputAgent().invoke_dispatchKeyEvent( |
| 678 {type: 'rawKeyDown', key: 'Down', windowsVirtualKeyCode: 40, nativeVir
tualKeyCode: 40}); |
| 679 SDK.targetManager.mainTarget().inputAgent().invoke_dispatchKeyEvent( |
| 680 {type: 'keyUp', key: 'Down', windowsVirtualKeyCode: 40, nativeVirtualK
eyCode: 40}); |
| 681 SDK.targetManager.mainTarget().inputAgent().invoke_dispatchKeyEvent( |
| 682 {type: 'rawKeyDown', key: 'Enter', windowsVirtualKeyCode: 13, nativeVi
rtualKeyCode: 13}); |
| 683 SDK.targetManager.mainTarget().inputAgent().invoke_dispatchKeyEvent( |
| 684 {type: 'keyUp', key: 'Enter', windowsVirtualKeyCode: 13, nativeVirtual
KeyCode: 13}); |
| 685 |
| 686 test.evaluateInConsole_('document.getElementById("name").value', onResultO
fInput); |
| 687 } |
| 688 |
| 689 function onResultOfInput(value) { |
| 690 // Console adds "" around the response. |
| 691 test.assertEquals('"Abbf"', value); |
| 692 test.releaseControl(); |
| 693 } |
| 694 |
| 695 function onConsoleMessage(event) { |
| 696 var message = event.data.messageText; |
| 697 if (message === 'ready' && !receivedReady) { |
| 698 receivedReady = true; |
| 699 signalToShowAutofill(); |
| 700 } |
| 701 // This log comes from the browser unittest code. |
| 702 if (message === 'didShowSuggestions') |
| 703 selectTopAutoFill(); |
| 704 } |
| 705 |
| 706 this.takeControl(); |
| 707 |
| 708 // It is possible for the ready console messagage to be already received but
not handled |
| 709 // or received later. This ensures we can catch both cases. |
| 710 ConsoleModel.consoleModel.addEventListener(ConsoleModel.ConsoleModel.Events.
MessageAdded, onConsoleMessage, this); |
| 711 |
| 712 var messages = ConsoleModel.consoleModel.messages(); |
| 713 if (messages.length) { |
| 714 var text = messages[0].messageText; |
| 715 this.assertEquals('ready', text); |
| 716 signalToShowAutofill(); |
| 717 } |
| 718 }; |
| 719 |
665 TestSuite.prototype.testDispatchKeyEventDoesNotCrash = function() { | 720 TestSuite.prototype.testDispatchKeyEventDoesNotCrash = function() { |
666 SDK.targetManager.mainTarget().inputAgent().invoke_dispatchKeyEvent( | 721 SDK.targetManager.mainTarget().inputAgent().invoke_dispatchKeyEvent( |
667 {type: 'rawKeyDown', windowsVirtualKeyCode: 0x23, key: 'End'}); | 722 {type: 'rawKeyDown', windowsVirtualKeyCode: 0x23, key: 'End'}); |
668 SDK.targetManager.mainTarget().inputAgent().invoke_dispatchKeyEvent( | 723 SDK.targetManager.mainTarget().inputAgent().invoke_dispatchKeyEvent( |
669 {type: 'keyUp', windowsVirtualKeyCode: 0x23, key: 'End'}); | 724 {type: 'keyUp', windowsVirtualKeyCode: 0x23, key: 'End'}); |
670 }; | 725 }; |
671 | 726 |
672 TestSuite.prototype.testEmulateNetworkConditions = function() { | 727 TestSuite.prototype.testEmulateNetworkConditions = function() { |
673 var test = this; | 728 var test = this; |
674 | 729 |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1100 if (runtimeModel.executionContexts().length >= n) | 1155 if (runtimeModel.executionContexts().length >= n) |
1101 callback.call(null); | 1156 callback.call(null); |
1102 else | 1157 else |
1103 this.addSniffer(SDK.RuntimeModel.prototype, '_executionContextCreated',
checkForExecutionContexts.bind(this)); | 1158 this.addSniffer(SDK.RuntimeModel.prototype, '_executionContextCreated',
checkForExecutionContexts.bind(this)); |
1104 } | 1159 } |
1105 }; | 1160 }; |
1106 | 1161 |
1107 | 1162 |
1108 window.uiTests = new TestSuite(window.domAutomationController); | 1163 window.uiTests = new TestSuite(window.domAutomationController); |
1109 })(window); | 1164 })(window); |
OLD | NEW |