selenium-webdriver 2.43.5 → 2.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (219) hide show
  1. package/CHANGES.md +20 -0
  2. package/README.md +8 -13
  3. package/builder.js +4 -3
  4. package/docs/class_webdriver_Alert.html +6 -6
  5. package/docs/class_webdriver_AlertPromise.html +6 -6
  6. package/docs/class_webdriver_UnhandledAlertError.html +4 -4
  7. package/docs/class_webdriver_WebDriver.html +39 -37
  8. package/docs/class_webdriver_WebDriver_Logs.html +3 -3
  9. package/docs/class_webdriver_WebDriver_Navigation.html +5 -5
  10. package/docs/class_webdriver_WebDriver_Options.html +9 -9
  11. package/docs/class_webdriver_WebDriver_TargetLocator.html +6 -6
  12. package/docs/class_webdriver_WebDriver_Timeouts.html +4 -4
  13. package/docs/class_webdriver_WebDriver_Window.html +6 -6
  14. package/docs/class_webdriver_WebElement.html +23 -23
  15. package/docs/class_webdriver_WebElementPromise.html +22 -22
  16. package/docs/class_webdriver_promise_CancellationError.html +3 -0
  17. package/docs/class_webdriver_promise_ControlFlow.html +32 -32
  18. package/docs/class_webdriver_promise_Deferred.html +7 -8
  19. package/docs/class_webdriver_promise_Frame_.html +14 -30
  20. package/docs/class_webdriver_promise_Promise.html +2 -2
  21. package/docs/class_webdriver_promise_Task_.html +12 -12
  22. package/docs/class_webdriver_until_Condition.html +3 -0
  23. package/docs/enum_webdriver_Key.html +1 -1
  24. package/docs/enum_webdriver_promise_ControlFlow_EventType.html +1 -1
  25. package/docs/enum_webdriver_promise_Deferred_State_.html +1 -1
  26. package/docs/index.html +8 -13
  27. package/docs/interface_webdriver_promise_Thenable.html +8 -10
  28. package/docs/license.html +1 -1
  29. package/docs/module_selenium-webdriver.html +2 -2
  30. package/docs/module_selenium-webdriver__base.html +1 -1
  31. package/docs/module_selenium-webdriver__base_class_Context.html +1 -1
  32. package/docs/module_selenium-webdriver_builder.html +1 -1
  33. package/docs/module_selenium-webdriver_builder_class_Builder.html +1 -1
  34. package/docs/module_selenium-webdriver_chrome.html +1 -1
  35. package/docs/module_selenium-webdriver_chrome_class_Driver.html +2 -2
  36. package/docs/module_selenium-webdriver_chrome_class_Options.html +2 -2
  37. package/docs/module_selenium-webdriver_chrome_class_ServiceBuilder.html +1 -1
  38. package/docs/module_selenium-webdriver_error.html +1 -1
  39. package/docs/module_selenium-webdriver_executors.html +1 -1
  40. package/docs/module_selenium-webdriver_firefox.html +1 -1
  41. package/docs/module_selenium-webdriver_firefox_binary.html +1 -1
  42. package/docs/module_selenium-webdriver_firefox_binary_class_Binary.html +1 -1
  43. package/docs/module_selenium-webdriver_firefox_class_Driver.html +2 -2
  44. package/docs/module_selenium-webdriver_firefox_class_Options.html +1 -1
  45. package/docs/module_selenium-webdriver_firefox_extension.html +1 -1
  46. package/docs/module_selenium-webdriver_firefox_profile.html +1 -1
  47. package/docs/module_selenium-webdriver_firefox_profile_class_Profile.html +1 -1
  48. package/docs/module_selenium-webdriver_http.html +1 -1
  49. package/docs/module_selenium-webdriver_http_class_HttpClient.html +1 -1
  50. package/docs/module_selenium-webdriver_http_util.html +1 -1
  51. package/docs/module_selenium-webdriver_io.html +1 -1
  52. package/docs/module_selenium-webdriver_io_exec.html +1 -1
  53. package/docs/module_selenium-webdriver_net.html +1 -1
  54. package/docs/module_selenium-webdriver_net_portprober.html +1 -1
  55. package/docs/module_selenium-webdriver_phantomjs.html +1 -1
  56. package/docs/module_selenium-webdriver_phantomjs_class_Driver.html +2 -2
  57. package/docs/module_selenium-webdriver_proxy.html +1 -1
  58. package/docs/module_selenium-webdriver_remote.html +1 -1
  59. package/docs/module_selenium-webdriver_remote_class_DriverService.html +2 -2
  60. package/docs/module_selenium-webdriver_remote_class_SeleniumServer.html +2 -2
  61. package/docs/module_selenium-webdriver_testing.html +16 -29
  62. package/docs/module_selenium-webdriver_testing_assert.html +1 -1
  63. package/docs/namespace_webdriver_promise.html +18 -20
  64. package/docs/namespace_webdriver_stacktrace.html +15 -15
  65. package/docs/namespace_webdriver_until.html +32 -0
  66. package/docs/source/_base.js.src.html +1 -1
  67. package/docs/source/builder.js.src.html +1 -1
  68. package/docs/source/chrome.js.src.html +1 -1
  69. package/docs/source/error.js.src.html +1 -1
  70. package/docs/source/executors.js.src.html +1 -1
  71. package/docs/source/firefox/binary.js.src.html +1 -1
  72. package/docs/source/firefox/extension.js.src.html +1 -1
  73. package/docs/source/firefox/index.js.src.html +1 -1
  74. package/docs/source/firefox/profile.js.src.html +1 -1
  75. package/docs/source/http/index.js.src.html +1 -1
  76. package/docs/source/http/util.js.src.html +1 -1
  77. package/docs/source/index.js.src.html +1 -1
  78. package/docs/source/io/exec.js.src.html +1 -1
  79. package/docs/source/io/index.js.src.html +1 -1
  80. package/docs/source/lib/atoms/error.js.src.html +1 -1
  81. package/docs/source/lib/atoms/json.js.src.html +1 -1
  82. package/docs/source/lib/atoms/response.js.src.html +1 -1
  83. package/docs/source/lib/atoms/userAgent.js.src.html +1 -1
  84. package/docs/source/lib/goog/array/array.js.src.html +1 -1
  85. package/docs/source/lib/goog/asserts/asserts.js.src.html +1 -1
  86. package/docs/source/lib/goog/async/nexttick.js.src.html +1 -1
  87. package/docs/source/lib/goog/async/run.js.src.html +1 -1
  88. package/docs/source/lib/goog/base.js.src.html +1 -1
  89. package/docs/source/lib/goog/debug/debug.js.src.html +1 -1
  90. package/docs/source/lib/goog/debug/entrypointregistry.js.src.html +1 -1
  91. package/docs/source/lib/goog/debug/error.js.src.html +1 -1
  92. package/docs/source/lib/goog/debug/logbuffer.js.src.html +1 -1
  93. package/docs/source/lib/goog/debug/logger.js.src.html +1 -1
  94. package/docs/source/lib/goog/debug/logrecord.js.src.html +1 -1
  95. package/docs/source/lib/goog/deps.js.src.html +1 -1
  96. package/docs/source/lib/goog/disposable/disposable.js.src.html +1 -1
  97. package/docs/source/lib/goog/disposable/idisposable.js.src.html +1 -1
  98. package/docs/source/lib/goog/dom/browserfeature.js.src.html +1 -1
  99. package/docs/source/lib/goog/dom/dom.js.src.html +1 -1
  100. package/docs/source/lib/goog/dom/nodetype.js.src.html +1 -1
  101. package/docs/source/lib/goog/dom/tagname.js.src.html +1 -1
  102. package/docs/source/lib/goog/dom/vendor.js.src.html +1 -1
  103. package/docs/source/lib/goog/events/browserevent.js.src.html +1 -1
  104. package/docs/source/lib/goog/events/browserfeature.js.src.html +1 -1
  105. package/docs/source/lib/goog/events/event.js.src.html +1 -1
  106. package/docs/source/lib/goog/events/eventid.js.src.html +1 -1
  107. package/docs/source/lib/goog/events/events.js.src.html +1 -1
  108. package/docs/source/lib/goog/events/eventtarget.js.src.html +1 -1
  109. package/docs/source/lib/goog/events/eventtype.js.src.html +1 -1
  110. package/docs/source/lib/goog/events/keycodes.js.src.html +1 -1
  111. package/docs/source/lib/goog/events/listenable.js.src.html +1 -1
  112. package/docs/source/lib/goog/events/listener.js.src.html +1 -1
  113. package/docs/source/lib/goog/events/listenermap.js.src.html +1 -1
  114. package/docs/source/lib/goog/functions/functions.js.src.html +1 -1
  115. package/docs/source/lib/goog/iter/iter.js.src.html +1 -1
  116. package/docs/source/lib/goog/json/json.js.src.html +1 -1
  117. package/docs/source/lib/goog/labs/testing/assertthat.js.src.html +1 -1
  118. package/docs/source/lib/goog/labs/testing/logicmatcher.js.src.html +1 -1
  119. package/docs/source/lib/goog/labs/testing/matcher.js.src.html +1 -1
  120. package/docs/source/lib/goog/labs/testing/numbermatcher.js.src.html +1 -1
  121. package/docs/source/lib/goog/labs/testing/objectmatcher.js.src.html +1 -1
  122. package/docs/source/lib/goog/labs/testing/stringmatcher.js.src.html +1 -1
  123. package/docs/source/lib/goog/labs/useragent/browser.js.src.html +1 -1
  124. package/docs/source/lib/goog/labs/useragent/engine.js.src.html +1 -1
  125. package/docs/source/lib/goog/labs/useragent/util.js.src.html +1 -1
  126. package/docs/source/lib/goog/math/box.js.src.html +1 -1
  127. package/docs/source/lib/goog/math/coordinate.js.src.html +1 -1
  128. package/docs/source/lib/goog/math/math.js.src.html +1 -1
  129. package/docs/source/lib/goog/math/rect.js.src.html +1 -1
  130. package/docs/source/lib/goog/math/size.js.src.html +1 -1
  131. package/docs/source/lib/goog/net/wrapperxmlhttpfactory.js.src.html +1 -1
  132. package/docs/source/lib/goog/net/xhrlike.js.src.html +1 -1
  133. package/docs/source/lib/goog/net/xmlhttp.js.src.html +1 -1
  134. package/docs/source/lib/goog/net/xmlhttpfactory.js.src.html +1 -1
  135. package/docs/source/lib/goog/object/object.js.src.html +1 -1
  136. package/docs/source/lib/goog/reflect/reflect.js.src.html +1 -1
  137. package/docs/source/lib/goog/string/string.js.src.html +1 -1
  138. package/docs/source/lib/goog/structs/collection.js.src.html +1 -1
  139. package/docs/source/lib/goog/structs/map.js.src.html +1 -1
  140. package/docs/source/lib/goog/structs/set.js.src.html +1 -1
  141. package/docs/source/lib/goog/structs/structs.js.src.html +1 -1
  142. package/docs/source/lib/goog/style/style.js.src.html +1 -1
  143. package/docs/source/lib/goog/testing/asserts.js.src.html +1 -1
  144. package/docs/source/lib/goog/testing/asynctestcase.js.src.html +1 -1
  145. package/docs/source/lib/goog/testing/events/events.js.src.html +1 -1
  146. package/docs/source/lib/goog/testing/functionmock.js.src.html +1 -1
  147. package/docs/source/lib/goog/testing/jsunit.js.src.html +1 -1
  148. package/docs/source/lib/goog/testing/loosemock.js.src.html +1 -1
  149. package/docs/source/lib/goog/testing/mock.js.src.html +1 -1
  150. package/docs/source/lib/goog/testing/mockclock.js.src.html +1 -1
  151. package/docs/source/lib/goog/testing/mockcontrol.js.src.html +1 -1
  152. package/docs/source/lib/goog/testing/mockinterface.js.src.html +1 -1
  153. package/docs/source/lib/goog/testing/mockmatchers.js.src.html +1 -1
  154. package/docs/source/lib/goog/testing/objectpropertystring.js.src.html +1 -1
  155. package/docs/source/lib/goog/testing/propertyreplacer.js.src.html +1 -1
  156. package/docs/source/lib/goog/testing/recordfunction.js.src.html +1 -1
  157. package/docs/source/lib/goog/testing/stacktrace.js.src.html +1 -1
  158. package/docs/source/lib/goog/testing/strictmock.js.src.html +1 -1
  159. package/docs/source/lib/goog/testing/testcase.js.src.html +1 -1
  160. package/docs/source/lib/goog/testing/testrunner.js.src.html +1 -1
  161. package/docs/source/lib/goog/testing/watchers.js.src.html +1 -1
  162. package/docs/source/lib/goog/uri/uri.js.src.html +1 -1
  163. package/docs/source/lib/goog/uri/utils.js.src.html +1 -1
  164. package/docs/source/lib/goog/useragent/product.js.src.html +1 -1
  165. package/docs/source/lib/goog/useragent/product_isversion.js.src.html +1 -1
  166. package/docs/source/lib/goog/useragent/useragent.js.src.html +1 -1
  167. package/docs/source/lib/webdriver/abstractbuilder.js.src.html +1 -1
  168. package/docs/source/lib/webdriver/actionsequence.js.src.html +1 -1
  169. package/docs/source/lib/webdriver/builder.js.src.html +1 -1
  170. package/docs/source/lib/webdriver/button.js.src.html +1 -1
  171. package/docs/source/lib/webdriver/capabilities.js.src.html +1 -1
  172. package/docs/source/lib/webdriver/command.js.src.html +1 -1
  173. package/docs/source/lib/webdriver/events.js.src.html +1 -1
  174. package/docs/source/lib/webdriver/firefoxdomexecutor.js.src.html +1 -1
  175. package/docs/source/lib/webdriver/http/corsclient.js.src.html +1 -1
  176. package/docs/source/lib/webdriver/http/http.js.src.html +1 -1
  177. package/docs/source/lib/webdriver/http/xhrclient.js.src.html +1 -1
  178. package/docs/source/lib/webdriver/key.js.src.html +1 -1
  179. package/docs/source/lib/webdriver/locators.js.src.html +1 -1
  180. package/docs/source/lib/webdriver/logging.js.src.html +1 -1
  181. package/docs/source/lib/webdriver/process.js.src.html +1 -1
  182. package/docs/source/lib/webdriver/promise.js.src.html +1 -1
  183. package/docs/source/lib/webdriver/session.js.src.html +1 -1
  184. package/docs/source/lib/webdriver/stacktrace.js.src.html +1 -1
  185. package/docs/source/lib/webdriver/testing/asserts.js.src.html +1 -1
  186. package/docs/source/lib/webdriver/testing/testcase.js.src.html +1 -1
  187. package/docs/source/lib/webdriver/until.js.src.html +1 -0
  188. package/docs/source/lib/webdriver/webdriver.js.src.html +1 -1
  189. package/docs/source/net/index.js.src.html +1 -1
  190. package/docs/source/net/portprober.js.src.html +1 -1
  191. package/docs/source/phantomjs.js.src.html +1 -1
  192. package/docs/source/proxy.js.src.html +1 -1
  193. package/docs/source/remote/index.js.src.html +1 -1
  194. package/docs/source/testing/assert.js.src.html +1 -1
  195. package/docs/source/testing/index.js.src.html +1 -1
  196. package/docs/types.js +1 -1
  197. package/example/google_search.js +9 -17
  198. package/example/google_search_generator.js +6 -7
  199. package/example/google_search_test.js +10 -18
  200. package/example/parallel_flows.js +4 -7
  201. package/index.js +6 -0
  202. package/lib/firefox/webdriver.xpi +0 -0
  203. package/lib/goog/deps.js +7 -5
  204. package/lib/test/index.js +0 -8
  205. package/lib/webdriver/promise.js +263 -251
  206. package/lib/webdriver/stacktrace.js +15 -1
  207. package/lib/webdriver/test/promise_flow_test.js +82 -76
  208. package/lib/webdriver/test/promise_test.js +22 -62
  209. package/lib/webdriver/test/stacktrace_test.js +18 -0
  210. package/lib/webdriver/test/until_test.js +388 -0
  211. package/lib/webdriver/test/webdriver_test.js +41 -0
  212. package/lib/webdriver/until.js +408 -0
  213. package/lib/webdriver/webdriver.js +91 -29
  214. package/package.json +2 -2
  215. package/test/element_finding_test.js +6 -6
  216. package/test/http/util_test.js +4 -5
  217. package/test/page_loading_test.js +7 -7
  218. package/test/stale_element_test.js +2 -10
  219. package/testing/index.js +9 -22
@@ -353,7 +353,9 @@ webdriver.stacktrace.V8_LOCATION_PATTERN_ = ' (?:\\((.*)\\)|(.*))';
353
353
  * @private {!RegExp}
354
354
  * @const
355
355
  */
356
- webdriver.stacktrace.V8_STACK_FRAME_REGEXP_ = new RegExp('^ at' +
356
+ webdriver.stacktrace.V8_STACK_FRAME_REGEXP_ = new RegExp('^\\s+at' +
357
+ // Prevent intersections with IE10 stack frame regex.
358
+ '(?! (?:Anonymous function|Global code|eval code) )' +
357
359
  '(?:' + webdriver.stacktrace.V8_FUNCTION_CALL_PATTERN_ + ')?' +
358
360
  webdriver.stacktrace.V8_LOCATION_PATTERN_ + '$');
359
361
 
@@ -591,6 +593,18 @@ webdriver.stacktrace.format = function(error) {
591
593
  var stack = webdriver.stacktrace.getStack_(error);
592
594
  var frames = webdriver.stacktrace.parse_(stack);
593
595
 
596
+ // If the original stack is in an unexpected format, our formatted stack
597
+ // trace will be a bunch of " at <anonymous>" lines. If this is the case,
598
+ // just return the error unmodified to avoid losing information. This is
599
+ // necessary since the user may have defined a custom stack formatter in
600
+ // V8 via Error.prepareStackTrace. See issue 7994.
601
+ var isAnonymousFrame = function(frame) {
602
+ return frame.toString() === ' at <anonymous>';
603
+ };
604
+ if (frames.length && goog.array.every(frames, isAnonymousFrame)) {
605
+ return error;
606
+ }
607
+
594
608
  // Older versions of IE simply return [object Error] for toString(), so
595
609
  // only use that as a last resort.
596
610
  var errorStr = '';
@@ -183,7 +183,7 @@ function testAddChild_withSubframes() {
183
183
  assertArrayEquals([task1, frame1], root.children_);
184
184
  assertArrayEquals([task2, task3], frame1.children_);
185
185
 
186
- frame1.lockFrame();
186
+ frame1.isLocked_ = true;
187
187
  var task4 = createTask('task4'), task5 = createTask('task5');
188
188
  root.addChild(task4);
189
189
  root.addChild(task5);
@@ -199,9 +199,9 @@ function testAddChild_withSubframes() {
199
199
  root.addChild(frame2);
200
200
  root.addChild(frame3);
201
201
  root.addChild(task6);
202
- frame3.lockFrame();
202
+ frame3.isLocked_ = true;
203
203
  root.addChild(task7);
204
- frame2.lockFrame();
204
+ frame2.isLocked_ = true;
205
205
  root.addChild(task8);
206
206
 
207
207
  assertArrayEquals([task1, frame1, task4, task5, frame2, task8],
@@ -218,11 +218,11 @@ function testAddChild_insertingFramesIntoAnActiveFrame() {
218
218
  task1 = createTask('task1');
219
219
 
220
220
  root.addChild(task1);
221
- root.isActive_ = true;
221
+ root.isLocked_ = true;
222
222
  root.addChild(frame2);
223
- frame2.lockFrame();
223
+ frame2.isLocked_ = true;
224
224
  root.addChild(frame3);
225
- frame3.lockFrame();
225
+ frame3.isLocked_ = true;
226
226
 
227
227
  assertArrayEquals([frame2, frame3, task1], root.children_);
228
228
  }
@@ -248,9 +248,9 @@ function testResolveFrame() {
248
248
  assertArrayEquals([frame3], frame2.children_);
249
249
  assertArrayEquals([frame2], frame1.children_);
250
250
 
251
- frame1.fulfill = callbackHelper();
252
- frame2.fulfill = callbackHelper();
253
- frame3.fulfill = callbackHelper();
251
+ frame1.close = callbackHelper();
252
+ frame2.close = callbackHelper();
253
+ frame3.close = callbackHelper();
254
254
 
255
255
  var obj = {
256
256
  activeFrame_: frame2,
@@ -260,9 +260,9 @@ function testResolveFrame() {
260
260
  };
261
261
  webdriver.promise.ControlFlow.prototype.resolveFrame_.call(obj, frame3);
262
262
  assertEquals(1, obj.trimHistory_.getCallCount());
263
- frame3.fulfill.assertCalled('frame 3 not resolved');
264
- frame2.fulfill.assertNotCalled('frame 2 should not be resolved yet');
265
- frame1.fulfill.assertNotCalled('frame 1 should not be resolved yet');
263
+ frame3.close.assertCalled('frame 3 not resolved');
264
+ frame2.close.assertNotCalled('frame 2 should not be resolved yet');
265
+ frame1.close.assertNotCalled('frame 1 should not be resolved yet');
266
266
  assertNull(frame3.getParent());
267
267
  assertArrayEquals([], frame2.children_);
268
268
  assertArrayEquals([frame2], frame1.children_);
@@ -270,8 +270,8 @@ function testResolveFrame() {
270
270
 
271
271
  webdriver.promise.ControlFlow.prototype.resolveFrame_.call(obj, frame2);
272
272
  assertEquals(2, obj.trimHistory_.getCallCount());
273
- frame2.fulfill.assertCalled('frame 2 not resolved');
274
- frame1.fulfill.assertNotCalled('frame 1 should not be resolved yet');
273
+ frame2.close.assertCalled('frame 2 not resolved');
274
+ frame1.close.assertNotCalled('frame 1 should not be resolved yet');
275
275
  assertNull(frame2.getParent());
276
276
  assertArrayEquals([], frame1.children_);
277
277
  assertEquals(frame1, obj.activeFrame_);
@@ -279,7 +279,7 @@ function testResolveFrame() {
279
279
  obj.commenceShutdown_.assertNotCalled();
280
280
  webdriver.promise.ControlFlow.prototype.resolveFrame_.call(obj, frame1);
281
281
  assertEquals(3, obj.trimHistory_.getCallCount());
282
- frame1.fulfill.assertCalled('frame 1 not resolved');
282
+ frame1.close.assertCalled('frame 1 not resolved');
283
283
  obj.commenceShutdown_.assertCalled();
284
284
  assertNull(frame1.getParent());
285
285
  assertNull(obj.activeFrame_);
@@ -302,10 +302,10 @@ function testGetNextTask() {
302
302
  task8 = createTask('task8');
303
303
 
304
304
  flow.commenceShutdown_ = callbackHelper();
305
- root.fulfill = callbackHelper();
306
- frame1.fulfill = callbackHelper();
307
- frame2.fulfill = callbackHelper();
308
- frame3.fulfill = callbackHelper();
305
+ root.close = callbackHelper();
306
+ frame1.close = callbackHelper();
307
+ frame2.close = callbackHelper();
308
+ frame3.close = callbackHelper();
309
309
 
310
310
  root.addChild(task1);
311
311
  root.addChild(frame1);
@@ -314,7 +314,7 @@ function testGetNextTask() {
314
314
  assertArrayEquals([task1, frame1], root.children_);
315
315
  assertArrayEquals([task2, task3], frame1.children_);
316
316
 
317
- frame1.lockFrame();
317
+ frame1.isLocked_ = true;
318
318
  root.addChild(task4);
319
319
  root.addChild(task5);
320
320
  assertArrayEquals([task1, frame1, task4, task5], root.children_);
@@ -324,9 +324,9 @@ function testGetNextTask() {
324
324
  root.addChild(frame2);
325
325
  root.addChild(frame3);
326
326
  root.addChild(task6);
327
- frame3.lockFrame();
327
+ frame3.isLocked_ = true;
328
328
  root.addChild(task7);
329
- frame2.lockFrame();
329
+ frame2.isLocked_ = true;
330
330
  root.addChild(task8);
331
331
 
332
332
  assertArrayEquals([task1, frame1, task4, task5, frame2, task8],
@@ -335,88 +335,79 @@ function testGetNextTask() {
335
335
  assertArrayEquals([frame3, task7], frame2.children_);
336
336
  assertArrayEquals([task6], frame3.children_);
337
337
 
338
- assertEquals(root, task1.getParent());
339
338
  assertEquals(task1, flow.getNextTask_());
340
- assertNull(task1.getParent());
341
339
  assertEquals(root, flow.activeFrame_);
342
- root.fulfill.assertNotCalled();
343
- frame1.fulfill.assertNotCalled();
344
- frame2.fulfill.assertNotCalled();
345
- frame3.fulfill.assertNotCalled();
340
+ root.close.assertNotCalled();
341
+ frame1.close.assertNotCalled();
342
+ frame2.close.assertNotCalled();
343
+ frame3.close.assertNotCalled();
346
344
 
347
345
  assertEquals(task2, flow.getNextTask_());
348
- assertNull(task2.getParent());
349
346
  assertEquals(frame1, flow.activeFrame_);
350
- root.fulfill.assertNotCalled();
351
- frame1.fulfill.assertNotCalled();
352
- frame2.fulfill.assertNotCalled();
353
- frame3.fulfill.assertNotCalled();
347
+ root.close.assertNotCalled();
348
+ frame1.close.assertNotCalled();
349
+ frame2.close.assertNotCalled();
350
+ frame3.close.assertNotCalled();
354
351
 
355
352
  assertEquals(task3, flow.getNextTask_());
356
- assertNull(task3.getParent());
357
353
  assertEquals(frame1, flow.activeFrame_);
358
- root.fulfill.assertNotCalled();
359
- frame1.fulfill.assertNotCalled();
360
- frame2.fulfill.assertNotCalled();
361
- frame3.fulfill.assertNotCalled();
354
+ root.close.assertNotCalled();
355
+ frame1.close.assertNotCalled();
356
+ frame2.close.assertNotCalled();
357
+ frame3.close.assertNotCalled();
362
358
 
363
359
  assertNull(flow.getNextTask_());
364
360
  assertNull(frame1.getParent());
365
361
  assertEquals(root, flow.activeFrame_);
366
- root.fulfill.assertNotCalled();
367
- frame1.fulfill.assertCalled();
368
- frame2.fulfill.assertNotCalled();
369
- frame3.fulfill.assertNotCalled();
362
+ root.close.assertNotCalled();
363
+ frame1.close.assertCalled();
364
+ frame2.close.assertNotCalled();
365
+ frame3.close.assertNotCalled();
370
366
 
371
367
  assertEquals(task4, flow.getNextTask_());
372
- assertNull(task4.getParent());
373
368
  assertEquals(root, flow.activeFrame_);
374
- root.fulfill.assertNotCalled();
375
- frame2.fulfill.assertNotCalled();
376
- frame3.fulfill.assertNotCalled();
369
+ root.close.assertNotCalled();
370
+ frame2.close.assertNotCalled();
371
+ frame3.close.assertNotCalled();
377
372
 
378
373
  assertEquals(task5, flow.getNextTask_());
379
- assertNull(task5.getParent());
380
374
  assertEquals(root, flow.activeFrame_);
381
- root.fulfill.assertNotCalled();
382
- frame2.fulfill.assertNotCalled();
383
- frame3.fulfill.assertNotCalled();
375
+ root.close.assertNotCalled();
376
+ frame2.close.assertNotCalled();
377
+ frame3.close.assertNotCalled();
384
378
 
385
379
  assertEquals(task6, flow.getNextTask_());
386
- assertNull(task6.getParent());
387
380
  assertEquals(frame3, flow.activeFrame_);
388
- root.fulfill.assertNotCalled();
389
- frame2.fulfill.assertNotCalled();
390
- frame3.fulfill.assertNotCalled();
381
+ root.close.assertNotCalled();
382
+ frame2.close.assertNotCalled();
383
+ frame3.close.assertNotCalled();
391
384
 
392
385
  assertNull(flow.getNextTask_());
393
386
  assertNull(frame3.getParent());
394
387
  assertEquals(frame2, flow.activeFrame_);
395
- root.fulfill.assertNotCalled();
396
- frame2.fulfill.assertNotCalled();
397
- frame3.fulfill.assertCalled('frame3 should have been resolved');
388
+ root.close.assertNotCalled();
389
+ frame2.close.assertNotCalled();
390
+ frame3.close.assertCalled('frame3 should have been resolved');
398
391
 
399
392
  assertEquals(task7, flow.getNextTask_());
400
- assertNull(task7.getParent());
401
393
  assertEquals(frame2, flow.activeFrame_);
402
- root.fulfill.assertNotCalled();
403
- frame2.fulfill.assertNotCalled();
394
+ root.close.assertNotCalled();
395
+ frame2.close.assertNotCalled();
404
396
 
405
397
  assertNull(flow.getNextTask_());
406
398
  assertNull(frame2.getParent());
407
399
  assertEquals(root, flow.activeFrame_);
408
- root.fulfill.assertNotCalled();
409
- frame2.fulfill.assertCalled('frame2 should have been resolved');
400
+ root.close.assertNotCalled();
401
+ frame2.close.assertCalled('frame2 should have been resolved');
410
402
 
411
403
  assertEquals(task8, flow.getNextTask_());
412
- assertNull(task8.getParent());
413
404
  assertEquals(root, flow.activeFrame_);
414
- root.fulfill.assertNotCalled();
405
+ root.close.assertNotCalled();
415
406
 
416
407
  flow.commenceShutdown_.assertNotCalled();
417
408
  assertNull(flow.getNextTask_());
418
409
  assertNull(flow.activeFrame_);
419
- root.fulfill.assertCalled('Root should have been resolved');
410
+ root.close.assertCalled('Root should have been resolved');
420
411
  flow.commenceShutdown_.assertCalled();
421
412
  }
422
413
 
@@ -504,14 +495,15 @@ function testAbortFrame_unhandledAbortionsBubbleUp() {
504
495
  assertNull(flow.activeFrame_);
505
496
  flow.abortNow_.assertCalled();
506
497
 
507
- function installResolveHelper(promise) {
508
- var reject = promise.reject;
509
- var pair = callbackPair(promise.fulfill, function(e) {
498
+ function installResolveHelper(frame) {
499
+ var abort = goog.bind(frame.abort, frame);
500
+ var close = goog.bind(frame.close, frame);
501
+ var pair = callbackPair(close, function(e) {
510
502
  assertIsStubError(e);
511
- reject(e);
503
+ abort(e);
512
504
  });
513
- promise.fulfill = pair.callback;
514
- promise.reject = pair.errback;
505
+ frame.close = pair.callback;
506
+ frame.abort = pair.errback;
515
507
  return pair;
516
508
  }
517
509
  }
@@ -667,6 +659,7 @@ function testRunInNewFrame_doesNotReturnUntilScheduledFrameResolved() {
667
659
  pair.assertNeither('active frame still not resolved yet');
668
660
 
669
661
  assertNull(flow.getNextTask_());
662
+ clock.tick();
670
663
  pair.assertCallback();
671
664
  assertEquals(root, flow.activeFrame_);
672
665
  assertEquals(task2, flow.getNextTask_());
@@ -693,9 +686,11 @@ function testRunInNewFrame_doesNotReturnUntilScheduledFrameResolved_nested() {
693
686
  assertEquals('task3', flow.getNextTask_().getDescription());
694
687
  assertEquals('task4', flow.getNextTask_().getDescription());
695
688
  assertNull(flow.getNextTask_());
689
+ clock.tick();
696
690
  pair1.assertNeither();
697
691
  pair2.assertCallback();
698
692
  assertNull(flow.getNextTask_());
693
+ clock.tick();
699
694
  pair1.assertCallback();
700
695
 
701
696
  assertEquals(root, flow.activeFrame_);
@@ -1372,6 +1367,7 @@ function testWaiting_aConditionThatReturnsATaskResult() {
1372
1367
  clock.tick(100); // Advance clock for next polling pass.
1373
1368
  assertEquals(1, count);
1374
1369
  turnEventLoop();
1370
+ clock.tick();
1375
1371
  assertEquals(2, count);
1376
1372
  turnEventLoop();
1377
1373
  assertFlowHistory(
@@ -1381,6 +1377,7 @@ function testWaiting_aConditionThatReturnsATaskResult() {
1381
1377
  clock.tick(100); // Advance clock for next polling pass.
1382
1378
  assertEquals(2, count);
1383
1379
  turnEventLoop();
1380
+ clock.tick();
1384
1381
  assertEquals(3, count);
1385
1382
  turnEventLoop();
1386
1383
  assertFlowHistory(
@@ -1502,7 +1499,7 @@ function testWaiting_pollingLoopWaitsForAllScheduledTasksInCondition() {
1502
1499
  scheduleWait(function() {
1503
1500
  scheduleAction('increment count', function() { ++count; });
1504
1501
  return count >= 3;
1505
- }, 300, 'counting to 3');
1502
+ }, 350, 'counting to 3');
1506
1503
  schedule('post wait');
1507
1504
 
1508
1505
  turnEventLoop();
@@ -1515,6 +1512,7 @@ function testWaiting_pollingLoopWaitsForAllScheduledTasksInCondition() {
1515
1512
  clock.tick(100); // Advance clock for next polling pass.
1516
1513
  assertEquals(1, count);
1517
1514
  turnEventLoop();
1515
+ clock.tick();
1518
1516
  assertEquals(2, count);
1519
1517
 
1520
1518
  clock.tick(100); // Advance clock for next polling pass.
@@ -1799,8 +1797,12 @@ function testEventLoopWaitsOnPendingPromiseRejections_multipleRejections() {
1799
1797
  }
1800
1798
 
1801
1799
  function testCancelsPromiseReturnedByCallbackIfFrameFails_promiseCallback() {
1802
- var chainPair = callbackPair(null, assertIsStubError);
1803
- var deferredPair = callbackPair(null, assertIsStubError);
1800
+ var isCancellationError = function(e) {
1801
+ assertEquals('CancellationError: Error: ouch', e.toString());
1802
+ };
1803
+
1804
+ var chainPair = callbackPair(null, isCancellationError);
1805
+ var deferredPair = callbackPair(null, isCancellationError);
1804
1806
 
1805
1807
  var d = new webdriver.promise.Deferred();
1806
1808
  d.then(deferredPair.callback, deferredPair.errback);
@@ -1820,8 +1822,12 @@ function testCancelsPromiseReturnedByCallbackIfFrameFails_promiseCallback() {
1820
1822
  }
1821
1823
 
1822
1824
  function testCancelsPromiseReturnedByCallbackIfFrameFails_taskCallback() {
1823
- var chainPair = callbackPair(null, assertIsStubError);
1824
- var deferredPair = callbackPair(null, assertIsStubError);
1825
+ var isCancellationError = function(e) {
1826
+ assertEquals('CancellationError: Error: ouch', e.toString());
1827
+ };
1828
+
1829
+ var chainPair = callbackPair(null, isCancellationError);
1830
+ var deferredPair = callbackPair(null, isCancellationError);
1825
1831
 
1826
1832
  var d = new webdriver.promise.Deferred();
1827
1833
  d.then(deferredPair.callback, deferredPair.errback);
@@ -341,7 +341,10 @@ function testWhen_WaitsForValueToBeResolvedBeforeInvokingCallback() {
341
341
 
342
342
 
343
343
  function testWhen_canCancelReturnedPromise() {
344
- var callbacks = callbackPair(null, assertIsStubError);
344
+ var callbacks = callbackPair(null, function(e) {
345
+ assertTrue(e instanceof webdriver.promise.CancellationError);
346
+ assertEquals('just because', e.message);
347
+ });
345
348
 
346
349
  var promiseLike = {
347
350
  then: function(cb, eb) {
@@ -354,7 +357,7 @@ function testWhen_canCancelReturnedPromise() {
354
357
  callbacks.callback, callbacks.errback);
355
358
 
356
359
  assertTrue(promise.isPending());
357
- promise.cancel(STUB_ERROR);
360
+ promise.cancel('just because');
358
361
  callbacks.assertErrback();
359
362
 
360
363
  // The following should have no effect.
@@ -1044,84 +1047,47 @@ function testCheckedNodeCall_functionThrowsAndReturns() {
1044
1047
 
1045
1048
 
1046
1049
  function testCancel_passesTheCancellationReasonToReject() {
1047
- var pair = callbackPair(null, assertIsStubError);
1048
- var d = new webdriver.promise.Deferred();
1049
- d.then(pair.callback, pair.errback);
1050
- d.cancel(STUB_ERROR);
1051
- pair.assertErrback();
1052
- }
1053
-
1054
-
1055
- function testCancel_invokesTheCancellerFunctionIfOneWasProvided() {
1056
- var pair = callbackPair(null, assertIsStubError);
1057
- var callback = callbackHelper();
1058
- var d = new webdriver.promise.Deferred(callback);
1059
- d.then(pair.callback, pair.errback);
1060
- d.cancel(STUB_ERROR);
1061
- pair.assertErrback();
1062
- callback.assertCalled();
1063
- }
1064
-
1065
-
1066
- function testCancel_canChangeRejectionReasonWithTruthyCancellerReturnValue() {
1067
- var pair = callbackPair(null, assertIsStubError);
1068
- var callback = callbackHelper(function() {
1069
- return STUB_ERROR;
1050
+ var pair = callbackPair(null, function(e) {
1051
+ assertTrue(e instanceof webdriver.promise.CancellationError);
1052
+ assertEquals('because i said so', e.message);
1070
1053
  });
1071
- var d = new webdriver.promise.Deferred(callback);
1054
+ var d = new webdriver.promise.Deferred();
1072
1055
  d.then(pair.callback, pair.errback);
1073
- d.cancel();
1056
+ d.cancel('because i said so');
1074
1057
  pair.assertErrback();
1075
- callback.assertCalled();
1076
1058
  }
1077
1059
 
1078
1060
 
1079
1061
  function testCancel_canCancelADeferredFromAChainedPromise() {
1080
- var pair1 = callbackPair(null, assertIsStubError),
1081
- pair2 = callbackPair();
1062
+ var pair1 = callbackPair(null, function(e) {
1063
+ assertTrue(e instanceof webdriver.promise.CancellationError);
1064
+ assertEquals('because i said so', e.message);
1065
+ });
1066
+ var pair2 = callbackPair();
1082
1067
 
1083
1068
  var d = new webdriver.promise.Deferred();
1084
1069
  var p = d.then(pair1.callback, pair1.errback);
1085
1070
  p.then(pair2.callback, pair2.errback);
1086
1071
 
1087
- p.cancel(STUB_ERROR);
1072
+ p.cancel('because i said so');
1088
1073
  pair1.assertErrback('The first errback should have fired.');
1089
1074
  pair2.assertCallback();
1090
1075
  }
1091
1076
 
1092
1077
 
1093
1078
  function testCancel_canCancelATimeout() {
1094
- var pair = callbackPair(null, assertIsStubError);
1079
+ var pair = callbackPair(null, function(e) {
1080
+ assertTrue(e instanceof webdriver.promise.CancellationError);
1081
+ });
1095
1082
  var p = webdriver.promise.delayed(250).
1096
1083
  then(pair.callback, pair.errback);
1097
- p.cancel(STUB_ERROR);
1084
+ p.cancel();
1098
1085
  pair.assertErrback();
1099
1086
  clock.tick(250); // Just to make sure nothing happens.
1100
1087
  pair.assertErrback();
1101
1088
  }
1102
1089
 
1103
1090
 
1104
- function testCancel_cannotCancelACheckedNodeCall() {
1105
- var d = webdriver.promise.checkedNodeCall(goog.nullFunction);
1106
- assertThrows(d.cancel);
1107
- }
1108
-
1109
-
1110
- function testCancel_cancellerFunctionExplicityResolvesPromise() {
1111
- var pair = callbackPair(goog.partial(assertEquals, 123));
1112
- var canceller;
1113
- var d = new webdriver.promise.Deferred(
1114
- canceller = callbackHelper(function(e) {
1115
- assertIsStubError(e);
1116
- d.fulfill(123);
1117
- }));
1118
- d.then(pair.callback, pair.errback);
1119
- d.cancel(STUB_ERROR);
1120
- canceller.assertCalled();
1121
- pair.assertCallback();
1122
- }
1123
-
1124
-
1125
1091
  function testCancel_cancelIsANoopOnceAPromiseHasBeenFulfilled() {
1126
1092
  var p = webdriver.promise.fulfilled(123);
1127
1093
  p.cancel();
@@ -1151,12 +1117,6 @@ function testCancel_noopCancelTriggeredOnCallbackOfResolvedPromise() {
1151
1117
  }
1152
1118
 
1153
1119
 
1154
- function testCancel_cancellerCanForbidCancellation() {
1155
- var d = new webdriver.promise.Deferred(throwStubError);
1156
- assertThrows(d.cancel);
1157
- }
1158
-
1159
-
1160
1120
  function testCallbackRegistersAnotherListener_callbacksConfiguredPreResolve() {
1161
1121
  var messages = [];
1162
1122
  var d = new webdriver.promise.Deferred();
@@ -1239,11 +1199,11 @@ function testResolvedReturnsInputValueIfItIsAPromise() {
1239
1199
 
1240
1200
  function testADeferredsParentControlFlowIsActiveForCallbacks() {
1241
1201
  var flow = new webdriver.promise.ControlFlow();
1242
- var d = new webdriver.promise.Deferred(null, flow);
1202
+ var d = new webdriver.promise.Deferred(flow);
1243
1203
  d.fulfill();
1244
1204
 
1245
1205
  var flow2 = new webdriver.promise.ControlFlow();
1246
- var d2 = new webdriver.promise.Deferred(null, flow2);
1206
+ var d2 = new webdriver.promise.Deferred(flow2);
1247
1207
  d2.fulfill();
1248
1208
 
1249
1209
  assertIsFlow(webdriver.promise.defaultFlow_)();
@@ -165,6 +165,11 @@ function testParseStackFrameInV8() {
165
165
  ' at Object.assert (http://bar:4000/bar.js?value=(a):150:3)',
166
166
  new webdriver.stacktrace.Frame('Object', 'assert', '',
167
167
  'http://bar:4000/bar.js?value=(a):150:3'));
168
+
169
+ assertStackFrame('Frame with non-standard leading whitespace (issue 7994)',
170
+ ' at module.exports.runCucumber (/local/dir/path)',
171
+ new webdriver.stacktrace.Frame('module.exports', 'runCucumber', '',
172
+ '/local/dir/path'));
168
173
  }
169
174
 
170
175
  function testParseStackFrameInOpera() {
@@ -468,6 +473,19 @@ function testFormatsUsingNameAndMessageIfAvailable() {
468
473
  assertEquals('TypeError: boom\n', ret.stack);
469
474
  }
470
475
 
476
+ function testDoesNotFormatErrorIfOriginalStacktraceIsInAnUnexpectedFormat() {
477
+ var error = Error('testing');
478
+ var stack = error.stack = [
479
+ 'Error: testing',
480
+ '..> at Color.red (http://x:1234)',
481
+ '..> at Foo.bar (http://y:5678)'
482
+ ].join('\n');
483
+
484
+ var ret = webdriver.stacktrace.format(error);
485
+ assertEquals(ret, error);
486
+ assertEquals(stack, error.stack);
487
+ }
488
+
471
489
  function testParseStackFrameInIE10() {
472
490
  assertStackFrame('name and path',
473
491
  ' at foo (http://bar:4000/bar.js:150:3)',