2 <title>Credential Manager: get() basics.
</title>
3 <script src=
"../resources/testharness.js"></script>
4 <script src=
"../resources/testharnessreport.js"></script>
5 <script src=
"/serviceworker/resources/interfaces.js"></script>
7 function stubResolverUndefinedChecker(c
) {
8 assert_equals(c
, undefined);
12 function stubRejectionChecker(reason
) {
13 assert_unreached("get() should not reject, but did: " + reason
.name
);
17 var t
= async_test("Verify the basics of get().");
19 navigator
.credentials
.get().then(
20 t
.step_func(stubResolverUndefinedChecker
.bind(t
)),
21 t
.step_func(stubRejectionChecker
.bind(t
)));
26 var t
= async_test("Verify the basics of get({}).");
28 navigator
.credentials
.get({}).then(
29 t
.step_func(stubResolverUndefinedChecker
.bind(t
)),
30 t
.step_func(stubRejectionChecker
.bind(t
)));
35 var t
= async_test("Verify the basics of get().");
37 navigator
.credentials
.get({
38 federated
: [ 'https://example.com/' ]
40 t
.step_func(stubResolverUndefinedChecker
.bind(t
)),
41 t
.step_func(stubRejectionChecker
.bind(t
)));
46 var t
= async_test("Verify the basics of get().");
48 navigator
.credentials
.get({
49 federated
: [ 'https://example.com/' ],
52 t
.step_func(stubResolverUndefinedChecker
.bind(t
)),
53 t
.step_func(stubRejectionChecker
.bind(t
)));
58 var t
= async_test("Verify the basics of get().");
60 navigator
.credentials
.get({
63 t
.step_func(stubResolverUndefinedChecker
.bind(t
)),
64 t
.step_func(stubRejectionChecker
.bind(t
)));
69 var t
= async_test("Verify the basics of get().");
71 navigator
.credentials
.get({
74 t
.step_func(stubResolverUndefinedChecker
.bind(t
)),
75 t
.step_func(stubRejectionChecker
.bind(t
)));
82 var icon
= "http://example.com/";
83 var password
= "pencil";
85 function stubResolverChecker(c
) {
86 verify_interface('PasswordCredential', c
, {
92 assert_equals(c
.id
, id
);
93 assert_equals(c
.name
, name
);
94 assert_equals(c
.iconURL
, icon
);
95 assert_true(c
.toFormData() instanceof FormData
);
100 var t
= async_test("Verify that the mock returns the values we give it.");
102 if (window
.testRunner
)
103 testRunner
.addMockCredentialManagerResponse(id
, name
, icon
, password
);
104 navigator
.credentials
.get().then(
105 t
.step_func(stubResolverChecker
.bind(t
)),
106 t
.step_func(stubRejectionChecker
.bind(t
)));