Created
September 27, 2012 20:55
-
-
Save s9tpepper/3796408 to your computer and use it in GitHub Desktop.
Making Zombie think its IE with Flash installed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this.Given(/^some steps that detect IE with Flash installed$/, function(arg1, callback) { | |
// Tell Zombie to pose as IE 8.0 | |
browser = new zombie.Browser({ | |
userAgent: "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)" | |
}); | |
browser.on("loaded", function (event) { | |
var window = browser.window; | |
// Make an ActiveXObject function w/ a GetVariable method prototype that returns the desired Flash version | |
window.ActiveXObject = function ActiveXObject() { | |
ActiveXObject.prototype.GetVariable = function (variable) { | |
var value; | |
if (variable === "$version") { | |
value = "Flash 10,1,102"; | |
} | |
return value; | |
}; | |
}; | |
// Add this attachEvent method that is used by swfobject to clean after itself in an IE environment | |
// It can be ignored since we're not in IE and we're just faking Zombie into telling swfobject it is. | |
window.attachEvent = function (event, callback) { | |
// swfobject adds a cleanup script if the agent is IE, ignore it | |
}; | |
}); | |
// Callback and go load a page to test | |
callback(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment