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