Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / chrome / test / data / extensions / api_test / passwords_private / test.js
blobd0e8d7c5f13c2048923df695b237aefee590ba7c
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
3 // found in the LICENSE file.
5 // This just tests the interface. It does not test for specific results, only
6 // that callbacks are correctly invoked, expected parameters are correct,
7 // and failures are detected.
9 var availableTests = [
10 function canPasswordAccountBeManaged() {
11 var callback = function() {
12 // Ensure that the callback is invoked.
13 chrome.test.succeed();
16 chrome.passwordsPrivate.canPasswordAccountBeManaged(callback);
19 function removeSavedPassword() {
20 var numCalls = 0;
21 var numSavedPasswords;
22 var callback = function(savedPasswordsList) {
23 numCalls++;
25 if (numCalls == 1) {
26 numSavedPasswords = savedPasswordsList.length;
27 chrome.passwordsPrivate.removeSavedPassword({
28 originUrl: savedPasswordsList[0].loginPair.originUrl,
29 username: savedPasswordsList[0].loginPair.username
30 });
31 } else if (numCalls == 2) {
32 chrome.test.assertEq(
33 savedPasswordsList.length, numSavedPasswords - 1);
34 chrome.test.succeed();
35 } else {
36 chrome.test.fail();
40 chrome.passwordsPrivate.onSavedPasswordsListChanged.addListener(callback);
43 function removePasswordException() {
44 var numCalls = 0;
45 var numPasswordExceptions;
46 var callback = function(passwordExceptionsList) {
47 numCalls++;
49 if (numCalls == 1) {
50 numPasswordExceptions = passwordExceptionsList.length;
51 chrome.passwordsPrivate.removePasswordException(
52 passwordExceptionsList[0]);
53 } else if (numCalls == 2) {
54 chrome.test.assertEq(
55 passwordExceptionsList.length, numPasswordExceptions - 1);
56 chrome.test.succeed();
57 } else {
58 chrome.test.fail();
62 chrome.passwordsPrivate.onPasswordExceptionsListChanged.addListener(
63 callback);
66 function requestPlaintextPassword() {
67 var callback = function() {
68 // Ensure that the callback is invoked.
69 chrome.test.succeed();
72 chrome.passwordsPrivate.onPlaintextPasswordRetrieved.addListener(callback);
73 chrome.passwordsPrivate.requestPlaintextPassword(
74 {originUrl: 'http://www.test.com', username: 'test@test.com'});
78 var testToRun = window.location.search.substring(1);
79 chrome.test.runTests(availableTests.filter(function(op) {
80 return op.name == testToRun;
81 }));