[WebAuthN] Implement authenticatorMakeCredential
[WebKit-https.git] / LayoutTests / http / wpt / credential-management / credentialscontainer-store-basics.https.html
index 01b9bbb..1988825 100644 (file)
             chars.push(str.charCodeAt(i));
         return new Uint8Array(chars);
     }
             chars.push(str.charCodeAt(i));
         return new Uint8Array(chars);
     }
+    function hexStringToUint8Array(hexString)
+    {
+        if (hexString.length % 2 != 0)
+            throw "Invalid hexString";
+        var arrayBuffer = new Uint8Array(hexString.length / 2);
+
+        for (var i = 0; i < hexString.length; i += 2) {
+            var byteValue = parseInt(hexString.substr(i, 2), 16);
+            if (byteValue == NaN)
+                throw "Invalid hexString";
+            arrayBuffer[i/2] = byteValue;
+        }
+
+        return arrayBuffer;
+    }
 
     promise_test(async function(t) {
         const options = {
 
     promise_test(async function(t) {
         const options = {
                 pubKeyCredParams: [{ type: "public-key", alg: -7 }],
             }
         };
                 pubKeyCredParams: [{ type: "public-key", alg: -7 }],
             }
         };
-
+        // A mock attestation object
+        internals.mockCredentialsMessenger.setCreationReturnBundle(hexStringToUint8Array('00'), hexStringToUint8Array('01'));
         const credential = await navigator.credentials.create(options);
         const credential = await navigator.credentials.create(options);
+
         return promise_rejects(t, "NotSupportedError",
             navigator.credentials.store(credential));
     }, "navigator.credentials.store().");
         return promise_rejects(t, "NotSupportedError",
             navigator.credentials.store(credential));
     }, "navigator.credentials.store().");