Index: third_party/WebKit/LayoutTests/http/tests/credentialmanager/credentialscontainer-create-basics.html |
diff --git a/third_party/WebKit/LayoutTests/http/tests/credentialmanager/credentialscontainer-create-basics.html b/third_party/WebKit/LayoutTests/http/tests/credentialmanager/credentialscontainer-create-basics.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d9bf371ab8cc9c290d1555ecb81f170bdf6e596c |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/http/tests/credentialmanager/credentialscontainer-create-basics.html |
@@ -0,0 +1,117 @@ |
+<!DOCTYPE html> |
+<title>Credential Manager: create() basics.</title> |
+<script src="../resources/testharness.js"></script> |
+<script src="../resources/testharnessreport.js"></script> |
+<script src="/serviceworker/resources/interfaces.js"></script> |
+<script> |
+(function() { |
Mike West
2017/05/17 06:57:57
You don't need this wrapper, here or elsewhere.
jdoerrie
2017/05/17 11:29:09
Done.
|
+ promise_test(function(t) { |
+ return promise_rejects(t, "NotSupportedError", |
+ navigator.credentials.create()); |
+ }, "navigator.credentials.create() with no argument."); |
+}()); |
+ |
+(function() { |
+ promise_test(function(t) { |
+ return promise_rejects(t, "NotSupportedError", |
+ navigator.credentials.create({})); |
Mike West
2017/05/17 06:57:57
Please add a test for `{password: { /* invalid pas
jdoerrie
2017/05/17 11:29:09
Done.
|
+ }, "navigator.credentials.create() with empty argument."); |
+}()); |
+ |
+(function() { |
+ promise_test(function(t) { |
+ var credential_data = { |
+ id: 'id', |
+ password: 'pencil', |
+ }; |
+ |
+ return navigator.credentials.create({password: credential_data}) |
+ .then(function(credential) { |
+ assert_equals(credential.id, 'id'); |
+ assert_equals(credential.name, ''); |
+ assert_equals(credential.iconURL, ''); |
+ assert_equals(credential.type, 'password'); |
+ assert_equals(credential.idName, 'username'); |
+ assert_equals(credential.passwordName, 'password'); |
Mike West
2017/05/17 06:57:57
Since this test doesn't rely on the internal mocks
jdoerrie
2017/05/17 08:53:22
Sound good :) Just to make sure I understand you c
|
+ assert_equals(credential.additionalData, null); |
+ }); |
+ }, "navigator.credentials.create() with valid PasswordCredentialData"); |
+}()); |
+ |
+(function() { |
+ promise_test(function(t) { |
+ var f = document.createElement('form'); |
+ f.innerHTML = "<input type='text' name='theId' value='musterman' autocomplete='username'>" |
+ + "<input type='text' name='thePassword' value='sekrit' autocomplete='current-password'>" |
+ + "<input type='text' name='theIcon' value='https://example.com/photo' autocomplete='photo'>" |
+ + "<input type='text' name='theExtraField' value='extra'>" |
+ + "<input type='text' name='theName' value='friendly name' autocomplete='name'>"; |
+ |
+ return navigator.credentials.create({password: f}) |
+ .then(function(credential) { |
+ assert_equals(credential.id, 'musterman'); |
+ assert_equals(credential.name, 'friendly name'); |
+ assert_equals(credential.iconURL, 'https://example.com/photo'); |
+ assert_equals(credential.idName, 'theId'); |
+ assert_equals(credential.passwordName, 'thePassword'); |
+ assert_equals(credential.type, 'password'); |
+ |
+ assert_equals(credential.additionalData.get('theId'), 'musterman'); |
+ assert_equals(credential.additionalData.get('thePassword'), 'sekrit'); |
+ assert_equals(credential.additionalData.get('theIcon'), |
+ 'https://example.com/photo'); |
+ assert_equals(credential.additionalData.get('theName'), 'friendly name'); |
+ assert_equals(credential.additionalData.get('theExtraField'), 'extra'); |
+ }); |
+ }, "navigator.credentials.create() with valid HTMLFormElement"); |
+}()); |
+ |
+(function() { |
+ promise_test(function(t) { |
+ return promise_rejects(t, new TypeError(), |
+ navigator.credentials.create({password: "bogus password data"})); |
+ }, "navigator.credentials.create() with bogus password data"); |
+}()); |
+ |
+(function() { |
+ promise_test(function(t) { |
+ var federated_data = { |
+ id: 'id', |
+ provider: 'https://example.com/', |
+ }; |
+ |
+ return navigator.credentials.create({federated: federated_data}) |
+ .then(function(credential) { |
+ assert_equals(credential.id, 'id'); |
+ assert_equals(credential.name, ''); |
+ assert_equals(credential.iconURL, ''); |
+ assert_equals(credential.type, 'federated'); |
+ }); |
+ }, "navigator.credentials.create() with valid FederatedCredentialData"); |
+}()); |
+ |
+(function() { |
+ promise_test(function(t) { |
+ return promise_rejects(t, new TypeError(), |
+ navigator.credentials.create({federated: "bogus federated data"})); |
+ }, "navigator.credentials.create() with bogus federated data"); |
+}()); |
+ |
+(function() { |
+ promise_test(function(t) { |
+ var credential_data = { |
+ id: 'id', |
+ password: 'pencil', |
+ }; |
+ |
+ var federated_data = { |
+ id: 'id', |
+ provider: 'https://example.com/', |
+ }; |
+ |
+ return promise_rejects(t, "NotSupportedError", |
+ navigator.credentials.create({password: credential_data, |
+ federated: federated_data})); |
+ }, "navigator.credentials.create() with both PasswordCredentialData and FederatedCredentialData"); |
+}()); |
+</script> |