Skip to content

Commit ede98de

Browse files
committed
[js] Only wrap function type arguments
Fixes SeleniumHQ#2127
1 parent a91690b commit ede98de

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

  • javascript/node/selenium-webdriver/testing

javascript/node/selenium-webdriver/testing/index.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,26 @@ function seal(fn) {
9292
function wrapped(globalFn) {
9393
return function() {
9494
if (arguments.length === 1) {
95-
return globalFn(makeAsyncTestFn(arguments[0]));
96-
}
97-
else if (arguments.length === 2) {
98-
return globalFn(arguments[0], makeAsyncTestFn(arguments[1]));
99-
}
100-
else {
95+
return globalFn(wrapArgument(arguments[0]));
96+
97+
} else if (arguments.length === 2) {
98+
return globalFn(arguments[0], wrapArgument(arguments[1]));
99+
100+
} else {
101101
throw Error('Invalid # arguments: ' + arguments.length);
102102
}
103103
};
104104
}
105105

106+
107+
function wrapArgument(value) {
108+
if (typeof value === 'function') {
109+
return makeAsyncTestFn(value);
110+
}
111+
return value;
112+
}
113+
114+
106115
/**
107116
* Make a wrapper to invoke caller's test function, fn. Run the test function
108117
* within a ControlFlow.

0 commit comments

Comments
 (0)