Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / credentialmanager / credentialscontainer-get-basics.html
blob96c784c7c200d213e10077245df05ab7beefe087
1 <!DOCTYPE html>
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>
6 <script>
7 function stubResolverUndefinedChecker(c) {
8 assert_equals(c, undefined);
9 this.done();
12 function stubRejectionChecker(reason) {
13 assert_unreached("get() should not reject, but did: " + reason.name);
16 (function() {
17 var t = async_test("Verify the basics of get().");
18 t.step(function () {
19 navigator.credentials.get().then(
20 t.step_func(stubResolverUndefinedChecker.bind(t)),
21 t.step_func(stubRejectionChecker.bind(t)));
22 });
23 }());
25 (function() {
26 var t = async_test("Verify the basics of get({}).");
27 t.step(function () {
28 navigator.credentials.get({}).then(
29 t.step_func(stubResolverUndefinedChecker.bind(t)),
30 t.step_func(stubRejectionChecker.bind(t)));
31 });
32 }());
34 (function() {
35 var t = async_test("Verify the basics of get().");
36 t.step(function () {
37 navigator.credentials.get({
38 federated: [ 'https://example.com/' ]
39 }).then(
40 t.step_func(stubResolverUndefinedChecker.bind(t)),
41 t.step_func(stubRejectionChecker.bind(t)));
42 });
43 }());
45 (function() {
46 var t = async_test("Verify the basics of get().");
47 t.step(function () {
48 navigator.credentials.get({
49 federated: [ 'https://example.com/' ],
50 suppressUI: true
51 }).then(
52 t.step_func(stubResolverUndefinedChecker.bind(t)),
53 t.step_func(stubRejectionChecker.bind(t)));
54 });
55 }());
57 (function() {
58 var t = async_test("Verify the basics of get().");
59 t.step(function () {
60 navigator.credentials.get({
61 suppressUI: true
62 }).then(
63 t.step_func(stubResolverUndefinedChecker.bind(t)),
64 t.step_func(stubRejectionChecker.bind(t)));
65 });
66 }());
68 (function() {
69 var t = async_test("Verify the basics of get().");
70 t.step(function () {
71 navigator.credentials.get({
72 notValid: 'yay!'
73 }).then(
74 t.step_func(stubResolverUndefinedChecker.bind(t)),
75 t.step_func(stubRejectionChecker.bind(t)));
76 });
77 }());
79 (function () {
80 var id = "id";
81 var name = "name";
82 var icon = "http://example.com/";
83 var password = "pencil";
85 function stubResolverChecker(c) {
86 verify_interface('PasswordCredential', c, {
87 id: 'string',
88 name: 'string',
89 iconURL: 'string'
90 });
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);
97 this.done();
100 var t = async_test("Verify that the mock returns the values we give it.");
101 t.step(function() {
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)));
107 });
108 }());
109 </script>