Commit 872a3b6d authored by grt@chromium.org's avatar grt@chromium.org

Chrome Frame test fixes for Vista/IE7.

Write the ActiveX control from an external script in all test documents.  This works around a "feature" of IE versions released between April, 2006 and April, 2008 that required the user to click on an ActiveX control to "activate" it.  See http://msdn.microsoft.com/en-us/library/ms537508.aspx.

I also added asserts for the copying of CFInstance and CFInstall so that the whole test aborts if the files can't be copied, since otherwise test results are bogus.

BUG=60987
TEST=no manual testing needed; chrome_frame_tests.exe will either become better or worse.

Review URL: http://codereview.chromium.org/8777002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113291 0039d316-1c4b-4281-b951-d872f2087c98
parent 65165551
...@@ -117,16 +117,16 @@ function DebugResizeChromeFrame(delta) { ...@@ -117,16 +117,16 @@ function DebugResizeChromeFrame(delta) {
Test running.... Test running....
</div> </div>
<object id="ChromeFrame" codebase="http://www.google.com" <span id="ChromeFrameSpan"></span>
classid="CLSID:E0A900DF-9611-4446-86BD-4B1D47E7DB2A" <script type="text/javascript">
style="border: 1px solid blue"> insertControl("ChromeFrameSpan",
<param name="onload" value="return OnNavigationSucceeded();" /> { "width": null,
<embed id="ChromeFramePlugin" name="ChromeFrame" "height": null,
onload="return OnNavigationSucceeded();" "objectAttributes": { "style": "border: 1px solid blue" },
type="application/chromeframe" "eventHandlers": { "onload": "return OnNavigationSucceeded();" },
style="border: 1px solid green"> "embedAttributes": { "style": "border: 1px solid green" }
</embed> });
</object> </script>
<br /> <br />
<br /> <br />
...@@ -135,4 +135,3 @@ Test running.... ...@@ -135,4 +135,3 @@ Test running....
</body> </body>
</html> </html>
...@@ -189,3 +189,128 @@ function buildURL(pageName, queryString) { ...@@ -189,3 +189,128 @@ function buildURL(pageName, queryString) {
url += ((queryString == "") ? "" : "?" + queryString); url += ((queryString == "") ? "" : "?" + queryString);
return url; return url;
} }
// Helper function for insertControl.
function generateControlHtml(configuration) {
var objectAttributes = new Object();
var params = new Array();
var embedAttributes = new Object();
var param;
var html;
function stringifyAttributes(attributeCollection) {
var result = new String();
for (var attributeName in attributeCollection) {
result += ' ' + attributeName + '="' +
attributeCollection[attributeName] + '"';
}
return result;
}
function applyAttribute(attributeCollection, name, value, defaultValue) {
if (value === undefined)
value = defaultValue;
if (value !== null)
attributeCollection[name] = value;
}
objectAttributes.classid="CLSID:E0A900DF-9611-4446-86BD-4B1D47E7DB2A";
objectAttributes.codebase="http://www.google.com";
applyAttribute(objectAttributes, "id", configuration.id, "ChromeFrame");
applyAttribute(objectAttributes, "width", configuration.width, "500");
applyAttribute(objectAttributes, "height", configuration.height, "500");
// Attributes provided by the caller override any defaults.
for (var attribute in configuration.objectAttributes) {
if (configuration.objectAttributes[attribute] === null)
delete objectAttributes[attribute];
else
objectAttributes[attribute] = configuration.objectAttributes[attribute];
}
embedAttributes.type = "application/chromeframe";
// By default, embed id = object.id + "Plugin". null id means omit id.
if (embedAttributes.id === null)
delete embedAttributes.id;
else if (embedAttributes.id === undefined && objectAttributes.id !== null)
embedAttributes.id = objectAttributes.id + "Plugin";
// By default, embed name = object.id. null name means omit name.
if (embedAttributes.name === null)
delete embedAttributes.name;
else if (embedAttributes.name === undefined && objectAttributes.id !== null)
embedAttributes.name = objectAttributes.id;
applyAttribute(embedAttributes, "width", configuration.width, "500");
applyAttribute(embedAttributes, "height", configuration.height, "500");
applyAttribute(embedAttributes, "src", configuration.src, null);
for (var attribute in configuration.embedAttributes) {
if (configuration.embedAttributes[attribute] === null)
delete embedAttributes[attribute];
else
embedAttributes[attribute] = configuration.embedAttributes[attribute];
}
if (embedAttributes.src !== undefined) {
param = new Object();
param.name = "src";
param.value = embedAttributes.src;
params.push(param);
}
// All event handlers are params and attributes of the embed object.
for (var eventName in configuration.eventHandlers) {
param = new Object();
param.name = eventName;
param.value = configuration.eventHandlers[eventName];
params.push(param);
embedAttributes[eventName] = configuration.eventHandlers[eventName];
}
html = "<object" + stringifyAttributes(objectAttributes) + ">\r\n";
for (var i = 0; i < params.length; ++i) {
html += " <param" + stringifyAttributes(params[i]) + ">\r\n";
}
html += " <embed" + stringifyAttributes(embedAttributes) + "></embed>\r\n"
html += "</object>";
return html;
}
// Write the text for the Chrome Frame ActiveX control into an element.
// This works around a "feature" of IE versions released between April, 2006
// and April, 2008 that required the user to click on an ActiveX control to
// "activate" it. See http://msdn.microsoft.com/en-us/library/ms537508.aspx.
//
// |elementId| identifies the element in the current document into which the
// control markup will be inserted. |configuration| is an Object used to
// configure the control as below. Values shown are defaults, which may be
// overridden by supplying null values.
// {
// "id": "ChromeFrame", // id of object tag, name of the embed tag, and
// // basis of id of the embed tag.
// "width": "500", // width of both object and embed tags.
// "height": "500", // height of both object and embed tags.
// "src": "url", // src of embed tag and of param to object tag.
// "eventHandlers": { // Applied to embed tag and params to object tag.
// "onclose": "...",
// "onload": "...",
// "onloaderror": "..."
// }
// "objectAttributes": { // Custom attributes for the object tag. Any
// "tabindex": "...", // properties explicitly set to null will override
// "border": "...", // defaults.
// "style": "..."
// },
// "embedAttributes": { // Custom attributes for the embed tag;
// "privileged_mode": "...", // similar to above.
// "style": "..."
// }
// }
function insertControl(elementId, configuration) {
var e = document.getElementById(elementId);
e.innerHTML = generateControlHtml(configuration);
}
...@@ -28,13 +28,10 @@ ...@@ -28,13 +28,10 @@
</script> </script>
</head> </head>
<body onload="onDocumentLoad();"> <body onload="onDocumentLoad();">
<object id="ChromeFrame" width="500" height ="300" <span id="ChromeFrameSpan"></span>
codebase="http://www.google.com" <script type="text/javascript">
classid="CLSID:E0A900DF-9611-4446-86BD-4B1D47E7DB2A"> insertControl("ChromeFrameSpan", { "objectAttributes": { "height": "300" } });
<embed id="ChromeFramePlugin" name="ChromeFrame" width="500" </script>
height="500" type="application/chromeframe">
</embed>
</object>
<div id="statusPanel" style="border: 1px solid red; width: 100%"> <div id="statusPanel" style="border: 1px solid red; width: 100%">
Test running.... Test running....
</div> </div>
......
...@@ -85,40 +85,34 @@ ...@@ -85,40 +85,34 @@
</script> </script>
</head> </head>
<body> <body>
<div id="CFDiv1" style="visibility: hidden;"> <div id="CFDiv1" style="visibility: hidden;"></div>
<object id="ChromeFrame1" width="300" height="80" tabindex="0" <script type="text/javascript">
codebase="http://www.google.com" insertControl("CFDiv1",
classid="CLSID:E0A900DF-9611-4446-86BD-4B1D47E7DB2A"> { "id": "ChromeFrame1",
<param name="src" value="simple_object_focus_cf.html"> "width": "300",
<param name="onload" value="OnCF1Loaded();"> "height": "80",
<param name="onloaderror" value="OnNavigationFailed();"> "src": "simple_object_focus_cf.html",
<param name="onmessage" value="OnCF1Message(arguments[0]);"> "eventHandlers": { "onload": "OnCF1Loaded();",
<embed width="300" height="80" name="ChromeFrame1" "onloaderror": "OnNavigationFailed();",
type="application/chromeframe" "onmessage": "OnCF1Message(arguments[0]);" },
src="simple_object_focus_cf.html" "objectAttributes": { "tabindex": "0" },
onload="OnCF1Loaded();" "embedAttributes": {"id": null}
onloaderror="OnNavigationFailed();" });
onmessage="OnCF1Message(arguments[0]);"> </script>
</embed> <div id="CFDiv2" style="display: none;"></div>
</object> <script type="text/javascript">
</div> insertControl("CFDiv2",
<div id="CFDiv2" style="display: none;"> { "id": "ChromeFrame2",
<object id="ChromeFrame2" width="300" height="80" tabindex="1" "width": "300",
codebase="http://www.google.com" "height": "80",
classid="CLSID:E0A900DF-9611-4446-86BD-4B1D47E7DB2A"> "src": "simple_object_focus_cf.html",
<param name="src" value="simple_object_focus_cf.html"> "eventHandlers": { "onload": "OnCF2Loaded();",
<param name="onload" value="OnCF2Loaded();"> "onloaderror": "OnNavigationFailed();",
<param name="onloaderror" value="OnNavigationFailed();"> "onmessage": "OnCF2Message(arguments[0]);" },
<param name="onmessage" value="OnCF2Message(arguments[0]);"> "objectAttributes": { "tabindex": "1" },
<embed width="300" height="80" name="ChromeFrame2" "embedAttributes": { "id": null}
type="application/chromeframe" });
src="simple_object_focus_cf.html" </script>
onload="OnCF2Loaded();"
onloaderror="OnNavigationFailed();"
onmessage="OnCF2Message(arguments[0]);">
</embed>
</object>
</div>
<div id="statusPanel" style="border: 1px solid red; width: 100%"> <div id="statusPanel" style="border: 1px solid red; width: 100%">
Test running.... Test running....
</div> </div>
......
<html> <html>
<head> <head>
<title>Multiple chrome frame instances test</title> <title>Multiple chrome frame instances test</title>
<script type="text/javascript" src="chrome_frame_tester_helpers.js"></script>
<script type="text/javascript"> <script type="text/javascript">
function createSecondChromeFrameInstance() { function createSecondChromeFrameInstance() {
var dummy = document.createElement('span'); var dummy = document.createElement('span');
dummy.id = "dummy";
document.body.appendChild(dummy); document.body.appendChild(dummy);
dummy.innerHTML = '<object border="1" width="100%" height ="200px"' + insertControl("dummy",
'classid="clsid:E0A900DF-9611-4446-86BD-4B1D47E7DB2A">' + { "src": "multiple_cf_instances_test.html",
'<param name="src"' + "objectAttributes": { "id": null, "border": "1", "width": "100%",
'value="multiple_cf_instances_test.html">' + "height": "200px", "codebase": null },
'<embed id="CFPlugin" width="500" height="500"' + "embedAttributes": {"id": "CFPlugin", "name": "ChromeFrame" }
'name="ChromeFrame" type="application/chromeframe"' + });
'src="multiple_cf_instances_test.html">' +
'</embed></object>';
} }
function onLoad() { function onLoad() {
...@@ -22,14 +22,15 @@ ...@@ -22,14 +22,15 @@
</head> </head>
<body onload="onLoad();"> <body onload="onLoad();">
<object id="ChromeFrame1" width="500" height="500" <span id="ChromeFrameSpan"></span>
classid="CLSID:E0A900DF-9611-4446-86BD-4B1D47E7DB2A"> <script type="text/javascript">
<param name="src" value="about:blank"> insertControl("ChromeFrameSpan",
<embed id="ChromeFramePlugin" width="500" height="500" { "id": "ChromeFrame1",
name="ChromeFrame" type="application/chromeframe" "src": "about:blank",
src="about:blank"> "objectAttributes": { "codebase": null },
</embed> "embedAttributes": {"id": "ChromeFramePlugin", "name": "ChromeFrame"}
</object> });
</script>
ChromeFrame multiple widget instances test page. This testcase verifies ChromeFrame multiple widget instances test page. This testcase verifies
whether multiple chrome frame widget instances can be created on the whether multiple chrome frame widget instances can be created on the
same page. same page.
......
...@@ -46,15 +46,11 @@ ...@@ -46,15 +46,11 @@
<div id="statusPanel" style="border: 1px solid red; width: 100%"> <div id="statusPanel" style="border: 1px solid red; width: 100%">
Test running.... Test running....
</div> </div>
<object id="ChromeFrame" width="500" height="500" <span id="ChromeFrameSpan"></span>
codebase="http://www.google.com" <script type="text/javascript">
classid="CLSID:E0A900DF-9611-4446-86BD-4B1D47E7DB2A"> insertControl("ChromeFrameSpan",
<param name="onload" value="return OnChromeFrameLoaded();"> { "eventHandlers": { "onload": "return OnChromeFrameLoaded();" } });
<embed id="ChromeFramePlugin" width="500" height="500" </script>
name="ChromeFrame" onload="return OnChromeFrameLoaded();"
type="application/chromeframe">
</embed>
</OBJECT>
<br /> <br />
<br /> <br />
......
...@@ -43,15 +43,11 @@ ...@@ -43,15 +43,11 @@
<div id="statusPanel" style="border: 1px solid red; width: 100%"> <div id="statusPanel" style="border: 1px solid red; width: 100%">
Test running.... Test running....
</div> </div>
<object id="ChromeFrame" width="500" height="500" <span id="ChromeFrameSpan"></span>
codebase="http://www.google.com" <script type="text/javascript">
classid="CLSID:E0A900DF-9611-4446-86BD-4B1D47E7DB2A"> insertControl("ChromeFrameSpan",
<param name="onload" value="return OnChromeFrameLoaded();"> { "eventHandlers": { "onload": "return OnChromeFrameLoaded();" } });
<embed id="ChromeFramePlugin" width="500" height="500" </script>
name="ChromeFrame" onload="return OnChromeFrameLoaded();"
type="application/chromeframe">
</embed>
</OBJECT>
<br /> <br />
<br /> <br />
......
...@@ -41,22 +41,17 @@ ...@@ -41,22 +41,17 @@
</head> </head>
<body> <body>
<object id="ChromeFrame" width="500" height ="300" <span id="ChromeFrameSpan"></span>
codebase="http://www.google.com" <script type="text/javascript">
classid="CLSID:E0A900DF-9611-4446-86BD-4B1D47E7DB2A"> insertControl(
<param name="src" value="postmessage_basic_frame.html"> "ChromeFrameSpan",
<param name="onload" value="onChromeFrameLoaded();"> { "src": "postmessage_basic_frame.html",
<param name="onloaderror" value="onNavigationFailed();"> "eventHandlers": { "onload": "onChromeFrameLoaded();",
<param name="onmessage" value="onChromeFrameMessage(arguments[0]);"> "onloaderror": "onNavigationFailed();",
<embed id="ChromeFramePlugin" name="ChromeFrame" "onmessage": "onChromeFrameMessage(arguments[0]);" },
width="500" height="500" "objectAttributes": { "height": "300" }
src="postmessage_basic_frame.html" });
type="application/chromeframe" </script>
onload="onChromeFrameLoaded();"
onloaderror="onNavigationFailed();"
onmessage="onChromeFrameMessage(arguments[0]);">
</embed>
</object>
<br> <br>
<br> <br>
<p>Test for PostMessage from the host browser to ChromeFrame and back</p> <p>Test for PostMessage from the host browser to ChromeFrame and back</p>
......
...@@ -69,23 +69,20 @@ ...@@ -69,23 +69,20 @@
Test running.... Test running....
</div> </div>
<span id='ChromeFrameSpan'></span>
<!-- TODO(siggi): Test setting onprivatemessage in these params --> <!-- TODO(siggi): Test setting onprivatemessage in these params -->
<object id='ChromeFrame' width='500' height='500' <script type='text/javascript'>
codebase='http://www.google.com' insertControl(
classid='CLSID:E0A900DF-9611-4446-86BD-4B1D47E7DB2A'> 'ChromeFrameSpan',
<param name='src' value='privileged_apis_frame.html'> { "src": "privileged_apis_frame.html",
<param name='onload' value='OnChromeFrameLoaded(arguments[0]);'> "eventHandlers": {
<param name='onloaderror' value='OnNavigationFailed();'> "onload": "OnChromeFrameLoaded(arguments[0]);",
<param name='onmessage' value='OnChromeFrameMessage(arguments[0]);'> "onloaderror": "OnNavigationFailed();",
<embed id='ChromeFramePlugin' width='500' height='500' name='ChromeFrame' "onmessage": "return OnChromeFrameMessage(arguments[0]);"
src='privileged_apis_frame.html' },
type='application/chromeframe' "embedAttributes": { "privileged_mode": "1" }
onload='OnChromeFrameLoaded(arguments[0]);' });
onloaderror='OnNavigationFailed();' </script>
onmessage='return OnChromeFrameMessage(arguments[0]);'
privileged_mode='1'
</embed>
</object>
<p>Tests that privileged apis are unavailable from regular pages</p> <p>Tests that privileged apis are unavailable from regular pages</p>
</body> </body>
</html> </html>
...@@ -82,14 +82,16 @@ function status(s) { ...@@ -82,14 +82,16 @@ function status(s) {
<div id="status_panel" style="border: 1px solid red; width: 100%"> <div id="status_panel" style="border: 1px solid red; width: 100%">
Test running.... Test running....
</div> </div>
<object id="ChromeFrame" width="300" height="60" tabindex="0" <span id="ChromeFrameSpan"></span>
codebase="http://www.google.com" <script type="text/javascript">
classid="CLSID:E0A900DF-9611-4446-86BD-4B1D47E7DB2A"> insertControl(
<param name="onload" value="return OnChromeFrameLoaded();"> "ChromeFrameSpan",
<embed width="300" height="60" name="ChromeFrame" { "width": "300",
onload="return OnChromeFrameLoaded();" "height": "60",
type="application/chromeframe"> "eventHandlers": { "onload": "return OnChromeFrameLoaded();" },
</embed> "objectAttributes": { "tabindex": "0" },
</object> "embedAttributes": {"id": null }
});
</script>
</body> </body>
</html> </html>
...@@ -26,20 +26,17 @@ ...@@ -26,20 +26,17 @@
<div id="statusPanel" style="border: 1px solid red; width: 100%"> <div id="statusPanel" style="border: 1px solid red; width: 100%">
Test running.... Test running....
</div> </div>
<span id="ChromeFrameSpan"></span>
<object id="ChromeFrame" width="500" height="500" <script type="text/javascript">
codebase="http://www.google.com" insertControl(
classid="CLSID:E0A900DF-9611-4446-86BD-4B1D47E7DB2A"> "ChromeFrameSpan",
<param name="src" value="src_property_frame1.html"> { "src": "src_property_frame1.html",
<param name="onload" value="return OnChromeFrameLoaded(arguments[0]);"> "eventHandlers": {
<param name="onloaderror" value="return OnNavigationFailed(arguments[0]);"> "onload": "return OnChromeFrameLoaded();",
<embed id="ChromeFramePlugin" width="500" height="500" name="ChromeFrame" "onloaderror": "return OnNavigationFailed(arguments[0]);"
src="src_property_frame1.html" }
type="application/chromeframe" });
onload="return OnChromeFrameLoaded(arguments[0]);" </script>
onloaderror="return OnNavigationFailed(arguments[0]);">
</embed>
</object>
<p>Tests ChromeFrame Navigation</p> <p>Tests ChromeFrame Navigation</p>
</body> </body>
</html> </html>
...@@ -12,13 +12,10 @@ ...@@ -12,13 +12,10 @@
</head> </head>
<body onload="onLoad();"> <body onload="onLoad();">
<object id="ChromeFrame" <span id="ChromeFrameSpan"></span>
codebase="http://www.google.com" <script type="text/javascript">
classid="CLSID:E0A900DF-9611-4446-86BD-4B1D47E7DB2A"> insertControl("ChromeFrameSpan", { "width": null, "height": null });
<embed id="ChromeFramePlugin" name="ChromeFrame" </script>
type="application/chromeframe"
</embed>
</object>
<br> <br>
<br> <br>
<p>Test for Chrome frame version</p> <p>Test for Chrome frame version</p>
......
...@@ -28,21 +28,18 @@ ...@@ -28,21 +28,18 @@
Test running.... Test running....
</div> </div>
<object id="ChromeFrame" width="500" height="500" <span id="ChromeFrameSpan"></span>
codebase="http://www.google.com" <script type="text/javascript">
classid="CLSID:E0A900DF-9611-4446-86BD-4B1D47E7DB2A"> insertControl(
<param name="src" value="window_close_frame.html"> "ChromeFrameSpan",
<param name="onload" value="return OnChromeFrameLoaded(arguments[0]);"> { "src": "window_close_frame.html",
<param name="onloaderror" value="return OnNavigationFailed(arguments[0]);"> "eventHandlers": {
<param name="onclose" value="return OnCloseWindow();"> "onload": "return OnChromeFrameLoaded(arguments[0]);",
<embed id="ChromeFramePlugin" width="500" height="500" name="ChromeFrame" "onloaderror": "return OnNavigationFailed(arguments[0]);",
src="window_close_frame.html" "onclose": "return OnCloseWindow();"
type="application/chromeframe" }
onload="return OnChromeFrameLoaded(arguments[0]);" });
onloaderror="return OnNavigationFailed(arguments[0]);" </script>
onclose="return OnCloseWindow();">
</embed>
</object>
<p>Tests window.close notification from ChromeFrame to its container</p> <p>Tests window.close notification from ChromeFrame to its container</p>
</body> </body>
</html> </html>
...@@ -115,12 +115,12 @@ void ChromeFrameTestWithWebServer::SetUp() { ...@@ -115,12 +115,12 @@ void ChromeFrameTestWithWebServer::SetUp() {
CFInstance_src_path = chrome_frame_source_path.AppendASCII("CFInstance.js"); CFInstance_src_path = chrome_frame_source_path.AppendASCII("CFInstance.js");
CFInstance_path_ = test_file_path_.AppendASCII("CFInstance.js"); CFInstance_path_ = test_file_path_.AppendASCII("CFInstance.js");
file_util::CopyFileW(CFInstance_src_path, CFInstance_path_); ASSERT_TRUE(file_util::CopyFile(CFInstance_src_path, CFInstance_path_));
CFInstall_src_path = chrome_frame_source_path.AppendASCII("CFInstall.js"); CFInstall_src_path = chrome_frame_source_path.AppendASCII("CFInstall.js");
CFInstall_path_ = test_file_path_.AppendASCII("CFInstall.js"); CFInstall_path_ = test_file_path_.AppendASCII("CFInstall.js");
file_util::CopyFileW(CFInstall_src_path, CFInstall_path_); ASSERT_TRUE(file_util::CopyFile(CFInstall_src_path, CFInstall_path_));
server_mock_.ExpectAndServeAnyRequests(CFInvocation(CFInvocation::NONE)); server_mock_.ExpectAndServeAnyRequests(CFInvocation(CFInvocation::NONE));
server_mock_.set_expected_result("OK"); server_mock_.set_expected_result("OK");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment