OLD | NEW |
| (Empty) |
1 <!-- saved from url=(0014)about:internet --> | |
2 <html> | |
3 <!-- This page is meant to load inside the host browser like IE/FF --> | |
4 <head> | |
5 <script type="text/javascript" src="chrome_frame_tester_helpers.js"></script> | |
6 <script type="text/javascript"> | |
7 var g_failure_timeout = null; | |
8 var g_test_id = 1; | |
9 var g_test_name = "ObjectFocus"; | |
10 | |
11 function onLoad() { | |
12 status("onload"); | |
13 | |
14 try { | |
15 var cf = getCf(); | |
16 cf.onmessage = OnChromeFrameMessage; | |
17 window.setTimeout(NavigateToURL, 100); | |
18 } catch(e) { | |
19 status("error: onload"); | |
20 onFailure(g_test_name, g_test_id, "error in onload"); | |
21 } | |
22 | |
23 sendOnLoadEvent(); | |
24 } | |
25 | |
26 function NavigateToURL() { | |
27 try { | |
28 status("Navigate to URL"); | |
29 var cf = getCf(); | |
30 cf.src = "simple_object_focus_cf.html"; | |
31 g_failure_timeout = window.setTimeout(OnObjectFocusFailed, 10000); | |
32 } catch(e) { | |
33 status("error: NavigateToURL"); | |
34 onFailure(g_test_name, g_test_id, "NavigateToURL error"); | |
35 } | |
36 } | |
37 | |
38 function OnObjectFocusFailed() { | |
39 status("OnNavigationFailed"); | |
40 onFailure(g_test_name, g_test_id, "focus test failed"); | |
41 } | |
42 | |
43 function OnChromeFrameLoaded() { | |
44 status("OnChromeFrameLoaded"); | |
45 try { | |
46 // Set focus to chrome frame. This should set focus to the first element | |
47 // inside the frame, which a script inside the page will detect and notify | |
48 // us back by sending us a message. | |
49 getCf().focus(); | |
50 } catch(e) { | |
51 status("error: can't set focus"); | |
52 onFailure(g_test_name, g_test_id, "focus() error"); | |
53 } | |
54 } | |
55 | |
56 function OnChromeFrameMessage(evt) { | |
57 if (evt.data != "btnOnFocus") { | |
58 status("unexpected message: " + evt.data + " from " + evt.origin); | |
59 } else { | |
60 window.clearTimeout(g_failure_timeout); | |
61 g_failure_timeout = null; | |
62 status("success"); | |
63 } | |
64 onSuccess(g_test_name, g_test_id); | |
65 } | |
66 | |
67 function getCf() { | |
68 // Fetching chrome frame with getElementById doesn't work in Firefox. | |
69 // Most likely due to object vs embed. | |
70 return document.ChromeFrame; | |
71 } | |
72 | |
73 // Useful while writing and debugging the unit test. | |
74 function status(s) { | |
75 var panel = document.getElementById("status_panel"); | |
76 panel.innerHTML = s; | |
77 } | |
78 | |
79 </script> | |
80 </head> | |
81 <body onload="onLoad();"> | |
82 <div id="status_panel" style="border: 1px solid red; width: 100%"> | |
83 Test running.... | |
84 </div> | |
85 <span id="ChromeFrameSpan"></span> | |
86 <script type="text/javascript"> | |
87 insertControl( | |
88 "ChromeFrameSpan", | |
89 { "width": "300", | |
90 "height": "60", | |
91 "eventHandlers": { "onload": "return OnChromeFrameLoaded();" }, | |
92 "objectAttributes": { "tabindex": "0" }, | |
93 "embedAttributes": {"id": null } | |
94 }); | |
95 </script> | |
96 </body> | |
97 </html> | |
OLD | NEW |