<html>
<head>
<script>
function debug(str) {
var c = document.getElementById('console')
c.innerHTML += (str + "<br>")
}
function runTests() {
if (window.testRunner)
testRunner.dumpAsText();
debug('document.all: ' + document.all)
var documentAllOld = document.all;
if (document.all) {
debug('FAILURE: document.all should evaluate to false')
return;
}
if (!document.all) {
// Do nothing
} else {
debug('FAILURE: document.all should evaluate to false')
return;
}
if (document.all != undefined) {
debug('FAILURE: document.all != undefined should evaluate to false ')
return;
}
if (undefined != document.all) {
debug('FAILURE: undefined != document.all should evaluate to false ')
return;
}
if (document.all != null) {
debug('FAILURE: document.all != null should evaluate to false')
return;
}
if (null != document.all) {
debug('FAILURE: null != document.all should evaluate to false')
return;
}
// Try replacing document.all with something else
document.all = { 'foo': 42}
if (document.all.foo == 42) {
debug('FAILURE: replacing document.all must not be allowed')
return;
}
// Delete new document.all
delete(document.all)
if (document.all.foo != undefined) {
debug('FAILURE: deleting replace document.all did not work')
return;
}
// Check typeof document.all
if (typeof document.all != 'undefined') {
debug('FAILURE: typeof document.all should be undefined');
return;
}
// document.all should be [SameObject].
if (documentAllOld != document.all) {
debug('FAILURE: document.all should be same object')
return;
}
var length = document.all.length;
var element = document.createElement("p");
element.id = 'change_all_length';
document.body.appendChild(element);
if ((document.all.length != length + 1) || (documentAllOld != document.all)) {
debug('FAILURE: document.all should be same object after adding an element')
return;
}
document.body.removeChild(document.getElementById('change_all_length'));
if ((document.all.length != length) || (documentAllOld != document.all)) {
debug('FAILURE: document.all should be same object after removing an element')
return;
}
debug('SUCCESS!')
}
</script>
</head>
<body onload="runTests();">
This tests that document.all should be undetectable, and that it should not be possible to set document.all to something else. If this test is successful, the text "SUCCESS" should be shown below.
<pre id="console"></pre>
</body>
</html>