| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 window.console.log(testName + ' ' + err); | 59 window.console.log(testName + ' ' + err); |
| 60 pass = false; | 60 pass = false; |
| 61 } | 61 } |
| 62 } | 62 } |
| 63 } | 63 } |
| 64 return pass; | 64 return pass; |
| 65 } | 65 } |
| 66 | 66 |
| 67 | 67 |
| 68 /** | 68 /** |
| 69 * Checks whether a given HTMLElement exists and is visible. |
| 70 * @param {HTMLElement|undefined} elem An HTMLElement. |
| 71 * @return {boolean} True if the element exists and is visible. |
| 72 */ |
| 73 function elementIsVisible(elem) { |
| 74 return elem && elem.offsetWidth > 0 && elem.offsetHeight > 0; |
| 75 } |
| 76 |
| 77 |
| 78 /** |
| 69 * Tests that Google NTPs show a fakebox and logo. | 79 * Tests that Google NTPs show a fakebox and logo. |
| 70 */ | 80 */ |
| 71 function testShowsFakeboxAndLogoIfGoogle() { | 81 function testShowsFakeboxAndLogoIfGoogle() { |
| 72 var localNTP = LocalNTP(); | 82 var localNTP = LocalNTP(); |
| 73 configData.isGooglePage = true; | 83 configData.isGooglePage = true; |
| 74 localNTP.init(); | 84 localNTP.init(); |
| 75 assert($('fakebox')); | 85 assert(elementIsVisible($('fakebox'))); |
| 76 assert($('logo')); | 86 assert(elementIsVisible($('logo'))); |
| 77 } | 87 } |
| 78 | 88 |
| 79 | 89 |
| 80 /** | 90 /** |
| 81 * Tests that non-Google NTPs do not show a fakebox. | 91 * Tests that non-Google NTPs do not show a fakebox. |
| 82 */ | 92 */ |
| 83 function testDoesNotShowFakeboxIfNotGoogle() { | 93 function testDoesNotShowFakeboxIfNotGoogle() { |
| 84 var localNTP = LocalNTP(); | 94 var localNTP = LocalNTP(); |
| 85 configData.isGooglePage = false; | 95 configData.isGooglePage = false; |
| 86 localNTP.init(); | 96 localNTP.init(); |
| 87 assert(!$('fakebox')); | 97 assert(!elementIsVisible($('fakebox'))); |
| 88 assert(!$('logo')); | 98 assert(!elementIsVisible($('logo'))); |
| 89 } | 99 } |
| OLD | NEW |