win-documentdomain.sub.html (2224B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <script src="/common/get-host-info.sub.js"></script> 5 <script> 6 function loadFrames() { 7 window.A = document.getElementById('A').contentWindow; 8 window.B = document.getElementById('B').contentWindow; 9 window.C = document.getElementById('C').contentWindow; 10 window.D = document.getElementById('D').contentWindow; 11 12 var path = location.pathname.substring(0, location.pathname.lastIndexOf('/')) + '/frame.html'; 13 A.location = 'frame.html'; 14 B.location = '//{{domains[www2]}}:' + get_port(location) + path; 15 C.location = '//{{domains[www2]}}:' + get_port(location) + path; 16 D.location = '//{{domains[www1]}}:' + get_port(location) + path; 17 18 var loadCount = 0; 19 function frameLoaded() { 20 if (++loadCount == 4) 21 go(); 22 } 23 var iframes = document.getElementsByTagName('iframe'); 24 for (var i = 0; i < iframes.length; i++) { 25 iframes[i].onload = frameLoaded; 26 } 27 } 28 29 var results = []; 30 function assert(cond, msg) { 31 results.push({pass: !!cond, message: msg}); 32 } 33 34 function go() { 35 window.onmessage = function(evt) { 36 try { 37 assert(evt.data == "PASS", "frame.html processing should be PASS but got " + evt.data); 38 assert(B.checkWindowReferences(), "B's Window references are still self-consistent after document.domain"); 39 for (var i = 0; i < window.length; ++i) { 40 assert(window[i] === B.windowReferences[i], 41 "Window reference " + i + " consistent between globals after document.domain"); 42 assert(window[i].location === B.locationReferences[i], 43 "Location reference " + i + " consistent between globals after document.domain"); 44 } 45 } catch(e) { 46 assert(false, "Should not receive exception: " + e); 47 } 48 opener.postMessage(results, '*'); 49 }; 50 A.document.domain = A.document.domain; 51 document.domain = document.domain; 52 B.postMessage('', '*'); 53 } 54 55 </script> 56 </head> 57 <body onload="loadFrames()"> 58 <iframe id="A"></iframe> 59 <iframe id="B"></iframe> 60 <iframe id="C"></iframe> 61 <iframe id="D"></iframe> 62 </body> 63 </html>