|
|
|
|
|
|
1 |
<!DOCTYPE HTML> |
| 2 |
<html> |
| 3 |
<!-- |
| 4 |
https://bugzilla.mozilla.org/show_bug.cgi?id=341604 |
| 5 |
Implement HTML5 sandbox attribute for IFRAMEs - tests for workers |
| 6 |
--> |
| 7 |
<head> |
| 8 |
<meta charset="utf-8"> |
| 9 |
<title>Test for Bug 341604</title> |
| 10 |
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
| 11 |
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> |
| 12 |
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
| 13 |
</head> |
| 14 |
<script type="application/javascript"> |
| 15 |
/** Test for Bug 341604 - Implement HTML5 sandbox attribute for IFRAMEs - test for workers **/ |
| 16 |
|
| 17 |
// a postMessage handler that is used by sandboxed iframes without |
| 18 |
// 'allow-same-origin' to communicate pass/fail back to this main page. |
| 19 |
// it expects to be called with an object like {ok: true/false, desc: |
| 20 |
// <description of the test> which it then forwards to ok() |
| 21 |
window.addEventListener("message", receiveMessage, false); |
| 22 |
|
| 23 |
function receiveMessage(event) |
| 24 |
{ |
| 25 |
ok_wrapper(event.data.ok, event.data.desc); |
| 26 |
} |
| 27 |
|
| 28 |
var completedTests = 0; |
| 29 |
var passedTests = 0; |
| 30 |
|
| 31 |
function ok_wrapper(result, desc) { |
| 32 |
ok(result, desc); |
| 33 |
|
| 34 |
completedTests++; |
| 35 |
|
| 36 |
if (result) { |
| 37 |
passedTests++; |
| 38 |
} |
| 39 |
|
| 40 |
// REVIEW : if one of these tests fails and this isn't called |
| 41 |
// this means this test will hang until the time out happens :( |
| 42 |
// advice on better ways to synchronize things appreciated ! |
| 43 |
if (completedTests == 3) { |
| 44 |
ok(passedTests == 3, "There are 2 worker tests that should pass"); |
| 45 |
SimpleTest.finish(); |
| 46 |
} |
| 47 |
} |
| 48 |
|
| 49 |
function doTest() { |
| 50 |
SimpleTest.waitForExplicitFinish(); |
| 51 |
|
| 52 |
// passes if good |
| 53 |
// 1) test that a worker in a sandboxed iframe with 'allow-scripts' can be loaded |
| 54 |
// from a data: URI |
| 55 |
// (done by file_iframe_sandbox_g_if1.html) |
| 56 |
|
| 57 |
// passes if good |
| 58 |
// 2) test that a worker in a sandboxed iframe with 'allow-scripts' can be loaded |
| 59 |
// from a blob URI created by the sandboxed document itself |
| 60 |
// (done by file_iframe_sandbox_g_if1.html) |
| 61 |
|
| 62 |
// passes if good |
| 63 |
// 3) test that a worker in a sandboxed iframe with 'allow-scripts' without |
| 64 |
// 'allow-same-origin' cannot load a script via a relative URI |
| 65 |
// (done by file_iframe_sandbox_g_if1.html) |
| 66 |
|
| 67 |
// TODO: implement this test when bug 722126 "Can't transfer File objects |
| 68 |
// with postMessage cross domain" is fixed |
| 69 |
// test that a worker in a sandboxed iframe with 'allow-scripts' cannot be loaded |
| 70 |
// from a blob URI not created by the sandboxed document itself |
| 71 |
} |
| 72 |
</script> |
| 73 |
<body onload="doTest()"> |
| 74 |
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=341604">Mozilla Bug 341604</a> - Implement HTML5 sandbox attribute for IFRAMEs |
| 75 |
<p id="display"></p> |
| 76 |
<div id="content"> |
| 77 |
<iframe sandbox="allow-scripts" id="if_1" src="file_iframe_sandbox_g_if1.html" height="10" width="10"></iframe> |
| 78 |
</div> |
| 79 |
</body> |
| 80 |
</html> |