| <!DOCTYPE html> |
| <title>Web Authentication API: PublicKeyCredential's [[get]] with invalid parameters.</title> |
| <script src="/resources/testharness.js"></script> |
| <script src="/resources/testharnessreport.js"></script> |
| <script src="./resources/util.js"></script> |
| <script> |
| const challenge = asciiToUint8Array("123456"); |
| const allowCredential = { type: "public-key", id: asciiToUint8Array("123456") }; |
| |
| const missingAttributeVector = [ |
| // missing top level attribute |
| [undefined], |
| // missing allowCredentials attribute |
| [challenge, undefined, undefined, [{ type: undefined, id: allowCredential.id }]], |
| [challenge, undefined, undefined, [{ type: allowCredential.type, id: undefined }]] |
| ]; |
| |
| const wrongTypeAttributeVector = [ |
| // wrong challenge type |
| [1], |
| [true], |
| [null], |
| [Symbol()], |
| ["foo"], |
| [[ ]], |
| [{ }], |
| // wrong timeout type |
| [challenge, Symbol(), undefined, undefined], |
| // wrong rpId type |
| [challenge, undefined, Symbol(), undefined], |
| // wrong allowCredentials type |
| [challenge, undefined, undefined, [{ type: 1, id: allowCredential.id }]], |
| [challenge, undefined, undefined, [{ type: true, id: allowCredential.id }]], |
| [challenge, undefined, undefined, [{ type: null, id: allowCredential.id }]], |
| [challenge, undefined, undefined, [{ type: Symbol(), id: allowCredential.id }]], |
| [challenge, undefined, undefined, [{ type: "foo", id: allowCredential.id }]], |
| [challenge, undefined, undefined, [{ type: [ ], id: allowCredential.id }]], |
| [challenge, undefined, undefined, [{ type: { }, id: allowCredential.id }]], |
| [challenge, undefined, undefined, [{ type: allowCredential.type, id: 1 }]], |
| [challenge, undefined, undefined, [{ type: allowCredential.type, id: true }]], |
| [challenge, undefined, undefined, [{ type: allowCredential.type, id: null }]], |
| [challenge, undefined, undefined, [{ type: allowCredential.type, id: Symbol() }]], |
| [challenge, undefined, undefined, [{ type: allowCredential.type, id: "foo" }]], |
| [challenge, undefined, undefined, [{ type: allowCredential.type, id: [ ] }]], |
| [challenge, undefined, undefined, [{ type: allowCredential.type, id: { } }]] |
| ]; |
| |
| function makeOptions(attributes) |
| { |
| if (attributes.length == 1) |
| return { publicKey: { challenge: attributes[0] } }; |
| return { publicKey: { challenge: attributes[0], timeout: attributes[1], rpId: attributes[2], allowCredentials: attributes[3] } }; |
| } |
| |
| let index = 1; |
| function runTest(attributesVectors) { |
| attributesVectors.forEach(function(attributesVector) { |
| attributesVector.forEach(async function(attributes) { |
| promise_test(function(t) { |
| return promise_rejects(t, new TypeError(), |
| navigator.credentials.get(makeOptions(attributes))); |
| }, "PublicKeyCredential's [[get]] with with invalid parameters. " + index); |
| index = index + 1; |
| }); |
| }); |
| } |
| |
| const vectors = []; |
| vectors.push(missingAttributeVector); |
| vectors.push(wrongTypeAttributeVector); |
| runTest(vectors); |
| </script> |