blob: 91fd118d9d170c89cdcd13c17e922c7e24958a4d [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<title>Setting `document.domain` to invalid values fails.</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(function () {
assert_equals(document.domain, '127.0.0.1');
assert_throws('SecurityError',
function () {
document.domain = null;
});
assert_equals(document.domain, '127.0.0.1');
}, 'Setting `document.domain` to null fails.');
test(function () {
assert_equals(document.domain, '127.0.0.1');
assert_throws('SecurityError',
function () {
document.domain = '';
});
assert_equals(document.domain, '127.0.0.1');
}, 'Setting `document.domain` to the empty string fails.');
test(function () {
assert_equals(document.domain, '127.0.0.1');
assert_throws('SecurityError',
function () {
document.domain = '0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001.1';
});
assert_equals(document.domain, '127.0.0.1');
}, 'Setting an invalid `document.domain` that looks like an IP address fails.');
test(function () {
assert_equals(document.domain, '127.0.0.1');
assert_throws('SecurityError',
function () {
document.domain = '[]';
});
assert_throws('SecurityError',
function () {
document.domain = 'example.test/path';
});
assert_throws('SecurityError',
function () {
document.domain = '%.com';
});
assert_equals(document.domain, '127.0.0.1');
}, 'Setting `document.domain` to a host that fails to parse fails.');
</script>
</head>