5 testRunner
.dumpAsText();
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, "&").replace(/</g, "<").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
)
44 if (typeof _e
== "undefined" || exception
== _ev
)
45 testPassed(_a
+ " threw exception \"" + exception
+ "\".");
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.");
51 testFailed(_a
+ " should throw " + (typeof _e
== "undefined" ? "an exception" : _ev
) + ". Was " + _av
+ ".");
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."') ;
69 <div id=
"console"></div>