OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 | 5 |
6 /** | 6 /** |
7 * @fileoverview Tests the local NTP. | 7 * @fileoverview Tests the local NTP. |
8 */ | 8 */ |
9 | 9 |
10 | 10 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 assert(!window.chrome.embeddedSearch.newTabPage.getMostVisitedItemData( | 132 assert(!window.chrome.embeddedSearch.newTabPage.getMostVisitedItemData( |
133 window.chrome.embeddedSearch.newTabPage.mostVisited[0].rid)); | 133 window.chrome.embeddedSearch.newTabPage.mostVisited[0].rid)); |
134 } | 134 } |
135 | 135 |
136 | 136 |
137 | 137 |
138 // ****************************** ADVANCED TESTS ****************************** | 138 // ****************************** ADVANCED TESTS ****************************** |
139 // Advanced tests are controlled from the native side. The helpers here are | 139 // Advanced tests are controlled from the native side. The helpers here are |
140 // called from native code to set up the page and to check results. | 140 // called from native code to set up the page and to check results. |
141 | 141 |
142 function setupAdvancedTest() { | 142 function handlePostMessage(event) { |
| 143 if (event.data.cmd == 'loaded') { |
| 144 domAutomationController.setAutomationId(0); |
| 145 domAutomationController.send('loaded'); |
| 146 } |
| 147 } |
| 148 |
| 149 function setupAdvancedTest(opt_waitForIframeLoaded) { |
| 150 if (opt_waitForIframeLoaded) { |
| 151 window.addEventListener('message', handlePostMessage); |
| 152 } |
| 153 |
143 setUp(); | 154 setUp(); |
144 initLocalNTP(/*isGooglePage=*/true); | 155 initLocalNTP(/*isGooglePage=*/true); |
145 | 156 |
146 assert(elementIsVisible($('fakebox'))); | 157 assert(elementIsVisible($('fakebox'))); |
147 | 158 |
148 return true; | 159 return true; |
149 } | 160 } |
150 | 161 |
151 function getFakeboxPositionX() { | 162 function getFakeboxPositionX() { |
152 assert(elementIsVisible($('fakebox'))); | 163 assert(elementIsVisible($('fakebox'))); |
153 var rect = $('fakebox').getBoundingClientRect(); | 164 var rect = $('fakebox').getBoundingClientRect(); |
154 return rect.left; | 165 return rect.left; |
155 } | 166 } |
156 | 167 |
157 function getFakeboxPositionY() { | 168 function getFakeboxPositionY() { |
158 assert(elementIsVisible($('fakebox'))); | 169 assert(elementIsVisible($('fakebox'))); |
159 var rect = $('fakebox').getBoundingClientRect(); | 170 var rect = $('fakebox').getBoundingClientRect(); |
160 return rect.top; | 171 return rect.top; |
161 } | 172 } |
162 | 173 |
163 function fakeboxIsVisible() { | 174 function fakeboxIsVisible() { |
164 return elementIsVisible($('fakebox')); | 175 return elementIsVisible($('fakebox')); |
165 } | 176 } |
166 | 177 |
167 function fakeboxIsFocused() { | 178 function fakeboxIsFocused() { |
168 return fakeboxIsVisible() && | 179 return fakeboxIsVisible() && |
169 document.body.classList.contains('fakebox-focused'); | 180 document.body.classList.contains('fakebox-focused'); |
170 } | 181 } |
OLD | NEW |