Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(263)

Unified Diff: chrome/browser/ui/webui/identity_internals_ui_browsertest.js

Issue 365513002: Port identity_internals to mojo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to ToT for commit Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/webui/identity_internals_ui_browsertest.cc ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/identity_internals_ui_browsertest.js
diff --git a/chrome/browser/ui/webui/identity_internals_ui_browsertest.js b/chrome/browser/ui/webui/identity_internals_ui_browsertest.js
deleted file mode 100644
index f71a7608c9de51272f20c3f294060769cc588de4..0000000000000000000000000000000000000000
--- a/chrome/browser/ui/webui/identity_internals_ui_browsertest.js
+++ /dev/null
@@ -1,260 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-GEN('#include "chrome/browser/ui/webui/identity_internals_ui_browsertest.h"');
-
-/**
- * Test C++ fixture for downloads WebUI testing.
- * @constructor
- * @extends {testing.Test}
- */
-function IdentityInternalsUIBrowserTest() {}
-
-/**
- * Base fixture for Downloads WebUI testing.
- * @extends {testing.Test}
- * @constructor
- */
-function BaseIdentityInternalsWebUITest() {}
-
-BaseIdentityInternalsWebUITest.prototype = {
- __proto__: testing.Test.prototype,
-
- /**
- * Browse to the downloads page & call our preLoad().
- */
- browsePreload: 'chrome://identity-internals',
-
- /** @override */
- typedefCppFixture: 'IdentityInternalsUIBrowserTest',
-
- /**
- * Gets all of the token entries on the page.
- * @return {!NodeList} Elements displaying token information.
- */
- getTokens: function() {
- return document.querySelectorAll('#token-list > div');
- },
-
- /**
- * Gets the expiration time displayed on the page for a given entry.
- * @param {Element} tokenEntry Display element holding token information.
- * @return {Date} Expiration date of the token.
- */
- getExpirationTime: function(tokenEntry) {
- // Full-date format has 'at' between date and time in en-US, but
- // ECMAScript's Date.parse cannot grok it.
- return Date.parse(tokenEntry.querySelector('.expiration-time')
- .innerText.replace(' at ', ' '));
- },
-
- /**
- * Gets the extension id displayed on the page for a given entry.
- * @param {Element} tokenEntry Display element holding token information.
- * @return {string} Extension Id of the token.
- */
- getExtensionId: function(tokenEntry) {
- return tokenEntry.querySelector('.extension-id').innerText;
- },
-
- /**
- * Gets the extension name displayed on the page for a given entry.
- * @param {Element} tokenEntry Display element holding token information.
- * @return {string} Extension Name of the token.
- */
- getExtensionName: function(tokenEntry) {
- return tokenEntry.querySelector('.extension-name').innerText;
- },
-
- /**
- * Gets the revoke button of the token entry.
- * @param {Element} tokenEntry Diplsy element holding token information.
- * @return {HTMLButtonElement} Revoke button belonging related to the token.
- */
- getRevokeButton: function(tokenEntry) {
- return tokenEntry.querySelector('.revoke-button');
- },
-
- /**
- * Gets the token ID displayed on the page for a given entry.
- * @param {Element} tokenEntry Display element holding token information.
- * @return {string} Token ID of the token.
- */
- getAccessToken: function(tokenEntry) {
- return tokenEntry.querySelector('.access-token').innerText;
- },
-
- /**
- * Gets the token status displayed on the page for a given entry.
- * @param {Element} tokenEntry Display element holding token information.
- * @return {string} Token status of the token.
- */
- getTokenStatus: function(tokenEntry) {
- return tokenEntry.querySelector('.token-status').innerText;
- },
-
- /**
- * Gets the token scopes displayed on the page for a given entry.
- * @param {Element} tokenEntry Display element holding token information.
- * @return {string[]} Token scopes of the token.
- */
- getScopes: function(tokenEntry) {
- return tokenEntry.querySelector('.scope-list')
- .innerHTML.split('<br>');
- },
-};
-
-// Test verifying chrome://identity-internals Web UI when the token cache is
-// empty.
-TEST_F('BaseIdentityInternalsWebUITest', 'emptyTokenCache', function() {
- var tokenListEntries = this.getTokens();
- expectEquals(0, tokenListEntries.length);
-});
-
-/**
- * Fixture for Identity Internals Web UI testing with a single token in the
- * Identity API token cache.
- * @extends {BaseIdentityInternalsWebUITest}
- * @constructor
- */
-function IdentityInternalsSingleTokenWebUITest() {}
-
-IdentityInternalsSingleTokenWebUITest.prototype = {
- __proto__: BaseIdentityInternalsWebUITest.prototype,
-
- /** @override */
- testGenPreamble: function() {
- GEN(' SetupTokenCacheWithStoreApp();');
- },
-};
-
-// Test for listing a token cache with a single token. It uses a known extension
-// - the Chrome Web Store, in order to check the extension name.
-TEST_F('IdentityInternalsSingleTokenWebUITest', 'getAllTokens', function() {
- var tokenListEntries = this.getTokens();
- expectEquals(1, tokenListEntries.length);
- expectEquals('Web Store', this.getExtensionName(tokenListEntries[0]));
- expectEquals('ahfgeienlihckogmohjhadlkjgocpleb',
- this.getExtensionId(tokenListEntries[0]));
- expectEquals('store_token', this.getAccessToken(tokenListEntries[0]));
- expectEquals('Token Present', this.getTokenStatus(tokenListEntries[0]));
- expectLT(this.getExpirationTime(tokenListEntries[0]) - new Date(),
- 3600 * 1000);
- var scopes = this.getScopes(tokenListEntries[0]);
- expectEquals(3, scopes.length);
- expectEquals('store_scope1', scopes[0]);
- expectEquals('store_scope2', scopes[1]);
- expectEquals('', scopes[2]);
-});
-
-// Test ensuring the getters on the BaseIdentityInternalsWebUITest work
-// correctly. They are implemented on the child class, because the parent does
-// not have any tokens to display.
-TEST_F('IdentityInternalsSingleTokenWebUITest', 'verifyGetters', function() {
- var tokenListEntries = document.querySelectorAll('#token-list > div');
- var actualTokens = this.getTokens();
- expectEquals(tokenListEntries.length, actualTokens.length);
- expectEquals(tokenListEntries[0], actualTokens[0]);
- expectEquals(this.getExtensionName(tokenListEntries[0]),
- tokenListEntries[0].querySelector('.extension-name').innerText);
- expectEquals(this.getExtensionId(tokenListEntries[0]),
- tokenListEntries[0].querySelector('.extension-id').innerText);
- expectEquals(this.getAccessToken(tokenListEntries[0]),
- tokenListEntries[0].querySelector('.access-token').innerText);
- expectEquals(this.getTokenStatus(tokenListEntries[0]),
- tokenListEntries[0].querySelector('.token-status').innerText);
- // Full-date format has 'at' between date and time in en-US, but
- // ECMAScript's Date.parse cannot grok it.
- expectEquals(this.getExpirationTime(tokenListEntries[0]),
- Date.parse(tokenListEntries[0].querySelector('.expiration-time')
- .innerText.replace(' at ', ' ')));
- var scopes = tokenListEntries[0].querySelector('.scope-list')
- .innerHTML.split('<br>');
- var actualScopes = this.getScopes(tokenListEntries[0]);
- expectEquals(scopes.length, actualScopes.length);
- for (var i = 0; i < scopes.length; i++) {
- expectEquals(scopes[i], actualScopes[i]);
- }
-});
-
-/**
- * Fixture for Identity Internals Web UI testing with multiple tokens in the
- * Identity API token cache.
- * @extends {BaseIdentityInternalsWebUITest}
- * @constructor
- */
-function IdentityInternalsMultipleTokensWebUITest() {}
-
-IdentityInternalsMultipleTokensWebUITest.prototype = {
- __proto__: BaseIdentityInternalsWebUITest.prototype,
-
- /** @override */
- testGenPreamble: function() {
- GEN(' SetupTokenCache(2);');
- },
-};
-
-// Test for listing a token cache with multiple tokens. Names of the extensions
-// are empty, because extensions are faked, and not present in the extension
-// service.
-TEST_F('IdentityInternalsMultipleTokensWebUITest', 'getAllTokens', function() {
- var tokenListEntries = this.getTokens();
- expectEquals(2, tokenListEntries.length);
- expectEquals('', this.getExtensionName(tokenListEntries[0]));
- expectEquals('extension0',
- this.getExtensionId(tokenListEntries[0]));
- expectEquals('token0', this.getAccessToken(tokenListEntries[0]));
- expectEquals('Token Present', this.getTokenStatus(tokenListEntries[0]));
- expectLT(this.getExpirationTime(tokenListEntries[0]) - new Date(),
- 3600 * 1000);
- var scopes = this.getScopes(tokenListEntries[0]);
- expectEquals(3, scopes.length);
- expectEquals('scope_1_0', scopes[0]);
- expectEquals('scope_2_0', scopes[1]);
- expectEquals('', scopes[2]);
- expectEquals('', this.getExtensionName(tokenListEntries[1]));
- expectEquals('extension1',
- this.getExtensionId(tokenListEntries[1]));
- expectEquals('token1', this.getAccessToken(tokenListEntries[1]));
- expectEquals('Token Present', this.getTokenStatus(tokenListEntries[1]));
- expectLT(this.getExpirationTime(tokenListEntries[1]) - new Date(),
- 3600 * 1000);
- var scopes = this.getScopes(tokenListEntries[1]);
- expectEquals(3, scopes.length);
- expectEquals('scope_1_1', scopes[0]);
- expectEquals('scope_2_1', scopes[1]);
- expectEquals('', scopes[2]);
-});
-
-/**
- * Fixture for asynchronous testing of Identity Internals Web UI with multiple
- * tokens in Identity API token cache.
- * @extends {IdentityInternalsMultipleTokensWebUITest}
- * @constructor
- */
-function IdentityInternalsWebUITestAsync() {}
-
-IdentityInternalsWebUITestAsync.prototype = {
- __proto__: IdentityInternalsMultipleTokensWebUITest.prototype,
-
- /** @override */
- isAsync: true,
-};
-
-TEST_F('IdentityInternalsWebUITestAsync', 'revokeToken', function() {
- var tokenListBefore = this.getTokens();
- expectEquals(2, tokenListBefore.length);
- var tokenRevokeDone = identity_internals.tokenRevokeDone;
- identity_internals.tokenRevokeDone = this.continueTest(
- WhenTestDone.ALWAYS, function(accessTokens) {
- tokenRevokeDone.call(identity_internals, accessTokens);
- identity_internals.tokenRevokeDone = tokenRevokeDone;
- var tokenListAfter = this.getTokens();
- expectEquals(1, tokenListAfter.length);
- expectEquals(this.getAccessToken(tokenListBefore[0]),
- this.getAccessToken(tokenListAfter[0]));
- }.bind(this));
- this.getRevokeButton(tokenListBefore[1]).click();
-});
-
« no previous file with comments | « chrome/browser/ui/webui/identity_internals_ui_browsertest.cc ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698