selenium-webdriver 2.48.2 → 2.52.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.
- package/CHANGES.md +57 -0
- package/NOTICE +1 -1
- package/README.md +56 -6
- package/builder.js +375 -358
- package/chrome.js +549 -586
- package/edge.js +378 -0
- package/error.js +597 -5
- package/example/google_search_generator.js +2 -4
- package/example/logging.js +6 -2
- package/executors.js +11 -27
- package/firefox/binary.js +79 -87
- package/firefox/extension.js +10 -18
- package/firefox/index.js +173 -173
- package/firefox/profile.js +220 -240
- package/http/index.js +396 -79
- package/http/util.js +35 -35
- package/ie.js +288 -309
- package/index.js +34 -125
- package/io/exec.js +58 -39
- package/io/index.js +54 -48
- package/lib/actions.js +594 -0
- package/lib/by.js +276 -0
- package/lib/capabilities.js +404 -0
- package/lib/{webdriver/command.js → command.js} +88 -72
- package/lib/{webdriver/button.js → devmode.js} +13 -8
- package/lib/events.js +210 -0
- package/lib/firefox/amd64/libnoblur64.so +0 -0
- package/lib/firefox/i386/libnoblur.so +0 -0
- package/lib/firefox/webdriver.json +5 -1
- package/lib/firefox/webdriver.xpi +0 -0
- package/lib/{webdriver/key.js → input.js} +82 -2
- package/lib/logging.js +668 -0
- package/lib/{webdriver/promise.js → promise.js} +688 -644
- package/lib/session.js +79 -0
- package/lib/{webdriver/serializable.js → symbols.js} +11 -16
- package/lib/test/build.js +4 -4
- package/lib/test/data/click_tests/html5_submit_buttons.html +2 -1
- package/lib/test/data/click_tests/overlapping_elements.html +15 -4
- package/lib/test/data/click_tests/partially_overlapping_elements.html +124 -0
- package/lib/test/data/click_tests/wrapped_overlapping_elements.html +13 -0
- package/lib/test/data/readOnlyPage.html +1 -1
- package/lib/test/data/selectPage.html +18 -2
- package/lib/test/fileserver.js +3 -4
- package/lib/test/index.js +7 -3
- package/lib/test/resources.js +1 -1
- package/lib/until.js +428 -0
- package/lib/webdriver.js +2351 -0
- package/net/portprober.js +15 -11
- package/opera.js +295 -314
- package/package.json +6 -5
- package/phantomjs.js +135 -140
- package/proxy.js +6 -4
- package/remote/index.js +229 -221
- package/safari.js +319 -310
- package/test/chrome/options_test.js +11 -9
- package/test/element_finding_test.js +51 -13
- package/test/error_test.js +163 -0
- package/test/execute_script_test.js +1 -1
- package/test/http/http_test.js +317 -55
- package/test/http/util_test.js +25 -23
- package/test/io_test.js +6 -1
- package/test/lib/by_test.js +127 -0
- package/test/lib/capabilities_test.js +84 -0
- package/test/lib/events_test.js +177 -0
- package/test/lib/logging_test.js +272 -0
- package/test/{promise_aplus_test.js → lib/promise_aplus_test.js} +4 -13
- package/test/lib/promise_error_test.js +808 -0
- package/test/lib/promise_flow_test.js +2282 -0
- package/test/lib/promise_generator_test.js +308 -0
- package/test/lib/promise_test.js +996 -0
- package/test/lib/testutil.js +90 -0
- package/test/lib/until_test.js +436 -0
- package/test/lib/webdriver_test.js +2207 -0
- package/test/page_loading_test.js +7 -9
- package/test/stale_element_test.js +2 -2
- package/test/testing/assert_test.js +374 -0
- package/test/testing/index_test.js +9 -11
- package/testing/assert.js +334 -17
- package/testing/index.js +10 -0
- package/_base.js +0 -200
- package/docs/Changes.html +0 -356
- package/docs/class_bot_Error.html +0 -15
- package/docs/class_webdriver_ActionSequence.html +0 -115
- package/docs/class_webdriver_Alert.html +0 -24
- package/docs/class_webdriver_AlertPromise.html +0 -92
- package/docs/class_webdriver_Capabilities.html +0 -60
- package/docs/class_webdriver_Command.html +0 -15
- package/docs/class_webdriver_EventEmitter.html +0 -35
- package/docs/class_webdriver_FileDetector.html +0 -21
- package/docs/class_webdriver_Locator.html +0 -12
- package/docs/class_webdriver_Serializable.html +0 -9
- package/docs/class_webdriver_Session.html +0 -13
- package/docs/class_webdriver_TouchSequence.html +0 -49
- package/docs/class_webdriver_UnhandledAlertError.html +0 -18
- package/docs/class_webdriver_WebDriver.html +0 -313
- package/docs/class_webdriver_WebDriver_Logs.html +0 -15
- package/docs/class_webdriver_WebDriver_Navigation.html +0 -16
- package/docs/class_webdriver_WebDriver_Options.html +0 -41
- package/docs/class_webdriver_WebDriver_TargetLocator.html +0 -38
- package/docs/class_webdriver_WebDriver_Timeouts.html +0 -29
- package/docs/class_webdriver_WebDriver_Window.html +0 -27
- package/docs/class_webdriver_WebElement.html +0 -223
- package/docs/class_webdriver_WebElementPromise.html +0 -274
- package/docs/class_webdriver_http_Executor.html +0 -22
- package/docs/class_webdriver_http_Request.html +0 -12
- package/docs/class_webdriver_http_Response.html +0 -13
- package/docs/class_webdriver_logging_Entry.html +0 -15
- package/docs/class_webdriver_logging_Level.html +0 -55
- package/docs/class_webdriver_logging_LogRecord.html +0 -45
- package/docs/class_webdriver_logging_Logger.html +0 -119
- package/docs/class_webdriver_logging_Preferences.html +0 -8
- package/docs/class_webdriver_promise_CancellationError.html +0 -17
- package/docs/class_webdriver_promise_ControlFlow.html +0 -153
- package/docs/class_webdriver_promise_Deferred.html +0 -84
- package/docs/class_webdriver_promise_MultipleUnhandledRejectionError.html +0 -14
- package/docs/class_webdriver_promise_Promise.html +0 -75
- package/docs/class_webdriver_stacktrace_Frame.html +0 -20
- package/docs/class_webdriver_stacktrace_Snapshot.html +0 -6
- package/docs/class_webdriver_testing_Assertion.html +0 -99
- package/docs/class_webdriver_testing_Assertion_DelegatingMatcher_.html +0 -13
- package/docs/class_webdriver_testing_ContainsMatcher.html +0 -11
- package/docs/class_webdriver_testing_NegatedAssertion.html +0 -97
- package/docs/class_webdriver_until_Condition.html +0 -7
- package/docs/dossier.css +0 -1
- package/docs/dossier.js +0 -86
- package/docs/enum_bot_ErrorCode.html +0 -3
- package/docs/enum_bot_Error_State.html +0 -2
- package/docs/enum_webdriver_Browser.html +0 -2
- package/docs/enum_webdriver_Button.html +0 -2
- package/docs/enum_webdriver_Capability.html +0 -33
- package/docs/enum_webdriver_CommandName.html +0 -3
- package/docs/enum_webdriver_Key.html +0 -12
- package/docs/enum_webdriver_logging_Type.html +0 -6
- package/docs/enum_webdriver_promise_ControlFlow_EventType.html +0 -9
- package/docs/index.html +0 -125
- package/docs/interface_webdriver_CommandExecutor.html +0 -9
- package/docs/interface_webdriver_http_Client.html +0 -10
- package/docs/interface_webdriver_promise_Thenable.html +0 -77
- package/docs/module_selenium-webdriver.html +0 -23
- package/docs/module_selenium-webdriver__base.html +0 -23
- package/docs/module_selenium-webdriver__base_class_Context.html +0 -5
- package/docs/module_selenium-webdriver_builder.html +0 -2
- package/docs/module_selenium-webdriver_builder_class_Builder.html +0 -138
- package/docs/module_selenium-webdriver_chrome.html +0 -90
- package/docs/module_selenium-webdriver_chrome_class_Driver.html +0 -280
- package/docs/module_selenium-webdriver_chrome_class_Options.html +0 -127
- package/docs/module_selenium-webdriver_chrome_class_ServiceBuilder.html +0 -46
- package/docs/module_selenium-webdriver_class_ActionSequence.html +0 -115
- package/docs/module_selenium-webdriver_class_Builder.html +0 -138
- package/docs/module_selenium-webdriver_class_Capabilities.html +0 -60
- package/docs/module_selenium-webdriver_class_Command.html +0 -15
- package/docs/module_selenium-webdriver_class_EventEmitter.html +0 -35
- package/docs/module_selenium-webdriver_class_FileDetector.html +0 -21
- package/docs/module_selenium-webdriver_class_Serializable.html +0 -9
- package/docs/module_selenium-webdriver_class_Session.html +0 -13
- package/docs/module_selenium-webdriver_class_WebDriver.html +0 -313
- package/docs/module_selenium-webdriver_class_WebElement.html +0 -223
- package/docs/module_selenium-webdriver_class_WebElementPromise.html +0 -274
- package/docs/module_selenium-webdriver_enum_Browser.html +0 -2
- package/docs/module_selenium-webdriver_enum_Button.html +0 -2
- package/docs/module_selenium-webdriver_enum_Capability.html +0 -33
- package/docs/module_selenium-webdriver_enum_CommandName.html +0 -3
- package/docs/module_selenium-webdriver_enum_Key.html +0 -12
- package/docs/module_selenium-webdriver_error.html +0 -4
- package/docs/module_selenium-webdriver_error_class_Error.html +0 -15
- package/docs/module_selenium-webdriver_error_enum_ErrorCode.html +0 -3
- package/docs/module_selenium-webdriver_executors.html +0 -10
- package/docs/module_selenium-webdriver_executors_class_DeferredExecutor.html +0 -12
- package/docs/module_selenium-webdriver_firefox.html +0 -68
- package/docs/module_selenium-webdriver_firefox_binary.html +0 -5
- package/docs/module_selenium-webdriver_firefox_binary_class_Binary.html +0 -20
- package/docs/module_selenium-webdriver_firefox_class_Binary.html +0 -20
- package/docs/module_selenium-webdriver_firefox_class_Driver.html +0 -276
- package/docs/module_selenium-webdriver_firefox_class_Options.html +0 -19
- package/docs/module_selenium-webdriver_firefox_class_Profile.html +0 -50
- package/docs/module_selenium-webdriver_firefox_extension.html +0 -8
- package/docs/module_selenium-webdriver_firefox_profile.html +0 -13
- package/docs/module_selenium-webdriver_firefox_profile_class_Profile.html +0 -50
- package/docs/module_selenium-webdriver_http.html +0 -9
- package/docs/module_selenium-webdriver_http_class_Executor.html +0 -22
- package/docs/module_selenium-webdriver_http_class_HttpClient.html +0 -16
- package/docs/module_selenium-webdriver_http_class_Request.html +0 -12
- package/docs/module_selenium-webdriver_http_class_Response.html +0 -13
- package/docs/module_selenium-webdriver_http_util.html +0 -17
- package/docs/module_selenium-webdriver_ie.html +0 -11
- package/docs/module_selenium-webdriver_ie_class_Driver.html +0 -274
- package/docs/module_selenium-webdriver_ie_class_Options.html +0 -89
- package/docs/module_selenium-webdriver_ie_enum_Level.html +0 -1
- package/docs/module_selenium-webdriver_io.html +0 -37
- package/docs/module_selenium-webdriver_io_exec.html +0 -6
- package/docs/module_selenium-webdriver_namespace_By.html +0 -56
- package/docs/module_selenium-webdriver_namespace_error.html +0 -4
- package/docs/module_selenium-webdriver_namespace_logging.html +0 -18
- package/docs/module_selenium-webdriver_namespace_promise.html +0 -163
- package/docs/module_selenium-webdriver_namespace_stacktrace.html +0 -17
- package/docs/module_selenium-webdriver_namespace_until.html +0 -82
- package/docs/module_selenium-webdriver_net.html +0 -7
- package/docs/module_selenium-webdriver_net_portprober.html +0 -12
- package/docs/module_selenium-webdriver_opera.html +0 -62
- package/docs/module_selenium-webdriver_opera_class_Driver.html +0 -276
- package/docs/module_selenium-webdriver_opera_class_Options.html +0 -44
- package/docs/module_selenium-webdriver_opera_class_ServiceBuilder.html +0 -35
- package/docs/module_selenium-webdriver_phantomjs.html +0 -2
- package/docs/module_selenium-webdriver_phantomjs_class_Driver.html +0 -299
- package/docs/module_selenium-webdriver_proxy.html +0 -28
- package/docs/module_selenium-webdriver_remote.html +0 -8
- package/docs/module_selenium-webdriver_remote_class_DriverService.html +0 -32
- package/docs/module_selenium-webdriver_remote_class_FileDetector.html +0 -22
- package/docs/module_selenium-webdriver_remote_class_SeleniumServer.html +0 -41
- package/docs/module_selenium-webdriver_safari.html +0 -9
- package/docs/module_selenium-webdriver_safari_class_Driver.html +0 -279
- package/docs/module_selenium-webdriver_safari_class_Options.html +0 -23
- package/docs/module_selenium-webdriver_testing.html +0 -74
- package/docs/module_selenium-webdriver_testing_assert.html +0 -9
- package/docs/namespace_bot.html +0 -4
- package/docs/namespace_bot_json.html +0 -20
- package/docs/namespace_bot_response.html +0 -18
- package/docs/namespace_bot_userAgent.html +0 -33
- package/docs/namespace_webdriver.html +0 -30
- package/docs/namespace_webdriver_By.html +0 -56
- package/docs/namespace_webdriver_http.html +0 -6
- package/docs/namespace_webdriver_logging.html +0 -70
- package/docs/namespace_webdriver_promise.html +0 -688
- package/docs/namespace_webdriver_stacktrace.html +0 -17
- package/docs/namespace_webdriver_testing.html +0 -7
- package/docs/namespace_webdriver_testing_assert.html +0 -9
- package/docs/namespace_webdriver_testing_asserts.html +0 -18
- package/docs/namespace_webdriver_until.html +0 -82
- package/docs/source/_base.js.src.html +0 -1
- package/docs/source/builder.js.src.html +0 -1
- package/docs/source/chrome.js.src.html +0 -1
- package/docs/source/error.js.src.html +0 -1
- package/docs/source/executors.js.src.html +0 -1
- package/docs/source/firefox/binary.js.src.html +0 -1
- package/docs/source/firefox/extension.js.src.html +0 -1
- package/docs/source/firefox/index.js.src.html +0 -1
- package/docs/source/firefox/profile.js.src.html +0 -1
- package/docs/source/http/index.js.src.html +0 -1
- package/docs/source/http/util.js.src.html +0 -1
- package/docs/source/ie.js.src.html +0 -1
- package/docs/source/index.js.src.html +0 -1
- package/docs/source/io/exec.js.src.html +0 -1
- package/docs/source/io/index.js.src.html +0 -1
- package/docs/source/lib/atoms/error.js.src.html +0 -1
- package/docs/source/lib/atoms/json.js.src.html +0 -1
- package/docs/source/lib/atoms/response.js.src.html +0 -1
- package/docs/source/lib/atoms/userAgent.js.src.html +0 -1
- package/docs/source/lib/goog/array/array.js.src.html +0 -1
- package/docs/source/lib/goog/asserts/asserts.js.src.html +0 -1
- package/docs/source/lib/goog/async/freelist.js.src.html +0 -1
- package/docs/source/lib/goog/async/nexttick.js.src.html +0 -1
- package/docs/source/lib/goog/async/run.js.src.html +0 -1
- package/docs/source/lib/goog/async/workqueue.js.src.html +0 -1
- package/docs/source/lib/goog/base.js.src.html +0 -1
- package/docs/source/lib/goog/debug/debug.js.src.html +0 -1
- package/docs/source/lib/goog/debug/entrypointregistry.js.src.html +0 -1
- package/docs/source/lib/goog/debug/error.js.src.html +0 -1
- package/docs/source/lib/goog/debug/logbuffer.js.src.html +0 -1
- package/docs/source/lib/goog/debug/logger.js.src.html +0 -1
- package/docs/source/lib/goog/debug/logrecord.js.src.html +0 -1
- package/docs/source/lib/goog/deps.js.src.html +0 -1
- package/docs/source/lib/goog/disposable/disposable.js.src.html +0 -1
- package/docs/source/lib/goog/disposable/idisposable.js.src.html +0 -1
- package/docs/source/lib/goog/dom/browserfeature.js.src.html +0 -1
- package/docs/source/lib/goog/dom/dom.js.src.html +0 -1
- package/docs/source/lib/goog/dom/nodetype.js.src.html +0 -1
- package/docs/source/lib/goog/dom/safe.js.src.html +0 -1
- package/docs/source/lib/goog/dom/tagname.js.src.html +0 -1
- package/docs/source/lib/goog/dom/tags.js.src.html +0 -1
- package/docs/source/lib/goog/dom/vendor.js.src.html +0 -1
- package/docs/source/lib/goog/events/browserevent.js.src.html +0 -1
- package/docs/source/lib/goog/events/browserfeature.js.src.html +0 -1
- package/docs/source/lib/goog/events/event.js.src.html +0 -1
- package/docs/source/lib/goog/events/eventid.js.src.html +0 -1
- package/docs/source/lib/goog/events/events.js.src.html +0 -1
- package/docs/source/lib/goog/events/eventtarget.js.src.html +0 -1
- package/docs/source/lib/goog/events/eventtype.js.src.html +0 -1
- package/docs/source/lib/goog/events/keycodes.js.src.html +0 -1
- package/docs/source/lib/goog/events/listenable.js.src.html +0 -1
- package/docs/source/lib/goog/events/listener.js.src.html +0 -1
- package/docs/source/lib/goog/events/listenermap.js.src.html +0 -1
- package/docs/source/lib/goog/fs/url.js.src.html +0 -1
- package/docs/source/lib/goog/functions/functions.js.src.html +0 -1
- package/docs/source/lib/goog/html/safehtml.js.src.html +0 -1
- package/docs/source/lib/goog/html/safescript.js.src.html +0 -1
- package/docs/source/lib/goog/html/safestyle.js.src.html +0 -1
- package/docs/source/lib/goog/html/safestylesheet.js.src.html +0 -1
- package/docs/source/lib/goog/html/safeurl.js.src.html +0 -1
- package/docs/source/lib/goog/html/trustedresourceurl.js.src.html +0 -1
- package/docs/source/lib/goog/html/uncheckedconversions.js.src.html +0 -1
- package/docs/source/lib/goog/i18n/bidi.js.src.html +0 -1
- package/docs/source/lib/goog/iter/iter.js.src.html +0 -1
- package/docs/source/lib/goog/json/json.js.src.html +0 -1
- package/docs/source/lib/goog/labs/testing/assertthat.js.src.html +0 -1
- package/docs/source/lib/goog/labs/testing/logicmatcher.js.src.html +0 -1
- package/docs/source/lib/goog/labs/testing/matcher.js.src.html +0 -1
- package/docs/source/lib/goog/labs/testing/numbermatcher.js.src.html +0 -1
- package/docs/source/lib/goog/labs/testing/objectmatcher.js.src.html +0 -1
- package/docs/source/lib/goog/labs/testing/stringmatcher.js.src.html +0 -1
- package/docs/source/lib/goog/labs/useragent/browser.js.src.html +0 -1
- package/docs/source/lib/goog/labs/useragent/engine.js.src.html +0 -1
- package/docs/source/lib/goog/labs/useragent/platform.js.src.html +0 -1
- package/docs/source/lib/goog/labs/useragent/util.js.src.html +0 -1
- package/docs/source/lib/goog/log/log.js.src.html +0 -1
- package/docs/source/lib/goog/math/box.js.src.html +0 -1
- package/docs/source/lib/goog/math/coordinate.js.src.html +0 -1
- package/docs/source/lib/goog/math/math.js.src.html +0 -1
- package/docs/source/lib/goog/math/rect.js.src.html +0 -1
- package/docs/source/lib/goog/math/size.js.src.html +0 -1
- package/docs/source/lib/goog/net/wrapperxmlhttpfactory.js.src.html +0 -1
- package/docs/source/lib/goog/net/xhrlike.js.src.html +0 -1
- package/docs/source/lib/goog/net/xmlhttp.js.src.html +0 -1
- package/docs/source/lib/goog/net/xmlhttpfactory.js.src.html +0 -1
- package/docs/source/lib/goog/object/object.js.src.html +0 -1
- package/docs/source/lib/goog/promise/promise.js.src.html +0 -1
- package/docs/source/lib/goog/promise/resolver.js.src.html +0 -1
- package/docs/source/lib/goog/promise/thenable.js.src.html +0 -1
- package/docs/source/lib/goog/reflect/reflect.js.src.html +0 -1
- package/docs/source/lib/goog/string/const.js.src.html +0 -1
- package/docs/source/lib/goog/string/string.js.src.html +0 -1
- package/docs/source/lib/goog/string/typedstring.js.src.html +0 -1
- package/docs/source/lib/goog/structs/collection.js.src.html +0 -1
- package/docs/source/lib/goog/structs/map.js.src.html +0 -1
- package/docs/source/lib/goog/structs/set.js.src.html +0 -1
- package/docs/source/lib/goog/structs/structs.js.src.html +0 -1
- package/docs/source/lib/goog/style/style.js.src.html +0 -1
- package/docs/source/lib/goog/testing/asserts.js.src.html +0 -1
- package/docs/source/lib/goog/testing/events/events.js.src.html +0 -1
- package/docs/source/lib/goog/testing/functionmock.js.src.html +0 -1
- package/docs/source/lib/goog/testing/jsunit.js.src.html +0 -1
- package/docs/source/lib/goog/testing/loosemock.js.src.html +0 -1
- package/docs/source/lib/goog/testing/mock.js.src.html +0 -1
- package/docs/source/lib/goog/testing/mockclock.js.src.html +0 -1
- package/docs/source/lib/goog/testing/mockcontrol.js.src.html +0 -1
- package/docs/source/lib/goog/testing/mockinterface.js.src.html +0 -1
- package/docs/source/lib/goog/testing/mockmatchers.js.src.html +0 -1
- package/docs/source/lib/goog/testing/objectpropertystring.js.src.html +0 -1
- package/docs/source/lib/goog/testing/propertyreplacer.js.src.html +0 -1
- package/docs/source/lib/goog/testing/recordfunction.js.src.html +0 -1
- package/docs/source/lib/goog/testing/stacktrace.js.src.html +0 -1
- package/docs/source/lib/goog/testing/strictmock.js.src.html +0 -1
- package/docs/source/lib/goog/testing/testcase.js.src.html +0 -1
- package/docs/source/lib/goog/testing/testrunner.js.src.html +0 -1
- package/docs/source/lib/goog/uri/uri.js.src.html +0 -1
- package/docs/source/lib/goog/uri/utils.js.src.html +0 -1
- package/docs/source/lib/goog/useragent/product.js.src.html +0 -1
- package/docs/source/lib/goog/useragent/product_isversion.js.src.html +0 -1
- package/docs/source/lib/goog/useragent/useragent.js.src.html +0 -1
- package/docs/source/lib/webdriver/actionsequence.js.src.html +0 -1
- package/docs/source/lib/webdriver/button.js.src.html +0 -1
- package/docs/source/lib/webdriver/capabilities.js.src.html +0 -1
- package/docs/source/lib/webdriver/command.js.src.html +0 -1
- package/docs/source/lib/webdriver/events.js.src.html +0 -1
- package/docs/source/lib/webdriver/http/http.js.src.html +0 -1
- package/docs/source/lib/webdriver/key.js.src.html +0 -1
- package/docs/source/lib/webdriver/locators.js.src.html +0 -1
- package/docs/source/lib/webdriver/logging.js.src.html +0 -1
- package/docs/source/lib/webdriver/promise.js.src.html +0 -1
- package/docs/source/lib/webdriver/serializable.js.src.html +0 -1
- package/docs/source/lib/webdriver/session.js.src.html +0 -1
- package/docs/source/lib/webdriver/stacktrace.js.src.html +0 -1
- package/docs/source/lib/webdriver/testing/asserts.js.src.html +0 -1
- package/docs/source/lib/webdriver/touchsequence.js.src.html +0 -1
- package/docs/source/lib/webdriver/until.js.src.html +0 -1
- package/docs/source/lib/webdriver/webdriver.js.src.html +0 -1
- package/docs/source/net/index.js.src.html +0 -1
- package/docs/source/net/portprober.js.src.html +0 -1
- package/docs/source/opera.js.src.html +0 -1
- package/docs/source/phantomjs.js.src.html +0 -1
- package/docs/source/proxy.js.src.html +0 -1
- package/docs/source/remote/index.js.src.html +0 -1
- package/docs/source/safari.js.src.html +0 -1
- package/docs/source/testing/assert.js.src.html +0 -1
- package/docs/source/testing/index.js.src.html +0 -1
- package/docs/types.js +0 -1
- package/lib/atoms/error.js +0 -202
- package/lib/atoms/json.js +0 -80
- package/lib/atoms/response.js +0 -110
- package/lib/atoms/userAgent.js +0 -257
- package/lib/goog/LICENSE +0 -176
- package/lib/goog/array/array.js +0 -1654
- package/lib/goog/asserts/asserts.js +0 -365
- package/lib/goog/async/freelist.js +0 -88
- package/lib/goog/async/nexttick.js +0 -241
- package/lib/goog/async/run.js +0 -133
- package/lib/goog/async/workqueue.js +0 -139
- package/lib/goog/base.js +0 -2548
- package/lib/goog/debug/debug.js +0 -653
- package/lib/goog/debug/entrypointregistry.js +0 -158
- package/lib/goog/debug/error.js +0 -63
- package/lib/goog/debug/logbuffer.js +0 -148
- package/lib/goog/debug/logger.js +0 -873
- package/lib/goog/debug/logrecord.js +0 -242
- package/lib/goog/deps.js +0 -151
- package/lib/goog/disposable/disposable.js +0 -307
- package/lib/goog/disposable/idisposable.js +0 -45
- package/lib/goog/dom/browserfeature.js +0 -72
- package/lib/goog/dom/dom.js +0 -2991
- package/lib/goog/dom/nodetype.js +0 -48
- package/lib/goog/dom/safe.js +0 -347
- package/lib/goog/dom/tagname.js +0 -160
- package/lib/goog/dom/tags.js +0 -41
- package/lib/goog/dom/vendor.js +0 -96
- package/lib/goog/events/browserevent.js +0 -400
- package/lib/goog/events/browserfeature.js +0 -85
- package/lib/goog/events/event.js +0 -143
- package/lib/goog/events/eventid.js +0 -47
- package/lib/goog/events/events.js +0 -984
- package/lib/goog/events/eventtarget.js +0 -394
- package/lib/goog/events/eventtype.js +0 -237
- package/lib/goog/events/keycodes.js +0 -427
- package/lib/goog/events/listenable.js +0 -335
- package/lib/goog/events/listener.js +0 -131
- package/lib/goog/events/listenermap.js +0 -308
- package/lib/goog/fs/url.js +0 -109
- package/lib/goog/functions/functions.js +0 -442
- package/lib/goog/html/safehtml.js +0 -757
- package/lib/goog/html/safescript.js +0 -234
- package/lib/goog/html/safestyle.js +0 -442
- package/lib/goog/html/safestylesheet.js +0 -276
- package/lib/goog/html/safeurl.js +0 -398
- package/lib/goog/html/trustedresourceurl.js +0 -224
- package/lib/goog/html/uncheckedconversions.js +0 -232
- package/lib/goog/i18n/bidi.js +0 -908
- package/lib/goog/iter/iter.js +0 -1302
- package/lib/goog/json/json.js +0 -363
- package/lib/goog/labs/testing/assertthat.js +0 -58
- package/lib/goog/labs/testing/logicmatcher.js +0 -212
- package/lib/goog/labs/testing/matcher.js +0 -80
- package/lib/goog/labs/testing/numbermatcher.js +0 -346
- package/lib/goog/labs/testing/objectmatcher.js +0 -317
- package/lib/goog/labs/testing/stringmatcher.js +0 -415
- package/lib/goog/labs/useragent/browser.js +0 -341
- package/lib/goog/labs/useragent/engine.js +0 -160
- package/lib/goog/labs/useragent/platform.js +0 -160
- package/lib/goog/labs/useragent/util.js +0 -148
- package/lib/goog/log/log.js +0 -197
- package/lib/goog/math/box.js +0 -398
- package/lib/goog/math/coordinate.js +0 -268
- package/lib/goog/math/math.js +0 -451
- package/lib/goog/math/rect.js +0 -476
- package/lib/goog/math/size.js +0 -227
- package/lib/goog/net/wrapperxmlhttpfactory.js +0 -71
- package/lib/goog/net/xhrlike.js +0 -124
- package/lib/goog/net/xmlhttp.js +0 -246
- package/lib/goog/net/xmlhttpfactory.js +0 -67
- package/lib/goog/object/object.js +0 -686
- package/lib/goog/promise/promise.js +0 -1350
- package/lib/goog/promise/resolver.js +0 -48
- package/lib/goog/promise/thenable.js +0 -126
- package/lib/goog/reflect/reflect.js +0 -77
- package/lib/goog/string/const.js +0 -182
- package/lib/goog/string/string.js +0 -1599
- package/lib/goog/string/typedstring.js +0 -48
- package/lib/goog/structs/collection.js +0 -56
- package/lib/goog/structs/map.js +0 -457
- package/lib/goog/structs/set.js +0 -279
- package/lib/goog/structs/structs.js +0 -354
- package/lib/goog/style/style.js +0 -2037
- package/lib/goog/testing/asserts.js +0 -1278
- package/lib/goog/testing/events/events.js +0 -767
- package/lib/goog/testing/functionmock.js +0 -175
- package/lib/goog/testing/jsunit.js +0 -162
- package/lib/goog/testing/loosemock.js +0 -242
- package/lib/goog/testing/mock.js +0 -645
- package/lib/goog/testing/mockclock.js +0 -606
- package/lib/goog/testing/mockcontrol.js +0 -220
- package/lib/goog/testing/mockinterface.js +0 -45
- package/lib/goog/testing/mockmatchers.js +0 -400
- package/lib/goog/testing/objectpropertystring.js +0 -68
- package/lib/goog/testing/propertyreplacer.js +0 -262
- package/lib/goog/testing/recordfunction.js +0 -215
- package/lib/goog/testing/stacktrace.js +0 -594
- package/lib/goog/testing/strictmock.js +0 -130
- package/lib/goog/testing/testcase.js +0 -1629
- package/lib/goog/testing/testrunner.js +0 -440
- package/lib/goog/uri/uri.js +0 -1524
- package/lib/goog/uri/utils.js +0 -1064
- package/lib/goog/useragent/product.js +0 -183
- package/lib/goog/useragent/product_isversion.js +0 -144
- package/lib/goog/useragent/useragent.js +0 -572
- package/lib/webdriver/actionsequence.js +0 -356
- package/lib/webdriver/builder.js +0 -207
- package/lib/webdriver/capabilities.js +0 -412
- package/lib/webdriver/events.js +0 -179
- package/lib/webdriver/firefoxdomexecutor.js +0 -175
- package/lib/webdriver/http/corsclient.js +0 -133
- package/lib/webdriver/http/http.js +0 -525
- package/lib/webdriver/http/xhrclient.js +0 -67
- package/lib/webdriver/locators.js +0 -257
- package/lib/webdriver/logging.js +0 -347
- package/lib/webdriver/session.js +0 -74
- package/lib/webdriver/stacktrace.js +0 -619
- package/lib/webdriver/test/builder_test.js +0 -53
- package/lib/webdriver/test/capabilities_test.js +0 -72
- package/lib/webdriver/test/events_test.js +0 -203
- package/lib/webdriver/test/http/corsclient_test.js +0 -151
- package/lib/webdriver/test/http/http_test.js +0 -428
- package/lib/webdriver/test/http/xhrclient_test.js +0 -196
- package/lib/webdriver/test/locators_test.js +0 -59
- package/lib/webdriver/test/logging_test.js +0 -85
- package/lib/webdriver/test/promise_error_test.js +0 -892
- package/lib/webdriver/test/promise_flow_test.js +0 -2365
- package/lib/webdriver/test/promise_generator_test.js +0 -323
- package/lib/webdriver/test/promise_test.js +0 -2012
- package/lib/webdriver/test/stacktrace_test.js +0 -480
- package/lib/webdriver/test/test_bootstrap.js +0 -67
- package/lib/webdriver/test/testing/asserts_test.js +0 -117
- package/lib/webdriver/test/testing/client_test.js +0 -88
- package/lib/webdriver/test/testing/testcase_test.js +0 -229
- package/lib/webdriver/test/testutil.js +0 -209
- package/lib/webdriver/test/testutil_test.js +0 -104
- package/lib/webdriver/test/until_test.js +0 -411
- package/lib/webdriver/test/webdriver_generator_test.js +0 -92
- package/lib/webdriver/test/webdriver_test.js +0 -2369
- package/lib/webdriver/testing/asserts.js +0 -487
- package/lib/webdriver/testing/client.js +0 -179
- package/lib/webdriver/testing/jsunit.js +0 -363
- package/lib/webdriver/testing/testcase.js +0 -168
- package/lib/webdriver/testing/window.js +0 -244
- package/lib/webdriver/touchsequence.js +0 -248
- package/lib/webdriver/until.js +0 -412
- package/lib/webdriver/webdriver.js +0 -2511
- package/test/_base_test.js +0 -129
|
@@ -1,2365 +0,0 @@
|
|
|
1
|
-
// Licensed to the Software Freedom Conservancy (SFC) under one
|
|
2
|
-
// or more contributor license agreements. See the NOTICE file
|
|
3
|
-
// distributed with this work for additional information
|
|
4
|
-
// regarding copyright ownership. The SFC licenses this file
|
|
5
|
-
// to you under the Apache License, Version 2.0 (the
|
|
6
|
-
// "License"); you may not use this file except in compliance
|
|
7
|
-
// with the License. You may obtain a copy of the License at
|
|
8
|
-
//
|
|
9
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
//
|
|
11
|
-
// Unless required by applicable law or agreed to in writing,
|
|
12
|
-
// software distributed under the License is distributed on an
|
|
13
|
-
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
-
// KIND, either express or implied. See the License for the
|
|
15
|
-
// specific language governing permissions and limitations
|
|
16
|
-
// under the License.
|
|
17
|
-
|
|
18
|
-
goog.require('goog.array');
|
|
19
|
-
goog.require('goog.string');
|
|
20
|
-
goog.require('goog.testing.jsunit');
|
|
21
|
-
goog.require('goog.userAgent');
|
|
22
|
-
goog.require('webdriver.promise');
|
|
23
|
-
goog.require('webdriver.stacktrace.Snapshot');
|
|
24
|
-
goog.require('webdriver.stacktrace');
|
|
25
|
-
goog.require('webdriver.test.testutil');
|
|
26
|
-
|
|
27
|
-
// Aliases for readability.
|
|
28
|
-
var StubError = webdriver.test.testutil.StubError,
|
|
29
|
-
throwStubError = webdriver.test.testutil.throwStubError,
|
|
30
|
-
assertIsStubError = webdriver.test.testutil.assertIsStubError,
|
|
31
|
-
assertingMessages = webdriver.test.testutil.assertingMessages,
|
|
32
|
-
callbackHelper = webdriver.test.testutil.callbackHelper,
|
|
33
|
-
callbackPair = webdriver.test.testutil.callbackPair;
|
|
34
|
-
|
|
35
|
-
var flow, flowHistory, uncaughtExceptions;
|
|
36
|
-
|
|
37
|
-
function shouldRunTests() {
|
|
38
|
-
return !goog.userAgent.IE || goog.userAgent.isVersionOrHigher(10);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
function setUp() {
|
|
43
|
-
webdriver.promise.LONG_STACK_TRACES = false;
|
|
44
|
-
flow = new webdriver.promise.ControlFlow();
|
|
45
|
-
webdriver.promise.setDefaultFlow(flow);
|
|
46
|
-
webdriver.test.testutil.messages = [];
|
|
47
|
-
flowHistory = [];
|
|
48
|
-
|
|
49
|
-
uncaughtExceptions = [];
|
|
50
|
-
flow.on(webdriver.promise.ControlFlow.EventType.UNCAUGHT_EXCEPTION,
|
|
51
|
-
onUncaughtException);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
function tearDown() {
|
|
56
|
-
flow.removeAllListeners(
|
|
57
|
-
webdriver.promise.ControlFlow.EventType.UNCAUGHT_EXCEPTION);
|
|
58
|
-
assertArrayEquals('There were uncaught exceptions', [], uncaughtExceptions);
|
|
59
|
-
flow.reset();
|
|
60
|
-
webdriver.promise.LONG_STACK_TRACES = false;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
function onUncaughtException(e) {
|
|
65
|
-
uncaughtExceptions.push(e);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
function waitForAbort(opt_flow) {
|
|
70
|
-
var theFlow = opt_flow || flow;
|
|
71
|
-
theFlow.removeAllListeners(
|
|
72
|
-
webdriver.promise.ControlFlow.EventType.UNCAUGHT_EXCEPTION);
|
|
73
|
-
return new goog.Promise(function(fulfill, reject) {
|
|
74
|
-
theFlow.once(webdriver.promise.ControlFlow.EventType.IDLE, function() {
|
|
75
|
-
reject(Error('expected flow to report an unhandled error'));
|
|
76
|
-
});
|
|
77
|
-
theFlow.once(
|
|
78
|
-
webdriver.promise.ControlFlow.EventType.UNCAUGHT_EXCEPTION,
|
|
79
|
-
fulfill);
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
function waitForIdle(opt_flow) {
|
|
85
|
-
var theFlow = opt_flow || flow;
|
|
86
|
-
return new goog.Promise(function(fulfill, reject) {
|
|
87
|
-
theFlow.once(webdriver.promise.ControlFlow.EventType.IDLE, fulfill);
|
|
88
|
-
theFlow.once(
|
|
89
|
-
webdriver.promise.ControlFlow.EventType.UNCAUGHT_EXCEPTION, reject);
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function timeout(ms) {
|
|
94
|
-
return new goog.Promise(function(fulfill) {
|
|
95
|
-
setTimeout(fulfill, ms);
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
function schedule(msg, opt_return) {
|
|
101
|
-
return scheduleAction(msg, function() {
|
|
102
|
-
return opt_return;
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* @param {string} value The value to push.
|
|
108
|
-
* @param {webdriver.promise.Promise=} opt_taskPromise Promise to return from
|
|
109
|
-
* the task.
|
|
110
|
-
* @return {!webdriver.promise.Promise} The result.
|
|
111
|
-
*/
|
|
112
|
-
function schedulePush(value, opt_taskPromise) {
|
|
113
|
-
return scheduleAction(value, function() {
|
|
114
|
-
webdriver.test.testutil.messages.push(value);
|
|
115
|
-
return opt_taskPromise;
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* @param {string} msg Debug message.
|
|
121
|
-
* @param {!Function} actionFn The function.
|
|
122
|
-
* @return {!webdriver.promise.Promise} The function result.
|
|
123
|
-
*/
|
|
124
|
-
function scheduleAction(msg, actionFn) {
|
|
125
|
-
return webdriver.promise.controlFlow().execute(function() {
|
|
126
|
-
flowHistory.push(msg);
|
|
127
|
-
return actionFn();
|
|
128
|
-
}, msg);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* @param {!Function} condition The condition function.
|
|
133
|
-
* @param {number=} opt_timeout The timeout.
|
|
134
|
-
* @param {string=} opt_message Optional message.
|
|
135
|
-
* @return {!webdriver.promise.Promise} The wait result.
|
|
136
|
-
*/
|
|
137
|
-
function scheduleWait(condition, opt_timeout, opt_message) {
|
|
138
|
-
var msg = opt_message || '';
|
|
139
|
-
// It's not possible to hook into when the wait itself is scheduled, so
|
|
140
|
-
// we record each iteration of the wait loop.
|
|
141
|
-
var count = 0;
|
|
142
|
-
return webdriver.promise.controlFlow().wait(function() {
|
|
143
|
-
flowHistory.push((count++) + ': ' + msg);
|
|
144
|
-
return condition();
|
|
145
|
-
}, opt_timeout, msg);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
function assertFlowHistory(var_args) {
|
|
150
|
-
var expected = goog.array.slice(arguments, 0);
|
|
151
|
-
assertArrayEquals(expected, flowHistory);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
function testScheduling_aSimpleFunction() {
|
|
156
|
-
schedule('go');
|
|
157
|
-
return waitForIdle().then(function() {
|
|
158
|
-
assertFlowHistory('go');
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
function testScheduling_aSimpleFunctionWithANonPromiseReturnValue() {
|
|
164
|
-
schedule('go', 123).then(function(value) {
|
|
165
|
-
assertEquals(123, value);
|
|
166
|
-
});
|
|
167
|
-
return waitForIdle().then(function() {
|
|
168
|
-
assertFlowHistory('go');
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
function testScheduling_aSimpleSequence() {
|
|
174
|
-
schedule('a');
|
|
175
|
-
schedule('b');
|
|
176
|
-
schedule('c');
|
|
177
|
-
return waitForIdle().then(function() {
|
|
178
|
-
assertFlowHistory('a', 'b', 'c');
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
function testScheduling_invokesCallbacksWhenTaskIsDone() {
|
|
184
|
-
var d = new webdriver.promise.Deferred();
|
|
185
|
-
var called = false;
|
|
186
|
-
var done = schedule('a', d.promise).then(function(value) {
|
|
187
|
-
called = true;
|
|
188
|
-
assertEquals(123, value);
|
|
189
|
-
});
|
|
190
|
-
return timeout(5).then(function() {
|
|
191
|
-
assertFalse(called);
|
|
192
|
-
d.fulfill(123);
|
|
193
|
-
return done;
|
|
194
|
-
}).
|
|
195
|
-
then(waitForIdle).
|
|
196
|
-
then(function() {
|
|
197
|
-
assertFlowHistory('a');
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
function testScheduling_blocksUntilPromiseReturnedByTaskIsResolved() {
|
|
203
|
-
var done = webdriver.promise.defer();
|
|
204
|
-
schedulePush('a', done.promise);
|
|
205
|
-
schedulePush('b');
|
|
206
|
-
setTimeout(function() {
|
|
207
|
-
done.fulfill();
|
|
208
|
-
webdriver.test.testutil.messages.push('c');
|
|
209
|
-
}, 25);
|
|
210
|
-
return waitForIdle().then(assertingMessages('a', 'c', 'b'));
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
function testScheduling_waitsForReturnedPromisesToResolve() {
|
|
215
|
-
var d1 = new webdriver.promise.Deferred();
|
|
216
|
-
var d2 = new webdriver.promise.Deferred();
|
|
217
|
-
|
|
218
|
-
var callback;
|
|
219
|
-
schedule('a', d1.promise).then(callback = callbackHelper(function(value) {
|
|
220
|
-
assertEquals('fluffy bunny', value);
|
|
221
|
-
}));
|
|
222
|
-
|
|
223
|
-
return timeout(5).then(function() {
|
|
224
|
-
callback.assertNotCalled('d1 not resolved yet');
|
|
225
|
-
d1.fulfill(d2);
|
|
226
|
-
return timeout(5);
|
|
227
|
-
}).then(function() {
|
|
228
|
-
callback.assertNotCalled('d2 not resolved yet');
|
|
229
|
-
d2.fulfill('fluffy bunny');
|
|
230
|
-
return waitForIdle();
|
|
231
|
-
}).then(function() {
|
|
232
|
-
callback.assertCalled('d2 has been resolved');
|
|
233
|
-
assertFlowHistory('a');
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
function testScheduling_executesTasksInAFutureTurnAfterTheyAreScheduled() {
|
|
239
|
-
var count = 0;
|
|
240
|
-
function incr() { count++; }
|
|
241
|
-
|
|
242
|
-
scheduleAction('', incr);
|
|
243
|
-
assertEquals(0, count);
|
|
244
|
-
return waitForIdle().then(function() {
|
|
245
|
-
assertEquals(1, count);
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
function testScheduling_executesOneTaskPerTurnOfTheEventLoop() {
|
|
251
|
-
var order = [];
|
|
252
|
-
function go() {
|
|
253
|
-
order.push(order.length / 2);
|
|
254
|
-
goog.async.run(function() {
|
|
255
|
-
order.push('-');
|
|
256
|
-
});
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
scheduleAction('', go);
|
|
260
|
-
scheduleAction('', go);
|
|
261
|
-
return waitForIdle().then(function() {
|
|
262
|
-
assertArrayEquals([0, '-', 1, '-'], order);
|
|
263
|
-
})
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
function testScheduling_firstScheduledTaskIsWithinACallback() {
|
|
268
|
-
webdriver.promise.fulfilled().then(function() {
|
|
269
|
-
schedule('a');
|
|
270
|
-
schedule('b');
|
|
271
|
-
schedule('c');
|
|
272
|
-
}).then(function() {
|
|
273
|
-
assertFlowHistory('a', 'b', 'c');
|
|
274
|
-
});
|
|
275
|
-
return waitForIdle();
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
function testScheduling_newTasksAddedWhileWaitingOnTaskReturnedPromise1() {
|
|
280
|
-
scheduleAction('a', function() {
|
|
281
|
-
var d = webdriver.promise.defer();
|
|
282
|
-
setTimeout(function() {
|
|
283
|
-
schedule('c');
|
|
284
|
-
d.fulfill();
|
|
285
|
-
}, 10);
|
|
286
|
-
return d.promise;
|
|
287
|
-
});
|
|
288
|
-
schedule('b');
|
|
289
|
-
return waitForIdle().then(function() {
|
|
290
|
-
assertFlowHistory('a', 'b', 'c');
|
|
291
|
-
});
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
function testScheduling_newTasksAddedWhileWaitingOnTaskReturnedPromise2() {
|
|
296
|
-
scheduleAction('a', function() {
|
|
297
|
-
var d = webdriver.promise.defer();
|
|
298
|
-
setTimeout(function() {
|
|
299
|
-
schedule('c');
|
|
300
|
-
goog.async.run(d.fulfill);
|
|
301
|
-
}, 10);
|
|
302
|
-
return d.promise;
|
|
303
|
-
});
|
|
304
|
-
schedule('b');
|
|
305
|
-
return waitForIdle().then(function() {
|
|
306
|
-
assertFlowHistory('a', 'c', 'b');
|
|
307
|
-
});
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
function testFraming_callbacksRunInANewFrame() {
|
|
312
|
-
schedule('a').then(function() {
|
|
313
|
-
schedule('c');
|
|
314
|
-
});
|
|
315
|
-
schedule('b');
|
|
316
|
-
return waitForIdle().then(function() {
|
|
317
|
-
assertFlowHistory('a', 'c', 'b');
|
|
318
|
-
});
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
function testFraming_lotsOfNesting() {
|
|
323
|
-
schedule('a').then(function() {
|
|
324
|
-
schedule('c').then(function() {
|
|
325
|
-
schedule('e').then(function() {
|
|
326
|
-
schedule('g');
|
|
327
|
-
});
|
|
328
|
-
schedule('f');
|
|
329
|
-
});
|
|
330
|
-
schedule('d');
|
|
331
|
-
});
|
|
332
|
-
schedule('b');
|
|
333
|
-
|
|
334
|
-
return waitForIdle().then(function() {
|
|
335
|
-
assertFlowHistory('a', 'c', 'e', 'g', 'f', 'd', 'b');
|
|
336
|
-
});
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
function testFrame_callbackReturnsPromiseThatDependsOnATask_1() {
|
|
341
|
-
schedule('a').then(function() {
|
|
342
|
-
schedule('b');
|
|
343
|
-
return webdriver.promise.delayed(5).then(function() {
|
|
344
|
-
return schedule('c');
|
|
345
|
-
});
|
|
346
|
-
});
|
|
347
|
-
schedule('d');
|
|
348
|
-
|
|
349
|
-
return waitForIdle().then(function() {
|
|
350
|
-
assertFlowHistory('a', 'b', 'c', 'd');
|
|
351
|
-
});
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
function testFrame_callbackReturnsPromiseThatDependsOnATask_2() {
|
|
356
|
-
schedule('a').then(function() {
|
|
357
|
-
schedule('b');
|
|
358
|
-
return webdriver.promise.delayed(5).
|
|
359
|
-
then(function() { return webdriver.promise.delayed(5) }).
|
|
360
|
-
then(function() { return webdriver.promise.delayed(5) }).
|
|
361
|
-
then(function() { return webdriver.promise.delayed(5) }).
|
|
362
|
-
then(function() { return schedule('c'); });
|
|
363
|
-
});
|
|
364
|
-
schedule('d');
|
|
365
|
-
|
|
366
|
-
return waitForIdle().then(function() {
|
|
367
|
-
assertFlowHistory('a', 'b', 'c', 'd');
|
|
368
|
-
});
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
function testFraming_eachCallbackWaitsForAllScheduledTasksToComplete() {
|
|
373
|
-
schedule('a').
|
|
374
|
-
then(function() {
|
|
375
|
-
schedule('b');
|
|
376
|
-
schedule('c');
|
|
377
|
-
}).
|
|
378
|
-
then(function() {
|
|
379
|
-
schedule('d');
|
|
380
|
-
});
|
|
381
|
-
schedule('e');
|
|
382
|
-
|
|
383
|
-
return waitForIdle().then(function() {
|
|
384
|
-
assertFlowHistory('a', 'b', 'c', 'd', 'e');
|
|
385
|
-
});
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
function testFraming_eachCallbackWaitsForReturnTasksToComplete() {
|
|
390
|
-
schedule('a').
|
|
391
|
-
then(function() {
|
|
392
|
-
schedule('b');
|
|
393
|
-
return schedule('c');
|
|
394
|
-
}).
|
|
395
|
-
then(function() {
|
|
396
|
-
schedule('d');
|
|
397
|
-
});
|
|
398
|
-
schedule('e');
|
|
399
|
-
|
|
400
|
-
return waitForIdle().then(function() {
|
|
401
|
-
assertFlowHistory('a', 'b', 'c', 'd', 'e');
|
|
402
|
-
});
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
function testFraming_callbacksOnAResolvedPromiseInsertIntoTheCurrentFlow() {
|
|
407
|
-
webdriver.promise.fulfilled().then(function() {
|
|
408
|
-
schedule('b');
|
|
409
|
-
});
|
|
410
|
-
schedule('a');
|
|
411
|
-
|
|
412
|
-
return waitForIdle().then(function() {
|
|
413
|
-
assertFlowHistory('b', 'a');
|
|
414
|
-
});
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
function testFraming_callbacksInterruptTheFlowWhenPromiseIsResolved() {
|
|
419
|
-
schedule('a').then(function() {
|
|
420
|
-
schedule('c');
|
|
421
|
-
});
|
|
422
|
-
schedule('b');
|
|
423
|
-
|
|
424
|
-
return waitForIdle().then(function() {
|
|
425
|
-
assertFlowHistory('a', 'c', 'b');
|
|
426
|
-
});
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
function testFraming_allCallbacksInAFrameAreScheduledWhenPromiseIsResolved() {
|
|
431
|
-
var a = schedule('a');
|
|
432
|
-
a.then(function() { schedule('b'); });
|
|
433
|
-
schedule('c');
|
|
434
|
-
a.then(function() { schedule('d'); });
|
|
435
|
-
schedule('e');
|
|
436
|
-
|
|
437
|
-
return waitForIdle().then(function() {
|
|
438
|
-
assertFlowHistory('a', 'b', 'c', 'd', 'e');
|
|
439
|
-
});
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
function testFraming_tasksScheduledInInActiveFrameDoNotGetPrecedence() {
|
|
444
|
-
var d = webdriver.promise.fulfilled();
|
|
445
|
-
schedule('a');
|
|
446
|
-
schedule('b');
|
|
447
|
-
d.then(function() { schedule('c'); });
|
|
448
|
-
|
|
449
|
-
return waitForIdle().then(function() {
|
|
450
|
-
assertFlowHistory('a', 'b', 'c');
|
|
451
|
-
});
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
function testFraming_tasksScheduledInAFrameGetPrecedence_1() {
|
|
456
|
-
var a = schedule('a');
|
|
457
|
-
schedule('b').then(function() {
|
|
458
|
-
a.then(function() {
|
|
459
|
-
schedule('c');
|
|
460
|
-
schedule('d');
|
|
461
|
-
});
|
|
462
|
-
var e = schedule('e');
|
|
463
|
-
a.then(function() {
|
|
464
|
-
schedule('f');
|
|
465
|
-
e.then(function() {
|
|
466
|
-
schedule('g');
|
|
467
|
-
});
|
|
468
|
-
schedule('h');
|
|
469
|
-
});
|
|
470
|
-
schedule('i');
|
|
471
|
-
});
|
|
472
|
-
schedule('j');
|
|
473
|
-
|
|
474
|
-
return waitForIdle().then(function() {
|
|
475
|
-
assertFlowHistory('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j');
|
|
476
|
-
});
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
function testErrorHandling_thrownErrorsArePassedToTaskErrback() {
|
|
481
|
-
scheduleAction('function that throws', throwStubError).
|
|
482
|
-
then(fail, assertIsStubError);
|
|
483
|
-
return waitForIdle();
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
function testErrorHandling_thrownErrorsPropagateThroughPromiseChain() {
|
|
488
|
-
scheduleAction('function that throws', throwStubError).
|
|
489
|
-
then(fail).
|
|
490
|
-
then(fail, assertIsStubError);
|
|
491
|
-
return waitForIdle();
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
function testErrorHandling_catchesErrorsFromFailedTasksInAFrame() {
|
|
496
|
-
schedule('a').then(function() {
|
|
497
|
-
schedule('b');
|
|
498
|
-
scheduleAction('function that throws', throwStubError);
|
|
499
|
-
}).
|
|
500
|
-
then(fail, assertIsStubError);
|
|
501
|
-
return waitForIdle();
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
function testErrorHandling_abortsIfOnlyTaskReturnsAnUnhandledRejection() {
|
|
506
|
-
scheduleAction('function that returns rejected promise', function() {
|
|
507
|
-
return webdriver.promise.rejected(new StubError);
|
|
508
|
-
});
|
|
509
|
-
return waitForAbort().then(assertIsStubError);
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
function testErrorHandling_abortsIfThereIsAnUnhandledRejection() {
|
|
514
|
-
webdriver.promise.rejected(new StubError);
|
|
515
|
-
schedule('this should not run');
|
|
516
|
-
return waitForAbort().
|
|
517
|
-
then(assertIsStubError).
|
|
518
|
-
then(function() {
|
|
519
|
-
assertFlowHistory(/* none */);
|
|
520
|
-
});
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
function testErrorHandling_abortsSequenceIfATaskFails() {
|
|
525
|
-
schedule('a');
|
|
526
|
-
schedule('b');
|
|
527
|
-
scheduleAction('c', throwStubError);
|
|
528
|
-
schedule('d'); // Should never execute.
|
|
529
|
-
|
|
530
|
-
return waitForAbort().
|
|
531
|
-
then(assertIsStubError).
|
|
532
|
-
then(function() {
|
|
533
|
-
assertFlowHistory('a', 'b', 'c');
|
|
534
|
-
});
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
function testErrorHandling_abortsFromUnhandledFramedTaskFailures_1() {
|
|
539
|
-
schedule('outer task').then(function() {
|
|
540
|
-
scheduleAction('inner task', throwStubError);
|
|
541
|
-
});
|
|
542
|
-
schedule('this should not run');
|
|
543
|
-
return waitForAbort().
|
|
544
|
-
then(assertIsStubError).
|
|
545
|
-
then(function() {
|
|
546
|
-
assertFlowHistory('outer task', 'inner task');
|
|
547
|
-
});
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
function testErrorHandling_abortsFromUnhandledFramedTaskFailures_2() {
|
|
552
|
-
schedule('a').then(function() {
|
|
553
|
-
schedule('b').then(function() {
|
|
554
|
-
scheduleAction('c', throwStubError);
|
|
555
|
-
// This should not execute.
|
|
556
|
-
schedule('d');
|
|
557
|
-
});
|
|
558
|
-
});
|
|
559
|
-
|
|
560
|
-
return waitForAbort().
|
|
561
|
-
then(assertIsStubError).
|
|
562
|
-
then(function() {
|
|
563
|
-
assertFlowHistory('a', 'b', 'c');
|
|
564
|
-
});
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
function testErrorHandling_abortsWhenErrorBubblesUpFromFullyResolvingAnObject() {
|
|
569
|
-
var callback = callbackHelper(function() {
|
|
570
|
-
return webdriver.promise.rejected('rejected 2');
|
|
571
|
-
});
|
|
572
|
-
|
|
573
|
-
scheduleAction('', function() {
|
|
574
|
-
var obj = {'foo': webdriver.promise.rejected(new StubError)};
|
|
575
|
-
return webdriver.promise.fullyResolved(obj).then(callback);
|
|
576
|
-
});
|
|
577
|
-
|
|
578
|
-
return waitForAbort().
|
|
579
|
-
then(assertIsStubError).
|
|
580
|
-
then(callback.assertNotCalled);
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
function testErrorHandling_abortsWhenErrorBubblesUpFromFullyResolvingAnObject_withCallback() {
|
|
585
|
-
var callback1 = callbackHelper(function() {
|
|
586
|
-
return webdriver.promise.rejected('rejected 2');
|
|
587
|
-
});
|
|
588
|
-
var callback2 = callbackHelper();
|
|
589
|
-
|
|
590
|
-
scheduleAction('', function() {
|
|
591
|
-
var obj = {'foo': webdriver.promise.rejected(new StubError)};
|
|
592
|
-
return webdriver.promise.fullyResolved(obj).then(callback1);
|
|
593
|
-
}).then(callback2);
|
|
594
|
-
|
|
595
|
-
return waitForAbort().
|
|
596
|
-
then(assertIsStubError).
|
|
597
|
-
then(callback1.assertNotCalled).
|
|
598
|
-
then(callback2.assertNotCalled);
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
function testErrorHandling_canCatchErrorsFromNestedTasks() {
|
|
603
|
-
var errback;
|
|
604
|
-
schedule('a').
|
|
605
|
-
then(function() {
|
|
606
|
-
return scheduleAction('b', throwStubError);
|
|
607
|
-
}).
|
|
608
|
-
thenCatch(errback = callbackHelper(assertIsStubError));
|
|
609
|
-
return waitForIdle().then(errback.assertCalled);
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
function testErrorHandling_nestedCommandFailuresCanBeCaughtAndSuppressed() {
|
|
614
|
-
var errback;
|
|
615
|
-
schedule('a').then(function() {
|
|
616
|
-
return schedule('b').then(function() {
|
|
617
|
-
return schedule('c').then(function() {
|
|
618
|
-
throw new StubError;
|
|
619
|
-
});
|
|
620
|
-
});
|
|
621
|
-
}).thenCatch(errback = callbackHelper(assertIsStubError));
|
|
622
|
-
schedule('d');
|
|
623
|
-
return waitForIdle().
|
|
624
|
-
then(errback.assertCalled).
|
|
625
|
-
then(function() {
|
|
626
|
-
assertFlowHistory('a', 'b', 'c', 'd');
|
|
627
|
-
});
|
|
628
|
-
}
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
function testErrorHandling_aTaskWithAnUnhandledPromiseRejection() {
|
|
632
|
-
schedule('a');
|
|
633
|
-
scheduleAction('sub-tasks', function() {
|
|
634
|
-
webdriver.promise.rejected(new StubError);
|
|
635
|
-
});
|
|
636
|
-
schedule('should never run');
|
|
637
|
-
|
|
638
|
-
return waitForAbort().
|
|
639
|
-
then(assertIsStubError).
|
|
640
|
-
then(function() {
|
|
641
|
-
assertFlowHistory('a', 'sub-tasks');
|
|
642
|
-
});
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
function testErrorHandling_aTaskThatReutrnsARejectedPromise() {
|
|
646
|
-
schedule('a');
|
|
647
|
-
scheduleAction('sub-tasks', function() {
|
|
648
|
-
return webdriver.promise.rejected(new StubError);
|
|
649
|
-
});
|
|
650
|
-
schedule('should never run');
|
|
651
|
-
|
|
652
|
-
return waitForAbort().
|
|
653
|
-
then(assertIsStubError).
|
|
654
|
-
then(function() {
|
|
655
|
-
assertFlowHistory('a', 'sub-tasks');
|
|
656
|
-
});
|
|
657
|
-
}
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
function testErrorHandling_discardsSubtasksIfTaskThrows() {
|
|
661
|
-
var pair = callbackPair(null, assertIsStubError);
|
|
662
|
-
scheduleAction('a', function() {
|
|
663
|
-
schedule('b');
|
|
664
|
-
schedule('c');
|
|
665
|
-
throwStubError();
|
|
666
|
-
}).then(pair.callback, pair.errback);
|
|
667
|
-
schedule('d');
|
|
668
|
-
|
|
669
|
-
return waitForIdle().
|
|
670
|
-
then(pair.assertErrback).
|
|
671
|
-
then(function() {
|
|
672
|
-
assertFlowHistory('a', 'd');
|
|
673
|
-
});
|
|
674
|
-
}
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
function testErrorHandling_discardsRemainingSubtasksIfASubtaskFails() {
|
|
678
|
-
var pair = callbackPair(null, assertIsStubError);
|
|
679
|
-
scheduleAction('a', function() {
|
|
680
|
-
schedule('b');
|
|
681
|
-
scheduleAction('c', throwStubError);
|
|
682
|
-
schedule('d');
|
|
683
|
-
}).then(pair.callback, pair.errback);
|
|
684
|
-
schedule('e');
|
|
685
|
-
|
|
686
|
-
return waitForIdle().
|
|
687
|
-
then(pair.assertErrback).
|
|
688
|
-
then(function() {
|
|
689
|
-
assertFlowHistory('a', 'b', 'c', 'e');
|
|
690
|
-
});
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
function testTryFinally_happyPath() {
|
|
695
|
-
/* Model:
|
|
696
|
-
try {
|
|
697
|
-
doFoo();
|
|
698
|
-
doBar();
|
|
699
|
-
} finally {
|
|
700
|
-
doBaz();
|
|
701
|
-
}
|
|
702
|
-
*/
|
|
703
|
-
schedulePush('foo').
|
|
704
|
-
then(goog.partial(schedulePush, 'bar')).
|
|
705
|
-
thenFinally(goog.partial(schedulePush, 'baz'));
|
|
706
|
-
return waitForIdle().then(assertingMessages('foo', 'bar', 'baz'));
|
|
707
|
-
}
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
function testTryFinally_firstTryFails() {
|
|
711
|
-
/* Model:
|
|
712
|
-
try {
|
|
713
|
-
doFoo();
|
|
714
|
-
doBar();
|
|
715
|
-
} finally {
|
|
716
|
-
doBaz();
|
|
717
|
-
}
|
|
718
|
-
*/
|
|
719
|
-
|
|
720
|
-
scheduleAction('doFoo and throw', function() {
|
|
721
|
-
webdriver.test.testutil.messages.push('foo');
|
|
722
|
-
throw new StubError;
|
|
723
|
-
}).
|
|
724
|
-
then(function() { schedulePush('bar'); }).
|
|
725
|
-
thenFinally(function() { schedulePush('baz'); });
|
|
726
|
-
|
|
727
|
-
return waitForAbort().
|
|
728
|
-
then(assertIsStubError).
|
|
729
|
-
then(assertingMessages('foo', 'baz'));
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
function testTryFinally_secondTryFails() {
|
|
734
|
-
/* Model:
|
|
735
|
-
try {
|
|
736
|
-
doFoo();
|
|
737
|
-
doBar();
|
|
738
|
-
} finally {
|
|
739
|
-
doBaz();
|
|
740
|
-
}
|
|
741
|
-
*/
|
|
742
|
-
|
|
743
|
-
schedulePush('foo').
|
|
744
|
-
then(function() {
|
|
745
|
-
return scheduleAction('doBar and throw', function() {
|
|
746
|
-
webdriver.test.testutil.messages.push('bar');
|
|
747
|
-
throw new StubError;
|
|
748
|
-
});
|
|
749
|
-
}).
|
|
750
|
-
thenFinally(function() {
|
|
751
|
-
return schedulePush('baz');
|
|
752
|
-
});
|
|
753
|
-
return waitForAbort().
|
|
754
|
-
then(assertIsStubError).
|
|
755
|
-
then(assertingMessages('foo', 'bar', 'baz'));
|
|
756
|
-
}
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
function testTaskCallbacksInterruptFlow() {
|
|
760
|
-
schedule('a').then(function() {
|
|
761
|
-
schedule('b');
|
|
762
|
-
});
|
|
763
|
-
schedule('c');
|
|
764
|
-
return waitForIdle().then(function() {
|
|
765
|
-
assertFlowHistory('a', 'b', 'c');
|
|
766
|
-
});
|
|
767
|
-
}
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
function
|
|
771
|
-
testTaskCallbacksInterruptFlow_taskDependsOnImmediatelyFulfilledPromise() {
|
|
772
|
-
scheduleAction('a', function() {
|
|
773
|
-
return webdriver.promise.fulfilled();
|
|
774
|
-
}).then(function() {
|
|
775
|
-
schedule('b');
|
|
776
|
-
});
|
|
777
|
-
schedule('c');
|
|
778
|
-
return waitForIdle().then(function() {
|
|
779
|
-
assertFlowHistory('a', 'b', 'c');
|
|
780
|
-
});
|
|
781
|
-
}
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
function testTaskCallbacksInterruptFlow_taskDependsOnPreviouslyFulfilledPromise() {
|
|
785
|
-
var promise = webdriver.promise.fulfilled(123);
|
|
786
|
-
scheduleAction('a', function() {
|
|
787
|
-
return promise;
|
|
788
|
-
}).then(function(value) {
|
|
789
|
-
assertEquals(123, value);
|
|
790
|
-
schedule('b');
|
|
791
|
-
});
|
|
792
|
-
schedule('c');
|
|
793
|
-
return waitForIdle().then(function() {
|
|
794
|
-
assertFlowHistory('a', 'b', 'c');
|
|
795
|
-
});
|
|
796
|
-
}
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
function testTaskCallbacksInterruptFlow_taskDependsOnAsyncPromise() {
|
|
800
|
-
scheduleAction('a', function() {
|
|
801
|
-
return webdriver.promise.delayed(25);
|
|
802
|
-
}).then(function() {
|
|
803
|
-
schedule('b');
|
|
804
|
-
});
|
|
805
|
-
schedule('c');
|
|
806
|
-
return waitForIdle().then(function() {
|
|
807
|
-
assertFlowHistory('a', 'b', 'c');
|
|
808
|
-
});
|
|
809
|
-
}
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
function testPromiseChainedToTaskInterruptFlow() {
|
|
813
|
-
schedule('a').then(function() {
|
|
814
|
-
return webdriver.promise.fulfilled();
|
|
815
|
-
}).then(function() {
|
|
816
|
-
return webdriver.promise.fulfilled();
|
|
817
|
-
}).then(function() {
|
|
818
|
-
schedule('b');
|
|
819
|
-
});
|
|
820
|
-
schedule('c');
|
|
821
|
-
return waitForIdle().then(function() {
|
|
822
|
-
assertFlowHistory('a', 'b', 'c');
|
|
823
|
-
});
|
|
824
|
-
}
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
function testNestedTaskCallbacksInterruptFlowWhenResolved() {
|
|
828
|
-
schedule('a').then(function() {
|
|
829
|
-
schedule('b').then(function() {
|
|
830
|
-
schedule('c');
|
|
831
|
-
});
|
|
832
|
-
});
|
|
833
|
-
schedule('d');
|
|
834
|
-
return waitForIdle().then(function() {
|
|
835
|
-
assertFlowHistory('a', 'b', 'c', 'd');
|
|
836
|
-
});
|
|
837
|
-
}
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
function testDelayedNesting_1() {
|
|
841
|
-
var a = schedule('a');
|
|
842
|
-
schedule('b').then(function() {
|
|
843
|
-
a.then(function() { schedule('c'); });
|
|
844
|
-
schedule('d');
|
|
845
|
-
});
|
|
846
|
-
schedule('e');
|
|
847
|
-
|
|
848
|
-
return waitForIdle().then(function() {
|
|
849
|
-
assertFlowHistory('a', 'b', 'c', 'd', 'e');
|
|
850
|
-
});
|
|
851
|
-
}
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
function testDelayedNesting_2() {
|
|
855
|
-
var a = schedule('a');
|
|
856
|
-
schedule('b').then(function() {
|
|
857
|
-
a.then(function() { schedule('c'); });
|
|
858
|
-
schedule('d');
|
|
859
|
-
a.then(function() { schedule('e'); });
|
|
860
|
-
});
|
|
861
|
-
schedule('f');
|
|
862
|
-
|
|
863
|
-
return waitForIdle().then(function() {
|
|
864
|
-
assertFlowHistory('a', 'b', 'c', 'd', 'e', 'f');
|
|
865
|
-
});
|
|
866
|
-
}
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
function testDelayedNesting_3() {
|
|
870
|
-
var a = schedule('a');
|
|
871
|
-
schedule('b').then(function() {
|
|
872
|
-
a.then(function() { schedule('c'); });
|
|
873
|
-
a.then(function() { schedule('d'); });
|
|
874
|
-
});
|
|
875
|
-
schedule('e');
|
|
876
|
-
|
|
877
|
-
return waitForIdle().then(function() {
|
|
878
|
-
assertFlowHistory('a', 'b', 'c', 'd', 'e');
|
|
879
|
-
});
|
|
880
|
-
}
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
function testDelayedNesting_4() {
|
|
884
|
-
var a = schedule('a');
|
|
885
|
-
schedule('b').then(function() {
|
|
886
|
-
a.then(function() { schedule('c'); }).then(function() {
|
|
887
|
-
schedule('d');
|
|
888
|
-
});
|
|
889
|
-
a.then(function() { schedule('e'); });
|
|
890
|
-
});
|
|
891
|
-
schedule('f');
|
|
892
|
-
|
|
893
|
-
return waitForIdle().then(function() {
|
|
894
|
-
assertFlowHistory('a', 'b', 'c', 'd', 'e', 'f');
|
|
895
|
-
});
|
|
896
|
-
}
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
function testDelayedNesting_5() {
|
|
900
|
-
var a = schedule('a');
|
|
901
|
-
schedule('b').then(function() {
|
|
902
|
-
var c;
|
|
903
|
-
a.then(function() { c = schedule('c'); }).then(function() {
|
|
904
|
-
schedule('d');
|
|
905
|
-
a.then(function() { schedule('e'); });
|
|
906
|
-
c.then(function() { schedule('f'); });
|
|
907
|
-
schedule('g');
|
|
908
|
-
});
|
|
909
|
-
a.then(function() { schedule('h'); });
|
|
910
|
-
});
|
|
911
|
-
schedule('i');
|
|
912
|
-
|
|
913
|
-
return waitForIdle().then(function() {
|
|
914
|
-
assertFlowHistory('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i');
|
|
915
|
-
});
|
|
916
|
-
}
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
function testWaiting_onAConditionThatIsAlwaysTrue() {
|
|
920
|
-
scheduleWait(function() { return true;}, 0, 'waiting on true');
|
|
921
|
-
return waitForIdle().then(function() {
|
|
922
|
-
assertFlowHistory('0: waiting on true');
|
|
923
|
-
});
|
|
924
|
-
}
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
function testWaiting_aSimpleCountingCondition() {
|
|
928
|
-
var count = 0;
|
|
929
|
-
scheduleWait(function() {
|
|
930
|
-
return ++count == 3;
|
|
931
|
-
}, 100, 'counting to 3');
|
|
932
|
-
|
|
933
|
-
return waitForIdle().then(function() {
|
|
934
|
-
assertEquals(3, count);
|
|
935
|
-
});
|
|
936
|
-
}
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
function testWaiting_aConditionThatReturnsAPromise() {
|
|
940
|
-
var d = new webdriver.promise.Deferred();
|
|
941
|
-
var count = 0;
|
|
942
|
-
|
|
943
|
-
scheduleWait(function() {
|
|
944
|
-
count += 1;
|
|
945
|
-
return d.promise;
|
|
946
|
-
}, 0, 'waiting for promise');
|
|
947
|
-
|
|
948
|
-
return timeout(50).then(function() {
|
|
949
|
-
assertEquals(1, count);
|
|
950
|
-
d.fulfill(123);
|
|
951
|
-
return waitForIdle();
|
|
952
|
-
});
|
|
953
|
-
}
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
function testWaiting_aConditionThatReturnsAPromise_2() {
|
|
957
|
-
var count = 0;
|
|
958
|
-
scheduleWait(function() {
|
|
959
|
-
return webdriver.promise.fulfilled(++count == 3);
|
|
960
|
-
}, 100, 'waiting for promise');
|
|
961
|
-
|
|
962
|
-
return waitForIdle().then(function() {
|
|
963
|
-
assertEquals(3, count);
|
|
964
|
-
});
|
|
965
|
-
}
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
function testWaiting_aConditionThatReturnsATaskResult() {
|
|
969
|
-
var count = 0;
|
|
970
|
-
scheduleWait(function() {
|
|
971
|
-
return scheduleAction('increment count', function() {
|
|
972
|
-
return ++count == 3;
|
|
973
|
-
});
|
|
974
|
-
}, 100, 'counting to 3');
|
|
975
|
-
schedule('post wait');
|
|
976
|
-
|
|
977
|
-
return waitForIdle().then(function() {
|
|
978
|
-
assertEquals(3, count);
|
|
979
|
-
assertFlowHistory(
|
|
980
|
-
'0: counting to 3', 'increment count',
|
|
981
|
-
'1: counting to 3', 'increment count',
|
|
982
|
-
'2: counting to 3', 'increment count',
|
|
983
|
-
'post wait');
|
|
984
|
-
});
|
|
985
|
-
}
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
function testWaiting_conditionContainsASubtask() {
|
|
989
|
-
var count = 0;
|
|
990
|
-
scheduleWait(function() {
|
|
991
|
-
schedule('sub task');
|
|
992
|
-
return ++count == 3;
|
|
993
|
-
}, 100, 'counting to 3');
|
|
994
|
-
schedule('post wait');
|
|
995
|
-
|
|
996
|
-
return waitForIdle().then(function() {
|
|
997
|
-
assertEquals(3, count);
|
|
998
|
-
assertFlowHistory(
|
|
999
|
-
'0: counting to 3', 'sub task',
|
|
1000
|
-
'1: counting to 3', 'sub task',
|
|
1001
|
-
'2: counting to 3', 'sub task',
|
|
1002
|
-
'post wait');
|
|
1003
|
-
});
|
|
1004
|
-
}
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
function testWaiting_cancelsWaitIfScheduledTaskFails() {
|
|
1008
|
-
var pair = callbackPair(null, assertIsStubError);
|
|
1009
|
-
scheduleWait(function() {
|
|
1010
|
-
scheduleAction('boom', throwStubError);
|
|
1011
|
-
schedule('this should not run');
|
|
1012
|
-
return true;
|
|
1013
|
-
}, 100, 'waiting to go boom').then(pair.callback, pair.errback);
|
|
1014
|
-
schedule('post wait');
|
|
1015
|
-
|
|
1016
|
-
return waitForIdle().
|
|
1017
|
-
then(pair.assertErrback).
|
|
1018
|
-
then(function() {
|
|
1019
|
-
assertFlowHistory(
|
|
1020
|
-
'0: waiting to go boom', 'boom',
|
|
1021
|
-
'post wait');
|
|
1022
|
-
});
|
|
1023
|
-
}
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
function testWaiting_failsIfConditionThrows() {
|
|
1027
|
-
var callbacks = callbackPair(null, assertIsStubError);
|
|
1028
|
-
scheduleWait(throwStubError, 0, 'goes boom').
|
|
1029
|
-
then(callbacks.callback, callbacks.errback);
|
|
1030
|
-
schedule('post wait');
|
|
1031
|
-
|
|
1032
|
-
return waitForIdle().
|
|
1033
|
-
then(callbacks.assertErrback).
|
|
1034
|
-
then(function() {
|
|
1035
|
-
assertFlowHistory('0: goes boom', 'post wait');
|
|
1036
|
-
});
|
|
1037
|
-
}
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
function testWaiting_failsIfConditionReturnsARejectedPromise() {
|
|
1041
|
-
var callbacks = callbackPair(null, assertIsStubError);
|
|
1042
|
-
scheduleWait(function() {
|
|
1043
|
-
return webdriver.promise.rejected(new StubError);
|
|
1044
|
-
}, 0, 'goes boom').then(callbacks.callback, callbacks.errback);
|
|
1045
|
-
schedule('post wait');
|
|
1046
|
-
|
|
1047
|
-
return waitForIdle().
|
|
1048
|
-
then(callbacks.assertErrback).
|
|
1049
|
-
then(function() {
|
|
1050
|
-
assertFlowHistory('0: goes boom', 'post wait');
|
|
1051
|
-
});
|
|
1052
|
-
}
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
function testWaiting_failsIfConditionHasUnhandledRejection() {
|
|
1056
|
-
var callbacks = callbackPair(null, assertIsStubError);
|
|
1057
|
-
scheduleWait(function() {
|
|
1058
|
-
webdriver.promise.controlFlow().execute(throwStubError);
|
|
1059
|
-
}, 0, 'goes boom').then(callbacks.callback, callbacks.errback);
|
|
1060
|
-
schedule('post wait');
|
|
1061
|
-
|
|
1062
|
-
return waitForIdle().
|
|
1063
|
-
then(callbacks.assertErrback).
|
|
1064
|
-
then(function() {
|
|
1065
|
-
assertFlowHistory('0: goes boom', 'post wait');
|
|
1066
|
-
});
|
|
1067
|
-
}
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
function testWaiting_failsIfConditionHasAFailedSubtask() {
|
|
1071
|
-
var callbacks = callbackPair(null, assertIsStubError);
|
|
1072
|
-
var count = 0;
|
|
1073
|
-
scheduleWait(function() {
|
|
1074
|
-
scheduleAction('maybe throw', function() {
|
|
1075
|
-
if (++count == 2) {
|
|
1076
|
-
throw new StubError;
|
|
1077
|
-
}
|
|
1078
|
-
});
|
|
1079
|
-
}, 100, 'waiting').then(callbacks.callback, callbacks.errback);
|
|
1080
|
-
schedule('post wait');
|
|
1081
|
-
|
|
1082
|
-
return waitForIdle().then(function() {
|
|
1083
|
-
assertEquals(2, count);
|
|
1084
|
-
assertFlowHistory(
|
|
1085
|
-
'0: waiting', 'maybe throw',
|
|
1086
|
-
'1: waiting', 'maybe throw',
|
|
1087
|
-
'post wait');
|
|
1088
|
-
});
|
|
1089
|
-
}
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
function testWaiting_pollingLoopWaitsForAllScheduledTasksInCondition() {
|
|
1093
|
-
var count = 0;
|
|
1094
|
-
scheduleWait(function() {
|
|
1095
|
-
scheduleAction('increment count', function() { ++count; });
|
|
1096
|
-
return count >= 3;
|
|
1097
|
-
}, 100, 'counting to 3');
|
|
1098
|
-
schedule('post wait');
|
|
1099
|
-
|
|
1100
|
-
return waitForIdle().then(function() {
|
|
1101
|
-
assertEquals(4, count);
|
|
1102
|
-
assertFlowHistory(
|
|
1103
|
-
'0: counting to 3', 'increment count',
|
|
1104
|
-
'1: counting to 3', 'increment count',
|
|
1105
|
-
'2: counting to 3', 'increment count',
|
|
1106
|
-
'3: counting to 3', 'increment count',
|
|
1107
|
-
'post wait');
|
|
1108
|
-
});
|
|
1109
|
-
}
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
function testWaiting_waitsForeverOnAZeroTimeout() {
|
|
1113
|
-
var done = false;
|
|
1114
|
-
setTimeout(function() {
|
|
1115
|
-
done = true;
|
|
1116
|
-
}, 150);
|
|
1117
|
-
var waitResult = scheduleWait(function() {
|
|
1118
|
-
return done;
|
|
1119
|
-
}, 0);
|
|
1120
|
-
|
|
1121
|
-
return timeout(75).then(function() {
|
|
1122
|
-
assertFalse(done);
|
|
1123
|
-
return timeout(100);
|
|
1124
|
-
}).then(function() {
|
|
1125
|
-
assertTrue(done);
|
|
1126
|
-
return waitResult;
|
|
1127
|
-
});
|
|
1128
|
-
}
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
function testWaiting_waitsForeverIfTimeoutOmitted() {
|
|
1132
|
-
var done = false;
|
|
1133
|
-
setTimeout(function() {
|
|
1134
|
-
done = true;
|
|
1135
|
-
}, 150);
|
|
1136
|
-
var waitResult = scheduleWait(function() {
|
|
1137
|
-
return done;
|
|
1138
|
-
});
|
|
1139
|
-
|
|
1140
|
-
return timeout(75).then(function() {
|
|
1141
|
-
assertFalse(done);
|
|
1142
|
-
return timeout(100);
|
|
1143
|
-
}).then(function() {
|
|
1144
|
-
assertTrue(done);
|
|
1145
|
-
return waitResult;
|
|
1146
|
-
});
|
|
1147
|
-
}
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
function testWaiting_timesOut_nonZeroTimeout() {
|
|
1151
|
-
var count = 0;
|
|
1152
|
-
scheduleWait(function() {
|
|
1153
|
-
count += 1;
|
|
1154
|
-
var ms = count === 2 ? 65 : 5;
|
|
1155
|
-
return webdriver.promise.delayed(ms).then(function() {
|
|
1156
|
-
return false;
|
|
1157
|
-
});
|
|
1158
|
-
}, 60, 'counting to 3');
|
|
1159
|
-
return waitForAbort().then(function(e) {
|
|
1160
|
-
switch (count) {
|
|
1161
|
-
case 1:
|
|
1162
|
-
assertFlowHistory('0: counting to 3');
|
|
1163
|
-
break;
|
|
1164
|
-
case 2:
|
|
1165
|
-
assertFlowHistory('0: counting to 3', '1: counting to 3');
|
|
1166
|
-
break;
|
|
1167
|
-
default:
|
|
1168
|
-
fail('unexpected polling count: ' + count);
|
|
1169
|
-
}
|
|
1170
|
-
assertRegExp(/^counting to 3\nWait timed out after \d+ms$/, e.message);
|
|
1171
|
-
});
|
|
1172
|
-
}
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
function testWaiting_shouldFailIfConditionReturnsARejectedPromise() {
|
|
1176
|
-
scheduleWait(function() {
|
|
1177
|
-
return webdriver.promise.rejected(new StubError);
|
|
1178
|
-
}, 100, 'returns rejected promise on first pass');
|
|
1179
|
-
return waitForAbort().then(assertIsStubError);
|
|
1180
|
-
}
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
function testWaiting_scheduleWithIntermittentWaits() {
|
|
1184
|
-
schedule('a');
|
|
1185
|
-
scheduleWait(function() { return true; }, 0, 'wait 1');
|
|
1186
|
-
schedule('b');
|
|
1187
|
-
scheduleWait(function() { return true; }, 0, 'wait 2');
|
|
1188
|
-
schedule('c');
|
|
1189
|
-
scheduleWait(function() { return true; }, 0, 'wait 3');
|
|
1190
|
-
|
|
1191
|
-
return waitForIdle().then(function() {
|
|
1192
|
-
assertFlowHistory('a', '0: wait 1', 'b', '0: wait 2', 'c', '0: wait 3');
|
|
1193
|
-
});
|
|
1194
|
-
}
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
function testWaiting_scheduleWithIntermittentAndNestedWaits() {
|
|
1198
|
-
schedule('a');
|
|
1199
|
-
scheduleWait(function() { return true; }, 0, 'wait 1').
|
|
1200
|
-
then(function() {
|
|
1201
|
-
schedule('d');
|
|
1202
|
-
scheduleWait(function() { return true; }, 0, 'wait 2');
|
|
1203
|
-
schedule('e');
|
|
1204
|
-
});
|
|
1205
|
-
schedule('b');
|
|
1206
|
-
scheduleWait(function() { return true; }, 0, 'wait 3');
|
|
1207
|
-
schedule('c');
|
|
1208
|
-
scheduleWait(function() { return true; }, 0, 'wait 4');
|
|
1209
|
-
|
|
1210
|
-
return waitForIdle().then(function() {
|
|
1211
|
-
assertFlowHistory(
|
|
1212
|
-
'a', '0: wait 1', 'd', '0: wait 2', 'e', 'b', '0: wait 3', 'c',
|
|
1213
|
-
'0: wait 4');
|
|
1214
|
-
});
|
|
1215
|
-
}
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
function testWait_requiresConditionToBeAPromiseOrFunction() {
|
|
1219
|
-
assertThrows(function() {
|
|
1220
|
-
flow.wait(1234, 0);
|
|
1221
|
-
});
|
|
1222
|
-
flow.wait(function() { return true;}, 0);
|
|
1223
|
-
flow.wait(webdriver.promise.fulfilled(), 0);
|
|
1224
|
-
return waitForIdle();
|
|
1225
|
-
}
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
function testWait_promiseThatDoesNotResolveBeforeTimeout() {
|
|
1229
|
-
var d = webdriver.promise.defer();
|
|
1230
|
-
flow.wait(d.promise, 5).then(fail, function(e) {
|
|
1231
|
-
assertRegExp(/Timed out waiting for promise to resolve after \d+ms/,
|
|
1232
|
-
e.message);
|
|
1233
|
-
});
|
|
1234
|
-
return waitForIdle().then(function() {
|
|
1235
|
-
assertTrue('Promise should not be cancelled', d.promise.isPending());
|
|
1236
|
-
});
|
|
1237
|
-
}
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
function testWait_unboundedWaitOnPromiseResolution() {
|
|
1241
|
-
var messages = [];
|
|
1242
|
-
var d = webdriver.promise.defer();
|
|
1243
|
-
var waitResult = flow.wait(d.promise).then(function(value) {
|
|
1244
|
-
messages.push('b');
|
|
1245
|
-
assertEquals(1234, value);
|
|
1246
|
-
});
|
|
1247
|
-
setTimeout(function() {
|
|
1248
|
-
messages.push('a');
|
|
1249
|
-
}, 5);
|
|
1250
|
-
|
|
1251
|
-
timeout(10).then(function() {
|
|
1252
|
-
assertArrayEquals(['a'], messages);
|
|
1253
|
-
assertTrue(waitResult.isPending());
|
|
1254
|
-
d.fulfill(1234);
|
|
1255
|
-
return waitResult;
|
|
1256
|
-
}).then(function() {
|
|
1257
|
-
assertArrayEquals(['a', 'b'], messages);
|
|
1258
|
-
});
|
|
1259
|
-
|
|
1260
|
-
return waitForIdle();
|
|
1261
|
-
}
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
function testSubtasks() {
|
|
1265
|
-
schedule('a');
|
|
1266
|
-
scheduleAction('sub-tasks', function() {
|
|
1267
|
-
schedule('c');
|
|
1268
|
-
schedule('d');
|
|
1269
|
-
});
|
|
1270
|
-
schedule('b');
|
|
1271
|
-
|
|
1272
|
-
return waitForIdle().then(function() {
|
|
1273
|
-
assertFlowHistory('a', 'sub-tasks', 'c', 'd', 'b');
|
|
1274
|
-
});
|
|
1275
|
-
}
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
function testSubtasks_nesting() {
|
|
1279
|
-
schedule('a');
|
|
1280
|
-
scheduleAction('sub-tasks', function() {
|
|
1281
|
-
schedule('b');
|
|
1282
|
-
scheduleAction('sub-sub-tasks', function() {
|
|
1283
|
-
schedule('c');
|
|
1284
|
-
schedule('d');
|
|
1285
|
-
});
|
|
1286
|
-
schedule('e');
|
|
1287
|
-
});
|
|
1288
|
-
schedule('f');
|
|
1289
|
-
|
|
1290
|
-
return waitForIdle().then(function() {
|
|
1291
|
-
assertFlowHistory(
|
|
1292
|
-
'a', 'sub-tasks', 'b', 'sub-sub-tasks', 'c', 'd', 'e', 'f');
|
|
1293
|
-
});
|
|
1294
|
-
}
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
function testSubtasks_taskReturnsSubTaskResult_1() {
|
|
1298
|
-
schedule('a');
|
|
1299
|
-
scheduleAction('sub-tasks', function() {
|
|
1300
|
-
return schedule('c');
|
|
1301
|
-
});
|
|
1302
|
-
schedule('b');
|
|
1303
|
-
|
|
1304
|
-
return waitForIdle().then(function() {
|
|
1305
|
-
assertFlowHistory('a', 'sub-tasks', 'c', 'b');
|
|
1306
|
-
});
|
|
1307
|
-
}
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
function testSubtasks_taskReturnsSubTaskResult_2() {
|
|
1311
|
-
var callback;
|
|
1312
|
-
schedule('a');
|
|
1313
|
-
schedule('sub-tasks', webdriver.promise.fulfilled(123)).
|
|
1314
|
-
then(callback = callbackHelper(function(value) {
|
|
1315
|
-
assertEquals(123, value);
|
|
1316
|
-
}));
|
|
1317
|
-
schedule('b');
|
|
1318
|
-
|
|
1319
|
-
return waitForIdle().then(function() {
|
|
1320
|
-
assertFlowHistory('a', 'sub-tasks','b');
|
|
1321
|
-
callback.assertCalled();
|
|
1322
|
-
});
|
|
1323
|
-
}
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
function testSubtasks_taskReturnsPromiseThatDependsOnSubtask_1() {
|
|
1327
|
-
scheduleAction('a', function() {
|
|
1328
|
-
return webdriver.promise.delayed(10).then(function() {
|
|
1329
|
-
schedule('b');
|
|
1330
|
-
});
|
|
1331
|
-
});
|
|
1332
|
-
schedule('c');
|
|
1333
|
-
return waitForIdle().then(function() {
|
|
1334
|
-
assertFlowHistory('a', 'b', 'c');
|
|
1335
|
-
});
|
|
1336
|
-
}
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
function testSubtasks_taskReturnsPromiseThatDependsOnSubtask_2() {
|
|
1340
|
-
scheduleAction('a', function() {
|
|
1341
|
-
return webdriver.promise.fulfilled().then(function() {
|
|
1342
|
-
schedule('b');
|
|
1343
|
-
});
|
|
1344
|
-
});
|
|
1345
|
-
schedule('c');
|
|
1346
|
-
return waitForIdle().then(function() {
|
|
1347
|
-
assertFlowHistory('a', 'b', 'c');
|
|
1348
|
-
});
|
|
1349
|
-
}
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
function testSubtasks_taskReturnsPromiseThatDependsOnSubtask_3() {
|
|
1353
|
-
scheduleAction('a', function() {
|
|
1354
|
-
return webdriver.promise.delayed(10).then(function() {
|
|
1355
|
-
return schedule('b');
|
|
1356
|
-
});
|
|
1357
|
-
});
|
|
1358
|
-
schedule('c');
|
|
1359
|
-
return waitForIdle().then(function() {
|
|
1360
|
-
assertFlowHistory('a', 'b', 'c');
|
|
1361
|
-
});
|
|
1362
|
-
}
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
function testSubtasks_taskReturnsPromiseThatDependsOnSubtask_4() {
|
|
1366
|
-
scheduleAction('a', function() {
|
|
1367
|
-
return webdriver.promise.delayed(5).then(function() {
|
|
1368
|
-
return webdriver.promise.delayed(5).then(function() {
|
|
1369
|
-
return schedule('b');
|
|
1370
|
-
});
|
|
1371
|
-
});
|
|
1372
|
-
});
|
|
1373
|
-
schedule('c');
|
|
1374
|
-
return waitForIdle().then(function() {
|
|
1375
|
-
assertFlowHistory('a', 'b', 'c');
|
|
1376
|
-
});
|
|
1377
|
-
}
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
function testSubtasks_taskReturnsPromiseThatDependsOnSubtask_5() {
|
|
1381
|
-
scheduleAction('a', function() {
|
|
1382
|
-
return webdriver.promise.delayed(5).then(function() {
|
|
1383
|
-
return webdriver.promise.delayed(5).then(function() {
|
|
1384
|
-
return webdriver.promise.delayed(5).then(function() {
|
|
1385
|
-
return webdriver.promise.delayed(5).then(function() {
|
|
1386
|
-
return schedule('b');
|
|
1387
|
-
});
|
|
1388
|
-
});
|
|
1389
|
-
});
|
|
1390
|
-
});
|
|
1391
|
-
});
|
|
1392
|
-
schedule('c');
|
|
1393
|
-
return waitForIdle().then(function() {
|
|
1394
|
-
assertFlowHistory('a', 'b', 'c');
|
|
1395
|
-
});
|
|
1396
|
-
}
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
function testSubtasks_taskReturnsPromiseThatDependsOnSubtask_6() {
|
|
1400
|
-
scheduleAction('a', function() {
|
|
1401
|
-
return webdriver.promise.delayed(5).
|
|
1402
|
-
then(function() { return webdriver.promise.delayed(5) }).
|
|
1403
|
-
then(function() { return webdriver.promise.delayed(5) }).
|
|
1404
|
-
then(function() { return webdriver.promise.delayed(5) }).
|
|
1405
|
-
then(function() { return schedule('b'); });
|
|
1406
|
-
});
|
|
1407
|
-
schedule('c');
|
|
1408
|
-
return waitForIdle().then(function() {
|
|
1409
|
-
assertFlowHistory('a', 'b', 'c');
|
|
1410
|
-
});
|
|
1411
|
-
}
|
|
1412
|
-
|
|
1413
|
-
function testSubtasks_subTaskFails_1() {
|
|
1414
|
-
schedule('a');
|
|
1415
|
-
scheduleAction('sub-tasks', function() {
|
|
1416
|
-
scheduleAction('sub-task that fails', throwStubError);
|
|
1417
|
-
});
|
|
1418
|
-
schedule('should never execute');
|
|
1419
|
-
|
|
1420
|
-
return waitForAbort().
|
|
1421
|
-
then(assertIsStubError).
|
|
1422
|
-
then(function() {
|
|
1423
|
-
assertFlowHistory('a', 'sub-tasks', 'sub-task that fails');
|
|
1424
|
-
});
|
|
1425
|
-
}
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
function testSubtasks_subTaskFails_2() {
|
|
1429
|
-
schedule('a');
|
|
1430
|
-
scheduleAction('sub-tasks', function() {
|
|
1431
|
-
return webdriver.promise.rejected(new StubError);
|
|
1432
|
-
});
|
|
1433
|
-
schedule('should never execute');
|
|
1434
|
-
|
|
1435
|
-
return waitForAbort().
|
|
1436
|
-
then(assertIsStubError).
|
|
1437
|
-
then(function() {
|
|
1438
|
-
assertFlowHistory('a', 'sub-tasks');
|
|
1439
|
-
});
|
|
1440
|
-
}
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
function testSubtasks_subTaskFails_3() {
|
|
1444
|
-
var callbacks = callbackPair(null, assertIsStubError);
|
|
1445
|
-
|
|
1446
|
-
schedule('a');
|
|
1447
|
-
scheduleAction('sub-tasks', function() {
|
|
1448
|
-
return webdriver.promise.rejected(new StubError);
|
|
1449
|
-
}).then(callbacks.callback, callbacks.errback);
|
|
1450
|
-
schedule('b');
|
|
1451
|
-
|
|
1452
|
-
return waitForIdle().
|
|
1453
|
-
then(function() {
|
|
1454
|
-
assertFlowHistory('a', 'sub-tasks', 'b');
|
|
1455
|
-
callbacks.assertErrback();
|
|
1456
|
-
});
|
|
1457
|
-
}
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
function testEventLoopWaitsOnPendingPromiseRejections_oneRejection() {
|
|
1461
|
-
var d = new webdriver.promise.Deferred;
|
|
1462
|
-
scheduleAction('one', function() {
|
|
1463
|
-
return d.promise;
|
|
1464
|
-
});
|
|
1465
|
-
scheduleAction('two', goog.nullFunction);
|
|
1466
|
-
|
|
1467
|
-
return timeout(50).then(function() {
|
|
1468
|
-
assertFlowHistory('one');
|
|
1469
|
-
d.reject(new StubError);
|
|
1470
|
-
return waitForAbort();
|
|
1471
|
-
}).
|
|
1472
|
-
then(assertIsStubError).
|
|
1473
|
-
then(function() {
|
|
1474
|
-
assertFlowHistory('one');
|
|
1475
|
-
});
|
|
1476
|
-
}
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
function testEventLoopWaitsOnPendingPromiseRejections_multipleRejections() {
|
|
1480
|
-
var once = Error('once');
|
|
1481
|
-
var twice = Error('twice');
|
|
1482
|
-
|
|
1483
|
-
scheduleAction('one', function() {
|
|
1484
|
-
webdriver.promise.rejected(once);
|
|
1485
|
-
webdriver.promise.rejected(twice);
|
|
1486
|
-
});
|
|
1487
|
-
var twoResult = scheduleAction('two', goog.nullFunction);
|
|
1488
|
-
|
|
1489
|
-
flow.removeAllListeners(
|
|
1490
|
-
webdriver.promise.ControlFlow.EventType.UNCAUGHT_EXCEPTION);
|
|
1491
|
-
return new goog.Promise(function(fulfill, reject) {
|
|
1492
|
-
setTimeout(function() {
|
|
1493
|
-
reject(Error('Should have reported the two errors by now'));
|
|
1494
|
-
}, 50);
|
|
1495
|
-
flow.on(
|
|
1496
|
-
webdriver.promise.ControlFlow.EventType.UNCAUGHT_EXCEPTION,
|
|
1497
|
-
fulfill);
|
|
1498
|
-
}).then(function(e) {
|
|
1499
|
-
assertTrue(e instanceof webdriver.promise.MultipleUnhandledRejectionError);
|
|
1500
|
-
// TODO: switch to Array.from when we drop node 0.12.x
|
|
1501
|
-
var errors = [];
|
|
1502
|
-
for (var e2 of e.errors) {
|
|
1503
|
-
errors.push(e2);
|
|
1504
|
-
}
|
|
1505
|
-
assertArrayEquals([once, twice], errors);
|
|
1506
|
-
assertFlowHistory('one');
|
|
1507
|
-
assertFalse('Did not cancel the second task', twoResult.isPending());
|
|
1508
|
-
});
|
|
1509
|
-
}
|
|
1510
|
-
|
|
1511
|
-
function testCancelsPromiseReturnedByCallbackIfFrameFails_promiseCallback() {
|
|
1512
|
-
var chainPair = callbackPair(null, assertIsStubError);
|
|
1513
|
-
var deferredPair = callbackPair(null, function(e) {
|
|
1514
|
-
assertEquals('callback result should be cancelled',
|
|
1515
|
-
'CancellationError: StubError',
|
|
1516
|
-
e.toString());
|
|
1517
|
-
});
|
|
1518
|
-
|
|
1519
|
-
var d = new webdriver.promise.Deferred();
|
|
1520
|
-
d.then(deferredPair.callback, deferredPair.errback);
|
|
1521
|
-
|
|
1522
|
-
webdriver.promise.fulfilled().
|
|
1523
|
-
then(function() {
|
|
1524
|
-
scheduleAction('boom', throwStubError);
|
|
1525
|
-
schedule('this should not run');
|
|
1526
|
-
return d.promise;
|
|
1527
|
-
}).
|
|
1528
|
-
then(chainPair.callback, chainPair.errback);
|
|
1529
|
-
|
|
1530
|
-
return waitForIdle().then(function() {
|
|
1531
|
-
assertFlowHistory('boom');
|
|
1532
|
-
chainPair.assertErrback('chain errback not invoked');
|
|
1533
|
-
deferredPair.assertErrback('deferred errback not invoked');
|
|
1534
|
-
});
|
|
1535
|
-
}
|
|
1536
|
-
|
|
1537
|
-
function testCancelsPromiseReturnedByCallbackIfFrameFails_taskCallback() {
|
|
1538
|
-
var chainPair = callbackPair(null, assertIsStubError);
|
|
1539
|
-
var deferredPair = callbackPair(null, function(e) {
|
|
1540
|
-
assertEquals('callback result should be cancelled',
|
|
1541
|
-
'CancellationError: StubError',
|
|
1542
|
-
e.toString());
|
|
1543
|
-
});
|
|
1544
|
-
|
|
1545
|
-
var d = new webdriver.promise.Deferred();
|
|
1546
|
-
d.then(deferredPair.callback, deferredPair.errback);
|
|
1547
|
-
|
|
1548
|
-
schedule('a').
|
|
1549
|
-
then(function() {
|
|
1550
|
-
scheduleAction('boom', throwStubError);
|
|
1551
|
-
schedule('this should not run');
|
|
1552
|
-
return d.promise;
|
|
1553
|
-
}).
|
|
1554
|
-
then(chainPair.callback, chainPair.errback);
|
|
1555
|
-
|
|
1556
|
-
return waitForIdle().then(function() {
|
|
1557
|
-
assertFlowHistory('a', 'boom');
|
|
1558
|
-
chainPair.assertErrback('chain errback not invoked');
|
|
1559
|
-
deferredPair.assertErrback('deferred errback not invoked');
|
|
1560
|
-
});
|
|
1561
|
-
}
|
|
1562
|
-
|
|
1563
|
-
function testMaintainsOrderInCallbacksWhenATaskReturnsAPromise() {
|
|
1564
|
-
schedule('__start__', webdriver.promise.fulfilled()).
|
|
1565
|
-
then(function() {
|
|
1566
|
-
webdriver.test.testutil.messages.push('a');
|
|
1567
|
-
schedulePush('b');
|
|
1568
|
-
webdriver.test.testutil.messages.push('c');
|
|
1569
|
-
}).
|
|
1570
|
-
then(function() {
|
|
1571
|
-
webdriver.test.testutil.messages.push('d');
|
|
1572
|
-
});
|
|
1573
|
-
schedulePush('e');
|
|
1574
|
-
|
|
1575
|
-
return waitForIdle().then(function() {
|
|
1576
|
-
assertFlowHistory('__start__', 'b', 'e');
|
|
1577
|
-
webdriver.test.testutil.assertMessages('a', 'c', 'b', 'd', 'e');
|
|
1578
|
-
});
|
|
1579
|
-
}
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
function assertFlowIs(flow) {
|
|
1583
|
-
assertEquals(flow, webdriver.promise.controlFlow());
|
|
1584
|
-
}
|
|
1585
|
-
|
|
1586
|
-
function testOwningFlowIsActivatedForExecutingTasks() {
|
|
1587
|
-
var defaultFlow = webdriver.promise.controlFlow();
|
|
1588
|
-
var order = [];
|
|
1589
|
-
|
|
1590
|
-
webdriver.promise.createFlow(function(flow) {
|
|
1591
|
-
assertFlowIs(flow);
|
|
1592
|
-
order.push(0);
|
|
1593
|
-
|
|
1594
|
-
defaultFlow.execute(function() {
|
|
1595
|
-
assertFlowIs(defaultFlow);
|
|
1596
|
-
order.push(1);
|
|
1597
|
-
});
|
|
1598
|
-
});
|
|
1599
|
-
|
|
1600
|
-
return waitForIdle().then(function() {
|
|
1601
|
-
assertFlowIs(defaultFlow);
|
|
1602
|
-
assertArrayEquals([0, 1], order);
|
|
1603
|
-
});
|
|
1604
|
-
}
|
|
1605
|
-
|
|
1606
|
-
function testCreateFlowReturnsPromisePairedWithCreatedFlow() {
|
|
1607
|
-
return new goog.Promise(function(fulfill, reject) {
|
|
1608
|
-
var newFlow;
|
|
1609
|
-
webdriver.promise.createFlow(function(flow) {
|
|
1610
|
-
newFlow = flow;
|
|
1611
|
-
assertFlowIs(newFlow);
|
|
1612
|
-
}).then(function() {
|
|
1613
|
-
assertFlowIs(newFlow);
|
|
1614
|
-
waitForIdle(newFlow).then(fulfill, reject);
|
|
1615
|
-
});
|
|
1616
|
-
});
|
|
1617
|
-
}
|
|
1618
|
-
|
|
1619
|
-
function testDeferredFactoriesCreateForActiveFlow_defaultFlow() {
|
|
1620
|
-
var e = Error();
|
|
1621
|
-
var defaultFlow = webdriver.promise.controlFlow();
|
|
1622
|
-
webdriver.promise.fulfilled().then(function() {
|
|
1623
|
-
assertFlowIs(defaultFlow);
|
|
1624
|
-
});
|
|
1625
|
-
webdriver.promise.rejected(e).then(null, function(err) {
|
|
1626
|
-
assertEquals(e, err);
|
|
1627
|
-
assertFlowIs(defaultFlow);
|
|
1628
|
-
});
|
|
1629
|
-
webdriver.promise.defer().then(function() {
|
|
1630
|
-
assertFlowIs(defaultFlow);
|
|
1631
|
-
});
|
|
1632
|
-
|
|
1633
|
-
return waitForIdle();
|
|
1634
|
-
}
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
function testDeferredFactoriesCreateForActiveFlow_newFlow() {
|
|
1638
|
-
var e = Error();
|
|
1639
|
-
var newFlow = new webdriver.promise.ControlFlow;
|
|
1640
|
-
newFlow.execute(function() {
|
|
1641
|
-
webdriver.promise.fulfilled().then(function() {
|
|
1642
|
-
assertFlowIs(newFlow);
|
|
1643
|
-
});
|
|
1644
|
-
|
|
1645
|
-
webdriver.promise.rejected(e).then(null, function(err) {
|
|
1646
|
-
assertEquals(e, err);
|
|
1647
|
-
assertFlowIs(newFlow);
|
|
1648
|
-
});
|
|
1649
|
-
|
|
1650
|
-
webdriver.promise.defer().then(function() {
|
|
1651
|
-
assertFlowIs(newFlow);
|
|
1652
|
-
});
|
|
1653
|
-
}).then(function() {
|
|
1654
|
-
assertFlowIs(newFlow);
|
|
1655
|
-
});
|
|
1656
|
-
|
|
1657
|
-
return waitForIdle(newFlow);
|
|
1658
|
-
}
|
|
1659
|
-
|
|
1660
|
-
function testFlowsSynchronizeWithThemselvesNotEachOther() {
|
|
1661
|
-
var defaultFlow = webdriver.promise.controlFlow();
|
|
1662
|
-
schedulePush('a', 'a');
|
|
1663
|
-
webdriver.promise.controlFlow().timeout(250);
|
|
1664
|
-
schedulePush('b', 'b');
|
|
1665
|
-
|
|
1666
|
-
webdriver.promise.createFlow(function() {
|
|
1667
|
-
schedulePush('c', 'c');
|
|
1668
|
-
schedulePush('d', 'd');
|
|
1669
|
-
});
|
|
1670
|
-
|
|
1671
|
-
return waitForIdle().then(function() {
|
|
1672
|
-
webdriver.test.testutil.assertMessages('a', 'c', 'd', 'b');
|
|
1673
|
-
});
|
|
1674
|
-
}
|
|
1675
|
-
|
|
1676
|
-
function testUnhandledErrorsAreReportedToTheOwningFlow() {
|
|
1677
|
-
var error1 = Error('e1');
|
|
1678
|
-
var error2 = Error('e2');
|
|
1679
|
-
|
|
1680
|
-
var defaultFlow = webdriver.promise.controlFlow();
|
|
1681
|
-
defaultFlow.removeAllListeners('uncaughtException');
|
|
1682
|
-
|
|
1683
|
-
var flow1Error = goog.Promise.withResolver();
|
|
1684
|
-
flow1Error.promise.then(function(value) {
|
|
1685
|
-
assertEquals(error2, value);
|
|
1686
|
-
});
|
|
1687
|
-
|
|
1688
|
-
var flow2Error = goog.Promise.withResolver();
|
|
1689
|
-
flow2Error.promise.then(function(value) {
|
|
1690
|
-
assertEquals(error1, value);
|
|
1691
|
-
});
|
|
1692
|
-
|
|
1693
|
-
webdriver.promise.createFlow(function(flow) {
|
|
1694
|
-
flow.once('uncaughtException', flow2Error.resolve);
|
|
1695
|
-
webdriver.promise.rejected(error1);
|
|
1696
|
-
|
|
1697
|
-
defaultFlow.once('uncaughtException', flow1Error.resolve);
|
|
1698
|
-
defaultFlow.execute(function() {
|
|
1699
|
-
webdriver.promise.rejected(error2);
|
|
1700
|
-
});
|
|
1701
|
-
});
|
|
1702
|
-
|
|
1703
|
-
return goog.Promise.all([flow1Error.promise, flow2Error.promise]);
|
|
1704
|
-
}
|
|
1705
|
-
|
|
1706
|
-
function testCanSynchronizeFlowsByReturningPromiseFromOneToAnother() {
|
|
1707
|
-
var flow1 = new webdriver.promise.ControlFlow;
|
|
1708
|
-
var flow1Done = goog.Promise.withResolver();
|
|
1709
|
-
flow1.once('idle', flow1Done.resolve);
|
|
1710
|
-
flow1.once('uncaughtException', flow1Done.reject);
|
|
1711
|
-
|
|
1712
|
-
var flow2 = new webdriver.promise.ControlFlow;
|
|
1713
|
-
var flow2Done = goog.Promise.withResolver();
|
|
1714
|
-
flow2.once('idle', flow2Done.resolve);
|
|
1715
|
-
flow2.once('uncaughtException', flow2Done.reject);
|
|
1716
|
-
|
|
1717
|
-
flow1.execute(function() {
|
|
1718
|
-
schedulePush('a', 'a');
|
|
1719
|
-
return webdriver.promise.delayed(25);
|
|
1720
|
-
}, 'start flow 1');
|
|
1721
|
-
|
|
1722
|
-
flow2.execute(function() {
|
|
1723
|
-
schedulePush('b', 'b');
|
|
1724
|
-
schedulePush('c', 'c');
|
|
1725
|
-
flow2.execute(function() {
|
|
1726
|
-
return flow1.execute(function() {
|
|
1727
|
-
schedulePush('d', 'd');
|
|
1728
|
-
}, 'flow 1 task');
|
|
1729
|
-
}, 'inject flow1 result into flow2');
|
|
1730
|
-
schedulePush('e', 'e');
|
|
1731
|
-
}, 'start flow 2');
|
|
1732
|
-
|
|
1733
|
-
return goog.Promise.all([flow1Done.promise, flow2Done.promise]).
|
|
1734
|
-
then(function() {
|
|
1735
|
-
webdriver.test.testutil.assertMessages('a', 'b', 'c', 'd', 'e');
|
|
1736
|
-
});
|
|
1737
|
-
}
|
|
1738
|
-
|
|
1739
|
-
function testFramesWaitToCompleteForPendingRejections() {
|
|
1740
|
-
return new goog.Promise(function(fulfill, reject) {
|
|
1741
|
-
|
|
1742
|
-
webdriver.promise.controlFlow().execute(function() {
|
|
1743
|
-
webdriver.promise.rejected(new StubError);
|
|
1744
|
-
}).then(fulfill, reject);
|
|
1745
|
-
|
|
1746
|
-
}).
|
|
1747
|
-
then(goog.partial(fail, 'expected to fail'), assertIsStubError).
|
|
1748
|
-
then(waitForIdle);
|
|
1749
|
-
}
|
|
1750
|
-
|
|
1751
|
-
function testSynchronizeErrorsPropagateToOuterFlow() {
|
|
1752
|
-
var outerFlow = new webdriver.promise.ControlFlow;
|
|
1753
|
-
var innerFlow = new webdriver.promise.ControlFlow;
|
|
1754
|
-
|
|
1755
|
-
var block = goog.Promise.withResolver();
|
|
1756
|
-
innerFlow.execute(function() {
|
|
1757
|
-
return block.promise;
|
|
1758
|
-
}, 'block inner flow');
|
|
1759
|
-
|
|
1760
|
-
outerFlow.execute(function() {
|
|
1761
|
-
block.resolve();
|
|
1762
|
-
return innerFlow.execute(function() {
|
|
1763
|
-
webdriver.promise.rejected(new StubError);
|
|
1764
|
-
}, 'trigger unhandled rejection error');
|
|
1765
|
-
}, 'run test');
|
|
1766
|
-
|
|
1767
|
-
return goog.Promise.all([
|
|
1768
|
-
waitForIdle(innerFlow),
|
|
1769
|
-
waitForAbort(outerFlow).then(assertIsStubError)
|
|
1770
|
-
]);
|
|
1771
|
-
}
|
|
1772
|
-
|
|
1773
|
-
function testFailsIfErrbackThrows() {
|
|
1774
|
-
webdriver.promise.rejected('').then(null, throwStubError);
|
|
1775
|
-
return waitForAbort().then(assertIsStubError);
|
|
1776
|
-
}
|
|
1777
|
-
|
|
1778
|
-
function testFailsIfCallbackReturnsRejectedPromise() {
|
|
1779
|
-
webdriver.promise.fulfilled().then(function() {
|
|
1780
|
-
return webdriver.promise.rejected(new StubError);
|
|
1781
|
-
});
|
|
1782
|
-
return waitForAbort().then(assertIsStubError);
|
|
1783
|
-
}
|
|
1784
|
-
|
|
1785
|
-
function testAbortsFrameIfTaskFails() {
|
|
1786
|
-
webdriver.promise.fulfilled().then(function() {
|
|
1787
|
-
webdriver.promise.controlFlow().execute(throwStubError);
|
|
1788
|
-
});
|
|
1789
|
-
return waitForAbort().then(assertIsStubError);
|
|
1790
|
-
}
|
|
1791
|
-
|
|
1792
|
-
function testAbortsFramePromisedChainedFromTaskIsNotHandled() {
|
|
1793
|
-
webdriver.promise.fulfilled().then(function() {
|
|
1794
|
-
webdriver.promise.controlFlow().execute(goog.nullFunction).
|
|
1795
|
-
then(throwStubError);
|
|
1796
|
-
});
|
|
1797
|
-
return waitForAbort().then(assertIsStubError);
|
|
1798
|
-
}
|
|
1799
|
-
|
|
1800
|
-
function testTrapsChainedUnhandledRejectionsWithinAFrame() {
|
|
1801
|
-
var pair = callbackPair(null, assertIsStubError);
|
|
1802
|
-
webdriver.promise.fulfilled().then(function() {
|
|
1803
|
-
webdriver.promise.controlFlow().execute(goog.nullFunction).
|
|
1804
|
-
then(throwStubError);
|
|
1805
|
-
}).then(pair.callback, pair.errback);
|
|
1806
|
-
|
|
1807
|
-
return waitForIdle().then(pair.assertErrback);
|
|
1808
|
-
}
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
function testCancelsRemainingTasksIfFrameThrowsDuringScheduling() {
|
|
1812
|
-
var task1, task2;
|
|
1813
|
-
var pair = callbackPair(null, assertIsStubError);
|
|
1814
|
-
var flow = webdriver.promise.controlFlow();
|
|
1815
|
-
flow.execute(function() {
|
|
1816
|
-
task1 = flow.execute(goog.nullFunction);
|
|
1817
|
-
task2 = flow.execute(goog.nullFunction);
|
|
1818
|
-
throw new StubError;
|
|
1819
|
-
}).then(pair.callback, pair.errback);
|
|
1820
|
-
|
|
1821
|
-
return waitForIdle().
|
|
1822
|
-
then(pair.assertErrback).
|
|
1823
|
-
then(function() {
|
|
1824
|
-
assertFalse(task1.isPending());
|
|
1825
|
-
pair = callbackPair();
|
|
1826
|
-
return task1.then(pair.callback, pair.errback);
|
|
1827
|
-
}).
|
|
1828
|
-
then(function() {
|
|
1829
|
-
pair.assertErrback();
|
|
1830
|
-
assertFalse(task2.isPending());
|
|
1831
|
-
pair = callbackPair();
|
|
1832
|
-
return task2.then(pair.callback, pair.errback);
|
|
1833
|
-
}).
|
|
1834
|
-
then(function() {
|
|
1835
|
-
pair.assertErrback();
|
|
1836
|
-
});
|
|
1837
|
-
}
|
|
1838
|
-
|
|
1839
|
-
function testCancelsRemainingTasksInFrameIfATaskFails() {
|
|
1840
|
-
var task;
|
|
1841
|
-
var pair = callbackPair(null, assertIsStubError);
|
|
1842
|
-
var flow = webdriver.promise.controlFlow();
|
|
1843
|
-
flow.execute(function() {
|
|
1844
|
-
flow.execute(throwStubError);
|
|
1845
|
-
task = flow.execute(goog.nullFunction);
|
|
1846
|
-
}).then(pair.callback, pair.errback);
|
|
1847
|
-
|
|
1848
|
-
return waitForIdle().then(pair.assertErrback).then(function() {
|
|
1849
|
-
assertFalse(task.isPending());
|
|
1850
|
-
pair = callbackPair();
|
|
1851
|
-
task.then(pair.callback, pair.errback);
|
|
1852
|
-
}).then(function() {
|
|
1853
|
-
pair.assertErrback();
|
|
1854
|
-
});
|
|
1855
|
-
}
|
|
1856
|
-
|
|
1857
|
-
function testDoesNotModifyRejectionErrorIfPromiseNotInsideAFlow() {
|
|
1858
|
-
var error = Error('original message');
|
|
1859
|
-
var originalStack = error.stack;
|
|
1860
|
-
var originalStr = error.toString();
|
|
1861
|
-
|
|
1862
|
-
var pair = callbackPair(null, function(e) {
|
|
1863
|
-
assertEquals(error, e);
|
|
1864
|
-
assertEquals('original message', e.message);
|
|
1865
|
-
assertEquals(originalStack, e.stack);
|
|
1866
|
-
assertEquals(originalStr, e.toString());
|
|
1867
|
-
});
|
|
1868
|
-
|
|
1869
|
-
webdriver.promise.rejected(error).then(pair.callback, pair.errback);
|
|
1870
|
-
return waitForIdle().then(pair.assertErrback);
|
|
1871
|
-
}
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
/** See https://github.com/SeleniumHQ/selenium/issues/444 */
|
|
1875
|
-
function testMaintainsOrderWithPromiseChainsCreatedWithinAForeach_1() {
|
|
1876
|
-
var messages = [];
|
|
1877
|
-
flow.execute(function() {
|
|
1878
|
-
return webdriver.promise.fulfilled(['a', 'b', 'c', 'd']);
|
|
1879
|
-
}, 'start').then(function(steps) {
|
|
1880
|
-
steps.forEach(function(step) {
|
|
1881
|
-
webdriver.promise.fulfilled(step)
|
|
1882
|
-
.then(function() {
|
|
1883
|
-
messages.push(step + '.1');
|
|
1884
|
-
}).then(function() {
|
|
1885
|
-
messages.push(step + '.2');
|
|
1886
|
-
});
|
|
1887
|
-
})
|
|
1888
|
-
});
|
|
1889
|
-
return waitForIdle().then(function() {
|
|
1890
|
-
assertArrayEquals(
|
|
1891
|
-
['a.1', 'a.2', 'b.1', 'b.2', 'c.1', 'c.2', 'd.1', 'd.2'],
|
|
1892
|
-
messages);
|
|
1893
|
-
});
|
|
1894
|
-
}
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
/** See https://github.com/SeleniumHQ/selenium/issues/444 */
|
|
1898
|
-
function testMaintainsOrderWithPromiseChainsCreatedWithinAForeach_2() {
|
|
1899
|
-
var messages = [];
|
|
1900
|
-
flow.execute(function() {
|
|
1901
|
-
return webdriver.promise.fulfilled(['a', 'b', 'c', 'd']);
|
|
1902
|
-
}, 'start').then(function(steps) {
|
|
1903
|
-
steps.forEach(function(step) {
|
|
1904
|
-
webdriver.promise.fulfilled(step)
|
|
1905
|
-
.then(function() {
|
|
1906
|
-
messages.push(step + '.1');
|
|
1907
|
-
}).then(function() {
|
|
1908
|
-
flow.execute(function() {}, step + '.2').then(function() {
|
|
1909
|
-
messages.push(step + '.2');
|
|
1910
|
-
});
|
|
1911
|
-
});
|
|
1912
|
-
})
|
|
1913
|
-
});
|
|
1914
|
-
return waitForIdle().then(function() {
|
|
1915
|
-
assertArrayEquals(
|
|
1916
|
-
['a.1', 'a.2', 'b.1', 'b.2', 'c.1', 'c.2', 'd.1', 'd.2'],
|
|
1917
|
-
messages);
|
|
1918
|
-
});
|
|
1919
|
-
}
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
/** See https://github.com/SeleniumHQ/selenium/issues/444 */
|
|
1923
|
-
function testMaintainsOrderWithPromiseChainsCreatedWithinAForeach_3() {
|
|
1924
|
-
var messages = [];
|
|
1925
|
-
flow.execute(function() {
|
|
1926
|
-
return webdriver.promise.fulfilled(['a', 'b', 'c', 'd']);
|
|
1927
|
-
}, 'start').then(function(steps) {
|
|
1928
|
-
steps.forEach(function(step) {
|
|
1929
|
-
webdriver.promise.fulfilled(step)
|
|
1930
|
-
.then(function(){})
|
|
1931
|
-
.then(function() {
|
|
1932
|
-
messages.push(step + '.1');
|
|
1933
|
-
return flow.execute(function() {}, step + '.1');
|
|
1934
|
-
}).then(function() {
|
|
1935
|
-
flow.execute(function() {}, step + '.2').then(function(text) {
|
|
1936
|
-
messages.push(step + '.2');
|
|
1937
|
-
});
|
|
1938
|
-
});
|
|
1939
|
-
})
|
|
1940
|
-
});
|
|
1941
|
-
return waitForIdle().then(function() {
|
|
1942
|
-
assertArrayEquals(
|
|
1943
|
-
['a.1', 'a.2', 'b.1', 'b.2', 'c.1', 'c.2', 'd.1', 'd.2'],
|
|
1944
|
-
messages);
|
|
1945
|
-
});
|
|
1946
|
-
}
|
|
1947
|
-
|
|
1948
|
-
/** See https://github.com/SeleniumHQ/selenium/issues/363 */
|
|
1949
|
-
function
|
|
1950
|
-
testTasksScheduledInASeparateTurnOfTheEventLoopGetASeparateTaskQueue_1() {
|
|
1951
|
-
scheduleAction('a', () => webdriver.promise.delayed(10));
|
|
1952
|
-
schedule('b');
|
|
1953
|
-
setTimeout(() => schedule('c'), 0);
|
|
1954
|
-
|
|
1955
|
-
return waitForIdle().then(function() {
|
|
1956
|
-
assertFlowHistory('a', 'c', 'b');
|
|
1957
|
-
});
|
|
1958
|
-
}
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
/** See https://github.com/SeleniumHQ/selenium/issues/363 */
|
|
1962
|
-
function
|
|
1963
|
-
testTasksScheduledInASeparateTurnOfTheEventLoopGetASeparateTaskQueue_2() {
|
|
1964
|
-
scheduleAction('a', () => webdriver.promise.delayed(10));
|
|
1965
|
-
schedule('b');
|
|
1966
|
-
schedule('c');
|
|
1967
|
-
setTimeout(function() {
|
|
1968
|
-
schedule('d');
|
|
1969
|
-
scheduleAction('e', () => webdriver.promise.delayed(10));
|
|
1970
|
-
schedule('f');
|
|
1971
|
-
}, 0);
|
|
1972
|
-
|
|
1973
|
-
return waitForIdle().then(function() {
|
|
1974
|
-
assertFlowHistory('a', 'd', 'e', 'b', 'c', 'f');
|
|
1975
|
-
});
|
|
1976
|
-
}
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
/** See https://github.com/SeleniumHQ/selenium/issues/363 */
|
|
1980
|
-
function testCanSynchronizeTasksFromAdjacentTaskQueues() {
|
|
1981
|
-
var task1 = scheduleAction('a', () => webdriver.promise.delayed(10));
|
|
1982
|
-
schedule('b');
|
|
1983
|
-
setTimeout(function() {
|
|
1984
|
-
scheduleAction('c', () => task1);
|
|
1985
|
-
schedule('d');
|
|
1986
|
-
}, 0);
|
|
1987
|
-
|
|
1988
|
-
return waitForIdle().then(function() {
|
|
1989
|
-
assertFlowHistory('a', 'c', 'd', 'b');
|
|
1990
|
-
});
|
|
1991
|
-
}
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
function testCancellingAScheduledTask_1() {
|
|
1995
|
-
var called = false;
|
|
1996
|
-
var task1 = scheduleAction('a', () => called = true);
|
|
1997
|
-
task1.cancel('no soup for you');
|
|
1998
|
-
|
|
1999
|
-
return waitForIdle().then(function() {
|
|
2000
|
-
assertFalse(called);
|
|
2001
|
-
assertFlowHistory();
|
|
2002
|
-
return task1.thenCatch(function(e) {
|
|
2003
|
-
assertTrue(e instanceof webdriver.promise.CancellationError);
|
|
2004
|
-
assertEquals('no soup for you', e.message);
|
|
2005
|
-
});
|
|
2006
|
-
});
|
|
2007
|
-
}
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
function testCancellingAScheduledTask_2() {
|
|
2011
|
-
schedule('a');
|
|
2012
|
-
var called = false;
|
|
2013
|
-
var task2 = scheduleAction('b', () => called = true);
|
|
2014
|
-
schedule('c');
|
|
2015
|
-
|
|
2016
|
-
task2.cancel('no soup for you');
|
|
2017
|
-
|
|
2018
|
-
return waitForIdle().then(function() {
|
|
2019
|
-
assertFalse(called);
|
|
2020
|
-
assertFlowHistory('a', 'c');
|
|
2021
|
-
return task2.thenCatch(function(e) {
|
|
2022
|
-
assertTrue(e instanceof webdriver.promise.CancellationError);
|
|
2023
|
-
assertEquals('no soup for you', e.message);
|
|
2024
|
-
});
|
|
2025
|
-
});
|
|
2026
|
-
}
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
function testCancellingAScheduledTask_3() {
|
|
2030
|
-
var called = false;
|
|
2031
|
-
var task = scheduleAction('a', () => called = true);
|
|
2032
|
-
task.cancel(new StubError);
|
|
2033
|
-
|
|
2034
|
-
return waitForIdle().then(function() {
|
|
2035
|
-
assertFalse(called);
|
|
2036
|
-
assertFlowHistory();
|
|
2037
|
-
return task.thenCatch(function(e) {
|
|
2038
|
-
assertTrue(e instanceof webdriver.promise.CancellationError);
|
|
2039
|
-
});
|
|
2040
|
-
});
|
|
2041
|
-
}
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
function testCancellingAScheduledTask_4() {
|
|
2045
|
-
var seen = [];
|
|
2046
|
-
var task = scheduleAction('a', () => seen.push(1))
|
|
2047
|
-
.then(() => seen.push(2))
|
|
2048
|
-
.then(() => seen.push(3))
|
|
2049
|
-
.then(() => seen.push(4))
|
|
2050
|
-
.then(() => seen.push(5));
|
|
2051
|
-
task.cancel(new StubError);
|
|
2052
|
-
|
|
2053
|
-
return waitForIdle().then(function() {
|
|
2054
|
-
assertArrayEquals([], seen);
|
|
2055
|
-
assertFlowHistory();
|
|
2056
|
-
return task.thenCatch(function(e) {
|
|
2057
|
-
assertTrue(e instanceof webdriver.promise.CancellationError);
|
|
2058
|
-
});
|
|
2059
|
-
});
|
|
2060
|
-
}
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
function testCancellingAScheduledTask_fromWithinAnExecutingTask() {
|
|
2064
|
-
var called = false;
|
|
2065
|
-
var task;
|
|
2066
|
-
scheduleAction('a', function() {
|
|
2067
|
-
task.cancel('no soup for you');
|
|
2068
|
-
});
|
|
2069
|
-
task = scheduleAction('b', () => called = true);
|
|
2070
|
-
schedule('c');
|
|
2071
|
-
|
|
2072
|
-
return waitForIdle().then(function() {
|
|
2073
|
-
assertFalse(called);
|
|
2074
|
-
assertFlowHistory('a', 'c');
|
|
2075
|
-
return task.thenCatch(function(e) {
|
|
2076
|
-
assertTrue(e instanceof webdriver.promise.CancellationError);
|
|
2077
|
-
assertEquals('no soup for you', e.message);
|
|
2078
|
-
});
|
|
2079
|
-
});
|
|
2080
|
-
}
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
function testCancellingAPendingTask() {
|
|
2084
|
-
var order = [];
|
|
2085
|
-
var unresolved = webdriver.promise.defer();
|
|
2086
|
-
|
|
2087
|
-
var innerTask;
|
|
2088
|
-
var outerTask = scheduleAction('a', function() {
|
|
2089
|
-
order.push(1);
|
|
2090
|
-
|
|
2091
|
-
// Schedule a task that will never finish.
|
|
2092
|
-
innerTask = scheduleAction('a.1', function() {
|
|
2093
|
-
return unresolved.promise;
|
|
2094
|
-
});
|
|
2095
|
-
|
|
2096
|
-
// Since the outerTask is cancelled below, innerTask should be cancelled
|
|
2097
|
-
// with a DiscardedTaskError, which means its callbacks are silently
|
|
2098
|
-
// dropped - so this should never execute.
|
|
2099
|
-
innerTask.thenCatch(function(e) {
|
|
2100
|
-
order.push(2);
|
|
2101
|
-
});
|
|
2102
|
-
});
|
|
2103
|
-
schedule('b');
|
|
2104
|
-
|
|
2105
|
-
outerTask.thenCatch(function(e) {
|
|
2106
|
-
order.push(3);
|
|
2107
|
-
assertTrue(e instanceof webdriver.promise.CancellationError);
|
|
2108
|
-
assertEquals('no soup for you', e.message);
|
|
2109
|
-
});
|
|
2110
|
-
|
|
2111
|
-
unresolved.promise.thenCatch(function(e) {
|
|
2112
|
-
order.push(4);
|
|
2113
|
-
assertTrue(e instanceof webdriver.promise.CancellationError);
|
|
2114
|
-
});
|
|
2115
|
-
|
|
2116
|
-
return timeout(10).then(function() {
|
|
2117
|
-
assertArrayEquals([1], order);
|
|
2118
|
-
assertTrue(unresolved.promise.isPending());
|
|
2119
|
-
|
|
2120
|
-
outerTask.cancel('no soup for you');
|
|
2121
|
-
return waitForIdle();
|
|
2122
|
-
}).then(function() {
|
|
2123
|
-
assertFlowHistory('a', 'a.1', 'b');
|
|
2124
|
-
assertArrayEquals([1, 3, 4], order);
|
|
2125
|
-
});
|
|
2126
|
-
}
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
function testCancellingAPendingPromiseCallback() {
|
|
2130
|
-
var called = false;
|
|
2131
|
-
|
|
2132
|
-
var root = webdriver.promise.fulfilled();
|
|
2133
|
-
root.then(function() {
|
|
2134
|
-
cb2.cancel('no soup for you');
|
|
2135
|
-
});
|
|
2136
|
-
|
|
2137
|
-
var cb2 = root.then(fail, fail); // These callbacks should never be called.
|
|
2138
|
-
cb2.then(fail, function(e) {
|
|
2139
|
-
called = true;
|
|
2140
|
-
assertTrue(e instanceof webdriver.promise.CancellationError);
|
|
2141
|
-
assertEquals('no soup for you', e.message);
|
|
2142
|
-
});
|
|
2143
|
-
|
|
2144
|
-
return waitForIdle().then(function() {
|
|
2145
|
-
assertTrue(called);
|
|
2146
|
-
});
|
|
2147
|
-
}
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
function testResetFlow_1() {
|
|
2151
|
-
var called = 0;
|
|
2152
|
-
var task = flow.execute(() => called++);
|
|
2153
|
-
task.thenFinally(() => called++);
|
|
2154
|
-
|
|
2155
|
-
return new Promise(function(fulfill) {
|
|
2156
|
-
flow.once('reset', fulfill);
|
|
2157
|
-
flow.reset();
|
|
2158
|
-
|
|
2159
|
-
}).then(function() {
|
|
2160
|
-
assertEquals(0, called);
|
|
2161
|
-
assertFalse(task.isPending());
|
|
2162
|
-
return task;
|
|
2163
|
-
|
|
2164
|
-
}).then(fail, function(e) {
|
|
2165
|
-
assertTrue(e instanceof webdriver.promise.CancellationError);
|
|
2166
|
-
assertEquals('ControlFlow was reset', e.message);
|
|
2167
|
-
});
|
|
2168
|
-
}
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
function testResetFlow_2() {
|
|
2172
|
-
var called = 0;
|
|
2173
|
-
var task1 = flow.execute(() => called++);
|
|
2174
|
-
task1.thenFinally(() => called++);
|
|
2175
|
-
|
|
2176
|
-
var task2 = flow.execute(() => called++);
|
|
2177
|
-
task2.thenFinally(() => called++);
|
|
2178
|
-
|
|
2179
|
-
var task3 = flow.execute(() => called++);
|
|
2180
|
-
task3.thenFinally(() => called++);
|
|
2181
|
-
|
|
2182
|
-
return new Promise(function(fulfill) {
|
|
2183
|
-
flow.once('reset', fulfill);
|
|
2184
|
-
flow.reset();
|
|
2185
|
-
|
|
2186
|
-
}).then(function() {
|
|
2187
|
-
assertEquals(0, called);
|
|
2188
|
-
assertFalse(task1.isPending());
|
|
2189
|
-
assertFalse(task2.isPending());
|
|
2190
|
-
assertFalse(task3.isPending());
|
|
2191
|
-
});
|
|
2192
|
-
}
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
function testPromiseFulfilledInsideTask_1() {
|
|
2196
|
-
var order = [];
|
|
2197
|
-
|
|
2198
|
-
flow.execute(function() {
|
|
2199
|
-
var d = webdriver.promise.defer();
|
|
2200
|
-
|
|
2201
|
-
d.promise.then(() => order.push('a'));
|
|
2202
|
-
d.promise.then(() => order.push('b'));
|
|
2203
|
-
d.promise.then(() => order.push('c'));
|
|
2204
|
-
d.fulfill();
|
|
2205
|
-
|
|
2206
|
-
flow.execute(() => order.push('d'));
|
|
2207
|
-
|
|
2208
|
-
}).then(() => order.push('fin'));
|
|
2209
|
-
|
|
2210
|
-
return waitForIdle().then(function() {
|
|
2211
|
-
assertArrayEquals(['a', 'b', 'c', 'd', 'fin'], order);
|
|
2212
|
-
});
|
|
2213
|
-
}
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
function testPromiseFulfilledInsideTask_2() {
|
|
2217
|
-
var order = [];
|
|
2218
|
-
|
|
2219
|
-
flow.execute(function() {
|
|
2220
|
-
flow.execute(() => order.push('a'));
|
|
2221
|
-
flow.execute(() => order.push('b'));
|
|
2222
|
-
|
|
2223
|
-
var d = webdriver.promise.defer();
|
|
2224
|
-
d.promise.then(() => order.push('c'));
|
|
2225
|
-
d.promise.then(() => order.push('d'));
|
|
2226
|
-
d.fulfill();
|
|
2227
|
-
|
|
2228
|
-
flow.execute(() => order.push('e'));
|
|
2229
|
-
|
|
2230
|
-
}).then(() => order.push('fin'));
|
|
2231
|
-
|
|
2232
|
-
return waitForIdle().then(function() {
|
|
2233
|
-
assertArrayEquals(['a', 'b', 'c', 'd', 'e', 'fin'], order);
|
|
2234
|
-
});
|
|
2235
|
-
}
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
function testPromiseFulfilledInsideTask_3() {
|
|
2239
|
-
var order = [];
|
|
2240
|
-
var d = webdriver.promise.defer();
|
|
2241
|
-
d.promise.then(() => order.push('c'));
|
|
2242
|
-
d.promise.then(() => order.push('d'));
|
|
2243
|
-
|
|
2244
|
-
flow.execute(function() {
|
|
2245
|
-
flow.execute(() => order.push('a'));
|
|
2246
|
-
flow.execute(() => order.push('b'));
|
|
2247
|
-
|
|
2248
|
-
d.promise.then(() => order.push('e'));
|
|
2249
|
-
d.fulfill();
|
|
2250
|
-
|
|
2251
|
-
flow.execute(() => order.push('f'));
|
|
2252
|
-
|
|
2253
|
-
}).then(() => order.push('fin'));
|
|
2254
|
-
|
|
2255
|
-
return waitForIdle().then(function() {
|
|
2256
|
-
assertArrayEquals(['c', 'd', 'a', 'b', 'e', 'f', 'fin'], order);
|
|
2257
|
-
});
|
|
2258
|
-
}
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
function testPromiseFulfilledInsideTask_4() {
|
|
2262
|
-
var order = [];
|
|
2263
|
-
var d = webdriver.promise.defer();
|
|
2264
|
-
d.promise.then(() => order.push('a'));
|
|
2265
|
-
d.promise.then(() => order.push('b'));
|
|
2266
|
-
|
|
2267
|
-
flow.execute(function() {
|
|
2268
|
-
flow.execute(function() {
|
|
2269
|
-
order.push('c');
|
|
2270
|
-
flow.execute(() => order.push('d'));
|
|
2271
|
-
d.promise.then(() => order.push('e'));
|
|
2272
|
-
});
|
|
2273
|
-
flow.execute(() => order.push('f'));
|
|
2274
|
-
|
|
2275
|
-
d.promise.then(() => order.push('g'));
|
|
2276
|
-
d.fulfill();
|
|
2277
|
-
|
|
2278
|
-
flow.execute(() => order.push('h'));
|
|
2279
|
-
|
|
2280
|
-
}).then(() => order.push('fin'));
|
|
2281
|
-
|
|
2282
|
-
return waitForIdle().then(function() {
|
|
2283
|
-
assertArrayEquals(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'fin'], order);
|
|
2284
|
-
});
|
|
2285
|
-
}
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
function testSettledPromiseCallbacksInsideATask_1() {
|
|
2289
|
-
var order = [];
|
|
2290
|
-
var p = webdriver.promise.fulfilled();
|
|
2291
|
-
|
|
2292
|
-
flow.execute(function() {
|
|
2293
|
-
flow.execute(() => order.push('a'));
|
|
2294
|
-
p.then(() => order.push('b'));
|
|
2295
|
-
flow.execute(() => order.push('c'));
|
|
2296
|
-
p.then(() => order.push('d'));
|
|
2297
|
-
}).then(() => order.push('fin'));
|
|
2298
|
-
|
|
2299
|
-
return waitForIdle().then(function() {
|
|
2300
|
-
assertArrayEquals(['a', 'b', 'c', 'd', 'fin'], order);
|
|
2301
|
-
});
|
|
2302
|
-
}
|
|
2303
|
-
|
|
2304
|
-
function testSettledPromiseCallbacksInsideATask_2() {
|
|
2305
|
-
var order = [];
|
|
2306
|
-
|
|
2307
|
-
flow.execute(function() {
|
|
2308
|
-
flow.execute(() => order.push('a'))
|
|
2309
|
-
.then( () => order.push('c'));
|
|
2310
|
-
flow.execute(() => order.push('b'));
|
|
2311
|
-
}).then(() => order.push('fin'));
|
|
2312
|
-
|
|
2313
|
-
return waitForIdle().then(function() {
|
|
2314
|
-
assertArrayEquals(['a', 'c', 'b', 'fin'], order);
|
|
2315
|
-
});
|
|
2316
|
-
}
|
|
2317
|
-
|
|
2318
|
-
function testTasksDoNotWaitForNewlyCreatedPromises() {
|
|
2319
|
-
var order = [];
|
|
2320
|
-
|
|
2321
|
-
flow.execute(function() {
|
|
2322
|
-
var d = webdriver.promise.defer();
|
|
2323
|
-
|
|
2324
|
-
// This is a normal promise, not a task, so the task for this callback is
|
|
2325
|
-
// considered volatile. Volatile tasks should be skipped when they reach
|
|
2326
|
-
// the front of the task queue.
|
|
2327
|
-
d.promise.then(() => order.push('a'));
|
|
2328
|
-
|
|
2329
|
-
flow.execute(() => order.push('b'));
|
|
2330
|
-
flow.execute(function() {
|
|
2331
|
-
flow.execute(() => order.push('c'));
|
|
2332
|
-
d.promise.then(() => order.push('d'));
|
|
2333
|
-
d.fulfill();
|
|
2334
|
-
});
|
|
2335
|
-
flow.execute(() => order.push('e'));
|
|
2336
|
-
|
|
2337
|
-
}).then(() => order.push('fin'));
|
|
2338
|
-
|
|
2339
|
-
return waitForIdle().then(function() {
|
|
2340
|
-
assertArrayEquals(['b', 'a', 'c', 'd', 'e', 'fin'], order);
|
|
2341
|
-
});
|
|
2342
|
-
}
|
|
2343
|
-
|
|
2344
|
-
function testCallbackDependenciesDoNotDeadlock() {
|
|
2345
|
-
var order = [];
|
|
2346
|
-
var root = webdriver.promise.defer();
|
|
2347
|
-
var dep = webdriver.promise.fulfilled().then(function() {
|
|
2348
|
-
order.push('a');
|
|
2349
|
-
return root.promise.then(function() {
|
|
2350
|
-
order.push('b');
|
|
2351
|
-
});
|
|
2352
|
-
});
|
|
2353
|
-
// This callback depends on |dep|, which depends on another callback
|
|
2354
|
-
// attached to |root| via a chain.
|
|
2355
|
-
root.promise.then(function() {
|
|
2356
|
-
order.push('c');
|
|
2357
|
-
return dep.then(() => order.push('d'));
|
|
2358
|
-
}).then(() => order.push('fin'));
|
|
2359
|
-
|
|
2360
|
-
setTimeout(() => root.fulfill(), 20);
|
|
2361
|
-
|
|
2362
|
-
return waitForIdle().then(function() {
|
|
2363
|
-
assertArrayEquals(['a', 'b', 'c', 'd', 'fin'], order);
|
|
2364
|
-
});
|
|
2365
|
-
}
|