SeleniumHQ/selenium — pull request #296 by candeira (2014-12-02 23:54:08+00:00)
Title: Tests for #8223 firefox webdriver problem with scope in executeScript

These tests work on Chrome 39, they fail on Firefox 33 (and via saucelabs, at least as far back as FF 28).

I'll comment again when the CLA is signed.

Output of tests on my system:

```
kandinski@desire:~/code/selenium/javascript/node/selenium-webdriver$ firefox --version

(process:31538): GLib-CRITICAL **: g_slice_set_config: assertion 'sys_page_size == 0' failed
Mozilla Firefox 33.0
kandinski@desire:~/code/selenium/javascript/node/selenium-webdriver$ google-chrome --version
Google Chrome 39.0.2171.71
kandinski@desire:~/code/selenium/javascript/node/selenium-webdriver$
kandinski@desire:~/code/selenium/javascript/node/selenium-webdriver$ git log --pretty=short -n 1 master
commit 446df4dd75851bdc41e610bfe28f395a517194e1
Author: Ondřej Čertík
Date: Mon Dec 1 12:56:55 2014 -0700

README: Fix the Yahoo example
kandinski@desire:~/code/selenium/javascript/node/selenium-webdriver$
kandinski@desire:~/code/selenium/javascript/node/selenium-webdriver$ SELENIUM_BROWSER=chrome,firefox ./node_modules/mocha/bin/mocha -t 120000 ./test/execute_script_test.js
Running tests against [chrome,firefox]

[chrome]
executeScript
✓ fails if script throws (44ms)
✓ fails if script does not parse
scripts
✓ do not pollute the global scope (53ms)
✓ can set global variables (62ms)
✓ may be defined as a function expression (50ms)
return values
✓ returns undefined as null
✓ can return null
✓ can return numbers (70ms)
✓ can return strings
✓ can return booleans (47ms)
✓ can return an array of primitives (38ms)
✓ can return nested arrays
✓ can return object literals (49ms)
✓ can return complex object literals (40ms)
✓ can return dom elements as web elements (120ms)
✓ can return array of dom elements (159ms)
✓ can return a NodeList as an array of web elements (167ms)
✓ can return object literal with element property (83ms)
parameters
✓ can pass numeric arguments (60ms)
✓ can pass boolean arguments (49ms)
✓ can pass string arguments
✓ can pass null arguments (57ms)
✓ passes undefined as a null argument (61ms)
✓ can pass multiple arguments (49ms)
✓ can return arguments object as array
✓ can pass object literal (45ms)
✓ WebElement arguments are passed as DOM elements (74ms)
✓ can pass array containing object literals
✓ does not modify object literal parameters
https://code.google.com/p/selenium/issues/detail?id=8223
✓ a for loop can build an array out of the index var, and return it
✓ a for loop can return an array built from elements passed in a list
✓ a for loop can return an array built from elements passed in a nested object (46ms)
✓ nested recursive functions can return an array built from elements passed in a list
✓ nested recursive functions can return an array built from elements passed in a nested object (39ms)

[firefox]

Building //javascript/firefox-driver:webdriver ...
(in /home/kandinski/code/selenium)
executeScript
✓ fails if script throws (72ms)
✓ fails if script does not parse (43ms)
scripts
✓ do not pollute the global scope (116ms)
✓ can set global variables (84ms)
✓ may be defined as a function expression (45ms)
return values
✓ returns undefined as null (45ms)
✓ can return null (42ms)
✓ can return numbers (83ms)
✓ can return strings (42ms)
✓ can return booleans (94ms)
✓ can return an array of primitives (43ms)
✓ can return nested arrays (43ms)
✓ can return object literals (95ms)
✓ can return complex object literals (62ms)
✓ can return dom elements as web elements (167ms)
✓ can return array of dom elements (231ms)
✓ can return a NodeList as an array of web elements (233ms)
✓ can return object literal with element property (125ms)
parameters
✓ can pass numeric arguments (195ms)
✓ can pass boolean arguments (94ms)
✓ can pass string arguments (41ms)
✓ can pass null arguments (96ms)
✓ passes undefined as a null argument (93ms)
✓ can pass multiple arguments (93ms)
✓ can return arguments object as array (43ms)
✓ can pass object literal (41ms)
✓ WebElement arguments are passed as DOM elements (94ms)
✓ can pass array containing object literals (53ms)
✓ does not modify object literal parameters (54ms)
https://code.google.com/p/selenium/issues/detail?id=8223
✓ a for loop can build an array out of the index var, and return it (52ms)
1) a for loop can return an array built from elements passed in a list
2) a for loop can return an array built from elements passed in a nested object
✓ nested recursive functions can return an array built from elements passed in a list (52ms)
3) nested recursive functions can return an array built from elements passed in a nested object

65 passing (21s)
3 failing

1) [firefox] executeScript https://code.google.com/p/selenium/issues/detail?id=8223 a for loop can return an array built from elements passed in a list:
CustomError: [] is not equal to ["fa","fe","fi"]
at Function.childCtor.base (/home/kandinski/code/selenium/third_party/closure/goog/base.js:2135:45)
at new goog.labs.testing.MatcherError (/home/kandinski/code/selenium/third_party/closure/goog/labs/testing/assertthat.js:56:34)
at Object.goog.labs.testing.assertThat (/home/kandinski/code/selenium/third_party/closure/goog/labs/testing/assertthat.js:42:11)
at webdriver.testing.Assertion.apply (/home/kandinski/code/selenium/javascript/webdriver/testing/asserts.js:153:23)
at webdriver.testing.Assertion.equalTo (/home/kandinski/code/selenium/javascript/webdriver/testing/asserts.js:346:15)
at /home/kandinski/code/selenium/javascript/node/selenium-webdriver/test/execute_script_test.js:304:38
at /home/kandinski/code/selenium/third_party/closure/goog/base.js:1781:15
at promise.ControlFlow.runInNewFrame_ (/home/kandinski/code/selenium/javascript/webdriver/promise.js:1630:20)
at Object.listener.onFulfilled (/home/kandinski/code/selenium/javascript/webdriver/promise.js:454:14)
at promise.Promise.notify_ (/home/kandinski/code/selenium/javascript/webdriver/promise.js:404:14)
at promise.Promise.notifyAll_ (/home/kandinski/code/selenium/javascript/webdriver/promise.js:376:10)
at promise.Promise.resolve_ (/home/kandinski/code/selenium/javascript/webdriver/promise.js:359:10)
at /home/kandinski/code/selenium/javascript/webdriver/promise.js:294:12
at Object.promise.asap (/home/kandinski/code/selenium/javascript/webdriver/promise.js:764:5)
at promise.ControlFlow.runInNewFrame_ (/home/kandinski/code/selenium/javascript/webdriver/promise.js:1641:15)
at Object.listener.onFulfilled (/home/kandinski/code/selenium/javascript/webdriver/promise.js:454:14)
at promise.Promise.notify_ (/home/kandinski/code/selenium/javascript/webdriver/promise.js:404:14)
at promise.Promise.notifyAll_ (/home/kandinski/code/selenium/javascript/webdriver/promise.js:376:10)
at promise.Promise.resolve_ (/home/kandinski/code/selenium/javascript/webdriver/promise.js:359:10)
at /home/kandinski/code/selenium/javascript/webdriver/promise.js:294:12
at fulfill (/home/kandinski/code/selenium/javascript/webdriver/promise.js:547:5)
at /home/kandinski/code/selenium/javascript/webdriver/promise.js:1501:10
at /home/kandinski/code/selenium/third_party/closure/goog/base.js:1781:15
at promise.ControlFlow.runInNewFrame_ (/home/kandinski/code/selenium/javascript/webdriver/promise.js:1630:20)
at Object.listener.onFulfilled (/home/kandinski/code/selenium/javascript/webdriver/promise.js:454:14)
at promise.Promise.notify_ (/home/kandinski/code/selenium/javascript/webdriver/promise.js:404:14)
at promise.Promise.notifyAll_ (/home/kandinski/code/selenium/javascript/webdriver/promise.js:376:10)
at promise.Promise.resolve_ (/home/kandinski/code/selenium/javascript/webdriver/promise.js:359:10)
at /home/kandinski/code/selenium/javascript/webdriver/promise.js:294:12
at /home/kandinski/code/selenium/third_party/closure/goog/base.js:1781:15
at promise.ControlFlow.runInNewFrame_ (/home/kandinski/code/selenium/javascript/webdriver/promise.js:1630:20)
at Object.listener.onFulfilled (/home/kandinski/code/selenium/javascript/webdriver/promise.js:454:14)
at promise.Promise.notify_ (/home/kandinski/code/selenium/javascript/webdriver/promise.js:404:14)
at promise.Promise.notifyAll_ (/home/kandinski/code/selenium/javascript/webdriver/promise.js:376:10)
at promise.Promise.resolve_ (/home/kandinski/code/selenium/javascript/webdriver/promise.js:359:10)
at /home/kandinski/code/selenium/javascript/webdriver/promise.js:294:12
at /home/kandinski/code/selenium/javascript/webdriver/promise.js:711:33
at /home/kandinski/code/selenium/javascript/webdriver/http/http.js:97:5
at IncomingMessage. (/home/kandinski/code/selenium/javascript/node/selenium-webdriver/http/index.js:131:7)
at IncomingMessage.EventEmitter.emit (events.js:117:20)
at _stream_readable.js:920:16
at process._tickCallback (node.js:415:13)
==== async task ====
WebDriver.executeScript()
at webdriver.WebDriver.schedule (/home/kandinski/code/selenium/javascript/webdriver/webdriver.js:356:15)
at webdriver.WebDriver.executeScript (/home/kandinski/code/selenium/javascript/webdriver/webdriver.js:501:15)
at execute (/home/kandinski/code/selenium/javascript/node/selenium-webdriver/test/execute_script_test.js:309:33)
at Context. (/home/kandinski/code/selenium/javascript/node/selenium-webdriver/test/execute_script_test.js:252:9)
at /home/kandinski/code/selenium/javascript/node/selenium-webdriver/testing/index.js:121:22
at promise.ControlFlow.runInNewFrame_ (/home/kandinski/code/selenium/javascript/webdriver/promise.js:1630:20)
at promise.ControlFlow.runEventLoop_ (/home/kandinski/code/selenium/javascript/webdriver/promise.js:1499:8)
at wrapper [as _onTimeout] (timers.js:252:14)
at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
==== async task ====
at Context.ret (/home/kandinski/code/selenium/javascript/node/selenium-webdriver/testing/index.js:119:12)
at Test.Runnable.run (/home/kandinski/code/selenium/javascript/node/selenium-webdriver/node_modules/mocha/lib/runnable.js:217:15)
at Runner.runTest (/home/kandinski/code/selenium/javascript/node/selenium-webdriver/node_modules/mocha/lib/runner.js:373:10)
at /home/kandinski/code/selenium/javascript/node/selenium-webdriver/node_modules/mocha/lib/runner.js:451:12
at next (/home/kandinski/code/selenium/javascript/node/selenium-webdriver/node_modules/mocha/lib/runner.js:298:14)
at /home/kandinski/code/selenium/javascript/node/selenium-webdriver/node_modules/mocha/lib/runner.js:308:7
at next (/home/kandinski/code/selenium/javascript/node/selenium-webdriver/node_modules/mocha/lib/runner.js:246:23)
at Object._onImmediate (/home/kandinski/code/selenium/javascript/node/selenium-webdriver/node_modules/mocha/lib/runner.js:275:5)
at processImmediate [as _immediateCallback] (timers.js:330:15)

2) [firefox] executeScript https://code.google.com/p/selenium/issues/detail?id=8223 a for loop can return an array built from elements passed in a nested object:
CustomError: [] is not equal to ["fa","fe","fi"]
at Function.childCtor.base (/home/kandinski/code/selenium/third_party/closure/goog/base.js:2135:45)
at new goog.labs.testing.MatcherError (/home/kandinski/code/selenium/third_party/closure/goog/labs/testing/assertthat.js:56:34)
at Object.goog.labs.testing.assertThat (/home/kandinski/code/selenium/third_party/closure/goog/labs/testing/assertthat.js:42:11)
at webdriver.testing.Assertion.apply (/home/kandinski/code/selenium/javascript/webdriver/testing/asserts.js:153:23)
at webdriver.testing.Assertion.equalTo (/home/kandinski/code/selenium/javascript/webdriver/testing/asserts.js:346:15)
at /home/kandinski/code/selenium/javascript/node/selenium-webdriver/test/execute_script_test.js:304:38
at /home/kandinski/code/selenium/third_party/closure/goog/base.js:1781:15
at promise.ControlFlow.runInNewFrame_ (/home/kandinski/code/selenium/javascript/webdriver/promise.js:1630:20)
at Object.listener.onFulfilled (/home/kandinski/code/selenium/javascript/webdriver/promise.js:454:14)
at promise.Promise.notify_ (/home/kandinski/code/selenium/javascript/webdriver/promise.js:404:14)
at promise.Promise.notifyAll_ (/home/kandinski/code/selenium/javascript/webdriver/promise.js:376:10)
at promise.Promise.resolve_ (/home/kandinski/code/selenium/javascript/webdriver/promise.js:359:10)
at /home/kandinski/code/selenium/javascript/webdriver/promise.js:294:12
at Object.promise.asap (/home/kandinski/code/selenium/javascript/webdriver/promise.js:764:5)
at promise.ControlFlow.runInNewFrame_ (/home/kandinski/code/selenium/javascript/webdriver/promise.js:1641:15)
at Object.listener.onFulfilled (/home/kandinski/code/selenium/javascript/webdriver/promise.js:454:14)
at promise.Promise.notify_ (/home/kandinski/code/selenium/javascript/webdriver/promise.js:404:14)
at promise.Promise.notifyAll_ (/home/kandinski/code/selenium/javascript/webdriver/promise.js:376:10)
at promise.Promise.resolve_ (/home/kandinski/code/selenium/javascript/webdriver/promise.js:359:10)
at /home/kandinski/code/selenium/javascript/webdriver/promise.js:294:12
at fulfill (/home/kandinski/code/selenium/javascript/webdriver/promise.js:547:5)
at /home/kandinski/code/selenium/javascript/webdriver/promise.js:1501:10
at /home/kandinski/code/selenium/third_party/closure/goog/base.js:1781:15
at promise.ControlFlow.runInNewFrame_ (/home/kandinski/code/selenium/javascript/webdriver/promise.js:1630:20)
at Object.listener.onFulfilled (/home/kandinski/code/selenium/javascript/webdriver/promise.js:454:14)
at promise.Promise.notify_ (/home/kandinski/code/selenium/javascript/webdriver/promise.js:404:14)
at promise.Promise.notifyAll_ (/home/kandinski/code/selenium/javascript/webdriver/promise.js:376:10)
at promise.Promise.resolve_ (/home/kandinski/code/selenium/javascript/webdriver/promise.js:359:10)
at /home/kandinski/code/selenium/javascript/webdriver/promise.js:294:12
at /home/kandinski/code/selenium/third_party/closure/goog/base.js:1781:15
at promise.ControlFlow.runInNewFrame_ (/home/kandinski/code/selenium/javascript/webdriver/promise.js:1630:20)
at Object.listener.onFulfilled (/home/kandinski/code/selenium/javascript/webdriver/promise.js:454:14)
at promise.Promise.notify_ (/home/kandinski/code/selenium/javascript/webdriver/promise.js:404:14)
at promise.Promise.notifyAll_ (/home/kandinski/code/selenium/javascript/webdriver/promise.js:376:10)
at promise.Promise.resolve_ (/home/kandinski/code/selenium/javascript/webdriver/promise.js:359:10)
at /home/kandinski/code/selenium/javascript/webdriver/promise.js:294:12
at /home/kandinski/code/selenium/javascript/webdriver/promise.js:711:33
at /home/kandinski/code/selenium/javascript/webdriver/http/http.js:97:5
at IncomingMessage. (/home/kandinski/code/selenium/javascript/node/selenium-webdriver/http/index.js:131:7)
at IncomingMessage.EventEmitter.emit (events.js:117:20)
at _stream_readable.js:920:16
at process._tickCallback (node.js:415:13)
==== async task ====
WebDriver.executeScript()
at webdriver.WebDriver.schedule (/home/kandinski/code/selenium/javascript/webdriver/webdriver.js:356:15)
at webdriver.WebDriver.executeScript (/home/kandinski/code/selenium/javascript/webdriver/webdriver.js:501:15)
at execute (/home/kandinski/code/selenium/javascript/node/selenium-webdriver/test/execute_script_test.js:309:33)
at Context. (/home/kandinski/code/selenium/javascript/node/selenium-webdriver/test/execute_script_test.js:263:9)
at /home/kandinski/code/selenium/javascript/node/selenium-webdriver/testing/index.js:121:22
at promise.ControlFlow.runInNewFrame_ (/home/kandinski/code/selenium/javascript/webdriver/promise.js:1630:20)
at promise.ControlFlow.runEventLoop_ (/home/kandinski/code/selenium/javascript/webdriver/promise.js:1499:8)
at wrapper [as _onTimeout] (timers.js:252:14)
at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
==== async task ====
at Context.ret (/home/kandinski/code/selenium/javascript/node/selenium-webdriver/testing/index.js:119:12)
at Test.Runnable.run (/home/kandinski/code/selenium/javascript/node/selenium-webdriver/node_modules/mocha/lib/runnable.js:217:15)
at Runner.runTest (/home/kandinski/code/selenium/javascript/node/selenium-webdriver/node_modules/mocha/lib/runner.js:373:10)
at /home/kandinski/code/selenium/javascript/node/selenium-webdriver/node_modules/mocha/lib/runner.js:451:12
at next (/home/kandinski/code/selenium/javascript/node/selenium-webdriver/node_modules/mocha/lib/runner.js:298:14)
at /home/kandinski/code/selenium/javascript/node/selenium-webdriver/node_modules/mocha/lib/runner.js:308:7
at next (/home/kandinski/code/selenium/javascript/node/selenium-webdriver/node_modules/mocha/lib/runner.js:246:23)
at Object._onImmediate (/home/kandinski/code/selenium/javascript/node/selenium-webdriver/node_modules/mocha/lib/runner.js:275:5)
at processImmediate [as _immediateCallback] (timers.js:330:15)

3) [firefox] executeScript https://code.google.com/p/selenium/issues/detail?id=8223 nested recursive functions can return an array built from elements passed in a nested object:
JavascriptError: Permission denied to pass object to chrome
at new bot.Error (/home/kandinski/code/selenium/javascript/atoms/error.js:113:18)
at Object.bot.response.checkResponse (/home/kandinski/code/selenium/javascript/atoms/response.js:106:9)
at /home/kandinski/code/selenium/javascript/webdriver/webdriver.js:373:20
at /home/kandinski/code/selenium/third_party/closure/goog/base.js:1781:15
at promise.ControlFlow.runInNewFrame_ (/home/kandinski/code/selenium/javascript/webdriver/promise.js:1630:20)
at Object.listener.onFulfilled (/home/kandinski/code/selenium/javascript/webdriver/promise.js:454:14)
at promise.Promise.notify_ (/home/kandinski/code/selenium/javascript/webdriver/promise.js:404:14)
at promise.Promise.notifyAll_ (/home/kandinski/code/selenium/javascript/webdriver/promise.js:376:10)
at promise.Promise.resolve_ (/home/kandinski/code/selenium/javascript/webdriver/promise.js:359:10)
at /home/kandinski/code/selenium/javascript/webdriver/promise.js:294:12
at fulfill (/home/kandinski/code/selenium/javascript/webdriver/promise.js:547:5)
at /home/kandinski/code/selenium/javascript/webdriver/promise.js:1501:10
at /home/kandinski/code/selenium/third_party/closure/goog/base.js:1781:15
at promise.ControlFlow.runInNewFrame_ (/home/kandinski/code/selenium/javascript/webdriver/promise.js:1630:20)
at Object.listener.onFulfilled (/home/kandinski/code/selenium/javascript/webdriver/promise.js:454:14)
at promise.Promise.notify_ (/home/kandinski/code/selenium/javascript/webdriver/promise.js:404:14)
at promise.Promise.notifyAll_ (/home/kandinski/code/selenium/javascript/webdriver/promise.js:376:10)
at promise.Promise.resolve_ (/home/kandinski/code/selenium/javascript/webdriver/promise.js:359:10)
at /home/kandinski/code/selenium/javascript/webdriver/promise.js:294:12
at /home/kandinski/code/selenium/third_party/closure/goog/base.js:1781:15
at promise.ControlFlow.runInNewFrame_ (/home/kandinski/code/selenium/javascript/webdriver/promise.js:1630:20)
at Object.listener.onFulfilled (/home/kandinski/code/selenium/javascript/webdriver/promise.js:454:14)
at promise.Promise.notify_ (/home/kandinski/code/selenium/javascript/webdriver/promise.js:404:14)
at promise.Promise.notifyAll_ (/home/kandinski/code/selenium/javascript/webdriver/promise.js:376:10)
at promise.Promise.resolve_ (/home/kandinski/code/selenium/javascript/webdriver/promise.js:359:10)
at /home/kandinski/code/selenium/javascript/webdriver/promise.js:294:12
at /home/kandinski/code/selenium/javascript/webdriver/promise.js:711:33
at /home/kandinski/code/selenium/javascript/webdriver/http/http.js:97:5
at IncomingMessage. (/home/kandinski/code/selenium/javascript/node/selenium-webdriver/http/index.js:131:7)
at IncomingMessage.EventEmitter.emit (events.js:117:20)
at _stream_readable.js:920:16
at process._tickCallback (node.js:415:13)
==== async task ====
WebDriver.executeScript()
at webdriver.WebDriver.schedule (/home/kandinski/code/selenium/javascript/webdriver/webdriver.js:356:15)
at webdriver.WebDriver.executeScript (/home/kandinski/code/selenium/javascript/webdriver/webdriver.js:501:15)
at execute (/home/kandinski/code/selenium/javascript/node/selenium-webdriver/test/execute_script_test.js:309:33)
at Context. (/home/kandinski/code/selenium/javascript/node/selenium-webdriver/test/execute_script_test.js:286:9)
at /home/kandinski/code/selenium/javascript/node/selenium-webdriver/testing/index.js:121:22
at promise.ControlFlow.runInNewFrame_ (/home/kandinski/code/selenium/javascript/webdriver/promise.js:1630:20)
at promise.ControlFlow.runEventLoop_ (/home/kandinski/code/selenium/javascript/webdriver/promise.js:1499:8)
at wrapper [as _onTimeout] (timers.js:252:14)
at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
==== async task ====
at Context.ret (/home/kandinski/code/selenium/javascript/node/selenium-webdriver/testing/index.js:119:12)
at Test.Runnable.run (/home/kandinski/code/selenium/javascript/node/selenium-webdriver/node_modules/mocha/lib/runnable.js:217:15)
at Runner.runTest (/home/kandinski/code/selenium/javascript/node/selenium-webdriver/node_modules/mocha/lib/runner.js:373:10)
at /home/kandinski/code/selenium/javascript/node/selenium-webdriver/node_modules/mocha/lib/runner.js:451:12
at next (/home/kandinski/code/selenium/javascript/node/selenium-webdriver/node_modules/mocha/lib/runner.js:298:14)
at /home/kandinski/code/selenium/javascript/node/selenium-webdriver/node_modules/mocha/lib/runner.js:308:7
at next (/home/kandinski/code/selenium/javascript/node/selenium-webdriver/node_modules/mocha/lib/runner.js:246:23)
at Object._onImmediate (/home/kandinski/code/selenium/javascript/node/selenium-webdriver/node_modules/mocha/lib/runner.js:275:5)
at processImmediate [as _immediateCallback] (timers.js:330:15)

kandinski@desire:~/code/selenium/javascript/node/selenium-webdriver$
```