Skip to content

Commit c43088d

Browse files
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
1 parent d85c529 commit c43088d

4 files changed

Lines changed: 70 additions & 0 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<html>
2+
<script src="/resources/testharness.js"></script>
3+
<script src="/resources/testharnessreport.js"></script>
4+
5+
<script>
6+
setup({ single_test: true });
7+
function handleEvent(e) {
8+
assert_equals(e.data, 'pass');
9+
done();
10+
}
11+
function on_iframe_load() {
12+
var frameWin = document.getElementById('confirmFrame').contentWindow;
13+
frameWin.postMessage('Confirm', '*');
14+
}
15+
window.addEventListener('message', handleEvent);
16+
</script>
17+
18+
<body>
19+
<iframe id='confirmFrame'
20+
src='http://{{hosts[alt][www]}}:{{ports[http][0]}}/html/webappapis/user-prompts/cannot-show-simple-dialogs/support/confirm.html'
21+
onload='on_iframe_load()'></iframe>
22+
</body>
23+
24+
</html>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<html>
2+
<script src="/resources/testharness.js"></script>
3+
<script src="/resources/testharnessreport.js"></script>
4+
5+
<script>
6+
setup({ single_test: true });
7+
function handleEvent(e) {
8+
assert_equals(e.data, 'pass');
9+
done();
10+
}
11+
function on_iframe_load() {
12+
var frameWin = document.getElementById('promptFrame').contentWindow;
13+
frameWin.postMessage('Prompt', '*');
14+
}
15+
window.addEventListener('message', handleEvent);
16+
</script>
17+
18+
<body>
19+
<iframe id='promptFrame'
20+
src='http://{{hosts[alt][www]}}:{{ports[http][0]}}/html/webappapis/user-prompts/cannot-show-simple-dialogs/support/prompt.html'
21+
onload='on_iframe_load()'></iframe>
22+
</body>
23+
24+
</html>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<script>
2+
function handleEvent(e) {
3+
var conf = window.confirm('Confirm Dialog');
4+
if (conf == false) {
5+
window.parent.postMessage('pass', '*');
6+
} else {
7+
window.parent.postMessage('fail', '*');
8+
}
9+
}
10+
window.addEventListener('message', handleEvent);
11+
</script>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<script>
2+
function handleEvent(e) {
3+
var conf = window.prompt('Prompt Dialog');
4+
if (conf == null) {
5+
window.parent.postMessage('pass', '*');
6+
} else {
7+
window.parent.postMessage('fail', '*');
8+
}
9+
}
10+
window.addEventListener('message', handleEvent);
11+
</script>

0 commit comments

Comments
 (0)