Skip to content

Instantly share code, notes, and snippets.

@jarib
Created January 15, 2015 15:06
Show Gist options
  • Save jarib/6a19bd42d2f90c9055b3 to your computer and use it in GitHub Desktop.
Save jarib/6a19bd42d2f90c9055b3 to your computer and use it in GitHub Desktop.
diff --git a/javascript/firefox-driver/js/firefoxDriver.js b/javascript/firefox-driver/js/firefoxDriver.js
index 3aadcc7..5a4e4f0 100644
--- a/javascript/firefox-driver/js/firefoxDriver.js
+++ b/javascript/firefox-driver/js/firefoxDriver.js
@@ -198,7 +198,7 @@ function injectAndExecuteScript(respond, parameters, isAsync, timer) {
var script = parameters['script'];
var converted = Utils.unwrapParameters(parameters['args'], doc);
- if (doc.designMode && 'on' == doc.designMode.toLowerCase()) {
+ if ((doc.designMode && 'on' == doc.designMode.toLowerCase()) || bot.userAgent.isProductVersion(35)) {
if (isAsync) {
respond.sendError(
'Document designMode is enabled; advanced operations, ' +
@@ -218,11 +218,13 @@ function injectAndExecuteScript(respond, parameters, isAsync, timer) {
sandbox.window = window;
sandbox.document = doc.wrappedJSObject ? doc.wrappedJSObject : doc;
sandbox.navigator = window.navigator;
- sandbox.__webdriverParams = converted;
try {
+ sandbox.__webdriverParams = Components.utils.cloneInto(converted, sandbox, { wrapReflectors: true });
+
var scriptSrc = 'with(window) { var __webdriverFunc = function(){' + parameters.script +
'}; __webdriverFunc.apply(null, __webdriverParams); }';
+
var res = Components.utils.evalInSandbox(scriptSrc, sandbox);
respond.value = Utils.wrapResult(res, doc);
respond.send();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment