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

Side by Side Diff: chrome/test/data/instant_extended.html

Issue 11889003: Fixing ESC in instant-extended. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Answered Sreeram's comment, fixed Jeremy's problem and updated tests. Created 7 years, 10 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 | Annotate | Revision Log
OLDNEW
1 <html> 1 <html>
2 <head> 2 <head>
3 <script> 3 <script>
4 4
5 var apiHandle; 5 var apiHandle;
6 var onnativesuggestioncalls = 0; 6 var onnativesuggestioncalls = 0;
7 var onsubmitcalls = 0; 7 var onsubmitcalls = 0;
8 var savedUserText = null; 8 var savedUserText = null;
9 var suggestionIndex = -1; 9 var suggestionIndex = -1;
10 var suggestions = ["result 1", "result 2", "result 3"]; 10 var suggestions = ["result 1", "result 2", "result 3"];
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 suggestionIndex++; 43 suggestionIndex++;
44 apiHandle.setValue(suggestions[suggestionIndex]); 44 apiHandle.setValue(suggestions[suggestionIndex]);
45 } 45 }
46 } 46 }
47 47
48 function previousSuggestion() { 48 function previousSuggestion() {
49 if (suggestionIndex != -1) { 49 if (suggestionIndex != -1) {
50 suggestionIndex--; 50 suggestionIndex--;
51 if (suggestionIndex == -1) { 51 if (suggestionIndex == -1) {
52 apiHandle.setValue(savedUserText); 52 apiHandle.setValue(savedUserText);
53 suggestionIndex = -1;
sreeram 2013/02/12 20:52:59 Huh? It's already -1, isn't it?
beaudoin 2013/02/12 21:34:41 Done.
53 } else { 54 } else {
54 apiHandle.setValue(suggestions[suggestionIndex]); 55 apiHandle.setValue(suggestions[suggestionIndex]);
55 } 56 }
56 } 57 }
57 } 58 }
58 59
59 function handleKeyPress(event) { 60 function handleKeyPress(event) {
60 var VKEY_UP = 0x26; 61 var VKEY_UP = 0x26;
61 var VKEY_DOWN = 0x28; 62 var VKEY_DOWN = 0x28;
63 var VKEY_ESCAPE = 0x1B;
62 64
63 if (event.keyCode == VKEY_DOWN) { 65 if (event.keyCode == VKEY_DOWN) {
64 nextSuggestion(); 66 nextSuggestion();
65 } else if (event.keyCode == VKEY_UP) { 67 } else if (event.keyCode == VKEY_UP) {
66 previousSuggestion(); 68 previousSuggestion();
69 } else if (event.keyCode == VKEY_ESCAPE) {
70 suggestionIndex = -1;
71 apiHandle.setAutocompleteText("helloab", 2)
sreeram 2013/02/12 20:52:59 ???
beaudoin 2013/02/12 21:34:41 Debugging leftovers. :( Done.
67 } 72 }
68 } 73 }
69 74
70 function setUp() { 75 function setUp() {
71 apiHandle = getApiHandle(); 76 apiHandle = getApiHandle();
72 apiHandle.onnativesuggestions = handleNativeSuggestions; 77 apiHandle.onnativesuggestions = handleNativeSuggestions;
73 apiHandle.onsubmit = handleSubmit; 78 apiHandle.onsubmit = handleSubmit;
74 apiHandle.onchange = handleOnChange; 79 apiHandle.onchange = handleOnChange;
75 apiHandle.onkeypress = handleKeyPress; 80 apiHandle.onkeypress = handleKeyPress;
76 if (apiHandle.value) { 81 if (apiHandle.value) {
77 handleNativeSuggestions(); 82 handleNativeSuggestions();
78 handleOnChange(); 83 handleOnChange();
79 } 84 }
80 } 85 }
81 86
82 setUp(); 87 setUp();
83 88
84 </script> 89 </script>
85 </head> 90 </head>
86 <body> 91 <body>
87 <h1>Instant</h1> 92 <h1>Instant</h1>
88 </body> 93 </body>
89 </html> 94 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698