1<html> 2<head> 3<script> 4function ok(b,m) { 5 return external.ok(b, m); 6} 7 8function nav_parent_test() { 9 external.trace("Running _parent navigation tests..."); 10 11 var iframe = document.getElementById("testframe"); 12 var subframe = iframe.contentWindow.document.createElement("iframe"); 13 14 subframe.onload = function() { 15 var doc = subframe.contentWindow.document; 16 doc.body.innerHTML = '<a href="blank2.html" id="aid" target="_parent">test</a>'; 17 doc.getElementById("aid").click(); 18 } 19 20 iframe.onload = function() { 21 iframe.onload = null; 22 var href = iframe.contentWindow.location.href; 23 ok(/.*blank2.html/.test(href), "Unexpected href " + href); 24 next_test(); 25 } 26 27 iframe.contentWindow.document.body.appendChild(subframe); 28 subframe.src = "blank.html"; 29} 30 31function window_navigate_test() { 32 external.trace("Running window.navigate() tests..."); 33 34 var iframe = document.getElementById("testframe"); 35 36 iframe.onload = function() { 37 iframe.onload = null; 38 var href = iframe.contentWindow.location.href; 39 ok(href === "about:blank", "Unexpected href " + href); 40 next_test(); 41 } 42 43 iframe.contentWindow.navigate("about:blank"); 44} 45 46function window_open_self_test() { 47 external.trace("Running window.open(_self) tests..."); 48 49 var iframe = document.getElementById("testframe"); 50 var iframe_window = iframe.contentWindow; 51 52 iframe.onload = function() { 53 iframe.onload = null; 54 var href = iframe.contentWindow.location.href; 55 ok(/.*blank.html\?window_open_self/.test(href), "Unexpected href " + href); 56 ok(iframe.contentWindow === iframe_window, "iframe.contentWindow !== iframe_window"); 57 next_test(); 58 } 59 60 iframe_window.open("blank.html?window_open_self", "_self"); 61} 62 63function detached_src_test() { 64 var iframe = document.createElement("iframe"); 65 var onload_called = false; 66 67 iframe.onload = function() { 68 onload_called = true; 69 next_test(); 70 } 71 72 iframe.src = "blank.html"; 73 document.body.appendChild(iframe); 74 ok(onload_called === false, "called onload too early?"); 75} 76 77var tests = [ 78 nav_parent_test, 79 window_navigate_test, 80 window_open_self_test, 81 detached_src_test, 82 function() { external.reportSuccess(); } 83]; 84 85function next_test() { 86 window.setTimeout(tests.shift(), 0); 87} 88</script> 89<body onload="next_test()"> 90<iframe src="about:blank" id="testframe"></iframe> 91</body> 92</html> 93