Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Side by Side Diff: chrome_frame/test/data/chrome_frame_tester_helpers.js

Issue 8777002: Chrome Frame test fixes for Vista/IE7. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ToT sync Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // 1 //
2 // This script provides some mechanics for testing ChromeFrame 2 // This script provides some mechanics for testing ChromeFrame
3 // 3 //
4 function onSuccess(name, id) { 4 function onSuccess(name, id) {
5 appendStatus("Success reported!"); 5 appendStatus("Success reported!");
6 onFinished(name, id, "OK"); 6 onFinished(name, id, "OK");
7 } 7 }
8 8
9 function onFailure(name, id, status) { 9 function onFailure(name, id, status) {
10 appendStatus("Failure reported: " + status); 10 appendStatus("Failure reported: " + status);
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 182
183 url += window.location.protocol + "//" + window.location.host; 183 url += window.location.protocol + "//" + window.location.host;
184 if (path.lastIndexOf("/") > 0) { 184 if (path.lastIndexOf("/") > 0) {
185 url += path.substring(0, path.lastIndexOf("/")) + "/" + pageName; 185 url += path.substring(0, path.lastIndexOf("/")) + "/" + pageName;
186 } else { 186 } else {
187 url += "/" + pageName; 187 url += "/" + pageName;
188 } 188 }
189 url += ((queryString == "") ? "" : "?" + queryString); 189 url += ((queryString == "") ? "" : "?" + queryString);
190 return url; 190 return url;
191 } 191 }
192
193 // Helper function for insertControl.
194 function generateControlHtml(configuration) {
195 var objectAttributes = new Object();
196 var params = new Array();
197 var embedAttributes = new Object();
198 var param;
199 var html;
200
201 function stringifyAttributes(attributeCollection) {
202 var result = new String();
203 for (var attributeName in attributeCollection) {
204 result += ' ' + attributeName + '="' +
205 attributeCollection[attributeName] + '"';
206 }
207 return result;
208 }
209
210 function applyAttribute(attributeCollection, name, value, defaultValue) {
211 if (value === undefined)
212 value = defaultValue;
213 if (value !== null)
214 attributeCollection[name] = value;
215 }
216
217 objectAttributes.classid="CLSID:E0A900DF-9611-4446-86BD-4B1D47E7DB2A";
218 objectAttributes.codebase="http://www.google.com";
219 applyAttribute(objectAttributes, "id", configuration.id, "ChromeFrame");
220 applyAttribute(objectAttributes, "width", configuration.width, "500");
221 applyAttribute(objectAttributes, "height", configuration.height, "500");
222
223 // Attributes provided by the caller override any defaults.
224 for (var attribute in configuration.objectAttributes) {
225 if (configuration.objectAttributes[attribute] === null)
226 delete objectAttributes[attribute];
227 else
228 objectAttributes[attribute] = configuration.objectAttributes[attribute];
229 }
230
231 embedAttributes.type = "application/chromeframe";
232
233 // By default, embed id = object.id + "Plugin". null id means omit id.
234 if (embedAttributes.id === null)
235 delete embedAttributes.id;
236 else if (embedAttributes.id === undefined && objectAttributes.id !== null)
237 embedAttributes.id = objectAttributes.id + "Plugin";
238
239 // By default, embed name = object.id. null name means omit name.
240 if (embedAttributes.name === null)
241 delete embedAttributes.name;
242 else if (embedAttributes.name === undefined && objectAttributes.id !== null)
243 embedAttributes.name = objectAttributes.id;
244
245 applyAttribute(embedAttributes, "width", configuration.width, "500");
246 applyAttribute(embedAttributes, "height", configuration.height, "500");
247 applyAttribute(embedAttributes, "src", configuration.src, null);
248
249 for (var attribute in configuration.embedAttributes) {
250 if (configuration.embedAttributes[attribute] === null)
251 delete embedAttributes[attribute];
252 else
253 embedAttributes[attribute] = configuration.embedAttributes[attribute];
254 }
255
256 if (embedAttributes.src !== undefined) {
257 param = new Object();
258 param.name = "src";
259 param.value = embedAttributes.src;
260 params.push(param);
261 }
262
263 // All event handlers are params and attributes of the embed object.
264 for (var eventName in configuration.eventHandlers) {
265 param = new Object();
266 param.name = eventName;
267 param.value = configuration.eventHandlers[eventName];
268 params.push(param);
269 embedAttributes[eventName] = configuration.eventHandlers[eventName];
270 }
271
272 html = "<object" + stringifyAttributes(objectAttributes) + ">\r\n";
273 for (var i = 0; i < params.length; ++i) {
274 html += " <param" + stringifyAttributes(params[i]) + ">\r\n";
275 }
276 html += " <embed" + stringifyAttributes(embedAttributes) + "></embed>\r\n"
277
278 html += "</object>";
279
280 return html;
281 }
282
283 // Write the text for the Chrome Frame ActiveX control into an element.
284 // This works around a "feature" of IE versions released between April, 2006
285 // and April, 2008 that required the user to click on an ActiveX control to
286 // "activate" it. See http://msdn.microsoft.com/en-us/library/ms537508.aspx.
287 //
288 // |elementId| identifies the element in the current document into which the
289 // control markup will be inserted. |configuration| is an Object used to
290 // configure the control as below. Values shown are defaults, which may be
291 // overridden by supplying null values.
292 // {
293 // "id": "ChromeFrame", // id of object tag, name of the embed tag, and
294 // // basis of id of the embed tag.
295 // "width": "500", // width of both object and embed tags.
296 // "height": "500", // height of both object and embed tags.
297 // "src": "url", // src of embed tag and of param to object tag.
298 // "eventHandlers": { // Applied to embed tag and params to object tag.
299 // "onclose": "...",
300 // "onload": "...",
301 // "onloaderror": "..."
302 // }
303 // "objectAttributes": { // Custom attributes for the object tag. Any
304 // "tabindex": "...", // properties explicitly set to null will override
305 // "border": "...", // defaults.
306 // "style": "..."
307 // },
308 // "embedAttributes": { // Custom attributes for the embed tag;
309 // "privileged_mode": "...", // similar to above.
310 // "style": "..."
311 // }
312 // }
313 function insertControl(elementId, configuration) {
314 var e = document.getElementById(elementId);
315 e.innerHTML = generateControlHtml(configuration);
316 }
OLDNEW
« no previous file with comments | « chrome_frame/test/data/chrome_frame_resize.html ('k') | chrome_frame/test/data/event_listener.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698