File: fedcm-iframe.https.html

package info (click to toggle)
firefox 144.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,637,504 kB
  • sloc: cpp: 7,576,692; javascript: 6,430,831; ansic: 3,748,119; python: 1,398,978; xml: 628,810; asm: 438,679; java: 186,194; sh: 63,212; makefile: 19,159; objc: 13,086; perl: 12,986; yacc: 4,583; cs: 3,846; pascal: 3,448; lex: 1,720; ruby: 1,003; exp: 762; php: 436; lisp: 258; awk: 247; sql: 66; sed: 53; csh: 10
file content (91 lines) | stat: -rw-r--r-- 3,757 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<!doctype html>
<link rel="help" href="https://wicg.github.io/FedCM">
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<div id=log>
<script type="module">
'use strict';

import {fedcm_test, set_fedcm_cookie} from './support/fedcm-helper.sub.js';

const host = get_host_info();
// This regex removes the filename from the path so that we just get
// the directory.
const basePath = window.location.pathname.replace(/\/[^\/]*$/, '/');
const remoteBaseURL = host.HTTPS_REMOTE_ORIGIN + basePath;
const localhostBaseURL = "http://localhost:" + host.HTTP_PORT + basePath;

async function createIframeAndWaitForMessage(test, iframeUrl, setPermissionPolicy, style = "") {
    const messageWatcher = new EventWatcher(test, window, "message");
    let iframe = document.createElement("iframe");
    iframe.src = iframeUrl;
    if (setPermissionPolicy) {
      iframe.allow = "identity-credentials-get";
    }
    if (style !== "") {
      iframe.style = style;
    }
    document.body.appendChild(iframe);
    let message = null;
    // Ignore internal "testdriver-complete" messages.
    do {
        message = await messageWatcher.wait_for("message");
    } while (!("result" in message.data));
    return message.data;
}

fedcm_test(async t => {
  const message = await createIframeAndWaitForMessage(
      t, remoteBaseURL + "support/fedcm-iframe.html",
      /*setPermissionPolicy=*/false);
  assert_equals(message.result, "Fail");
  assert_equals(message.errorType, "NotAllowedError");
}, "FedCM disabled in cross origin iframe without permissions policy");

fedcm_test(async t => {
  const message = await createIframeAndWaitForMessage(
      t, remoteBaseURL + "support/fedcm-iframe-level2.html",
      /*setPermissionPolicy=*/true);
  assert_equals(message.result, "Pass");
  assert_equals(message.token, "token");
}, "FedCM enabled in 2 level deep nested iframe. FedCM should be enabled regardless of iframe nesting depth");

fedcm_test(async t => {
  const message = await createIframeAndWaitForMessage(
      t, remoteBaseURL + "support/fedcm-iframe.html",
      /*setPermissionPolicy=*/true, /*style=*/"display:none;");
  assert_equals(message.result, "Pass");
  assert_equals(message.token, "token");
}, "FedCM enabled in invisible iframe. FedCM should be enabled as long as the top frame is visible");

fedcm_test(async t => {
  const message = await createIframeAndWaitForMessage(
      t, remoteBaseURL + "support/fedcm-iframe-level2.html",
      /*setPermissionPolicy=*/false);
  assert_equals(message.result, "Fail");
  assert_equals(message.errorType, "NotAllowedError");
}, "FedCM disabled in 2 level deep nested iframe where middle iframe does not have permission policy");

fedcm_test(async t => {
  const message = await createIframeAndWaitForMessage(
      t, remoteBaseURL + "support/fedcm-iframe-level2.html?permission=0",
      /*setPermissionPolicy=*/true);
  assert_equals(message.result, "Fail");
  assert_equals(message.errorType, "NotAllowedError");
}, "FedCM disabled in 2 level deep nested iframe where innermost iframe does not have permission policy");

fedcm_test(async t => {
  // This is only an iframe because there's no other way to have this URL
  // loaded from localhost.
  const message = await createIframeAndWaitForMessage(
      t, localhostBaseURL + "support/fedcm-iframe.html",
      /*setPermissionPolicy=*/true);
  assert_equals(message.result, "Pass");
  assert_equals(message.token, "token");
}, "FedCM should work in non-HTTPS URLs on localhost");

</script>