blob: 4d93f2861f594594b7eba47379e06b4adba29705 [file] [log] [blame]
<!-- saved from url=(0014)about:internet -->
<html>
<!-- This page is meant to load inside the host browser like IE/FF -->
<head>
<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 = "ObjectFocus";
function onLoad() {
status("onload");
try {
var cf = getCf();
cf.onmessage = OnChromeFrameMessage;
window.setTimeout(NavigateToURL, 100);
} catch(e) {
status("error: onload");
onFailure(g_test_name, g_test_id, "error in onload");
}
sendOnLoadEvent();
}
function NavigateToURL() {
try {
status("Navigate to URL");
var cf = getCf();
cf.src = "simple_object_focus_cf.html";
g_failure_timeout = window.setTimeout(OnObjectFocusFailed, 10000);
} catch(e) {
status("error: NavigateToURL");
onFailure(g_test_name, g_test_id, "NavigateToURL error");
}
}
function OnObjectFocusFailed() {
status("OnNavigationFailed");
onFailure(g_test_name, g_test_id, "focus test failed");
}
function OnChromeFrameLoaded() {
status("OnChromeFrameLoaded");
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.
getCf().focus();
} catch(e) {
status("error: can't set focus");
onFailure(g_test_name, g_test_id, "focus() error");
}
}
function OnChromeFrameMessage(evt) {
if (evt.data != "btnOnFocus") {
status("unexpected message: " + evt.data + " from " + evt.origin);
} else {
window.clearTimeout(g_failure_timeout);
g_failure_timeout = null;
status("success");
}
onSuccess(g_test_name, g_test_id);
}
function getCf() {
// Fetching chrome frame with getElementById doesn't work in Firefox.
// Most likely due to object vs embed.
return document.ChromeFrame;
}
// Useful while writing and debugging the unit test.
function status(s) {
var panel = document.getElementById("status_panel");
panel.innerHTML = s;
}
</script>
</head>
<body onload="onLoad();">
<div id="status_panel" style="border: 1px solid red; width: 100%">
Test running....
</div>
<span id="ChromeFrameSpan"></span>
<script type="text/javascript">
insertControl(
"ChromeFrameSpan",
{ "width": "300",
"height": "60",
"eventHandlers": { "onload": "return OnChromeFrameLoaded();" },
"objectAttributes": { "tabindex": "0" },
"embedAttributes": {"id": null }
});
</script>
</body>
</html>