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

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

Issue 2412093002: Remove obsolete parts of InstantExtended tests (Closed)
Patch Set: . Created 4 years, 2 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
« no previous file with comments | « chrome/test/data/instant_extended.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <html> 1 <html>
2 <head> 2 <head>
3 <script> 3 <script>
4 4
5 var apiHandle; 5 var apiHandle;
6 var newTabPageHandle; 6 var newTabPageHandle;
7 var savedUserText = null;
8 var suggestionIndex = -1;
9 var suggestions = ["result 1", "result 2", "http://www.google.com"];
10 var suggestion; 7 var suggestion;
11 var suggestionType = 0; // INSTANT_SUGGESTION_SEARCH
12 var behavior = 2; // INSTANT_COMPLETE_NEVER
13 var onMostVisitedChangedCalls = 0; 8 var onMostVisitedChangedCalls = 0;
14 var mostVisitedItemsCount = 0; 9 var mostVisitedItemsCount = 0;
15 var firstMostVisitedItemId = 0; 10 var firstMostVisitedItemId = 0;
16 var onNativeSuggestionsCalls = 0;
17 var onChangeCalls = 0;
18 var submitCount = 0; 11 var submitCount = 0;
19 var onEscKeyPressedCalls = 0;
20 var onFocusChangedCalls = 0; 12 var onFocusChangedCalls = 0;
21 var prefetchQuery = ''; 13 var prefetchQuery = '';
22 var isFocused = false; 14 var isFocused = false;
23 var onvisibilitycalls = 0; 15 var onvisibilitycalls = 0;
24 var onThemeChangedCalls = 0; 16 var onThemeChangedCalls = 0;
25 17
26 function getApiHandle() { 18 function getApiHandle() {
27 if (window.navigator && window.navigator.searchBox) 19 if (window.navigator && window.navigator.searchBox)
28 return window.navigator.searchBox; 20 return window.navigator.searchBox;
29 if (window.chrome && window.chrome.searchBox) 21 if (window.chrome && window.chrome.searchBox)
30 return window.chrome.searchBox; 22 return window.chrome.searchBox;
31 return null; 23 return null;
32 } 24 }
33 25
34 function getNewTabPageHandle() { 26 function getNewTabPageHandle() {
35 if (window.navigator && window.navigator.embeddedSearch && 27 if (window.navigator && window.navigator.embeddedSearch &&
36 window.navigator.embeddedSearch.newTabPage) 28 window.navigator.embeddedSearch.newTabPage)
37 return window.navigator.embeddedSearch.newTabPage; 29 return window.navigator.embeddedSearch.newTabPage;
38 if (window.chrome && window.chrome.embeddedSearch && 30 if (window.chrome && window.chrome.embeddedSearch &&
39 window.chrome.embeddedSearch.newTabPage) 31 window.chrome.embeddedSearch.newTabPage)
40 return window.chrome.embeddedSearch.newTabPage; 32 return window.chrome.embeddedSearch.newTabPage;
41 return null; 33 return null;
42 } 34 }
43 35
44 function handleNativeSuggestions() {
45 onNativeSuggestionsCalls++;
46 // Showing the loader at 100% height.
47 apiHandle.hideBars();
48 apiHandle.showOverlay();
49 }
50
51 function handleSubmit() { 36 function handleSubmit() {
52 location.hash = 'q=' + encodeURIComponent(apiHandle.value); 37 location.hash = 'q=' + encodeURIComponent(apiHandle.value);
53 submitCount++; 38 submitCount++;
54 } 39 }
55 40
56 function handleOnChange() {
57 onChangeCalls++;
58 savedUserText = apiHandle.value;
59 suggestionIndex = -1;
60 apiHandle.setAutocompleteText(suggestion, behavior);
61 }
62
63 function nextSuggestion() {
64 if (suggestionIndex < suggestions.length - 1) {
65 suggestionIndex++;
66 apiHandle.setValue(suggestions[suggestionIndex], suggestionType);
67 }
68 }
69
70 function previousSuggestion() {
71 if (suggestionIndex != -1) {
72 suggestionIndex--;
73 if (suggestionIndex == -1) {
74 apiHandle.setValue(savedUserText, suggestionType);
75 } else {
76 apiHandle.setValue(suggestions[suggestionIndex], suggestionType);
77 }
78 }
79 }
80
81 function handleKeyPress(event) {
82 var VKEY_ESCAPE = 0x1B;
83 var VKEY_UP = 0x26;
84 var VKEY_DOWN = 0x28;
85
86 if (event.keyCode == VKEY_ESCAPE) {
87 onEscKeyPressedCalls++;
88 if (suggestionIndex != -1) {
89 suggestionIndex = -1;
90 apiHandle.setAutocompleteText(suggestion, behavior);
91 }
92 } else if (event.keyCode == VKEY_DOWN) {
93 nextSuggestion();
94 } else if (event.keyCode == VKEY_UP) {
95 previousSuggestion();
96 }
97 }
98
99 function handleMostVisitedChange() { 41 function handleMostVisitedChange() {
100 onMostVisitedChangedCalls++; 42 onMostVisitedChangedCalls++;
101 var items = newTabPageHandle.mostVisited; 43 var items = newTabPageHandle.mostVisited;
102 if (items) { 44 if (items) {
103 mostVisitedItemsCount = items.length; 45 mostVisitedItemsCount = items.length;
104 firstMostVisitedItemId = items[0] ? items[0].rid : 0; 46 firstMostVisitedItemId = items[0] ? items[0].rid : 0;
105 } 47 }
106 } 48 }
107 49
108 document.addEventListener("visibilitychange", function() { 50 document.addEventListener("visibilitychange", function() {
(...skipping 11 matching lines...) Expand all
120 62
121 function handleThemeChange() { 63 function handleThemeChange() {
122 onThemeChangedCalls++; 64 onThemeChangedCalls++;
123 } 65 }
124 66
125 function setUp() { 67 function setUp() {
126 apiHandle = getApiHandle(); 68 apiHandle = getApiHandle();
127 if (!apiHandle) 69 if (!apiHandle)
128 return; 70 return;
129 71
130 newTabPageHandle = getNewTabPageHandle();
131 apiHandle.onnativesuggestions = handleNativeSuggestions;
132 apiHandle.onsubmit = handleSubmit; 72 apiHandle.onsubmit = handleSubmit;
133 apiHandle.onchange = handleOnChange;
134 apiHandle.onkeypress = handleKeyPress;
135 apiHandle.onfocuschange = handleFocusChange; 73 apiHandle.onfocuschange = handleFocusChange;
136 apiHandle.onsuggestionchange = handleSuggestionChange; 74 apiHandle.onsuggestionchange = handleSuggestionChange;
75
76 newTabPageHandle = getNewTabPageHandle();
137 newTabPageHandle.onmostvisitedchange = handleMostVisitedChange; 77 newTabPageHandle.onmostvisitedchange = handleMostVisitedChange;
138 newTabPageHandle.onthemechange = handleThemeChange; 78 newTabPageHandle.onthemechange = handleThemeChange;
139 if (apiHandle.value) {
140 handleNativeSuggestions();
141 handleOnChange();
142 }
143 if (newTabPageHandle.mostVisited && newTabPageHandle.mostVisited.length) { 79 if (newTabPageHandle.mostVisited && newTabPageHandle.mostVisited.length) {
144 handleMostVisitedChange(); 80 handleMostVisitedChange();
145 } 81 }
146 handleFocusChange(); 82 handleFocusChange();
147 } 83 }
148 84
149 setUp(); 85 setUp();
150 86
151 </script> 87 </script>
152 88
153 <meta name="referrer" content="origin" /> 89 <meta name="referrer" content="origin" />
154 90
155 </head> 91 </head>
156 <body> 92 <body>
157 <h1>Instant</h1> 93 <h1>Instant</h1>
158 </body> 94 </body>
159 </html> 95 </html>
OLDNEW
« no previous file with comments | « chrome/test/data/instant_extended.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698