OLD | NEW |
| (Empty) |
1 <!-- saved from url=(0014)about:internet --> | |
2 <!-- Please preserve the CR/LF at the end of the previous line. --> | |
3 <html> | |
4 <!-- This page is meant to load inside the host browser like IE/FF --> | |
5 <head> | |
6 <script type="text/javascript" src="chrome_frame_tester_helpers.js"></script> | |
7 <script type="text/javascript"> | |
8 function onLoad() { | |
9 var chromeFrame = GetChromeFrame(); | |
10 chromeFrame.onmessage = OnChromeFrameResize; | |
11 setTimeout(NavigateToURL, 100); | |
12 } | |
13 | |
14 function NavigateToURL() { | |
15 var chromeFrame = GetChromeFrame(); | |
16 chromeFrame.src = "chrome_frame_resize_hosted.html"; | |
17 setTimeout(CheckIfNavigationFailed, 15000); | |
18 } | |
19 | |
20 var navigation_success = false; | |
21 | |
22 function CheckIfNavigationFailed() { | |
23 if (!navigation_success) { | |
24 onFailure("Resize", 1, "ChromeFrame Navigation failed"); | |
25 } | |
26 } | |
27 | |
28 function OnNavigationSucceeded() { | |
29 navigation_success = true; | |
30 appendStatus("ChromeFrame hosted page loaded, beginning test..."); | |
31 setTimeout(ResizeChromeFrame, 100); | |
32 } | |
33 | |
34 var resize_step = 0; | |
35 | |
36 function ResizeChromeFrame() { | |
37 var chromeFrame = GetChromeFrame(); | |
38 | |
39 if (resize_step == 0) { | |
40 appendStatus("Setting chromeFrame to 100x100"); | |
41 resize_step = 1; | |
42 chromeFrame.width = 100; | |
43 setTimeout("OnResizeFailure(0)", 2000); | |
44 } else if (resize_step == 1) { | |
45 resize_step = 2; | |
46 chromeFrame.height = 100; | |
47 setTimeout("OnResizeFailure(1)", 2000); | |
48 } else if (resize_step == 2) { | |
49 appendStatus("Setting chromeFrame to 10x10"); | |
50 resize_step = 3; | |
51 chromeFrame.width = 10; | |
52 setTimeout("OnResizeFailure(0)", 2000); | |
53 } else if (resize_step == 3) { | |
54 resize_step = 4; | |
55 chromeFrame.height = 10; | |
56 setTimeout("OnResizeFailure(1)", 2000); | |
57 } | |
58 | |
59 // Note that setting the ChromeFrame window to 0x0 (or < 2x2 if we have the | |
60 // WS_BORDER style defined on our window) currently results | |
61 // in a check failure from the child chrome.exe process. | |
62 // TODO(robertshield): Figure out why and fix it. | |
63 } | |
64 | |
65 var resize_step_received = 0; | |
66 | |
67 function OnChromeFrameResize(evt) { | |
68 resize_step_received++; | |
69 appendStatus("ChromeFrame resized: " + evt.data + "step=" + | |
70 resize_step_received); | |
71 | |
72 if (resize_step == 4) { | |
73 onSuccess("Resize", 1); | |
74 } else { | |
75 setTimeout(ResizeChromeFrame, 100); | |
76 } | |
77 } | |
78 | |
79 function OnResizeFailure(step) { | |
80 // It turns out that the hosted page gets two calls to onresize() | |
81 // every time a single size parameter (i.e. width OR height) is changed. | |
82 // As such this check doesn't quite guarantee success, but if it fails, | |
83 // then we should fail the unit test. | |
84 if (step >= resize_step_received) { | |
85 onFailure("Resize", 1, "Did not receive resize reply back from frame."); | |
86 } | |
87 } | |
88 | |
89 function GetChromeFrame() { | |
90 return window.document.ChromeFrame; | |
91 } | |
92 | |
93 var debug_counter = 0; | |
94 | |
95 function DebugResizeChromeFrame(delta) { | |
96 var chromeFrame = GetChromeFrame(); | |
97 var newWidth = chromeFrame.clientWidth + delta; | |
98 var newHeight = chromeFrame.clientHeight + delta; | |
99 | |
100 appendStatus(debug_counter + ". DEBUG resizing CF to (" + newWidth + "," + | |
101 newHeight + ")"); | |
102 | |
103 debug_counter++; | |
104 | |
105 chromeFrame.width = newWidth; | |
106 chromeFrame.height = newHeight; | |
107 } | |
108 | |
109 </script> | |
110 </head> | |
111 | |
112 <body onload="onLoad();"> | |
113 <div id="description" style="border: 2px solid black; width: 100%"> | |
114 Test for resizing the chrome frame control. | |
115 </div> | |
116 <div id="statusPanel" style="border: 1px solid red; width: 100%"> | |
117 Test running.... | |
118 </div> | |
119 | |
120 <span id="ChromeFrameSpan"></span> | |
121 <script type="text/javascript"> | |
122 insertControl("ChromeFrameSpan", | |
123 { "width": null, | |
124 "height": null, | |
125 "objectAttributes": { "style": "border: 1px solid blue" }, | |
126 "eventHandlers": { "onload": "return OnNavigationSucceeded();" }, | |
127 "embedAttributes": { "style": "border: 1px solid green" } | |
128 }); | |
129 </script> | |
130 <br /> | |
131 <br /> | |
132 | |
133 <button onclick="javascript:DebugResizeChromeFrame(20);">Bigger</button> | |
134 <button onclick="javascript:DebugResizeChromeFrame(-20);">Smaller</button> | |
135 | |
136 </body> | |
137 </html> | |
OLD | NEW |