| Index: chrome_frame/test/data/simple_object_focus.html
|
| ===================================================================
|
| --- chrome_frame/test/data/simple_object_focus.html (revision 0)
|
| +++ chrome_frame/test/data/simple_object_focus.html (revision 0)
|
| @@ -0,0 +1,95 @@
|
| +<!-- 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>
|
| +<object id="ChromeFrame" width="300" height="60" tabindex="0"
|
| + codebase="http://www.google.com"
|
| + classid="CLSID:E0A900DF-9611-4446-86BD-4B1D47E7DB2A">
|
| + <param name="onload" value="return OnChromeFrameLoaded();">
|
| + <embed width="300" height="60" name="ChromeFrame"
|
| + onload="return OnChromeFrameLoaded();"
|
| + type="application/chromeframe">
|
| + </embed>
|
| +</object>
|
| +</body>
|
| +</html>
|
|
|