| 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 // This just tests the interface. It does not test for specific results, only | 5 // This just tests the interface. It does not test for specific results, only |
| 6 // that callbacks are correctly invoked, expected parameters are correct, | 6 // that callbacks are correctly invoked, expected parameters are correct, |
| 7 // and failures are detected. | 7 // and failures are detected. |
| 8 | 8 |
| 9 var availableTests = [ | 9 var availableTests = [ |
| 10 function removeSavedPassword() { | 10 function removeSavedPassword() { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 | 34 |
| 35 function removePasswordException() { | 35 function removePasswordException() { |
| 36 var numCalls = 0; | 36 var numCalls = 0; |
| 37 var numPasswordExceptions; | 37 var numPasswordExceptions; |
| 38 var callback = function(passwordExceptionsList) { | 38 var callback = function(passwordExceptionsList) { |
| 39 numCalls++; | 39 numCalls++; |
| 40 | 40 |
| 41 if (numCalls == 1) { | 41 if (numCalls == 1) { |
| 42 numPasswordExceptions = passwordExceptionsList.length; | 42 numPasswordExceptions = passwordExceptionsList.length; |
| 43 chrome.passwordsPrivate.removePasswordException( | 43 chrome.passwordsPrivate.removePasswordException( |
| 44 passwordExceptionsList[0]); | 44 passwordExceptionsList[0].exceptionUrl); |
| 45 } else if (numCalls == 2) { | 45 } else if (numCalls == 2) { |
| 46 chrome.test.assertEq( | 46 chrome.test.assertEq( |
| 47 passwordExceptionsList.length, numPasswordExceptions - 1); | 47 passwordExceptionsList.length, numPasswordExceptions - 1); |
| 48 chrome.test.succeed(); | 48 chrome.test.succeed(); |
| 49 } else { | 49 } else { |
| 50 chrome.test.fail(); | 50 chrome.test.fail(); |
| 51 } | 51 } |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 chrome.passwordsPrivate.onPasswordExceptionsListChanged.addListener( | 54 chrome.passwordsPrivate.onPasswordExceptionsListChanged.addListener( |
| 55 callback); | 55 callback); |
| 56 chrome.passwordsPrivate.getPasswordExceptionList(callback); | 56 chrome.passwordsPrivate.getPasswordExceptionList(callback); |
| 57 }, | 57 }, |
| 58 | 58 |
| 59 function requestPlaintextPassword() { | 59 function requestPlaintextPassword() { |
| 60 var callback = function() { | 60 var callback = function() { |
| 61 // Ensure that the callback is invoked. | 61 // Ensure that the callback is invoked. |
| 62 chrome.test.succeed(); | 62 chrome.test.succeed(); |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 chrome.passwordsPrivate.onPlaintextPasswordRetrieved.addListener(callback); | 65 chrome.passwordsPrivate.onPlaintextPasswordRetrieved.addListener(callback); |
| 66 chrome.passwordsPrivate.requestPlaintextPassword( | 66 chrome.passwordsPrivate.requestPlaintextPassword( |
| 67 {originUrl: 'http://www.test.com', username: 'test@test.com'}); | 67 {originUrl: 'http://www.test.com', username: 'test@test.com'}); |
| 68 }, | 68 }, |
| 69 | 69 |
| 70 function getSavedPasswordList() { | 70 function getSavedPasswordList() { |
| 71 var callback = function(list) { | 71 var callback = function(list) { |
| 72 chrome.test.assertTrue(!!list); | 72 chrome.test.assertTrue(!!list); |
| 73 chrome.test.assertTrue(list.length > 0); |
| 74 |
| 75 for (var i = 0; i < list.length; ++i) { |
| 76 var entry = list[i]; |
| 77 chrome.test.assertTrue(!!entry.loginPair); |
| 78 chrome.test.assertTrue(!!entry.loginPair.originUrl); |
| 79 chrome.test.assertTrue(!!entry.linkUrl); |
| 80 } |
| 81 |
| 73 // Ensure that the callback is invoked. | 82 // Ensure that the callback is invoked. |
| 74 chrome.test.succeed(); | 83 chrome.test.succeed(); |
| 75 }; | 84 }; |
| 76 | 85 |
| 77 chrome.passwordsPrivate.getSavedPasswordList(callback); | 86 chrome.passwordsPrivate.getSavedPasswordList(callback); |
| 78 }, | 87 }, |
| 79 | 88 |
| 80 function getPasswordExceptionList() { | 89 function getPasswordExceptionList() { |
| 81 var callback = function(list) { | 90 var callback = function(list) { |
| 82 chrome.test.assertTrue(!!list); | 91 chrome.test.assertTrue(!!list); |
| 92 chrome.test.assertTrue(list.length > 0); |
| 93 |
| 94 for (var i = 0; i < list.length; ++i) { |
| 95 var exception = list[i]; |
| 96 chrome.test.assertTrue(!!exception.exceptionUrl); |
| 97 chrome.test.assertTrue(!!exception.linkUrl); |
| 98 } |
| 99 |
| 83 // Ensure that the callback is invoked. | 100 // Ensure that the callback is invoked. |
| 84 chrome.test.succeed(); | 101 chrome.test.succeed(); |
| 85 }; | 102 }; |
| 86 | 103 |
| 87 chrome.passwordsPrivate.getPasswordExceptionList(callback); | 104 chrome.passwordsPrivate.getPasswordExceptionList(callback); |
| 88 }, | 105 }, |
| 89 ]; | 106 ]; |
| 90 | 107 |
| 91 var testToRun = window.location.search.substring(1); | 108 var testToRun = window.location.search.substring(1); |
| 92 chrome.test.runTests(availableTests.filter(function(op) { | 109 chrome.test.runTests(availableTests.filter(function(op) { |
| 93 return op.name == testToRun; | 110 return op.name == testToRun; |
| 94 })); | 111 })); |
| OLD | NEW |