summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/cross-origin-opener-policy/tentative/restrict-properties/iframe-popup-about-blank.https.window.js
blob: d63b69e83f33fe10d88c5e9aad59da0f596606e1 (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
// META: script=/common/get-host-info.sub.js
// META: script=/common/utils.js
// META: script=/common/dispatcher/dispatcher.js

const executor_path = '/common/dispatcher/executor.html?pipe=';
const cross_origin = get_host_info().OTHER_ORIGIN;
const coep_require_corp_header =
    '|header(Cross-Origin-Embedder-Policy,require-corp)';
const corp_cross_origin_header =
    '|header(Cross-Origin-Resource-Policy,cross-origin)';

promise_test(async t => {
  assert_true(crossOriginIsolated, 'Is main frame crossOriginIsolated?');

  const reply_token = token();
  const iframe_token = token();

  const iframe = document.createElement('iframe');
  iframe.src = cross_origin + executor_path + coep_require_corp_header +
      corp_cross_origin_header + `&uuid=${iframe_token}`;
  document.body.appendChild(iframe);

  send(iframe_token, `send('${reply_token}', 'Iframe loaded');`);
  assert_equals(await receive(reply_token), 'Iframe loaded');

  send(iframe_token, `
    window.popup = window.open();
    send('${reply_token}', popup === null);
  `);
  assert_equals(await receive(reply_token), 'false', 'Is popup handle null?');

  send(
      iframe_token,
      `send('${reply_token}', popup.window.crossOriginIsolated);`);
  assert_equals(
      await receive(reply_token), 'false', 'Is popup crossOriginIsolated?');
});