indexed-browsing-contexts-02.html (2771B)
1 <!DOCTYPE html> 2 <head> 3 <meta charset="utf-8"> 4 <title>HTML Test: the browsing contexts created by various container elements</title> 5 <link rel="author" title="Intel" href="http://www.intel.com/" /> 6 <script src="/resources/testharness.js"></script> 7 <script src="/resources/testharnessreport.js"></script> 8 <script> 9 10 var t1 = async_test("Accessing child browsing contexts 1"); 11 var t2 = async_test("Accessing child browsing contexts 2"); 12 var t3 = async_test("Accessing child browsing contexts 3"); 13 function on_load() { 14 //Child browsing contexts created by iframe, object and embed elements. 15 t1.step(function () { 16 assert_equals(window.length, 3, "The top browsing context should have 3 child browsing contexts."); 17 }); 18 t1.step(function () { 19 assert_equals(window[0].name, "win1", "The browsing context name should be 'win1'."); 20 assert_equals(window[1].name, "win2", "The browsing context name should be 'win2'."); 21 assert_equals(window[2].name, "win3", "The browsing context name should be 'win3'."); 22 }); 23 t1.done(); 24 25 //Child browsing contexts created by frame elements. 26 t2.step(function () { 27 assert_equals(document.getElementById("fr").contentWindow.length, 2, 28 "The child browsing context created by the iframe element should have 2 child browsing contexts."); 29 }); 30 t2.step(function () { 31 assert_equals(document.getElementById("fr").contentWindow[0].name, "win4", 32 "The browsing context name should be 'win4'."); 33 assert_equals(document.getElementById("fr").contentWindow[1].name, "win5", 34 "The browsing context name should be 'win5'."); 35 }); 36 t2.done(); 37 38 //The child browsing context will be removed if the data attribute of the associated object element is removed. 39 t3.step(function () { 40 document.getElementById("obj").removeAttribute("type"); 41 assert_equals(window.length, 3, "The top browsing context should have 3 child browsing contexts."); 42 document.getElementById("obj").removeAttribute("data"); 43 assert_equals(window.length, 3, "The top browsing context should have 3 child browsing contexts."); 44 45 setTimeout(function () { 46 assert_equals(window.length, 2, "The top browsing context should have 2 child browsing contexts."); 47 }, 1); 48 }); 49 t3.done(); 50 } 51 52 </script> 53 </head> 54 <body onload="on_load()"> 55 <div id="log"></div> 56 <div style="display:none"> 57 <iframe id="fr" name="win1" src="test3.html"></iframe> 58 <object id="obj" name="win2" type="text/html" data="about:blank"></object> 59 <object type="image/png" src="/images/green.png"></object> 60 <embed id="emb" name="win3" type="image/svg+xml" src="/images/green.svg"></embed> 61 </div> 62 </body>