| 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 /** | 101 /** |
| 102 * Tests that non-Google NTPs do not show a fakebox. | 102 * Tests that non-Google NTPs do not show a fakebox. |
| 103 */ | 103 */ |
| 104 function testDoesNotShowFakeboxIfNotGoogle() { | 104 function testDoesNotShowFakeboxIfNotGoogle() { |
| 105 initLocalNTP(/*isGooglePage=*/false); | 105 initLocalNTP(/*isGooglePage=*/false); |
| 106 assert(!elementIsVisible($('fakebox'))); | 106 assert(!elementIsVisible($('fakebox'))); |
| 107 assert(!elementIsVisible($('logo'))); | 107 assert(!elementIsVisible($('logo'))); |
| 108 } | 108 } |
| 109 | 109 |
| 110 | 110 |
| 111 /** |
| 112 * Tests that the embeddedSearch.newTabPage.mostVisited API is hooked up, and |
| 113 * provides the correct data for the tiles (i.e. only IDs, no URLs). |
| 114 */ |
| 115 function testMostVisitedContents() { |
| 116 // Check that the API is available and properly hooked up, so that it returns |
| 117 // some data (see history::PrepopulatedPageList for the default contents). |
| 118 assert(window.chrome.embeddedSearch.newTabPage.mostVisited.length > 0); |
| 119 |
| 120 // Check that the items have the required fields: We expect a "restricted ID" |
| 121 // (rid), but there mustn't be url, title, etc. Those are only available |
| 122 // through getMostVisitedItemData(rid). |
| 123 for (var mvItem of window.chrome.embeddedSearch.newTabPage.mostVisited) { |
| 124 assert(isFinite(mvItem.rid)); |
| 125 assert(!mvItem.url); |
| 126 assert(!mvItem.title); |
| 127 assert(!mvItem.domain); |
| 128 } |
| 129 |
| 130 // Try to get an item's details via getMostVisitedItemData. This should fail, |
| 131 // because that API is only available to the MV iframe. |
| 132 assert(!window.chrome.embeddedSearch.newTabPage.getMostVisitedItemData( |
| 133 window.chrome.embeddedSearch.newTabPage.mostVisited[0].rid)); |
| 134 } |
| 135 |
| 136 |
| 111 | 137 |
| 112 // ****************************** ADVANCED TESTS ****************************** | 138 // ****************************** ADVANCED TESTS ****************************** |
| 113 // 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 |
| 114 // 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. |
| 115 | 141 |
| 116 function setupAdvancedTest() { | 142 function setupAdvancedTest() { |
| 117 setUp(); | 143 setUp(); |
| 118 initLocalNTP(/*isGooglePage=*/true); | 144 initLocalNTP(/*isGooglePage=*/true); |
| 119 | 145 |
| 120 assert(elementIsVisible($('fakebox'))); | 146 assert(elementIsVisible($('fakebox'))); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 135 } | 161 } |
| 136 | 162 |
| 137 function fakeboxIsVisible() { | 163 function fakeboxIsVisible() { |
| 138 return elementIsVisible($('fakebox')); | 164 return elementIsVisible($('fakebox')); |
| 139 } | 165 } |
| 140 | 166 |
| 141 function fakeboxIsFocused() { | 167 function fakeboxIsFocused() { |
| 142 return fakeboxIsVisible() && | 168 return fakeboxIsVisible() && |
| 143 document.body.classList.contains('fakebox-focused'); | 169 document.body.classList.contains('fakebox-focused'); |
| 144 } | 170 } |
| OLD | NEW |