OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <title>Credential Manager: get() basics.</title> | 2 <title>Credential Manager: get() basics.</title> |
3 <script src="../resources/testharness.js"></script> | 3 <script src="../resources/testharness.js"></script> |
4 <script src="../resources/testharnessreport.js"></script> | 4 <script src="../resources/testharnessreport.js"></script> |
5 <script src="/serviceworker/resources/interfaces.js"></script> | 5 <script src="/serviceworker/resources/interfaces.js"></script> |
6 <script> | 6 <script> |
7 function stubResolverUndefinedChecker(c) { | 7 function stubResolverUndefinedChecker(c) { |
8 assert_equals(c, undefined); | 8 assert_equals(c, undefined); |
9 this.done(); | 9 this.done(); |
10 } | 10 } |
11 | 11 |
12 function stubRejectionChecker(reason) { | 12 function stubRejectionChecker(reason) { |
13 assert_unreached("get(...) should not reject, but did: " + reason.name); | 13 assert_unreached("get(...) should not reject, but did: " + reason.name); |
14 } | 14 } |
15 | 15 |
| 16 add_completion_callback(() => { |
| 17 if (window.testRunner) |
| 18 window.testRunner.clearMockCredentialManagerResponse(); |
| 19 }); |
| 20 |
16 (function() { | 21 (function() { |
17 var t = async_test("Verify the basics of get()."); | 22 var t = async_test("navigator.credentials.get() (no argument) should throw."
); |
18 t.step(function () { | 23 t.step(function () { |
19 navigator.credentials.get().then( | 24 navigator.credentials.get().then( |
20 t.unreached_func(), | 25 t.unreached_func(), |
21 t.step_func_done()); | 26 t.step_func_done()); |
22 }); | 27 }); |
23 }()); | 28 }()); |
24 | 29 |
25 (function() { | 30 (function() { |
26 var t = async_test("Verify the basics of get({})."); | 31 var t = async_test("navigator.credentials.get({})."); |
27 t.step(function () { | 32 t.step(function () { |
28 navigator.credentials.get({}).then( | 33 navigator.credentials.get({}).then( |
29 t.step_func(stubResolverUndefinedChecker.bind(t)), | 34 t.step_func(stubResolverUndefinedChecker.bind(t)), |
30 t.step_func(stubRejectionChecker.bind(t))); | 35 t.step_func(stubRejectionChecker.bind(t))); |
31 }); | 36 }); |
32 }()); | 37 }()); |
33 | 38 |
34 (function() { | 39 (function() { |
35 var t = async_test("Verify the basics of get()."); | 40 var t = async_test("navigator.credentials.get() with a valid options includi
ng FederatedCredentialRequestOptions."); |
36 t.step(function () { | 41 t.step(function () { |
37 navigator.credentials.get({ | 42 navigator.credentials.get({ |
38 federated: { | 43 federated: { |
39 providers: [ 'https://example.com/' ] | 44 providers: [ 'https://example.com/' ] |
40 } | 45 } |
41 }).then( | 46 }).then( |
42 t.step_func(stubResolverUndefinedChecker.bind(t)), | 47 t.step_func(stubResolverUndefinedChecker.bind(t)), |
43 t.step_func(stubRejectionChecker.bind(t))); | 48 t.step_func(stubRejectionChecker.bind(t))); |
44 }); | 49 }); |
45 }()); | 50 }()); |
46 | 51 |
47 (function() { | 52 (function() { |
48 var t = async_test("Verify the basics of get()."); | 53 var t = async_test("navigator.credentials.get() with a valid options includi
ng password and unmediated."); |
49 t.step(function () { | 54 t.step(function () { |
50 navigator.credentials.get({ | 55 navigator.credentials.get({ |
51 password: true, | 56 password: true, |
52 unmediated: true | 57 unmediated: true |
53 }).then( | 58 }).then( |
54 t.step_func(stubResolverUndefinedChecker.bind(t)), | 59 t.step_func(stubResolverUndefinedChecker.bind(t)), |
55 t.step_func(stubRejectionChecker.bind(t))); | 60 t.step_func(stubRejectionChecker.bind(t))); |
56 }); | 61 }); |
57 }()); | 62 }()); |
58 | 63 |
59 (function() { | 64 (function() { |
60 var t = async_test("Verify the basics of get()."); | 65 var t = async_test("navigator.credentials.get() with a valid options includi
ng federated and unmediated."); |
61 t.step(function () { | 66 t.step(function () { |
62 navigator.credentials.get({ | 67 navigator.credentials.get({ |
63 federated: { | 68 federated: { |
64 providers: [ 'https://example.com/' ] | 69 providers: [ 'https://example.com/' ] |
65 }, | 70 }, |
66 unmediated: true | 71 unmediated: true |
67 }).then( | 72 }).then( |
68 t.step_func(stubResolverUndefinedChecker.bind(t)), | 73 t.step_func(stubResolverUndefinedChecker.bind(t)), |
69 t.step_func(stubRejectionChecker.bind(t))); | 74 t.step_func(stubRejectionChecker.bind(t))); |
70 }); | 75 }); |
71 }()); | 76 }()); |
72 | 77 |
73 (function() { | 78 (function() { |
74 var t = async_test("Verify the basics of get()."); | 79 var t = async_test("navigator.credentials.get() with a valid options includi
ng federated, password and unmediated."); |
75 t.step(function () { | 80 t.step(function () { |
76 navigator.credentials.get({ | 81 navigator.credentials.get({ |
77 password: true, | 82 password: true, |
78 federated: { | 83 federated: { |
79 providers: [ 'https://example.com/' ] | 84 providers: [ 'https://example.com/' ] |
80 }, | 85 }, |
81 unmediated: true | 86 unmediated: true |
82 }).then( | 87 }).then( |
83 t.step_func(stubResolverUndefinedChecker.bind(t)), | 88 t.step_func(stubResolverUndefinedChecker.bind(t)), |
84 t.step_func(stubRejectionChecker.bind(t))); | 89 t.step_func(stubRejectionChecker.bind(t))); |
85 }); | 90 }); |
86 }()); | 91 }()); |
87 | 92 |
88 (function() { | 93 (function() { |
89 var t = async_test("Verify the basics of get()."); | 94 var t = async_test("navigator.credentials.get() with a valid options includi
ng unmediated."); |
90 t.step(function () { | 95 t.step(function () { |
91 navigator.credentials.get({ | 96 navigator.credentials.get({ |
92 unmediated: true | 97 unmediated: true |
93 }).then( | 98 }).then( |
94 t.step_func(stubResolverUndefinedChecker.bind(t)), | 99 t.step_func(stubResolverUndefinedChecker.bind(t)), |
95 t.step_func(stubRejectionChecker.bind(t))); | 100 t.step_func(stubRejectionChecker.bind(t))); |
96 }); | 101 }); |
97 }()); | 102 }()); |
98 | 103 |
99 (function() { | 104 (function() { |
100 var t = async_test("Verify the basics of get()."); | 105 var t = async_test("navigator.credentials.get() with an options including an
unknown attribute."); |
101 t.step(function () { | 106 t.step(function () { |
102 navigator.credentials.get({ | 107 navigator.credentials.get({ |
103 notValid: 'yay!' | 108 notValid: 'yay!' |
104 }).then( | 109 }).then( |
105 t.step_func(stubResolverUndefinedChecker.bind(t)), | 110 t.step_func(stubResolverUndefinedChecker.bind(t)), |
106 t.step_func(stubRejectionChecker.bind(t))); | 111 t.step_func(stubRejectionChecker.bind(t))); |
107 }); | 112 }); |
108 }()); | 113 }()); |
109 | 114 |
110 (function () { | 115 (function () { |
(...skipping 15 matching lines...) Expand all Loading... |
126 assert_equals(c.idName, 'username'); | 131 assert_equals(c.idName, 'username'); |
127 assert_equals(c.passwordName, 'password'); | 132 assert_equals(c.passwordName, 'password'); |
128 assert_equals(c.additionalData, null); | 133 assert_equals(c.additionalData, null); |
129 | 134 |
130 this.done(); | 135 this.done(); |
131 } | 136 } |
132 | 137 |
133 var t = async_test("Verify that the mock returns the values we give it."); | 138 var t = async_test("Verify that the mock returns the values we give it."); |
134 t.step(function() { | 139 t.step(function() { |
135 if (window.testRunner) | 140 if (window.testRunner) |
136 testRunner.addMockCredentialManagerResponse(id, name, icon, password
); | 141 testRunner.setMockCredentialManagerResponse(id, name, icon, password
); |
137 navigator.credentials.get({ | 142 navigator.credentials.get({ |
138 password: true | 143 password: true |
139 }).then( | 144 }).then( |
140 t.step_func(stubResolverChecker.bind(t)), | 145 t.step_func(stubResolverChecker.bind(t)), |
141 t.step_func(stubRejectionChecker.bind(t))); | 146 t.step_func(stubRejectionChecker.bind(t))); |
142 }); | 147 }); |
143 }()); | 148 }()); |
144 </script> | 149 </script> |
OLD | NEW |