tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

fedcm-third-party-iframe-active-mode.https.html (1699B)


      1 <!doctype html>
      2 <link rel="help" href="https://wicg.github.io/FedCM">
      3 <meta name="timeout" content="long">
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 <script src="/resources/testdriver.js"></script>
      7 <script src="/resources/testdriver-vendor.js"></script>
      8 <script src="/common/get-host-info.sub.js"></script>
      9 <div id=log>
     10 <script type="module">
     11 'use strict';
     12 
     13 import {fedcm_test,
     14        request_options_with_mediation_required,
     15        select_manifest} from '../support/fedcm-helper.sub.js';
     16 
     17 const host = get_host_info();
     18 // This regex removes the filename from the path so that we just get
     19 // the directory.
     20 const basePath = window.location.pathname.replace(/\/[^\/]*$/, '/');
     21 const remoteBaseURL = host.HTTPS_NOTSAMESITE_ORIGIN + basePath;
     22 
     23 async function createIframeAndWaitForMessage(test, iframeUrl) {
     24    const messageWatcher = new EventWatcher(test, window, "message");
     25    let iframe = document.createElement("iframe");
     26    iframe.src = iframeUrl;
     27    iframe.allow = "identity-credentials-get";
     28    document.body.appendChild(iframe);
     29    let message = null;
     30    // Ignore internal "testdriver-complete" messages.
     31    do {
     32        message = await messageWatcher.wait_for("message");
     33    } while (!("result" in message.data));
     34    return message.data;
     35 }
     36 
     37 fedcm_test(async t => {
     38  await select_manifest(t, request_options_with_mediation_required("manifest_iframe.py"));
     39  const message = await createIframeAndWaitForMessage(
     40      t, remoteBaseURL + "../support/fedcm-third-party-iframe.sub.html?active");
     41  assert_equals(message.result, "Pass");
     42 }, "FedCM active mode in third-party iframe shows the iframe origin");
     43 
     44 </script>