summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/credential-management/credentialscontainer-create-basics.https.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/credential-management/credentialscontainer-create-basics.https.html
parentInitial commit. (diff)
downloadfirefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz
firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/credential-management/credentialscontainer-create-basics.https.html')
-rw-r--r--testing/web-platform/tests/credential-management/credentialscontainer-create-basics.https.html135
1 files changed, 135 insertions, 0 deletions
diff --git a/testing/web-platform/tests/credential-management/credentialscontainer-create-basics.https.html b/testing/web-platform/tests/credential-management/credentialscontainer-create-basics.https.html
new file mode 100644
index 0000000000..ea2326c4ae
--- /dev/null
+++ b/testing/web-platform/tests/credential-management/credentialscontainer-create-basics.https.html
@@ -0,0 +1,135 @@
+<!DOCTYPE html>
+<title>Credential Management API: create() basics.</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+promise_test(function(t) {
+ return promise_rejects_dom(t, "NotSupportedError",
+ navigator.credentials.create());
+}, "navigator.credentials.create() with no argument.");
+
+promise_test(function(t) {
+ return promise_rejects_dom(t, "NotSupportedError",
+ navigator.credentials.create({}));
+}, "navigator.credentials.create() with empty argument.");
+
+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.password, 'pencil');
+ });
+}, "navigator.credentials.create() with valid PasswordCredentialData");
+
+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.type, 'password');
+ assert_equals(credential.password, 'sekrit');
+ });
+}, "navigator.credentials.create() with valid HTMLFormElement");
+
+promise_test(function(t) {
+ return promise_rejects_js(t, TypeError,
+ navigator.credentials.create({password: "bogus password data"}));
+}, "navigator.credentials.create() with bogus password data");
+
+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");
+
+promise_test(function(t) {
+ return promise_rejects_js(t, TypeError,
+ navigator.credentials.create({federated: "bogus federated data"}));
+}, "navigator.credentials.create() with bogus federated data");
+
+promise_test(function(t) {
+ return promise_rejects_js(t, TypeError,
+ navigator.credentials.create({publicKey: "bogus publicKey data"}));
+}, "navigator.credentials.create() with bogus publicKey data");
+
+promise_test(function(t) {
+ var credential_data = {
+ id: 'id',
+ password: 'pencil',
+ };
+
+ var federated_data = {
+ id: 'id',
+ provider: 'https://example.com/',
+ };
+
+ return promise_rejects_dom(t, "NotSupportedError",
+ navigator.credentials.create({
+ password: credential_data,
+ federated: federated_data,
+ }));
+}, "navigator.credentials.create() with both PasswordCredentialData and FederatedCredentialData");
+
+promise_test(function(t) {
+ return promise_rejects_js(t, TypeError,
+ navigator.credentials.create({
+ password: "bogus password data",
+ federated: "bogus federated data",
+ }));
+}, "navigator.credentials.create() with bogus password and federated data");
+
+promise_test(function(t) {
+ return promise_rejects_js(t, TypeError,
+ navigator.credentials.create({
+ federated: "bogus federated data",
+ publicKey: "bogus publicKey data",
+ }));
+}, "navigator.credentials.create() with bogus federated and publicKey data");
+
+promise_test(function(t) {
+ return promise_rejects_js(t, TypeError,
+ navigator.credentials.create({
+ password: "bogus password data",
+ publicKey: "bogus publicKey data",
+ }));
+}, "navigator.credentials.create() with bogus password and publicKey data");
+
+promise_test(function(t) {
+ return promise_rejects_js(t, TypeError,
+ navigator.credentials.create({
+ password: "bogus password data",
+ federated: "bogus federated data",
+ publicKey: "bogus publicKey data",
+ }));
+}, "navigator.credentials.create() with bogus password, federated, and publicKey data");
+
+promise_test(function(t) {
+ return promise_rejects_dom(t, "NotSupportedError",
+ navigator.credentials.create({bogus_key: "bogus data"}));
+}, "navigator.credentials.create() with bogus data");
+</script>