|
|
|
|
|
|
1 |
<!DOCTYPE HTML> |
| 2 |
<html> |
| 3 |
<!-- |
| 4 |
https://bugzilla.mozilla.org/show_bug.cgi?id=886262 |
| 5 |
--> |
| 6 |
<head> |
| 7 |
<meta charset="utf-8"> |
| 8 |
<title>Test for Bug 886262</title> |
| 9 |
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
| 10 |
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
| 11 |
<script type="application/javascript"> |
| 12 |
|
| 13 |
/** Test for Bug 886262 **/ |
| 14 |
SimpleTest.waitForExplicitFinish(); |
| 15 |
var gotSet1 = false; |
| 16 |
var gotSet2 = false; |
| 17 |
var gotSet3 = false; |
| 18 |
|
| 19 |
var gotMessage = false, gotLoad = false; |
| 20 |
|
| 21 |
window.onmessage = function(e) { |
| 22 |
ok(e.data.ran, "Sandboxed allow-scripts iframe should run script"); |
| 23 |
ok(e.data.gotSet, |
| 24 |
"Sandboxed allow-scripts iframe's kid should not be able to set props on its parent"); |
| 25 |
ok(!gotSet2, |
| 26 |
"Sandboxed allow-scripts iframe should not be able to set props on us"); |
| 27 |
if (gotLoad) { |
| 28 |
SimpleTest.finish(); |
| 29 |
} else { |
| 30 |
gotMessage = true; |
| 31 |
} |
| 32 |
} |
| 33 |
addLoadEvent(function() { |
| 34 |
ok(!gotSet1, "Sandboxed iframe should not be able to set props on us"); |
| 35 |
ok(!frames[0][0].scriptRan, "Sandboxed iframe should not run script"); |
| 36 |
|
| 37 |
ok(gotSet3, |
| 38 |
"Sandboxed allow-scripts same-origin iframe should be able to set " + |
| 39 |
"props on us"); |
| 40 |
ok(frames[2][0].scriptRan, |
| 41 |
"Sandboxed allow-scripts same-origin iframe should run script"); |
| 42 |
if (gotMessage) { |
| 43 |
SimpleTest.finish(); |
| 44 |
} else { |
| 45 |
gotLoad = true; |
| 46 |
} |
| 47 |
}); |
| 48 |
</script> |
| 49 |
</head> |
| 50 |
<body> |
| 51 |
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=886262">Mozilla Bug 886262</a> |
| 52 |
<p id="display"></p> |
| 53 |
<div id="content" style="display: none"> |
| 54 |
<iframe sandbox="allow-same-origin" src="data:text/html,<object%20data='data:text/html,<script>var scriptRan = true;</script><script>parent.parent.gotSet1 = true</script>'></object>"></iframe> |
| 55 |
<iframe sandbox="allow-scripts" |
| 56 |
src="data:text/html,<script>var gotSet = false;</script><object%20data='data:text/html,<script>var scriptRan = true;</script><script>parent.gotSet = true</script>'></object><script>window.onload = function() {parent.postMessage({ 'ran': frames[0].scriptRan, 'gotSet': window.gotSet }, '*'); }</script>"></iframe> |
| 57 |
<iframe sandbox="allow-scripts allow-same-origin" src="data:text/html,<object%20data='data:text/html,<script>var scriptRan = true;</script><script>parent.parent.gotSet3 = true</script>'></object>"></iframe> |
| 58 |
</div> |
| 59 |
<pre id="test"> |
| 60 |
</pre> |
| 61 |
</body> |
| 62 |
</html> |