-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[shared storage] Disallow shared storage in opaque origin contexts
Why: This aligns with the handling for similar APIs such as localStorage. This should also fix a renderer crash, which is due to the fact that the browser's check for IsSecureFrame() would fail for opaque origin, while the renderer(IDL)'s check for SecureContext wouldn't fail for opaque origin. Bug: 1470628 Change-Id: I52a46ae11b2395b81b6c69236495b32b8e44fd2a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4790029 Reviewed-by: Cammie Smith Barnes <cammie@chromium.org> Commit-Queue: Yao Xiao <yaoxia@chromium.org> Cr-Commit-Position: refs/heads/main@{#1184938}
- Loading branch information
1 parent
b24613a
commit 3685e92
Showing
6 changed files
with
76 additions
and
3 deletions.
There are no files selected for viewing
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
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
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
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
13 changes: 13 additions & 0 deletions
13
...ty/blink/web_tests/external/wpt/shared-storage/resources/verify-shared-storage.https.html
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,13 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<body> | ||
<script> | ||
try { | ||
window.sharedStorage; | ||
window.parent.postMessage({ accessSharedStorageResult: 'success'}, "*"); | ||
} catch (error) { | ||
window.parent.postMessage({ accessSharedStorageResult: 'failure'}, "*"); | ||
} | ||
</script> | ||
</body> | ||
</html> |
41 changes: 41 additions & 0 deletions
41
...tests/external/wpt/shared-storage/shared-storage-in-sandboxed-iframe.tentative.https.html
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,41 @@ | ||
<!doctype html> | ||
<body> | ||
<script src=/resources/testharness.js></script> | ||
<script src=/resources/testharnessreport.js></script> | ||
<script src=/browsing-topics/resources/header-util.sub.js></script> | ||
<script> | ||
function test_shared_storage_in_sandboxed_iframe(test, sandbox_flags, expect_success) { | ||
let frame = document.createElement('iframe'); | ||
frame.sandbox = sandbox_flags; | ||
frame.src = '/shared-storage/resources/verify-shared-storage.https.html'; | ||
|
||
window.addEventListener('message', test.step_func(function handler(evt) { | ||
if (evt.source === frame.contentWindow) { | ||
if (expect_success) { | ||
assert_equals(evt.data.accessSharedStorageResult, 'success'); | ||
} else { | ||
assert_equals(evt.data.accessSharedStorageResult, 'failure'); | ||
} | ||
|
||
document.body.removeChild(frame); | ||
window.removeEventListener('message', handler); | ||
test.done(); | ||
} | ||
})); | ||
|
||
document.body.appendChild(frame); | ||
} | ||
|
||
async_test(t => { | ||
test_shared_storage_in_sandboxed_iframe(t, | ||
/*sandbox_flags=*/'allow-scripts allow-same-origin', | ||
/*expect_success=*/true); | ||
}, 'test shared storage in sandboxed iframe with "allow-same-origin"'); | ||
|
||
async_test(t => { | ||
test_shared_storage_in_sandboxed_iframe(t, | ||
/*sandbox_flags=*/'allow-scripts', | ||
/*expect_success=*/false); | ||
}, 'test shared storage in sandboxed iframe without "allow-same-origin"'); | ||
</script> | ||
</body> |