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 25 matching lines...) Expand all Loading... |
36 getTokens: function() { | 36 getTokens: function() { |
37 return document.querySelectorAll('#token-list > div'); | 37 return document.querySelectorAll('#token-list > div'); |
38 }, | 38 }, |
39 | 39 |
40 /** | 40 /** |
41 * Gets the expiration time displayed on the page for a given entry. | 41 * Gets the expiration time displayed on the page for a given entry. |
42 * @param {Element} tokenEntry Display element holding token information. | 42 * @param {Element} tokenEntry Display element holding token information. |
43 * @return {Date} Expiration date of the token. | 43 * @return {Date} Expiration date of the token. |
44 */ | 44 */ |
45 getExpirationTime: function(tokenEntry) { | 45 getExpirationTime: function(tokenEntry) { |
46 // Full-date format has 'at' between date and time in en-US, but | |
47 // ECMAScript's Date.parse cannot grok it. | |
48 return Date.parse(tokenEntry.querySelector('.expiration-time') | 46 return Date.parse(tokenEntry.querySelector('.expiration-time') |
49 .innerText.replace(' at ', ' ')); | 47 .innerText); |
50 }, | 48 }, |
51 | 49 |
52 /** | 50 /** |
53 * Gets the extension id displayed on the page for a given entry. | 51 * Gets the extension id displayed on the page for a given entry. |
54 * @param {Element} tokenEntry Display element holding token information. | 52 * @param {Element} tokenEntry Display element holding token information. |
55 * @return {string} Extension Id of the token. | 53 * @return {string} Extension Id of the token. |
56 */ | 54 */ |
57 getExtensionId: function(tokenEntry) { | 55 getExtensionId: function(tokenEntry) { |
58 return tokenEntry.querySelector('.extension-id').innerText; | 56 return tokenEntry.querySelector('.extension-id').innerText; |
59 }, | 57 }, |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 expectEquals(tokenListEntries.length, actualTokens.length); | 155 expectEquals(tokenListEntries.length, actualTokens.length); |
158 expectEquals(tokenListEntries[0], actualTokens[0]); | 156 expectEquals(tokenListEntries[0], actualTokens[0]); |
159 expectEquals(this.getExtensionName(tokenListEntries[0]), | 157 expectEquals(this.getExtensionName(tokenListEntries[0]), |
160 tokenListEntries[0].querySelector('.extension-name').innerText); | 158 tokenListEntries[0].querySelector('.extension-name').innerText); |
161 expectEquals(this.getExtensionId(tokenListEntries[0]), | 159 expectEquals(this.getExtensionId(tokenListEntries[0]), |
162 tokenListEntries[0].querySelector('.extension-id').innerText); | 160 tokenListEntries[0].querySelector('.extension-id').innerText); |
163 expectEquals(this.getAccessToken(tokenListEntries[0]), | 161 expectEquals(this.getAccessToken(tokenListEntries[0]), |
164 tokenListEntries[0].querySelector('.access-token').innerText); | 162 tokenListEntries[0].querySelector('.access-token').innerText); |
165 expectEquals(this.getTokenStatus(tokenListEntries[0]), | 163 expectEquals(this.getTokenStatus(tokenListEntries[0]), |
166 tokenListEntries[0].querySelector('.token-status').innerText); | 164 tokenListEntries[0].querySelector('.token-status').innerText); |
167 // Full-date format has 'at' between date and time in en-US, but | |
168 // ECMAScript's Date.parse cannot grok it. | |
169 expectEquals(this.getExpirationTime(tokenListEntries[0]), | 165 expectEquals(this.getExpirationTime(tokenListEntries[0]), |
170 Date.parse(tokenListEntries[0].querySelector('.expiration-time') | 166 Date.parse(tokenListEntries[0].querySelector('.expiration-time') |
171 .innerText.replace(' at ', ' '))); | 167 .innerText)); |
172 var scopes = tokenListEntries[0].querySelector('.scope-list') | 168 var scopes = tokenListEntries[0].querySelector('.scope-list') |
173 .innerHTML.split('<br>'); | 169 .innerHTML.split('<br>'); |
174 var actualScopes = this.getScopes(tokenListEntries[0]); | 170 var actualScopes = this.getScopes(tokenListEntries[0]); |
175 expectEquals(scopes.length, actualScopes.length); | 171 expectEquals(scopes.length, actualScopes.length); |
176 for (var i = 0; i < scopes.length; i++) { | 172 for (var i = 0; i < scopes.length; i++) { |
177 expectEquals(scopes[i], actualScopes[i]); | 173 expectEquals(scopes[i], actualScopes[i]); |
178 } | 174 } |
179 }); | 175 }); |
180 | 176 |
181 /** | 177 /** |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 tokenRevokeDone.call(identity_internals, accessTokens); | 247 tokenRevokeDone.call(identity_internals, accessTokens); |
252 identity_internals.tokenRevokeDone = tokenRevokeDone; | 248 identity_internals.tokenRevokeDone = tokenRevokeDone; |
253 var tokenListAfter = this.getTokens(); | 249 var tokenListAfter = this.getTokens(); |
254 expectEquals(1, tokenListAfter.length); | 250 expectEquals(1, tokenListAfter.length); |
255 expectEquals(this.getAccessToken(tokenListBefore[0]), | 251 expectEquals(this.getAccessToken(tokenListBefore[0]), |
256 this.getAccessToken(tokenListAfter[0])); | 252 this.getAccessToken(tokenListAfter[0])); |
257 }.bind(this)); | 253 }.bind(this)); |
258 this.getRevokeButton(tokenListBefore[1]).click(); | 254 this.getRevokeButton(tokenListBefore[1]).click(); |
259 }); | 255 }); |
260 | 256 |
OLD | NEW |