Source code

Revision control

Copy as Markdown

Other Tools

<!DOCTYPE html>
<script>
function checkDomain(str, msg) {
window.parent.postMessage((str == document.domain) + ";" +msg,
}
function reportException(msg) {
window.parent.postMessage(false + ";" + msg, "http://mochi.test:8888");
}
var win1;
try {
win1 = window.open("", "", "width=100,height=100");
var otherDomain1 = win1.document.domain;
win1.close();
checkDomain(otherDomain1, "Opened document should have our domain");
} catch(e) {
reportException("Exception getting document.domain: " + e);
} finally {
win1.close();
}
document.domain = "example.org";
var win2;
try {
win2 = window.open("", "", "width=100,height=100");
var otherDomain2 = win2.document.domain;
checkDomain(otherDomain2, "Opened document should have our domain");
win2.close();
} catch(e) {
reportException("Exception getting document.domain after domain set: " + e);
} finally {
win2.close();
}
</script>