-
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.
Add ability to block same-origin access via document-access feature p…
…olicy Intent to Implement: https://groups.google.com/a/chromium.org/d/msg/blink-dev/Cibo-GNPs7Y/RznlX7WKDAAJ Spec: whatwg/html#4606 BUG=961448 Change-Id: I3c2ff129a71a8ccb5a0015661770adc7ff22d14b
- Loading branch information
1 parent
1cb5f28
commit 021922b
Showing
4 changed files
with
113 additions
and
0 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
23 changes: 23 additions & 0 deletions
23
html/browsers/windows/document-access/document_access_feature_policy.tentative.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,23 @@ | ||
<!DOCTYPE html> | ||
<body> | ||
<script src=/resources/testharness.js></script> | ||
<script src=/resources/testharnessreport.js></script> | ||
<script src=/feature-policy/resources/featurepolicy.js></script> | ||
<script> | ||
run_all_fp_tests_allow_all_same_origin( | ||
'document-access', | ||
'SecurityError', | ||
() => { | ||
return new Promise((resolve, reject) => { | ||
try { | ||
// attempt to access something in your parent that would | ||
// be same-origin access only. | ||
parent.location.href; | ||
resolve(); | ||
} catch(e) { | ||
reject(e); | ||
} | ||
}); | ||
}); | ||
</script> | ||
</body> |
25 changes: 25 additions & 0 deletions
25
html/browsers/windows/document-access/document_access_parent_access.tentative.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,25 @@ | ||
<!DOCTYPE html> | ||
<body> | ||
<script src=/resources/testharness.js></script> | ||
<script src=/resources/testharnessreport.js></script> | ||
<iframe allow="document-access 'none'" src="resources/child.html"></iframe> | ||
<script> | ||
async_test(function (t) { | ||
// Ensure post message works correctly. | ||
window.onmessage = t.step_func((e) => { | ||
if (e.data == 'load') { | ||
frames[0].postMessage('ping'); | ||
} else if (e.data == 'pong') { | ||
t.done(); | ||
} | ||
}); | ||
try { | ||
// Test that the parent is not allowed to access the child either. | ||
frames[0].alert; | ||
assert_unreachable('Security Error should have been thrown'); | ||
} catch(e) { | ||
assert_equals(e.name, 'SecurityError', 'Security Error thrown'); | ||
} | ||
}); | ||
</script> | ||
</body> |
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,6 @@ | ||
<script> | ||
parent.postMessage('load'); | ||
window.onmessage = (e) => { | ||
parent.postMessage('pong'); | ||
}; | ||
</script> |