dom/u2f/tests/frame_appid_facet_subdomain.html
author ffxbld <ffxbld@mozilla.com>
Mon, 10 Aug 2020 10:14:10 +0000
changeset 605814 7bf8ce68eb7981796d4e06fc6c75b3c9ffd5c2a1
parent 555809 3b3c5e0e1bc4a58d8a7d5718745cc41153e06a76
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>
<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>AppID / FacetID behavior check for subdomain processing</p>
<script class="testbody" type="text/javascript">
"use strict";

async function doTests() {
  var version = "U2F_V2";
  var challenge = new Uint8Array(16);

  local_is(window.location.origin, "https://test1.example.com", "Is loaded correctly");

  // same domain check
  await promiseU2FRegister("https://test1.example.com/appId", [{
    version,
    challenge: bytesToBase64UrlSafe(challenge),
  }], [], function(res){
    local_is(res.errorCode, 0, "AppID should work from a different path of this domain");
  });

  // same domain check, but wrong scheme
  await promiseU2FRegister("http://test1.example.com/appId", [{
    version,
    challenge: bytesToBase64UrlSafe(challenge),
  }], [], function(res){
    local_isnot(res.errorCode, 0, "AppID should not work when using a different scheme");
  });

  // eTLD+1 subdomain check
  await promiseU2FRegister("https://example.com/appId", [{
    version,
    challenge: bytesToBase64UrlSafe(challenge),
  }], [], function(res){
    // Changed in Bug 1244959 to behave like W3C Web Authentication
    local_is(res.errorCode, 0, "AppID should work from another subdomain in this registered domain");
  });

  // sub-subdomain check
  await promiseU2FRegister("https://sub.test1.example.com/appId", [{
    version,
    challenge: bytesToBase64UrlSafe(challenge),
  }], [], function(res){
    // Changed in Bug 1244959 to behave like W3C Web Authentication
    local_is(res.errorCode, 0, "AppID should work from a sub-subdomain");
  });

  // sub-subdomain check
  await promiseU2FRegister("https://test2.example.com/appId", [{
    version,
    challenge: bytesToBase64UrlSafe(challenge),
  }], [], function(res){
    // Changed in Bug 1244959 to behave like W3C Web Authentication
    local_is(res.errorCode, 0, "AppID should work from another subdomain of the eTLD+1");
  });

  // other domain check
  await promiseU2FRegister("https://mochi.test:8888/appId", [{
    version,
    challenge: bytesToBase64UrlSafe(challenge),
  }], [], function(res){
    local_isnot(res.errorCode, 0, "AppID should not work from other domains");
  });

  // TLD check
  await promiseU2FRegister("https://com:8888/appId", [{
    version,
    challenge: bytesToBase64UrlSafe(challenge),
  }], [], function(res){
    local_isnot(res.errorCode, 0, "AppID should not work from the eTLD itself");
  });

  local_finished();
};

doTests();

</script>
</body>
</html>