-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test anonymous iframe in cross-origin-isolated context.
Instead of crashing, relax checks to allow anonymous iframe inside cross-origin-isolated context. Add a WPT test asking interesting questions about when the cross-origin-isolated capability is delegated toward the anonymous iframe (=open question). In any case, the anonymous iframe must never be blocked, which this test tests too. Bug: 1237018 Change-Id: I973a98ccc58c7ee8399052a53ef2b2f3f5610f59 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3074564 Commit-Queue: Camille Lamy <clamy@chromium.org> Auto-Submit: Arthur Sonzogni <arthursonzogni@chromium.org> Reviewed-by: Camille Lamy <clamy@chromium.org> Cr-Commit-Position: refs/heads/master@{#910303}
- Loading branch information
1 parent
a8f1515
commit da3d99e
Showing
1 changed file
with
112 additions
and
0 deletions.
There are no files selected for viewing
112 changes: 112 additions & 0 deletions
112
html/cross-origin-embedder-policy/anonymous-iframe/cross-origin-isolated.tentative.window.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
// META: script=/common/get-host-info.sub.js | ||
// META: script=/common/utils.js | ||
// META: script=../credentialless/resources/common.js | ||
// META: script=../credentialless/resources/dispatcher.js | ||
// META: timeout=long | ||
|
||
const same_origin = get_host_info().HTTPS_ORIGIN; | ||
const cross_origin = get_host_info().HTTPS_REMOTE_ORIGIN; | ||
|
||
const CROSS_ORIGIN_ISOLATED = "true"; | ||
const NOT_CROSS_ORIGIN_ISOLATED = "false"; | ||
const BLOCKED = "blocked"; | ||
|
||
// Vary the headers of a parent and its anonymous iframe. Determine in which | ||
// cases the anonymous iframe gets the cross-origin-isolated capability. | ||
const crossOriginIsolatedTest = (description, params) => { | ||
const default_params = { | ||
parent_origin: same_origin, | ||
parent_headers: '', | ||
parent_allow: '', | ||
child_origin: same_origin, | ||
child_headers: '', | ||
child_state: NOT_CROSS_ORIGIN_ISOLATED, | ||
}; | ||
params = {...default_params, ...params}; | ||
|
||
promise_test_parallel(async test => { | ||
// Create the parent. | ||
const parent_token = token(); | ||
const parent_url = params.parent_origin + executor_path + | ||
params.parent_headers + `&uuid=${parent_token}`; | ||
const parent = window.open(parent_url) | ||
add_completion_callback(() => parent.close()); | ||
|
||
// Create its anonymous iframe. | ||
const child_token = token(); | ||
const child_url = params.child_origin + executor_path + | ||
params.child_headers + `&uuid=${child_token}`; | ||
send(parent_token, ` | ||
const iframe = document.createElement("iframe"); | ||
iframe.src = "${child_url}"; | ||
iframe.anonymous = true; | ||
iframe.allow="${params.parent_allow}"; | ||
document.body.appendChild(iframe); | ||
`); | ||
|
||
// Check child's cross-origin isolation state. | ||
const this_token = token(); | ||
send(child_token, ` | ||
send("${this_token}", window.crossOriginIsolated); | ||
`); | ||
|
||
test.step_timeout(() => { | ||
send(this_token, 'blocked'); | ||
}, 3000); | ||
|
||
assert_equals(await receive(this_token), params.child_state); | ||
}, description); | ||
}; | ||
|
||
crossOriginIsolatedTest("Basic", { | ||
child_state: NOT_CROSS_ORIGIN_ISOLATED, | ||
}); | ||
|
||
crossOriginIsolatedTest("Basic + child cross_origin", { | ||
child_origin: cross_origin, | ||
child_state: NOT_CROSS_ORIGIN_ISOLATED, | ||
}); | ||
|
||
crossOriginIsolatedTest("Parent coep_require-corp", { | ||
parent_headers: coep_require_corp, | ||
child_state: NOT_CROSS_ORIGIN_ISOLATED, | ||
}); | ||
|
||
crossOriginIsolatedTest("Parent coep_require-corp + cross_origin", { | ||
parent_headers: coep_require_corp, | ||
child_origin: cross_origin, | ||
child_state: NOT_CROSS_ORIGIN_ISOLATED, | ||
}); | ||
|
||
crossOriginIsolatedTest("Parent COI", { | ||
parent_headers: coop_same_origin + coep_require_corp, | ||
child_state: CROSS_ORIGIN_ISOLATED, | ||
}); | ||
|
||
crossOriginIsolatedTest("Parent COI + child cross-origin", { | ||
parent_headers: coop_same_origin + coep_require_corp, | ||
child_origin: cross_origin, | ||
child_state: NOT_CROSS_ORIGIN_ISOLATED, | ||
}); | ||
|
||
crossOriginIsolatedTest("Parent COI + child cross-origin COEP/CORP", { | ||
parent_headers: coop_same_origin + coep_require_corp, | ||
child_headers: coep_require_corp + corp_cross_origin, | ||
child_origin: cross_origin, | ||
child_state: NOT_CROSS_ORIGIN_ISOLATED, | ||
}); | ||
|
||
crossOriginIsolatedTest('Parent COI allow + child cross_origin', { | ||
parent_headers: coop_same_origin + coep_require_corp, | ||
parent_allow: 'cross-origin-isolated', | ||
child_origin: cross_origin, | ||
child_state: CROSS_ORIGIN_ISOLATED, | ||
}); | ||
|
||
crossOriginIsolatedTest('Parent COI allow + child cross-origin COEP/CORP', { | ||
parent_headers: coop_same_origin + coep_require_corp, | ||
parent_allow: 'cross-origin-isolated', | ||
child_headers: coep_require_corp + corp_cross_origin, | ||
child_origin: cross_origin, | ||
child_state: CROSS_ORIGIN_ISOLATED, | ||
}); |