summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/fenced-frame/input-on-coop-fenced-frame.https.html
blob: e7b44a0784d2708b313efb7075a1c50c8dcff46d (plain)
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
<!DOCTYPE html>
<title>Test input inside a fenced frame with non-matching COOP.</title>
<link rel="help" href="https://crbug.com/1316535">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/utils.js"></script>
<script src="/common/dispatcher/dispatcher.js"></script>
<script src="resources/utils.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<body>
<script>

// Navigating a fenced frame to a page with a COOP mismatch (in this case,
// unsafe-none -> same-origin-allow-popups) will force the page into a new
// browsing context group.
//
// In Chromium, this forces using a "speculative" frame host which initializes
// the new frame using a different path than normal.
//
// This test is a basic smoke test that sending input through this setup works
// and doesn't cause any crashes. See linked bug for more details.
//
// TODO(https://crbug.com/1411599): COOP is no longer taken into account inside
// fenced frames. To test the "speculative" frame host route, we might only need
// to do a cross-site navigation. Once figured out, use the new approach to test
// that route.
promise_test(async () => {
  const frame = attachFencedFrameContext({
    headers: [["Cross-Origin-Opener-Policy", "same-origin-allow-popups"]]
  });

  await frame.execute(async () => {
    if (document.readyState !== 'complete') {
      await new Promise((resolve) => { addEventListener('load', resolve); });
    }

    assert_equals(document.readyState, 'complete', 'Fenced frame was loaded');

    window.was_clicked = false;
    addEventListener('click', () => {
      window.was_clicked = true;
    });
  });

  await test_driver.click(frame.element);

  // Ensure the fenced frame actually saw the click but the real test is that
  // there isn't a crash.
  await frame.execute(async () => {
    assert_equals(window.was_clicked, true, 'Fenced frame received click');
  });

}, 'Input in non-matching COOP fenced frame doesn\'t crash.');
</script>
</body>