-
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 feature to disallow 3rd party origin subframe JS dialogs
Test: Covered by WPT, except for alert (which can't be tested in WPT). Bug: 1065085 Change-Id: I8a58be63014c7893ab864d3582516a9eddbf5e25 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2645693 Commit-Queue: Carlos IL <[email protected]> Reviewed-by: Avi Drissman <[email protected]> Cr-Commit-Position: refs/heads/master@{#851920}
- Loading branch information
1 parent
7e94a4b
commit 25d7afb
Showing
4 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
...ebappapis/user-prompts/cannot-show-simple-dialogs/confirm-different-origin-frame.sub.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,24 @@ | ||
<html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
|
||
<script> | ||
setup({ single_test: true }); | ||
function handleEvent(e) { | ||
assert_equals(e.data, 'pass'); | ||
done(); | ||
} | ||
function on_iframe_load() { | ||
var frameWin = document.getElementById('confirmFrame').contentWindow; | ||
frameWin.postMessage('Confirm', '*'); | ||
} | ||
window.addEventListener('message', handleEvent); | ||
</script> | ||
|
||
<body> | ||
<iframe id='confirmFrame' | ||
src='http://{{hosts[alt][www]}}:{{ports[http][0]}}/html/webappapis/user-prompts/cannot-show-simple-dialogs/support/confirm.html' | ||
onload='on_iframe_load()'></iframe> | ||
</body> | ||
|
||
</html> |
24 changes: 24 additions & 0 deletions
24
...webappapis/user-prompts/cannot-show-simple-dialogs/prompt-different-origin-frame.sub.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,24 @@ | ||
<html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
|
||
<script> | ||
setup({ single_test: true }); | ||
function handleEvent(e) { | ||
assert_equals(e.data, 'pass'); | ||
done(); | ||
} | ||
function on_iframe_load() { | ||
var frameWin = document.getElementById('promptFrame').contentWindow; | ||
frameWin.postMessage('Prompt', '*'); | ||
} | ||
window.addEventListener('message', handleEvent); | ||
</script> | ||
|
||
<body> | ||
<iframe id='promptFrame' | ||
src='http://{{hosts[alt][www]}}:{{ports[http][0]}}/html/webappapis/user-prompts/cannot-show-simple-dialogs/support/prompt.html' | ||
onload='on_iframe_load()'></iframe> | ||
</body> | ||
|
||
</html> |
11 changes: 11 additions & 0 deletions
11
html/webappapis/user-prompts/cannot-show-simple-dialogs/support/confirm.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,11 @@ | ||
<script> | ||
function handleEvent(e) { | ||
var conf = window.confirm('Confirm Dialog'); | ||
if (conf == false) { | ||
window.parent.postMessage('pass', '*'); | ||
} else { | ||
window.parent.postMessage('fail', '*'); | ||
} | ||
} | ||
window.addEventListener('message', handleEvent); | ||
</script> |
11 changes: 11 additions & 0 deletions
11
html/webappapis/user-prompts/cannot-show-simple-dialogs/support/prompt.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,11 @@ | ||
<script> | ||
function handleEvent(e) { | ||
var conf = window.prompt('Prompt Dialog'); | ||
if (conf == null) { | ||
window.parent.postMessage('pass', '*'); | ||
} else { | ||
window.parent.postMessage('fail', '*'); | ||
} | ||
} | ||
window.addEventListener('message', handleEvent); | ||
</script> |