1 <html> 2 <!-- This page is meant to load inside the host browser like IE/FF --> 3 <head><title>Initialize hidden chrome frame</title> 4 <script type="text/javascript" src="chrome_frame_tester_helpers.js"> 5 </script> 6 <script type="text/javascript"> 7 var g_failure_timeout = null; 8 var g_test_id = 1; 9 var g_test_name = 'InitializeHidden'; 10 var g_cf3_loaded = false; 11 12 function OnNavigationFailed() { 13 onFailure(g_test_name, g_test_id, 'ChromeFrame Navigation failed'); 14 } 15 16 function OnObjectFocusFailed() { 17 appendStatus('chrome frame focus failed'); 18 onFailure(g_test_name, g_test_id, 'Visibility test failed'); 19 } 20 21 function OnCF1Loaded() { 22 appendStatus('Chrome frame 1 loaded, not visible yet.'); 23 try { 24 // Make chrome frame visible 25 var cf1 = document.getElementById('CFDiv1'); 26 cf1.style.visibility = 'visible'; 27 appendStatus('Chrome frame 1 visibility - ' + cf1.style.visibility); 28 // Set focus to chrome frame. This should set focus to the 29 // first element inside the frame, which a script inside the 30 // page will detect and notify us back by sending us a message. 31 document.ChromeFrame1.focus(); 32 g_failure_timeout = window.setTimeout(OnObjectFocusFailed, 10000); 33 } catch(e) { 34 appendStatus('Error setting focus to CF1. Error: ' + e.description); 35 onFailure(g_test_name, g_test_id, 'CF1 focus() error'); 36 } 37 } 38 39 function OnCF1Message(evt) { 40 if (evt.data == 'btnOnFocus') { 41 window.clearTimeout(g_failure_timeout); 42 g_failure_timeout = null; 43 appendStatus('CF1 visible and focused'); 44 45 // Now make second chrome frame instance visible 46 document.getElementById('CFDiv2').style.display = 'block'; 47 appendStatus('Chrome frame 2 visible, should start loading now'); 48 g_failure_timeout = window.setTimeout(OnObjectFocusFailed, 10000); 49 } 50 } 51 52 function OnCF2Loaded() { 53 appendStatus('Chrome frame 2 loaded'); 54 try { 55 // Set focus to chrome frame. This should set focus to the 56 // first element inside the frame, which a script inside the 57 // page will detect and notify us back by sending us a message. 58 // We set focus on a timeout as on IE it takes a while for the window 59 // to become visible. 60 setTimeout(SetFocusToCF2, 1000); 61 } catch(e) { 62 appendStatus('Error setting focus to CF2. Error: ' + e.description); 63 onFailure(g_test_name, g_test_id, 'CF2 focus() error'); 64 } 65 } 66 67 function SetFocusToCF2() { 68 try { 69 document.ChromeFrame2.focus(); 70 } catch (e) { 71 appendStatus('SetFocusToCF2: Error: ' + e.description); 72 onFailure(g_test_name, g_test_id, 'SetFocusToCF2 error ' + 73 e.description); 74 } 75 } 76 77 function OnCF2Message(evt) { 78 if (evt.data == 'btnOnFocus') { 79 window.clearTimeout(g_failure_timeout); 80 g_failure_timeout = null; 81 appendStatus('CF2 visible and focused'); 82 onSuccess(g_test_name, g_test_id); 83 } 84 } 85 </script> 86 </head> 87 <body> 88 <div id="CFDiv1" style="visibility: hidden;"></div> 89 <script type="text/javascript"> 90 insertControl("CFDiv1", 91 { "id": "ChromeFrame1", 92 "width": "300", 93 "height": "80", 94 "src": "simple_object_focus_cf.html", 95 "eventHandlers": { "onload": "OnCF1Loaded();", 96 "onloaderror": "OnNavigationFailed();", 97 "onmessage": "OnCF1Message(arguments[0]);" }, 98 "objectAttributes": { "tabindex": "0" }, 99 "embedAttributes": {"id": null} 100 }); 101 </script> 102 <div id="CFDiv2" style="display: none;"></div> 103 <script type="text/javascript"> 104 insertControl("CFDiv2", 105 { "id": "ChromeFrame2", 106 "width": "300", 107 "height": "80", 108 "src": "simple_object_focus_cf.html", 109 "eventHandlers": { "onload": "OnCF2Loaded();", 110 "onloaderror": "OnNavigationFailed();", 111 "onmessage": "OnCF2Message(arguments[0]);" }, 112 "objectAttributes": { "tabindex": "1" }, 113 "embedAttributes": { "id": null} 114 }); 115 </script> 116 <div id="statusPanel" style="border: 1px solid red; width: 100%"> 117 Test running.... 118 </div> 119 </body> 120 </html> 121