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 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
658 } | 658 } |
659 | 659 |
660 function finish() { | 660 function finish() { |
661 test.releaseControl(); | 661 test.releaseControl(); |
662 } | 662 } |
663 | 663 |
664 test.takeControl(); | 664 test.takeControl(); |
665 step1(); | 665 step1(); |
666 }; | 666 }; |
667 | 667 |
668 TestSuite.prototype.testDispatchKeyEventShowsAutoFill = function() { | |
669 var test = this; | |
670 var receivedReady = false; | |
671 | |
672 function signalToShowAutofill() { | |
673 SDK.targetManager.mainTarget().inputAgent().invoke_dispatchKeyEvent( | |
674 {type: 'rawKeyDown', key: 'Down', windowsVirtualKeyCode: 40, nativeVir tualKeyCode: 40}); | |
675 SDK.targetManager.mainTarget().inputAgent().invoke_dispatchKeyEvent( | |
676 {type: 'keyUp', key: 'Down', windowsVirtualKeyCode: 40, nativeVirtualK eyCode: 40}); | |
677 } | |
678 | |
679 function selectTopAutoFill() { | |
680 SDK.targetManager.mainTarget().inputAgent().invoke_dispatchKeyEvent( | |
681 {type: 'rawKeyDown', key: 'Down', windowsVirtualKeyCode: 40, nativeVir tualKeyCode: 40}); | |
682 SDK.targetManager.mainTarget().inputAgent().invoke_dispatchKeyEvent( | |
683 {type: 'keyUp', key: 'Down', windowsVirtualKeyCode: 40, nativeVirtualK eyCode: 40}); | |
684 SDK.targetManager.mainTarget().inputAgent().invoke_dispatchKeyEvent( | |
685 {type: 'rawKeyDown', key: 'Enter', windowsVirtualKeyCode: 13, nativeVi rtualKeyCode: 13}); | |
686 SDK.targetManager.mainTarget().inputAgent().invoke_dispatchKeyEvent( | |
687 {type: 'keyUp', key: 'Enter', windowsVirtualKeyCode: 13, nativeVirtual KeyCode: 13}); | |
688 | |
689 test.evaluateInConsole_('document.getElementById("name").value', onResultO fInput); | |
690 } | |
691 | |
692 function onResultOfInput(value) { | |
693 // Console adds "" around the response. | |
694 test.assertEquals('"Abbf"', value); | |
695 test.releaseControl(); | |
696 } | |
697 | |
698 function onConsoleMessage(event) { | |
699 var message = event.data.messageText; | |
700 if (message === 'ready' && !receivedReady) { | |
701 receivedReady = true; | |
702 signalToShowAutofill(); | |
703 } | |
704 // This log comes from the browser unittest code. | |
705 if (message === 'didShowSuggestions') | |
706 selectTopAutoFill(); | |
707 } | |
708 | |
709 this.takeControl(); | |
710 | |
711 // It is possible for the ready console messagage to be already received but not handled | |
712 // or received later. This ensures we can catch both cases. | |
713 SDK.multitargetConsoleModel.addEventListener(SDK.ConsoleModel.Events.Message Added, onConsoleMessage, this); | |
dgozman
2017/06/08 23:52:27
This is ConsoleModel.consoleModel now.
allada
2017/06/09 18:19:00
Done.
| |
714 | |
715 var messages = SDK.multitargetConsoleModel.messages(); | |
716 if (messages.length) { | |
717 var text = messages[0].messageText; | |
718 this.assertEquals('ready', text); | |
719 signalToShowAutofill(); | |
720 } | |
721 }; | |
722 | |
668 TestSuite.prototype.testDispatchKeyEventDoesNotCrash = function() { | 723 TestSuite.prototype.testDispatchKeyEventDoesNotCrash = function() { |
669 SDK.targetManager.mainTarget().inputAgent().invoke_dispatchKeyEvent( | 724 SDK.targetManager.mainTarget().inputAgent().invoke_dispatchKeyEvent( |
670 {type: 'rawKeyDown', windowsVirtualKeyCode: 0x23, key: 'End'}); | 725 {type: 'rawKeyDown', windowsVirtualKeyCode: 0x23, key: 'End'}); |
671 SDK.targetManager.mainTarget().inputAgent().invoke_dispatchKeyEvent( | 726 SDK.targetManager.mainTarget().inputAgent().invoke_dispatchKeyEvent( |
672 {type: 'keyUp', windowsVirtualKeyCode: 0x23, key: 'End'}); | 727 {type: 'keyUp', windowsVirtualKeyCode: 0x23, key: 'End'}); |
673 }; | 728 }; |
674 | 729 |
675 TestSuite.prototype.testEmulateNetworkConditions = function() { | 730 TestSuite.prototype.testEmulateNetworkConditions = function() { |
676 var test = this; | 731 var test = this; |
677 | 732 |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1103 if (runtimeModel.executionContexts().length >= n) | 1158 if (runtimeModel.executionContexts().length >= n) |
1104 callback.call(null); | 1159 callback.call(null); |
1105 else | 1160 else |
1106 this.addSniffer(SDK.RuntimeModel.prototype, '_executionContextCreated', checkForExecutionContexts.bind(this)); | 1161 this.addSniffer(SDK.RuntimeModel.prototype, '_executionContextCreated', checkForExecutionContexts.bind(this)); |
1107 } | 1162 } |
1108 }; | 1163 }; |
1109 | 1164 |
1110 | 1165 |
1111 window.uiTests = new TestSuite(window.domAutomationController); | 1166 window.uiTests = new TestSuite(window.domAutomationController); |
1112 })(window); | 1167 })(window); |
OLD | NEW |