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 GEN('#include "chrome/browser/ui/webui/identity_internals_ui_browsertest.h"'); | 5 GEN('#include "chrome/browser/ui/webui/identity_internals_ui_browsertest.h"'); |
6 | 6 |
7 /** | 7 /** |
8 * Test C++ fixture for downloads WebUI testing. | 8 * Test C++ fixture for downloads WebUI testing. |
9 * @constructor | 9 * @constructor |
10 * @extends {testing.Test} | 10 * @extends {testing.Test} |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 */ | 72 */ |
73 getRevokeButton: function(tokenEntry) { | 73 getRevokeButton: function(tokenEntry) { |
74 return tokenEntry.querySelector('.revoke-button'); | 74 return tokenEntry.querySelector('.revoke-button'); |
75 }, | 75 }, |
76 | 76 |
77 /** | 77 /** |
78 * Gets the token ID displayed on the page for a given entry. | 78 * Gets the token ID displayed on the page for a given entry. |
79 * @param {Element} tokenEntry Display element holding token information. | 79 * @param {Element} tokenEntry Display element holding token information. |
80 * @return {string} Token ID of the token. | 80 * @return {string} Token ID of the token. |
81 */ | 81 */ |
82 getTokenId: function(tokenEntry) { | 82 getAccessToken: function(tokenEntry) { |
83 return tokenEntry.querySelector('.token-id').innerText; | 83 return tokenEntry.querySelector('.access-token').innerText; |
84 }, | 84 }, |
85 | 85 |
86 /** | 86 /** |
87 * Gets the token status displayed on the page for a given entry. | 87 * Gets the token status displayed on the page for a given entry. |
88 * @param {Element} tokenEntry Display element holding token information. | 88 * @param {Element} tokenEntry Display element holding token information. |
89 * @return {string} Token status of the token. | 89 * @return {string} Token status of the token. |
90 */ | 90 */ |
91 getTokenStatus: function(tokenEntry) { | 91 getTokenStatus: function(tokenEntry) { |
92 return tokenEntry.querySelector('.token-status').innerText; | 92 return tokenEntry.querySelector('.token-status').innerText; |
93 }, | 93 }, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 }; | 128 }; |
129 | 129 |
130 // Test for listing a token cache with a single token. It uses a known extension | 130 // Test for listing a token cache with a single token. It uses a known extension |
131 // - the Chrome Web Store, in order to check the extension name. | 131 // - the Chrome Web Store, in order to check the extension name. |
132 TEST_F('IdentityInternalsSingleTokenWebUITest', 'getAllTokens', function() { | 132 TEST_F('IdentityInternalsSingleTokenWebUITest', 'getAllTokens', function() { |
133 var tokenListEntries = this.getTokens(); | 133 var tokenListEntries = this.getTokens(); |
134 expectEquals(1, tokenListEntries.length); | 134 expectEquals(1, tokenListEntries.length); |
135 expectEquals('Store', this.getExtensionName(tokenListEntries[0])); | 135 expectEquals('Store', this.getExtensionName(tokenListEntries[0])); |
136 expectEquals('ahfgeienlihckogmohjhadlkjgocpleb', | 136 expectEquals('ahfgeienlihckogmohjhadlkjgocpleb', |
137 this.getExtensionId(tokenListEntries[0])); | 137 this.getExtensionId(tokenListEntries[0])); |
138 expectEquals('store_token', this.getTokenId(tokenListEntries[0])); | 138 expectEquals('store_token', this.getAccessToken(tokenListEntries[0])); |
139 expectEquals('Token Present', this.getTokenStatus(tokenListEntries[0])); | 139 expectEquals('Token Present', this.getTokenStatus(tokenListEntries[0])); |
140 expectLT(this.getExpirationTime(tokenListEntries[0]) - new Date(), | 140 expectLT(this.getExpirationTime(tokenListEntries[0]) - new Date(), |
141 3600 * 1000); | 141 3600 * 1000); |
142 var scopes = this.getScopes(tokenListEntries[0]); | 142 var scopes = this.getScopes(tokenListEntries[0]); |
143 expectEquals(3, scopes.length); | 143 expectEquals(3, scopes.length); |
144 expectEquals('store_scope1', scopes[0]); | 144 expectEquals('store_scope1', scopes[0]); |
145 expectEquals('store_scope2', scopes[1]); | 145 expectEquals('store_scope2', scopes[1]); |
146 expectEquals('', scopes[2]); | 146 expectEquals('', scopes[2]); |
147 }); | 147 }); |
148 | 148 |
149 // Test ensuring the getters on the BaseIdentityInternalsWebUITest work | 149 // Test ensuring the getters on the BaseIdentityInternalsWebUITest work |
150 // correctly. They are implemented on the child class, because the parent does | 150 // correctly. They are implemented on the child class, because the parent does |
151 // not have any tokens to display. | 151 // not have any tokens to display. |
152 TEST_F('IdentityInternalsSingleTokenWebUITest', 'verifyGetters', function() { | 152 TEST_F('IdentityInternalsSingleTokenWebUITest', 'verifyGetters', function() { |
153 var tokenListEntries = document.querySelectorAll('#token-list > div'); | 153 var tokenListEntries = document.querySelectorAll('#token-list > div'); |
154 var actualTokens = this.getTokens(); | 154 var actualTokens = this.getTokens(); |
155 expectEquals(tokenListEntries.length, actualTokens.length); | 155 expectEquals(tokenListEntries.length, actualTokens.length); |
156 expectEquals(tokenListEntries[0], actualTokens[0]); | 156 expectEquals(tokenListEntries[0], actualTokens[0]); |
157 expectEquals(this.getExtensionName(tokenListEntries[0]), | 157 expectEquals(this.getExtensionName(tokenListEntries[0]), |
158 tokenListEntries[0].querySelector('.extension-name').innerText); | 158 tokenListEntries[0].querySelector('.extension-name').innerText); |
159 expectEquals(this.getExtensionId(tokenListEntries[0]), | 159 expectEquals(this.getExtensionId(tokenListEntries[0]), |
160 tokenListEntries[0].querySelector('.extension-id').innerText); | 160 tokenListEntries[0].querySelector('.extension-id').innerText); |
161 expectEquals(this.getTokenId(tokenListEntries[0]), | 161 expectEquals(this.getAccessToken(tokenListEntries[0]), |
162 tokenListEntries[0].querySelector('.token-id').innerText); | 162 tokenListEntries[0].querySelector('.access-token').innerText); |
163 expectEquals(this.getTokenStatus(tokenListEntries[0]), | 163 expectEquals(this.getTokenStatus(tokenListEntries[0]), |
164 tokenListEntries[0].querySelector('.token-status').innerText); | 164 tokenListEntries[0].querySelector('.token-status').innerText); |
165 expectEquals(this.getExpirationTime(tokenListEntries[0]), | 165 expectEquals(this.getExpirationTime(tokenListEntries[0]), |
166 Date.parse(tokenListEntries[0].querySelector('.expiration-time') | 166 Date.parse(tokenListEntries[0].querySelector('.expiration-time') |
167 .innerText)); | 167 .innerText)); |
168 var scopes = tokenListEntries[0].querySelector('.scope-list') | 168 var scopes = tokenListEntries[0].querySelector('.scope-list') |
169 .innerHTML.split('<br>'); | 169 .innerHTML.split('<br>'); |
170 var actualScopes = this.getScopes(tokenListEntries[0]); | 170 var actualScopes = this.getScopes(tokenListEntries[0]); |
171 expectEquals(scopes.length, actualScopes.length); | 171 expectEquals(scopes.length, actualScopes.length); |
172 for (var i = 0; i < scopes.length; i++) { | 172 for (var i = 0; i < scopes.length; i++) { |
(...skipping 20 matching lines...) Expand all Loading... |
193 | 193 |
194 // Test for listing a token cache with multiple tokens. Names of the extensions | 194 // Test for listing a token cache with multiple tokens. Names of the extensions |
195 // are empty, because extensions are faked, and not present in the extension | 195 // are empty, because extensions are faked, and not present in the extension |
196 // service. | 196 // service. |
197 TEST_F('IdentityInternalsMultipleTokensWebUITest', 'getAllTokens', function() { | 197 TEST_F('IdentityInternalsMultipleTokensWebUITest', 'getAllTokens', function() { |
198 var tokenListEntries = this.getTokens(); | 198 var tokenListEntries = this.getTokens(); |
199 expectEquals(2, tokenListEntries.length); | 199 expectEquals(2, tokenListEntries.length); |
200 expectEquals('', this.getExtensionName(tokenListEntries[0])); | 200 expectEquals('', this.getExtensionName(tokenListEntries[0])); |
201 expectEquals('extension0', | 201 expectEquals('extension0', |
202 this.getExtensionId(tokenListEntries[0])); | 202 this.getExtensionId(tokenListEntries[0])); |
203 expectEquals('token0', this.getTokenId(tokenListEntries[0])); | 203 expectEquals('token0', this.getAccessToken(tokenListEntries[0])); |
204 expectEquals('Token Present', this.getTokenStatus(tokenListEntries[0])); | 204 expectEquals('Token Present', this.getTokenStatus(tokenListEntries[0])); |
205 expectLT(this.getExpirationTime(tokenListEntries[0]) - new Date(), | 205 expectLT(this.getExpirationTime(tokenListEntries[0]) - new Date(), |
206 3600 * 1000); | 206 3600 * 1000); |
207 var scopes = this.getScopes(tokenListEntries[0]); | 207 var scopes = this.getScopes(tokenListEntries[0]); |
208 expectEquals(3, scopes.length); | 208 expectEquals(3, scopes.length); |
209 expectEquals('scope_1_0', scopes[0]); | 209 expectEquals('scope_1_0', scopes[0]); |
210 expectEquals('scope_2_0', scopes[1]); | 210 expectEquals('scope_2_0', scopes[1]); |
211 expectEquals('', scopes[2]); | 211 expectEquals('', scopes[2]); |
212 expectEquals('', this.getExtensionName(tokenListEntries[1])); | 212 expectEquals('', this.getExtensionName(tokenListEntries[1])); |
213 expectEquals('extension1', | 213 expectEquals('extension1', |
214 this.getExtensionId(tokenListEntries[1])); | 214 this.getExtensionId(tokenListEntries[1])); |
215 expectEquals('token1', this.getTokenId(tokenListEntries[1])); | 215 expectEquals('token1', this.getAccessToken(tokenListEntries[1])); |
216 expectEquals('Token Present', this.getTokenStatus(tokenListEntries[1])); | 216 expectEquals('Token Present', this.getTokenStatus(tokenListEntries[1])); |
217 expectLT(this.getExpirationTime(tokenListEntries[1]) - new Date(), | 217 expectLT(this.getExpirationTime(tokenListEntries[1]) - new Date(), |
218 3600 * 1000); | 218 3600 * 1000); |
219 var scopes = this.getScopes(tokenListEntries[1]); | 219 var scopes = this.getScopes(tokenListEntries[1]); |
220 expectEquals(3, scopes.length); | 220 expectEquals(3, scopes.length); |
221 expectEquals('scope_1_1', scopes[0]); | 221 expectEquals('scope_1_1', scopes[0]); |
222 expectEquals('scope_2_1', scopes[1]); | 222 expectEquals('scope_2_1', scopes[1]); |
223 expectEquals('', scopes[2]); | 223 expectEquals('', scopes[2]); |
224 }); | 224 }); |
225 | 225 |
(...skipping 10 matching lines...) Expand all Loading... |
236 | 236 |
237 /** @inhritDoc */ | 237 /** @inhritDoc */ |
238 isAsync: true, | 238 isAsync: true, |
239 }; | 239 }; |
240 | 240 |
241 TEST_F('IdentityInternalsWebUITestAsync', 'revokeToken', function() { | 241 TEST_F('IdentityInternalsWebUITestAsync', 'revokeToken', function() { |
242 var tokenListBefore = this.getTokens(); | 242 var tokenListBefore = this.getTokens(); |
243 expectEquals(2, tokenListBefore.length); | 243 expectEquals(2, tokenListBefore.length); |
244 var tokenRevokeDone = identity_internals.tokenRevokeDone; | 244 var tokenRevokeDone = identity_internals.tokenRevokeDone; |
245 identity_internals.tokenRevokeDone = this.continueTest( | 245 identity_internals.tokenRevokeDone = this.continueTest( |
246 WhenTestDone.ALWAYS, function (tokenIds) { | 246 WhenTestDone.ALWAYS, function (accessTokens) { |
247 tokenRevokeDone.call(identity_internals, tokenIds); | 247 tokenRevokeDone.call(identity_internals, accessTokens); |
248 identity_internals.tokenRevokeDone = tokenRevokeDone; | 248 identity_internals.tokenRevokeDone = tokenRevokeDone; |
249 var tokenListAfter = this.getTokens(); | 249 var tokenListAfter = this.getTokens(); |
250 expectEquals(1, tokenListAfter.length); | 250 expectEquals(1, tokenListAfter.length); |
251 expectEquals(this.getTokenId(tokenListBefore[0]), | 251 expectEquals(this.getAccessToken(tokenListBefore[0]), |
252 this.getTokenId(tokenListAfter[0])); | 252 this.getAccessToken(tokenListAfter[0])); |
253 }.bind(this)); | 253 }.bind(this)); |
254 this.getRevokeButton(tokenListBefore[1]).click(); | 254 this.getRevokeButton(tokenListBefore[1]).click(); |
255 }); | 255 }); |
256 | 256 |
OLD | NEW |