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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 /** | 80 /** |
81 * Tests that non-Google NTPs do not show a fakebox. | 81 * Tests that non-Google NTPs do not show a fakebox. |
82 */ | 82 */ |
83 function testDoesNotShowFakeboxIfNotGoogle() { | 83 function testDoesNotShowFakeboxIfNotGoogle() { |
84 var localNTP = LocalNTP(); | 84 var localNTP = LocalNTP(); |
85 configData.isGooglePage = false; | 85 configData.isGooglePage = false; |
86 localNTP.init(); | 86 localNTP.init(); |
87 assert(!$('fakebox')); | 87 assert(!$('fakebox')); |
88 assert(!$('logo')); | 88 assert(!$('logo')); |
89 } | 89 } |
90 | |
91 | |
92 /** | |
93 * Tests that clicking on a Most Visited link calls navigateContentWindow. | |
94 */ | |
95 function testMostVisitedLinkCallsNavigateContentWindow() { | |
96 var ntpHandle = chrome.embeddedSearch.newTabPage; | |
97 var originalNavigateContentWindow = ntpHandle.navigateContentWindow; | |
98 | |
99 var navigateContentWindowCalls = 0; | |
100 ntpHandle.navigateContentWindow = function() { | |
101 navigateContentWindowCalls++; | |
102 } | |
103 | |
104 // Most Visited links have an rid (restricted id). | |
105 var params = { 'rid' : 1 }; | |
106 var href = 'file:///some/local/file'; | |
107 var title = 'Title'; | |
108 var text = 'text'; | |
109 var provider = 'foobar'; | |
110 var link = createMostVisitedLink(params, href, title, text, provider); | |
111 | |
112 link.click(); | |
113 | |
114 ntpHandle.navigateContentWindow = originalNavigateContentWindow; | |
115 assert(navigateContentWindowCalls > 0); | |
116 } | |
117 | |
118 | |
119 /** | |
120 * Tests that clicking on a Most Likely link does not call | |
121 * navigateContentWindow (it's a regular link). | |
122 */ | |
123 function testMostLikelyLinkDoesNotCallNavigateContentWindow() { | |
124 var ntpHandle = chrome.embeddedSearch.newTabPage; | |
125 var originalNavigateContentWindow = ntpHandle.navigateContentWindow; | |
126 | |
127 var navigateContentWindowCalls = 0; | |
128 ntpHandle.navigateContentWindow = function() { | |
129 navigateContentWindowCalls++; | |
130 } | |
131 | |
132 var params = {}; | |
133 var href = 'https://www.site.com'; | |
134 var title = 'Title'; | |
135 var text = 'text'; | |
136 var provider = 'foobar'; | |
137 var link = createMostVisitedLink(params, href, title, text, provider); | |
138 | |
139 link.click(); | |
140 | |
141 ntpHandle.navigateContentWindow = originalNavigateContentWindow; | |
142 assert(navigateContentWindowCalls == 0); | |
143 } | |
OLD | NEW |