| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 /** @fileoverview Runs the Polymer Password Settings tests. */ | 5 /** @fileoverview Runs the Polymer Password Settings tests. */ |
| 6 | 6 |
| 7 /** @const {string} Path to root from chrome/test/data/webui/settings/. */ | 7 /** @const {string} Path to root from chrome/test/data/webui/settings/. */ |
| 8 var ROOT_PATH = '../../../../../'; | 8 var ROOT_PATH = '../../../../../'; |
| 9 | 9 |
| 10 // Polymer BrowserTest fixture. | 10 // Polymer BrowserTest fixture. |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 if (++index < exceptionList.length) | 355 if (++index < exceptionList.length) |
| 356 clickRemoveButton(); // Click 'remove' on all passwords, one by one. | 356 clickRemoveButton(); // Click 'remove' on all passwords, one by one. |
| 357 else | 357 else |
| 358 done(); | 358 done(); |
| 359 }); | 359 }); |
| 360 | 360 |
| 361 // Start removing. | 361 // Start removing. |
| 362 clickRemoveButton(); | 362 clickRemoveButton(); |
| 363 }); | 363 }); |
| 364 | 364 |
| 365 test('usePasswordDialogTwice', function() { | |
| 366 var BLANK_PASSWORD = ' '; | |
| 367 var item = FakeDataMaker.passwordEntry('google.com', 'homer', | |
| 368 BLANK_PASSWORD.length); | |
| 369 var passwordDialog = self.createPasswordDialog_(item); | |
| 370 | |
| 371 passwordDialog.open(); | |
| 372 Polymer.dom.flush(); | |
| 373 | |
| 374 assertEquals(item.loginPair.originUrl, | |
| 375 passwordDialog.$.websiteInput.value); | |
| 376 assertEquals(item.loginPair.username, | |
| 377 passwordDialog.$.usernameInput.value); | |
| 378 assertEquals(BLANK_PASSWORD, | |
| 379 passwordDialog.$.passwordInput.value); | |
| 380 // Password should NOT be visible. | |
| 381 assertEquals('password', | |
| 382 passwordDialog.$.passwordInput.type); | |
| 383 | |
| 384 passwordDialog.close(); | |
| 385 Polymer.dom.flush(); | |
| 386 | |
| 387 var blankPassword2 = ' '.repeat(17); | |
| 388 var item2 = FakeDataMaker.passwordEntry('drive.google.com', 'marge', | |
| 389 blankPassword2.length); | |
| 390 | |
| 391 passwordDialog.item = item2; | |
| 392 passwordDialog.open(); | |
| 393 Polymer.dom.flush(); | |
| 394 | |
| 395 assertEquals(item2.loginPair.originUrl, | |
| 396 passwordDialog.$.websiteInput.value); | |
| 397 assertEquals(item2.loginPair.username, | |
| 398 passwordDialog.$.usernameInput.value); | |
| 399 assertEquals(blankPassword2, | |
| 400 passwordDialog.$.passwordInput.value); | |
| 401 // Password should NOT be visible. | |
| 402 assertEquals('password', | |
| 403 passwordDialog.$.passwordInput.type); | |
| 404 }); | |
| 405 | |
| 406 test('showSavedPassword', function() { | 365 test('showSavedPassword', function() { |
| 407 var PASSWORD = 'bAn@n@5'; | 366 var PASSWORD = 'bAn@n@5'; |
| 408 var item = FakeDataMaker.passwordEntry('goo.gl', 'bart', PASSWORD.length); | 367 var item = FakeDataMaker.passwordEntry('goo.gl', 'bart', PASSWORD.length); |
| 409 var passwordDialog = self.createPasswordDialog_(item); | 368 var passwordDialog = self.createPasswordDialog_(item); |
| 410 | 369 |
| 411 passwordDialog.open(); | |
| 412 Polymer.dom.flush(); | |
| 413 | |
| 414 passwordDialog.password = PASSWORD; | 370 passwordDialog.password = PASSWORD; |
| 415 passwordDialog.showPassword = true; | 371 passwordDialog.showPassword = true; |
| 416 | 372 |
| 417 Polymer.dom.flush(); | 373 Polymer.dom.flush(); |
| 418 | 374 |
| 419 assertEquals(PASSWORD, | 375 assertEquals(PASSWORD, |
| 420 passwordDialog.$.passwordInput.value); | 376 passwordDialog.$.passwordInput.value); |
| 421 // Password should be visible. | 377 // Password should be visible. |
| 422 assertEquals('text', | 378 assertEquals('text', |
| 423 passwordDialog.$.passwordInput.type); | 379 passwordDialog.$.passwordInput.type); |
| 424 }); | 380 }); |
| 425 | 381 |
| 426 // Test will timeout if event is not received. | 382 // Test will timeout if event is not received. |
| 427 test('onShowSavedPassword', function(done) { | 383 test('onShowSavedPassword', function(done) { |
| 428 var item = FakeDataMaker.passwordEntry('goo.gl', 'bart', 1); | 384 var item = FakeDataMaker.passwordEntry('goo.gl', 'bart', 1); |
| 429 var passwordDialog = self.createPasswordDialog_(item); | 385 var passwordDialog = self.createPasswordDialog_(item); |
| 430 | 386 |
| 431 passwordDialog.open(); | |
| 432 Polymer.dom.flush(); | |
| 433 | |
| 434 passwordDialog.addEventListener('show-password', function(event) { | 387 passwordDialog.addEventListener('show-password', function(event) { |
| 435 assertEquals(item.loginPair.originUrl, event.detail.originUrl); | 388 assertEquals(item.loginPair.originUrl, event.detail.originUrl); |
| 436 assertEquals(item.loginPair.username, event.detail.username); | 389 assertEquals(item.loginPair.username, event.detail.username); |
| 437 done(); | 390 done(); |
| 438 }); | 391 }); |
| 439 | 392 |
| 440 MockInteractions.tap(passwordDialog.$.showPasswordButton); | 393 MockInteractions.tap(passwordDialog.$.showPasswordButton); |
| 441 }); | 394 }); |
| 442 }); | 395 }); |
| 443 | 396 |
| 444 mocha.run(); | 397 mocha.run(); |
| 445 }); | 398 }); |
| OLD | NEW |