Skip to content

Instantly share code, notes, and snippets.

@s9tpepper
Created September 27, 2012 18:54
Show Gist options
  • Save s9tpepper/3795727 to your computer and use it in GitHub Desktop.
Save s9tpepper/3795727 to your computer and use it in GitHub Desktop.
Make Zombie think Flash is available
// These 'settings' put on the navigator will result in a plugin detection, not ActiveX
// I will link a gist for IE when I finish that one.
// edit: Link to IE example: https://gist.github.com/3796408
var SHOCKWAVE_FLASH = "Shockwave Flash",
FLASH_MIME_TYPE = "application/x-shockwave-flash";
this.Given(/^some step that tests Flash availability$/, function(callback) {
// Tell Zombie to pose as Safari 5.0
browser = new zombie.Browser({
userAgent: "Mozilla/5.0 (CPU OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko ) Version/5.0 Safari/7534.48.3"
});
// Add a callback for the loaded event, which fires before DOMContentLoaded
browser.on("loaded", function (event) {
var window = browser.window;
// Fake a mimeTypes array and set the Flash mimeType to enabled
window.navigator.mimeTypes = [];
window.navigator.mimeTypes[FLASH_MIME_TYPE] = {
enabledPlugin: true
};
// Add an entry for SHOCKWAVE_FLASH and set the description to the Flash version report required
window.navigator.plugins[SHOCKWAVE_FLASH] = {
description: "Shockwave Flash 10.1 r102"
};
});
callback();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment