summaryrefslogtreecommitdiffstats
path: root/dom/u2f/tests/frame_register.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
commit2aa4a82499d4becd2284cdb482213d541b8804dd (patch)
treeb80bf8bf13c3766139fbacc530efd0dd9d54394c /dom/u2f/tests/frame_register.html
parentInitial commit. (diff)
downloadfirefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz
firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/u2f/tests/frame_register.html')
-rw-r--r--dom/u2f/tests/frame_register.html80
1 files changed, 80 insertions, 0 deletions
diff --git a/dom/u2f/tests/frame_register.html b/dom/u2f/tests/frame_register.html
new file mode 100644
index 0000000000..4fd484d23c
--- /dev/null
+++ b/dom/u2f/tests/frame_register.html
@@ -0,0 +1,80 @@
+<!DOCTYPE html>
+<meta charset=utf-8>
+<head>
+ <script type="text/javascript" src="frame_utils.js"></script>
+ <script type="text/javascript" src="u2futil.js"></script>
+</head>
+<body>
+<p>Register behavior</p>
+<script class="testbody" type="text/javascript">
+"use strict";
+var version = "U2F_V2";
+var challenge = new Uint8Array(16);
+
+async function doTests() {
+ local_is(window.location.origin, "https://example.com", "Is loaded correctly");
+
+ // basic check
+ await promiseU2FRegister("https://example.com/appId", [{
+ version,
+ challenge: bytesToBase64UrlSafe(challenge),
+ }], [], function(res){
+ local_is(res.version, version, "Version should be set correctly");
+ local_ok(res.clientData.length > 0, "ClientData must be set");
+ local_ok(res.registrationData.length > 0, "RegistrationData must be set");
+ local_is(res.errorCode, 0, "AppID should work from the domain");
+ });
+
+ await promiseU2FRegister("https://example.net/appId", [{
+ version,
+ challenge: bytesToBase64UrlSafe(challenge),
+ }], [], function(res){
+ local_is(res.errorCode, 2, "AppID should not work from other domains");
+ });
+
+ await promiseU2FRegister("", [], [], function(res){
+ local_is(res.errorCode, 2, "Empty register requests");
+ });
+
+ local_doesThrow(function(){
+ u2f.register("", null, [], null);
+ }, "Non-array register requests");
+
+ local_doesThrow(function(){
+ u2f.register("", [], null, null);
+ }, "Non-array sign requests");
+
+ local_doesThrow(function(){
+ u2f.register("", null, null, null);
+ }, "Non-array for both arguments");
+
+ await promiseU2FRegister("", [{}], [], function(res){
+ local_is(res.errorCode, 2, "Empty request");
+ });
+
+ await promiseU2FRegister("https://example.net/appId", [{
+ version,
+ }], [], function(res){
+ local_is(res.errorCode, 2, "Missing challenge");
+ });
+
+ await promiseU2FRegister("https://example.net/appId", [{
+ challenge: bytesToBase64UrlSafe(challenge),
+ }], [], function(res){
+ local_is(res.errorCode, 2, "Missing version");
+ });
+
+ await promiseU2FRegister("https://example.net/appId", [{
+ version: "a_version_00",
+ challenge: bytesToBase64UrlSafe(challenge),
+ }], [], function(res){
+ local_is(res.errorCode, 2, "Invalid version");
+ });
+
+ local_finished();
+};
+
+doTests();
+</script>
+</body>
+</html>