dom/u2f/tests/test_bind.html
author ffxbld <ffxbld@mozilla.com>
Mon, 10 Aug 2020 10:14:10 +0000
changeset 605814 7bf8ce68eb7981796d4e06fc6c75b3c9ffd5c2a1
parent 536485 617d77613a30d7feab1621cd36cf6d29d8e08544
permissions -rw-r--r--
No Bug, mozilla-release repo-update remote-settings - a=repo-update r=RyanVM Differential Revision: https://phabricator.services.mozilla.com/D86531

<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
  <title>Test that bind() can be called on u2f.register/sign</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
  <script>
    SimpleTest.waitForExplicitFinish();
    SpecialPowers.pushPrefEnv({ "set": [["security.webauth.u2f", true]] },
                              doTest);
    function doTest() {
        // For some reason, exceptions from inside here do not cause a test
        // failure!  Run the actual code we want off something that will report
        // errors properly.
        SimpleTest.executeSoon(function() {
            // Need a new global for the pref to really take effect.
            var iframe = document.createElement("iframe");
            document.documentElement.appendChild(iframe);
            var win = iframe.contentWindow;
            is(typeof(win.u2f.register.bind(win.u2f)), "function",
               "Should be able to bind u2f.register");
            is(typeof(win.u2f.sign.bind(win.u2f)), "function",
               "Should be able to bind u2f.sign");
            iframe.remove();
            SimpleTest.finish();
        });
    }
  </script>
</head>
<body>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test"></pre>
</body>
</html>