bug196523-subframe.html (1022B)
1 <!DOCTYPE html> 2 <script> 3 function checkDomain(str, msg) { 4 window.parent.postMessage((str == document.domain) + ";" +msg, 5 "http://mochi.test:8888"); 6 } 7 8 function reportException(msg) { 9 window.parent.postMessage(false + ";" + msg, "http://mochi.test:8888"); 10 } 11 12 var win1; 13 try { 14 win1 = window.open("", "", "width=100,height=100"); 15 var otherDomain1 = win1.document.domain; 16 win1.close(); 17 checkDomain(otherDomain1, "Opened document should have our domain"); 18 } catch(e) { 19 reportException("Exception getting document.domain: " + e); 20 } finally { 21 win1.close(); 22 } 23 24 document.domain = "example.org"; 25 26 var win2; 27 try { 28 win2 = window.open("", "", "width=100,height=100"); 29 var otherDomain2 = win2.document.domain; 30 checkDomain(otherDomain2, "Opened document should have our domain"); 31 win2.close(); 32 } catch(e) { 33 reportException("Exception getting document.domain after domain set: " + e); 34 } finally { 35 win2.close(); 36 } 37 </script>