test_nestediframe.html (1130B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <title>Test for same URLs nested iframes</title> 5 <script src="/tests/SimpleTest/SimpleTest.js"></script> 6 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 7 </head> 8 <body> 9 test_nestediframe body 10 <script> 11 12 SimpleTest.waitForExplicitFinish(); 13 14 function reportState(msg) { 15 if (location.href.includes("#")) { 16 parent.postMessage(msg, "*"); 17 return; 18 } 19 20 if (msg == "OK 1") { 21 ok(true, "First frame loaded"); 22 } else if (msg == "KO 2") { 23 ok(true, "Second frame load failed"); 24 SimpleTest.finish(); 25 } else { 26 ok(false, "Unknown message: " + msg); 27 } 28 } 29 30 addEventListener("message", event => { 31 reportState(event.data); 32 }); 33 34 var recursion; 35 if (!location.href.includes("#")) { 36 recursion = 1; 37 } else { 38 recursion = parseInt(location.href.split("#")[1]) + 1; 39 } 40 41 var ifr = document.createElement('iframe'); 42 ifr.src = location.href.split("#")[0] + "#" + recursion; 43 44 ifr.onload = function() { 45 reportState("OK " + recursion); 46 } 47 ifr.onerror = function() { 48 reportState("KO " + recursion); 49 } 50 51 document.body.appendChild(ifr); 52 53 </script> 54 </body> 55 </html>