Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / frames / resources / sandboxed-iframe-storage-disallowed.html
blob35f54e557d4540b34e4ce1f98f2729d87ec44cdf
1 <html>
2 <head>
3 <script>
4 if (window.testRunner)
5 testRunner.dumpAsText();
7 function debug(msg)
9 var span = document.createElement("span");
10 document.getElementById("console").appendChild(span);
11 span.innerHTML = msg + '<br />';
14 function escapeHTML(text)
16 return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/\0/g, "\\0");
19 function testPassed(msg)
21 debug('<span><span class="pass">PASS</span> ' + escapeHTML(msg) + '</span>');
24 function testFailed(msg)
26 debug('<span><span class="fail">FAIL</span> ' + escapeHTML(msg) + '</span>');
29 function shouldThrow(_a, _e)
31 var exception;
32 var _av;
33 try {
34 _av = eval(_a);
35 } catch (e) {
36 exception = e;
39 var _ev;
40 if (_e)
41 _ev = eval(_e);
43 if (exception) {
44 if (typeof _e == "undefined" || exception == _ev)
45 testPassed(_a + " threw exception \"" + exception + "\".");
46 else
47 testFailed(_a + " should throw " + (typeof _e == "undefined" ? "an exception" : _ev) + ". Threw exception " + exception + ".");
48 } else if (typeof _av == "undefined")
49 testFailed(_a + " should throw " + (typeof _e == "undefined" ? "an exception" : _ev) + ". Was undefined.");
50 else
51 testFailed(_a + " should throw " + (typeof _e == "undefined" ? "an exception" : _ev) + ". Was " + _av + ".");
53 </script>
54 <script>
56 window.onload = function() {
57 shouldThrow("window.openDatabase('SandboxedIframeStorageDisallowed', '1.0', '', 1)", '"SecurityError: Failed to execute \'openDatabase\' on \'Window\': Access to the WebDatabase API is denied in this context."');
58 shouldThrow("window.indexedDB.webkitGetDatabaseNames()", '"SecurityError: Failed to execute \'webkitGetDatabaseNames\' on \'IDBFactory\': access to the Indexed Database API is denied in this context."');
59 shouldThrow("window.indexedDB.open('foo')", '"SecurityError: Failed to execute \'open\' on \'IDBFactory\': access to the Indexed Database API is denied in this context."');
60 shouldThrow("window.indexedDB.deleteDatabase('foo')", '"SecurityError: Failed to execute \'deleteDatabase\' on \'IDBFactory\': access to the Indexed Database API is denied in this context."');
61 shouldThrow("window.localStorage", '"SecurityError: Failed to read the \'localStorage\' property from \'Window\': The document is sandboxed and lacks the \'allow-same-origin\' flag."');
62 shouldThrow("window.sessionStorage", '"SecurityError: Failed to read the \'sessionStorage\' property from \'Window\': The document is sandboxed and lacks the \'allow-same-origin\' flag."');
63 shouldThrow("document.cookie",'"SecurityError: Failed to read the \'cookie\' property from \'Document\': The document is sandboxed and lacks the \'allow-same-origin\' flag."') ;
66 </script>
67 </head>
68 <body>
69 <div id="console"></div>
70 </body>
71 </html>