|
|
|
Lines 9-24
Implement HTML5 sandbox attribute for IF
|
Link Here
|
|---|
|
| 9 |
<title>Test for Bug 341604</title> |
9 |
<title>Test for Bug 341604</title> |
| 10 |
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
10 |
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
| 11 |
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
11 |
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
| 12 |
</head> |
12 |
</head> |
| 13 |
<script type="application/javascript"> |
13 |
<script type="application/javascript"> |
| 14 |
/** Test for Bug 341604 - Implement HTML5 sandbox attribute for IFRAMEs **/ |
14 |
/** Test for Bug 341604 - Implement HTML5 sandbox attribute for IFRAMEs **/ |
| 15 |
/** Inheritance Tests **/ |
15 |
/** Inheritance Tests **/ |
| 16 |
|
16 |
|
|
|
17 |
SimpleTest.expectAssertions(1, 1); |
| 17 |
SimpleTest.waitForExplicitFinish(); |
18 |
SimpleTest.waitForExplicitFinish(); |
| 18 |
|
19 |
|
| 19 |
// A postMessage handler that is used by sandboxed iframes without |
20 |
// A postMessage handler that is used by sandboxed iframes without |
| 20 |
// 'allow-same-origin' to communicate pass/fail back to this main page. |
21 |
// 'allow-same-origin' to communicate pass/fail back to this main page. |
| 21 |
// It expects to be called with an object like {ok: true/false, desc: |
22 |
// It expects to be called with an object like {ok: true/false, desc: |
| 22 |
// <description of the test> which it then forwards to ok(). |
23 |
// <description of the test> which it then forwards to ok(). |
| 23 |
window.addEventListener("message", receiveMessage, false); |
24 |
window.addEventListener("message", receiveMessage, false); |
| 24 |
|
25 |
|
|
Lines 34-51
function ok_wrapper(result, desc) {
|
Link Here
|
|---|
|
| 34 |
ok(result, desc); |
35 |
ok(result, desc); |
| 35 |
|
36 |
|
| 36 |
completedTests++; |
37 |
completedTests++; |
| 37 |
|
38 |
|
| 38 |
if (result) { |
39 |
if (result) { |
| 39 |
passedTests++; |
40 |
passedTests++; |
| 40 |
} |
41 |
} |
| 41 |
|
42 |
|
| 42 |
if (completedTests == 6) { |
43 |
if (completedTests == 13) { |
| 43 |
is(passedTests, 6, "there should be 6 passed inheritance tests"); |
44 |
is(passedTests, completedTests, "there should be " + completedTests + " passed inheritance tests"); |
| 44 |
SimpleTest.finish(); |
45 |
SimpleTest.finish(); |
| 45 |
} |
46 |
} |
| 46 |
} |
47 |
} |
| 47 |
|
48 |
|
| 48 |
function doTest() { |
49 |
function doTest() { |
| 49 |
// fails if bad |
50 |
// fails if bad |
| 50 |
// 1) an iframe with no sandbox attribute inside an iframe that has sandbox = "" |
51 |
// 1) an iframe with no sandbox attribute inside an iframe that has sandbox = "" |
| 51 |
// should not be able to execute scripts (cannot ever loosen permissions) |
52 |
// should not be able to execute scripts (cannot ever loosen permissions) |
|
Lines 97-118
function doTest() {
|
Link Here
|
|---|
|
| 97 |
// 10) a <frame> inside an <iframe> sandboxed with 'allow-scripts' should not be same |
98 |
// 10) a <frame> inside an <iframe> sandboxed with 'allow-scripts' should not be same |
| 98 |
// origin with this document |
99 |
// origin with this document |
| 99 |
// done by file_iframe_sandbox_a_if11.html which is contained with file_iframe_sandbox_a_if10.html |
100 |
// done by file_iframe_sandbox_a_if11.html which is contained with file_iframe_sandbox_a_if10.html |
| 100 |
|
101 |
|
| 101 |
// passes if good |
102 |
// passes if good |
| 102 |
// 11) a <frame> inside a <frame> inside an <iframe> sandboxed with 'allow-scripts' should not be same |
103 |
// 11) a <frame> inside a <frame> inside an <iframe> sandboxed with 'allow-scripts' should not be same |
| 103 |
// origin with its parent frame or this document |
104 |
// origin with its parent frame or this document |
| 104 |
// done by file_iframe_sandbox_a_if12.html which is contained with file_iframe_sandbox_a_if11.html |
105 |
// done by file_iframe_sandbox_a_if12.html which is contained with file_iframe_sandbox_a_if11.html |
|
|
106 |
|
| 107 |
// passes if good, fails if bad |
| 108 |
// 12) An <object> inside an <iframe> sandboxed with 'allow-scripts' should not be same |
| 109 |
// origin with this document |
| 110 |
// Done by file_iframe_sandbox_a_if14.html which is contained within file_iframe_sandbox_a_if13.html |
| 111 |
|
| 112 |
// passes if good, fails if bad |
| 113 |
// 13) An <object> inside an <object> inside an <iframe> sandboxed with 'allow-scripts' should not be same |
| 114 |
// origin with its parent frame or this document |
| 115 |
// Done by file_iframe_sandbox_a_if15.html which is contained within file_iframe_sandbox_a_if14.html |
| 116 |
|
| 117 |
// passes if good, fails if bad |
| 118 |
// 14) An <object> inside a <frame> inside an <iframe> sandboxed with 'allow-scripts' should not be same |
| 119 |
// origin with its parent frame or this document |
| 120 |
// Done by file_iframe_sandbox_a_if15.html which is contained within file_iframe_sandbox_a_if16.html |
| 121 |
// which is contained within file_iframe_sandbox_a_if10.html |
| 122 |
|
| 123 |
// passes if good |
| 124 |
// 15) An <object> inside an <object> inside an <iframe> sandboxed with 'allow-scripts allow-forms' |
| 125 |
// should be able to submit forms. |
| 126 |
// Done by file_iframe_sandbox_a_if15.html which is contained within file_iframe_sandbox_a_if14.html |
| 127 |
|
| 128 |
// passes if good |
| 129 |
// 16) An <object> inside a <frame> inside an <iframe> sandboxed with 'allow-scripts allow-forms' |
| 130 |
// should be able to submit forms. |
| 131 |
// Done by file_iframe_sandbox_a_if15.html which is contained within file_iframe_sandbox_a_if16.html |
| 132 |
// which is contained within file_iframe_sandbox_a_if10.html |
| 133 |
|
| 134 |
// fails if bad |
| 135 |
// 17) An <object> inside an <iframe> sandboxed with 'allow-same-origin' |
| 136 |
// should not be able to run scripts. |
| 137 |
// Done by iframe "if_no_scripts" using a data: load. |
| 138 |
|
| 139 |
// passes if good |
| 140 |
// 18) An <object> inside an <iframe> sandboxed with 'allow-scripts allow-same-origin' |
| 141 |
// should be able to run scripts and be same origin with this document. |
| 142 |
// Done by iframe "if_scripts" using a data: load. |
| 143 |
|
| 144 |
// passes if good, fails if bad |
| 145 |
// 19) Make sure that the parent's document's sandboxing flags are copied when |
| 146 |
// changing the sandbox flags on an iframe inside an iframe. |
| 147 |
// Done in file_iframe_sandbox_a_if17.html and file_iframe_sandbox_a_if18.html |
| 105 |
} |
148 |
} |
| 106 |
|
149 |
|
| 107 |
addLoadEvent(doTest); |
150 |
addLoadEvent(doTest); |
| 108 |
</script> |
151 |
</script> |
| 109 |
<body> |
152 |
<body> |
| 110 |
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=341604">Mozilla Bug 341604</a> - Implement HTML5 sandbox attribute for IFRAMEs |
153 |
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=341604">Mozilla Bug 341604</a> - Implement HTML5 sandbox attribute for IFRAMEs |
| 111 |
<p id="display"></p> |
154 |
<p id="display"></p> |
| 112 |
<div id="content"> |
155 |
<div id="content"> |
| 113 |
<iframe sandbox="" id="if_1" src="file_iframe_sandbox_a_if1.html" height="10" width="10"></iframe> |
156 |
<iframe sandbox="" id="if_1" src="file_iframe_sandbox_a_if1.html" height="10" width="10"></iframe> |
| 114 |
<iframe sandbox="allow-scripts" id="if_3" src="file_iframe_sandbox_a_if3.html" height="10" width="10"></iframe> |
157 |
<iframe sandbox="allow-scripts" id="if_3" src="file_iframe_sandbox_a_if3.html" height="10" width="10"></iframe> |
| 115 |
<iframe sandbox="allow-scripts allow-same-origin" id="if_5" src="file_iframe_sandbox_a_if5.html" height="10" width="10"></iframe> |
158 |
<iframe sandbox="allow-scripts allow-same-origin" id="if_5" src="file_iframe_sandbox_a_if5.html" height="10" width="10"></iframe> |
| 116 |
<iframe sandbox="allow-scripts allow-same-origin" id="if_8" src="file_iframe_sandbox_a_if8.html" height="10" width="10"></iframe> |
159 |
<iframe sandbox="allow-scripts allow-same-origin" id="if_8" src="file_iframe_sandbox_a_if8.html" height="10" width="10"></iframe> |
| 117 |
<iframe sandbox="allow-scripts" id="if_10" src="file_iframe_sandbox_a_if10.html" height="10" width="10"></iframe> |
160 |
<iframe sandbox="allow-scripts allow-forms" id="if_10" src="file_iframe_sandbox_a_if10.html" height="10" width="10"></iframe> |
|
|
161 |
<iframe sandbox="allow-scripts allow-forms" id="if_13" src="file_iframe_sandbox_a_if13.html" height="10" width="10"></iframe> |
| 162 |
<iframe sandbox="allow-same-origin" id="if_no_scripts" src="data:text/html,<object%20data='data:text/html,<script>parent.parent.ok_wrapper(false, "an object inside an iframe sandboxed with only allow-same-origin should not be able to run scripts")</script>'></object>" height="10" width="10"></iframe> |
| 163 |
<iframe sandbox="allow-scripts allow-same-origin" id="if_scripts" src="data:text/html,<object%20data='data:text/html,<script>parent.parent.ok_wrapper(true, "an object inside an iframe sandboxed with allow-scripts allow-same-origin should be able to run scripts and call functions in the parent of the iframe")</script>'></object>" height="10" width="10"></iframe> |
| 164 |
<iframe sandbox="allow-same-origin" id="if_19" src="data:text/html,<iframe%20data='data:text/html,<script>parent.parent.ok_wrapper(true, "an object inside an iframe sandboxed with allow-scripts allow-same-origin should be able to run scripts and call functions in the parent of the iframe")</script>'></object>" height="10" width="10"></iframe> |
| 165 |
<iframe sandbox="allow-scripts" id="if_17" src="file_iframe_sandbox_a_if17.html" height="10" width="10"></iframe> |
| 118 |
</div> |
166 |
</div> |