OLD | NEW |
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; | 7 var savedUserText = null; |
8 var suggestionIndex = -1; | 8 var suggestionIndex = -1; |
9 var suggestions = ["result 1", "result 2", "http://www.google.com"]; | 9 var suggestions = ["result 1", "result 2", "http://www.google.com"]; |
10 var suggestion; | 10 var suggestion; |
11 var suggestionType = 0; // INSTANT_SUGGESTION_SEARCH | 11 var suggestionType = 0; // INSTANT_SUGGESTION_SEARCH |
12 var behavior = 2; // INSTANT_COMPLETE_NEVER | 12 var behavior = 2; // INSTANT_COMPLETE_NEVER |
13 var onMostVisitedChangedCalls = 0; | 13 var onMostVisitedChangedCalls = 0; |
14 var mostVisitedItemsCount = 0; | 14 var mostVisitedItemsCount = 0; |
15 var firstMostVisitedItemId = 0; | 15 var firstMostVisitedItemId = 0; |
16 var onNativeSuggestionsCalls = 0; | 16 var onNativeSuggestionsCalls = 0; |
17 var onChangeCalls = 0; | 17 var onChangeCalls = 0; |
18 var submitCount = 0; | 18 var submitCount = 0; |
19 var onEscKeyPressedCalls = 0; | 19 var onEscKeyPressedCalls = 0; |
| 20 var onFocusChangedCalls = 0; |
| 21 var isFocused = false; |
20 var onvisibilitycalls = 0; | 22 var onvisibilitycalls = 0; |
21 | 23 |
22 function getApiHandle() { | 24 function getApiHandle() { |
23 if (window.navigator && window.navigator.searchBox) | 25 if (window.navigator && window.navigator.searchBox) |
24 return window.navigator.searchBox; | 26 return window.navigator.searchBox; |
25 if (window.chrome && window.chrome.searchBox) | 27 if (window.chrome && window.chrome.searchBox) |
26 return window.chrome.searchBox; | 28 return window.chrome.searchBox; |
27 return null; | 29 return null; |
28 } | 30 } |
29 | 31 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 if (items) { | 100 if (items) { |
99 mostVisitedItemsCount = items.length; | 101 mostVisitedItemsCount = items.length; |
100 firstMostVisitedItemId = items[0] ? items[0].rid : 0; | 102 firstMostVisitedItemId = items[0] ? items[0].rid : 0; |
101 } | 103 } |
102 } | 104 } |
103 | 105 |
104 document.addEventListener("webkitvisibilitychange", function() { | 106 document.addEventListener("webkitvisibilitychange", function() { |
105 onvisibilitycalls++; | 107 onvisibilitycalls++; |
106 }, false); | 108 }, false); |
107 | 109 |
| 110 function handleFocusChange() { |
| 111 onFocusChangedCalls++; |
| 112 isFocused = apiHandle.isFocused; |
| 113 } |
| 114 |
108 function setUp() { | 115 function setUp() { |
109 apiHandle = getApiHandle(); | 116 apiHandle = getApiHandle(); |
110 if (!apiHandle) | 117 if (!apiHandle) |
111 return; | 118 return; |
112 | 119 |
113 newTabPageHandle = getNewTabPageHandle(); | 120 newTabPageHandle = getNewTabPageHandle(); |
114 apiHandle.onnativesuggestions = handleNativeSuggestions; | 121 apiHandle.onnativesuggestions = handleNativeSuggestions; |
115 apiHandle.onsubmit = handleSubmit; | 122 apiHandle.onsubmit = handleSubmit; |
116 apiHandle.onchange = handleOnChange; | 123 apiHandle.onchange = handleOnChange; |
117 apiHandle.onkeypress = handleKeyPress; | 124 apiHandle.onkeypress = handleKeyPress; |
| 125 apiHandle.onfocuschange = handleFocusChange; |
118 newTabPageHandle.onmostvisitedchange = handleMostVisitedChange; | 126 newTabPageHandle.onmostvisitedchange = handleMostVisitedChange; |
119 if (apiHandle.value) { | 127 if (apiHandle.value) { |
120 handleNativeSuggestions(); | 128 handleNativeSuggestions(); |
121 handleOnChange(); | 129 handleOnChange(); |
122 } | 130 } |
123 if (newTabPageHandle.mostVisited && newTabPageHandle.mostVisited.length) { | 131 if (newTabPageHandle.mostVisited && newTabPageHandle.mostVisited.length) { |
124 handleMostVisitedChange(); | 132 handleMostVisitedChange(); |
125 } | 133 } |
| 134 handleFocusChange(); |
126 } | 135 } |
127 | 136 |
128 setUp(); | 137 setUp(); |
129 | 138 |
130 </script> | 139 </script> |
131 </head> | 140 </head> |
132 <body> | 141 <body> |
133 <h1>Instant</h1> | 142 <h1>Instant</h1> |
134 </body> | 143 </body> |
135 </html> | 144 </html> |
OLD | NEW |