selenium-webdriver 2.47.0 → 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.
Files changed (529) hide show
  1. package/CHANGES.md +96 -0
  2. package/NOTICE +1 -1
  3. package/README.md +57 -6
  4. package/builder.js +375 -358
  5. package/chrome.js +549 -586
  6. package/edge.js +378 -0
  7. package/error.js +597 -5
  8. package/example/google_search_generator.js +2 -4
  9. package/example/logging.js +6 -2
  10. package/executors.js +11 -27
  11. package/firefox/binary.js +80 -114
  12. package/firefox/extension.js +10 -19
  13. package/firefox/index.js +175 -171
  14. package/firefox/profile.js +221 -239
  15. package/http/index.js +396 -77
  16. package/http/util.js +35 -35
  17. package/ie.js +288 -309
  18. package/index.js +34 -125
  19. package/io/exec.js +58 -39
  20. package/io/index.js +54 -48
  21. package/lib/actions.js +594 -0
  22. package/lib/by.js +276 -0
  23. package/lib/capabilities.js +404 -0
  24. package/lib/{webdriver/command.js → command.js} +89 -72
  25. package/lib/{webdriver/button.js → devmode.js} +13 -8
  26. package/lib/events.js +210 -0
  27. package/lib/firefox/amd64/libnoblur64.so +0 -0
  28. package/lib/firefox/i386/libnoblur.so +0 -0
  29. package/lib/firefox/webdriver.json +6 -1
  30. package/lib/firefox/webdriver.xpi +0 -0
  31. package/lib/{webdriver/key.js → input.js} +82 -2
  32. package/lib/logging.js +668 -0
  33. package/lib/promise.js +3093 -0
  34. package/lib/safari/client.js +697 -659
  35. package/lib/session.js +79 -0
  36. package/{test/promise_aplus_test.js → lib/symbols.js} +15 -25
  37. package/lib/test/build.js +4 -4
  38. package/lib/test/data/click_tests/disappearing_element.html +62 -0
  39. package/lib/test/data/click_tests/html5_submit_buttons.html +2 -1
  40. package/lib/test/data/click_tests/overlapping_elements.html +70 -0
  41. package/lib/test/data/click_tests/partially_overlapping_elements.html +124 -0
  42. package/lib/test/data/click_tests/wrapped_overlapping_elements.html +13 -0
  43. package/lib/test/data/readOnlyPage.html +3 -1
  44. package/lib/test/data/selectPage.html +18 -2
  45. package/lib/test/data/simpleTest.html +1 -0
  46. package/lib/test/fileserver.js +3 -4
  47. package/lib/test/index.js +13 -4
  48. package/lib/test/resources.js +1 -1
  49. package/lib/until.js +428 -0
  50. package/lib/webdriver.js +2351 -0
  51. package/net/portprober.js +15 -11
  52. package/opera.js +295 -314
  53. package/package.json +6 -5
  54. package/phantomjs.js +135 -140
  55. package/proxy.js +6 -4
  56. package/remote/index.js +234 -219
  57. package/safari.js +319 -310
  58. package/test/chrome/options_test.js +11 -9
  59. package/test/element_finding_test.js +51 -13
  60. package/test/error_test.js +163 -0
  61. package/test/execute_script_test.js +1 -1
  62. package/test/firefox/firefox_test.js +24 -0
  63. package/test/http/http_test.js +354 -43
  64. package/test/http/util_test.js +25 -23
  65. package/test/io_test.js +6 -1
  66. package/test/lib/by_test.js +127 -0
  67. package/test/lib/capabilities_test.js +84 -0
  68. package/test/lib/events_test.js +177 -0
  69. package/test/lib/logging_test.js +272 -0
  70. package/test/lib/promise_aplus_test.js +74 -0
  71. package/test/lib/promise_error_test.js +808 -0
  72. package/test/lib/promise_flow_test.js +2282 -0
  73. package/test/lib/promise_generator_test.js +308 -0
  74. package/test/lib/promise_test.js +996 -0
  75. package/test/lib/testutil.js +90 -0
  76. package/test/lib/until_test.js +436 -0
  77. package/test/lib/webdriver_test.js +2207 -0
  78. package/test/page_loading_test.js +7 -9
  79. package/test/stale_element_test.js +2 -2
  80. package/test/testing/assert_test.js +374 -0
  81. package/test/testing/index_test.js +9 -11
  82. package/testing/assert.js +334 -17
  83. package/testing/index.js +10 -0
  84. package/_base.js +0 -200
  85. package/docs/Changes.html +0 -317
  86. package/docs/class_bot_Error.html +0 -15
  87. package/docs/class_webdriver_ActionSequence.html +0 -115
  88. package/docs/class_webdriver_Alert.html +0 -24
  89. package/docs/class_webdriver_AlertPromise.html +0 -91
  90. package/docs/class_webdriver_Capabilities.html +0 -60
  91. package/docs/class_webdriver_Command.html +0 -15
  92. package/docs/class_webdriver_EventEmitter.html +0 -35
  93. package/docs/class_webdriver_FileDetector.html +0 -21
  94. package/docs/class_webdriver_Locator.html +0 -12
  95. package/docs/class_webdriver_Serializable.html +0 -9
  96. package/docs/class_webdriver_Session.html +0 -13
  97. package/docs/class_webdriver_TouchSequence.html +0 -49
  98. package/docs/class_webdriver_UnhandledAlertError.html +0 -18
  99. package/docs/class_webdriver_WebDriver.html +0 -313
  100. package/docs/class_webdriver_WebDriver_Logs.html +0 -15
  101. package/docs/class_webdriver_WebDriver_Navigation.html +0 -16
  102. package/docs/class_webdriver_WebDriver_Options.html +0 -41
  103. package/docs/class_webdriver_WebDriver_TargetLocator.html +0 -38
  104. package/docs/class_webdriver_WebDriver_Timeouts.html +0 -29
  105. package/docs/class_webdriver_WebDriver_Window.html +0 -27
  106. package/docs/class_webdriver_WebElement.html +0 -216
  107. package/docs/class_webdriver_WebElementPromise.html +0 -266
  108. package/docs/class_webdriver_http_Executor.html +0 -22
  109. package/docs/class_webdriver_http_Request.html +0 -12
  110. package/docs/class_webdriver_http_Response.html +0 -13
  111. package/docs/class_webdriver_logging_Entry.html +0 -15
  112. package/docs/class_webdriver_logging_Level.html +0 -55
  113. package/docs/class_webdriver_logging_LogRecord.html +0 -45
  114. package/docs/class_webdriver_logging_Logger.html +0 -119
  115. package/docs/class_webdriver_logging_Preferences.html +0 -8
  116. package/docs/class_webdriver_promise_CancellationError.html +0 -18
  117. package/docs/class_webdriver_promise_ControlFlow.html +0 -109
  118. package/docs/class_webdriver_promise_Deferred.html +0 -84
  119. package/docs/class_webdriver_promise_Promise.html +0 -74
  120. package/docs/class_webdriver_stacktrace_Frame.html +0 -20
  121. package/docs/class_webdriver_stacktrace_Snapshot.html +0 -6
  122. package/docs/class_webdriver_testing_Assertion.html +0 -99
  123. package/docs/class_webdriver_testing_Assertion_DelegatingMatcher_.html +0 -13
  124. package/docs/class_webdriver_testing_ContainsMatcher.html +0 -11
  125. package/docs/class_webdriver_testing_NegatedAssertion.html +0 -97
  126. package/docs/class_webdriver_until_Condition.html +0 -7
  127. package/docs/dossier.css +0 -1
  128. package/docs/dossier.js +0 -86
  129. package/docs/enum_bot_ErrorCode.html +0 -3
  130. package/docs/enum_bot_Error_State.html +0 -2
  131. package/docs/enum_webdriver_Browser.html +0 -2
  132. package/docs/enum_webdriver_Button.html +0 -2
  133. package/docs/enum_webdriver_Capability.html +0 -33
  134. package/docs/enum_webdriver_CommandName.html +0 -3
  135. package/docs/enum_webdriver_Key.html +0 -12
  136. package/docs/enum_webdriver_logging_Type.html +0 -6
  137. package/docs/enum_webdriver_promise_ControlFlow_EventType.html +0 -9
  138. package/docs/index.html +0 -123
  139. package/docs/interface_webdriver_CommandExecutor.html +0 -9
  140. package/docs/interface_webdriver_http_Client.html +0 -10
  141. package/docs/interface_webdriver_promise_Thenable.html +0 -77
  142. package/docs/module_selenium-webdriver.html +0 -23
  143. package/docs/module_selenium-webdriver__base.html +0 -23
  144. package/docs/module_selenium-webdriver__base_class_Context.html +0 -5
  145. package/docs/module_selenium-webdriver_builder.html +0 -2
  146. package/docs/module_selenium-webdriver_builder_class_Builder.html +0 -138
  147. package/docs/module_selenium-webdriver_chrome.html +0 -90
  148. package/docs/module_selenium-webdriver_chrome_class_Driver.html +0 -280
  149. package/docs/module_selenium-webdriver_chrome_class_Options.html +0 -127
  150. package/docs/module_selenium-webdriver_chrome_class_ServiceBuilder.html +0 -46
  151. package/docs/module_selenium-webdriver_class_ActionSequence.html +0 -115
  152. package/docs/module_selenium-webdriver_class_Builder.html +0 -138
  153. package/docs/module_selenium-webdriver_class_Capabilities.html +0 -60
  154. package/docs/module_selenium-webdriver_class_Command.html +0 -15
  155. package/docs/module_selenium-webdriver_class_EventEmitter.html +0 -35
  156. package/docs/module_selenium-webdriver_class_FileDetector.html +0 -21
  157. package/docs/module_selenium-webdriver_class_Serializable.html +0 -9
  158. package/docs/module_selenium-webdriver_class_Session.html +0 -13
  159. package/docs/module_selenium-webdriver_class_WebDriver.html +0 -313
  160. package/docs/module_selenium-webdriver_class_WebElement.html +0 -216
  161. package/docs/module_selenium-webdriver_class_WebElementPromise.html +0 -266
  162. package/docs/module_selenium-webdriver_enum_Browser.html +0 -2
  163. package/docs/module_selenium-webdriver_enum_Button.html +0 -2
  164. package/docs/module_selenium-webdriver_enum_Capability.html +0 -33
  165. package/docs/module_selenium-webdriver_enum_CommandName.html +0 -3
  166. package/docs/module_selenium-webdriver_enum_Key.html +0 -12
  167. package/docs/module_selenium-webdriver_error.html +0 -4
  168. package/docs/module_selenium-webdriver_error_class_Error.html +0 -15
  169. package/docs/module_selenium-webdriver_error_enum_ErrorCode.html +0 -3
  170. package/docs/module_selenium-webdriver_executors.html +0 -10
  171. package/docs/module_selenium-webdriver_executors_class_DeferredExecutor.html +0 -12
  172. package/docs/module_selenium-webdriver_firefox.html +0 -67
  173. package/docs/module_selenium-webdriver_firefox_binary.html +0 -4
  174. package/docs/module_selenium-webdriver_firefox_binary_class_Binary.html +0 -21
  175. package/docs/module_selenium-webdriver_firefox_class_Binary.html +0 -21
  176. package/docs/module_selenium-webdriver_firefox_class_Driver.html +0 -276
  177. package/docs/module_selenium-webdriver_firefox_class_Options.html +0 -19
  178. package/docs/module_selenium-webdriver_firefox_class_Profile.html +0 -50
  179. package/docs/module_selenium-webdriver_firefox_extension.html +0 -8
  180. package/docs/module_selenium-webdriver_firefox_profile.html +0 -13
  181. package/docs/module_selenium-webdriver_firefox_profile_class_Profile.html +0 -50
  182. package/docs/module_selenium-webdriver_http.html +0 -9
  183. package/docs/module_selenium-webdriver_http_class_Executor.html +0 -22
  184. package/docs/module_selenium-webdriver_http_class_HttpClient.html +0 -16
  185. package/docs/module_selenium-webdriver_http_class_Request.html +0 -12
  186. package/docs/module_selenium-webdriver_http_class_Response.html +0 -13
  187. package/docs/module_selenium-webdriver_http_util.html +0 -17
  188. package/docs/module_selenium-webdriver_ie.html +0 -11
  189. package/docs/module_selenium-webdriver_ie_class_Driver.html +0 -274
  190. package/docs/module_selenium-webdriver_ie_class_Options.html +0 -89
  191. package/docs/module_selenium-webdriver_ie_enum_Level.html +0 -1
  192. package/docs/module_selenium-webdriver_io.html +0 -37
  193. package/docs/module_selenium-webdriver_io_exec.html +0 -6
  194. package/docs/module_selenium-webdriver_namespace_By.html +0 -56
  195. package/docs/module_selenium-webdriver_namespace_error.html +0 -4
  196. package/docs/module_selenium-webdriver_namespace_logging.html +0 -18
  197. package/docs/module_selenium-webdriver_namespace_promise.html +0 -162
  198. package/docs/module_selenium-webdriver_namespace_stacktrace.html +0 -17
  199. package/docs/module_selenium-webdriver_namespace_until.html +0 -82
  200. package/docs/module_selenium-webdriver_net.html +0 -7
  201. package/docs/module_selenium-webdriver_net_portprober.html +0 -12
  202. package/docs/module_selenium-webdriver_opera.html +0 -62
  203. package/docs/module_selenium-webdriver_opera_class_Driver.html +0 -276
  204. package/docs/module_selenium-webdriver_opera_class_Options.html +0 -44
  205. package/docs/module_selenium-webdriver_opera_class_ServiceBuilder.html +0 -35
  206. package/docs/module_selenium-webdriver_phantomjs.html +0 -2
  207. package/docs/module_selenium-webdriver_phantomjs_class_Driver.html +0 -299
  208. package/docs/module_selenium-webdriver_proxy.html +0 -28
  209. package/docs/module_selenium-webdriver_remote.html +0 -8
  210. package/docs/module_selenium-webdriver_remote_class_DriverService.html +0 -32
  211. package/docs/module_selenium-webdriver_remote_class_FileDetector.html +0 -22
  212. package/docs/module_selenium-webdriver_remote_class_SeleniumServer.html +0 -40
  213. package/docs/module_selenium-webdriver_safari.html +0 -9
  214. package/docs/module_selenium-webdriver_safari_class_Driver.html +0 -279
  215. package/docs/module_selenium-webdriver_safari_class_Options.html +0 -23
  216. package/docs/module_selenium-webdriver_testing.html +0 -74
  217. package/docs/module_selenium-webdriver_testing_assert.html +0 -9
  218. package/docs/namespace_bot.html +0 -4
  219. package/docs/namespace_bot_json.html +0 -20
  220. package/docs/namespace_bot_response.html +0 -18
  221. package/docs/namespace_bot_userAgent.html +0 -33
  222. package/docs/namespace_webdriver.html +0 -30
  223. package/docs/namespace_webdriver_By.html +0 -56
  224. package/docs/namespace_webdriver_http.html +0 -6
  225. package/docs/namespace_webdriver_logging.html +0 -70
  226. package/docs/namespace_webdriver_promise.html +0 -165
  227. package/docs/namespace_webdriver_stacktrace.html +0 -17
  228. package/docs/namespace_webdriver_testing.html +0 -7
  229. package/docs/namespace_webdriver_testing_assert.html +0 -9
  230. package/docs/namespace_webdriver_testing_asserts.html +0 -18
  231. package/docs/namespace_webdriver_until.html +0 -82
  232. package/docs/source/_base.js.src.html +0 -1
  233. package/docs/source/builder.js.src.html +0 -1
  234. package/docs/source/chrome.js.src.html +0 -1
  235. package/docs/source/error.js.src.html +0 -1
  236. package/docs/source/executors.js.src.html +0 -1
  237. package/docs/source/firefox/binary.js.src.html +0 -1
  238. package/docs/source/firefox/extension.js.src.html +0 -1
  239. package/docs/source/firefox/index.js.src.html +0 -1
  240. package/docs/source/firefox/profile.js.src.html +0 -1
  241. package/docs/source/http/index.js.src.html +0 -1
  242. package/docs/source/http/util.js.src.html +0 -1
  243. package/docs/source/ie.js.src.html +0 -1
  244. package/docs/source/index.js.src.html +0 -1
  245. package/docs/source/io/exec.js.src.html +0 -1
  246. package/docs/source/io/index.js.src.html +0 -1
  247. package/docs/source/lib/atoms/error.js.src.html +0 -1
  248. package/docs/source/lib/atoms/json.js.src.html +0 -1
  249. package/docs/source/lib/atoms/response.js.src.html +0 -1
  250. package/docs/source/lib/atoms/userAgent.js.src.html +0 -1
  251. package/docs/source/lib/goog/array/array.js.src.html +0 -1
  252. package/docs/source/lib/goog/asserts/asserts.js.src.html +0 -1
  253. package/docs/source/lib/goog/async/freelist.js.src.html +0 -1
  254. package/docs/source/lib/goog/async/nexttick.js.src.html +0 -1
  255. package/docs/source/lib/goog/async/run.js.src.html +0 -1
  256. package/docs/source/lib/goog/async/workqueue.js.src.html +0 -1
  257. package/docs/source/lib/goog/base.js.src.html +0 -1
  258. package/docs/source/lib/goog/debug/debug.js.src.html +0 -1
  259. package/docs/source/lib/goog/debug/entrypointregistry.js.src.html +0 -1
  260. package/docs/source/lib/goog/debug/error.js.src.html +0 -1
  261. package/docs/source/lib/goog/debug/logbuffer.js.src.html +0 -1
  262. package/docs/source/lib/goog/debug/logger.js.src.html +0 -1
  263. package/docs/source/lib/goog/debug/logrecord.js.src.html +0 -1
  264. package/docs/source/lib/goog/deps.js.src.html +0 -1
  265. package/docs/source/lib/goog/disposable/disposable.js.src.html +0 -1
  266. package/docs/source/lib/goog/disposable/idisposable.js.src.html +0 -1
  267. package/docs/source/lib/goog/dom/browserfeature.js.src.html +0 -1
  268. package/docs/source/lib/goog/dom/dom.js.src.html +0 -1
  269. package/docs/source/lib/goog/dom/nodetype.js.src.html +0 -1
  270. package/docs/source/lib/goog/dom/safe.js.src.html +0 -1
  271. package/docs/source/lib/goog/dom/tagname.js.src.html +0 -1
  272. package/docs/source/lib/goog/dom/tags.js.src.html +0 -1
  273. package/docs/source/lib/goog/dom/vendor.js.src.html +0 -1
  274. package/docs/source/lib/goog/events/browserevent.js.src.html +0 -1
  275. package/docs/source/lib/goog/events/browserfeature.js.src.html +0 -1
  276. package/docs/source/lib/goog/events/event.js.src.html +0 -1
  277. package/docs/source/lib/goog/events/eventid.js.src.html +0 -1
  278. package/docs/source/lib/goog/events/events.js.src.html +0 -1
  279. package/docs/source/lib/goog/events/eventtarget.js.src.html +0 -1
  280. package/docs/source/lib/goog/events/eventtype.js.src.html +0 -1
  281. package/docs/source/lib/goog/events/keycodes.js.src.html +0 -1
  282. package/docs/source/lib/goog/events/listenable.js.src.html +0 -1
  283. package/docs/source/lib/goog/events/listener.js.src.html +0 -1
  284. package/docs/source/lib/goog/events/listenermap.js.src.html +0 -1
  285. package/docs/source/lib/goog/fs/url.js.src.html +0 -1
  286. package/docs/source/lib/goog/functions/functions.js.src.html +0 -1
  287. package/docs/source/lib/goog/html/safehtml.js.src.html +0 -1
  288. package/docs/source/lib/goog/html/safescript.js.src.html +0 -1
  289. package/docs/source/lib/goog/html/safestyle.js.src.html +0 -1
  290. package/docs/source/lib/goog/html/safestylesheet.js.src.html +0 -1
  291. package/docs/source/lib/goog/html/safeurl.js.src.html +0 -1
  292. package/docs/source/lib/goog/html/trustedresourceurl.js.src.html +0 -1
  293. package/docs/source/lib/goog/html/uncheckedconversions.js.src.html +0 -1
  294. package/docs/source/lib/goog/i18n/bidi.js.src.html +0 -1
  295. package/docs/source/lib/goog/iter/iter.js.src.html +0 -1
  296. package/docs/source/lib/goog/json/json.js.src.html +0 -1
  297. package/docs/source/lib/goog/labs/testing/assertthat.js.src.html +0 -1
  298. package/docs/source/lib/goog/labs/testing/logicmatcher.js.src.html +0 -1
  299. package/docs/source/lib/goog/labs/testing/matcher.js.src.html +0 -1
  300. package/docs/source/lib/goog/labs/testing/numbermatcher.js.src.html +0 -1
  301. package/docs/source/lib/goog/labs/testing/objectmatcher.js.src.html +0 -1
  302. package/docs/source/lib/goog/labs/testing/stringmatcher.js.src.html +0 -1
  303. package/docs/source/lib/goog/labs/useragent/browser.js.src.html +0 -1
  304. package/docs/source/lib/goog/labs/useragent/engine.js.src.html +0 -1
  305. package/docs/source/lib/goog/labs/useragent/platform.js.src.html +0 -1
  306. package/docs/source/lib/goog/labs/useragent/util.js.src.html +0 -1
  307. package/docs/source/lib/goog/math/box.js.src.html +0 -1
  308. package/docs/source/lib/goog/math/coordinate.js.src.html +0 -1
  309. package/docs/source/lib/goog/math/math.js.src.html +0 -1
  310. package/docs/source/lib/goog/math/rect.js.src.html +0 -1
  311. package/docs/source/lib/goog/math/size.js.src.html +0 -1
  312. package/docs/source/lib/goog/net/wrapperxmlhttpfactory.js.src.html +0 -1
  313. package/docs/source/lib/goog/net/xhrlike.js.src.html +0 -1
  314. package/docs/source/lib/goog/net/xmlhttp.js.src.html +0 -1
  315. package/docs/source/lib/goog/net/xmlhttpfactory.js.src.html +0 -1
  316. package/docs/source/lib/goog/object/object.js.src.html +0 -1
  317. package/docs/source/lib/goog/promise/promise.js.src.html +0 -1
  318. package/docs/source/lib/goog/promise/resolver.js.src.html +0 -1
  319. package/docs/source/lib/goog/promise/thenable.js.src.html +0 -1
  320. package/docs/source/lib/goog/reflect/reflect.js.src.html +0 -1
  321. package/docs/source/lib/goog/string/const.js.src.html +0 -1
  322. package/docs/source/lib/goog/string/string.js.src.html +0 -1
  323. package/docs/source/lib/goog/string/typedstring.js.src.html +0 -1
  324. package/docs/source/lib/goog/structs/collection.js.src.html +0 -1
  325. package/docs/source/lib/goog/structs/map.js.src.html +0 -1
  326. package/docs/source/lib/goog/structs/set.js.src.html +0 -1
  327. package/docs/source/lib/goog/structs/structs.js.src.html +0 -1
  328. package/docs/source/lib/goog/style/style.js.src.html +0 -1
  329. package/docs/source/lib/goog/testing/asserts.js.src.html +0 -1
  330. package/docs/source/lib/goog/testing/events/events.js.src.html +0 -1
  331. package/docs/source/lib/goog/testing/functionmock.js.src.html +0 -1
  332. package/docs/source/lib/goog/testing/jsunit.js.src.html +0 -1
  333. package/docs/source/lib/goog/testing/loosemock.js.src.html +0 -1
  334. package/docs/source/lib/goog/testing/mock.js.src.html +0 -1
  335. package/docs/source/lib/goog/testing/mockclock.js.src.html +0 -1
  336. package/docs/source/lib/goog/testing/mockcontrol.js.src.html +0 -1
  337. package/docs/source/lib/goog/testing/mockinterface.js.src.html +0 -1
  338. package/docs/source/lib/goog/testing/mockmatchers.js.src.html +0 -1
  339. package/docs/source/lib/goog/testing/objectpropertystring.js.src.html +0 -1
  340. package/docs/source/lib/goog/testing/propertyreplacer.js.src.html +0 -1
  341. package/docs/source/lib/goog/testing/recordfunction.js.src.html +0 -1
  342. package/docs/source/lib/goog/testing/stacktrace.js.src.html +0 -1
  343. package/docs/source/lib/goog/testing/strictmock.js.src.html +0 -1
  344. package/docs/source/lib/goog/testing/testcase.js.src.html +0 -1
  345. package/docs/source/lib/goog/testing/testrunner.js.src.html +0 -1
  346. package/docs/source/lib/goog/testing/watchers.js.src.html +0 -1
  347. package/docs/source/lib/goog/uri/uri.js.src.html +0 -1
  348. package/docs/source/lib/goog/uri/utils.js.src.html +0 -1
  349. package/docs/source/lib/goog/useragent/product.js.src.html +0 -1
  350. package/docs/source/lib/goog/useragent/product_isversion.js.src.html +0 -1
  351. package/docs/source/lib/goog/useragent/useragent.js.src.html +0 -1
  352. package/docs/source/lib/webdriver/actionsequence.js.src.html +0 -1
  353. package/docs/source/lib/webdriver/button.js.src.html +0 -1
  354. package/docs/source/lib/webdriver/capabilities.js.src.html +0 -1
  355. package/docs/source/lib/webdriver/command.js.src.html +0 -1
  356. package/docs/source/lib/webdriver/events.js.src.html +0 -1
  357. package/docs/source/lib/webdriver/http/http.js.src.html +0 -1
  358. package/docs/source/lib/webdriver/key.js.src.html +0 -1
  359. package/docs/source/lib/webdriver/locators.js.src.html +0 -1
  360. package/docs/source/lib/webdriver/logging.js.src.html +0 -1
  361. package/docs/source/lib/webdriver/promise.js.src.html +0 -1
  362. package/docs/source/lib/webdriver/serializable.js.src.html +0 -1
  363. package/docs/source/lib/webdriver/session.js.src.html +0 -1
  364. package/docs/source/lib/webdriver/stacktrace.js.src.html +0 -1
  365. package/docs/source/lib/webdriver/testing/asserts.js.src.html +0 -1
  366. package/docs/source/lib/webdriver/touchsequence.js.src.html +0 -1
  367. package/docs/source/lib/webdriver/until.js.src.html +0 -1
  368. package/docs/source/lib/webdriver/webdriver.js.src.html +0 -1
  369. package/docs/source/net/index.js.src.html +0 -1
  370. package/docs/source/net/portprober.js.src.html +0 -1
  371. package/docs/source/opera.js.src.html +0 -1
  372. package/docs/source/phantomjs.js.src.html +0 -1
  373. package/docs/source/proxy.js.src.html +0 -1
  374. package/docs/source/remote/index.js.src.html +0 -1
  375. package/docs/source/safari.js.src.html +0 -1
  376. package/docs/source/testing/assert.js.src.html +0 -1
  377. package/docs/source/testing/index.js.src.html +0 -1
  378. package/docs/types.js +0 -1
  379. package/lib/atoms/error.js +0 -202
  380. package/lib/atoms/json.js +0 -80
  381. package/lib/atoms/response.js +0 -110
  382. package/lib/atoms/userAgent.js +0 -257
  383. package/lib/goog/LICENSE +0 -176
  384. package/lib/goog/array/array.js +0 -1655
  385. package/lib/goog/asserts/asserts.js +0 -365
  386. package/lib/goog/async/freelist.js +0 -88
  387. package/lib/goog/async/nexttick.js +0 -241
  388. package/lib/goog/async/run.js +0 -139
  389. package/lib/goog/async/workqueue.js +0 -139
  390. package/lib/goog/base.js +0 -2547
  391. package/lib/goog/debug/debug.js +0 -653
  392. package/lib/goog/debug/entrypointregistry.js +0 -158
  393. package/lib/goog/debug/error.js +0 -63
  394. package/lib/goog/debug/logbuffer.js +0 -148
  395. package/lib/goog/debug/logger.js +0 -873
  396. package/lib/goog/debug/logrecord.js +0 -242
  397. package/lib/goog/deps.js +0 -151
  398. package/lib/goog/disposable/disposable.js +0 -307
  399. package/lib/goog/disposable/idisposable.js +0 -45
  400. package/lib/goog/dom/browserfeature.js +0 -72
  401. package/lib/goog/dom/dom.js +0 -2995
  402. package/lib/goog/dom/nodetype.js +0 -48
  403. package/lib/goog/dom/safe.js +0 -347
  404. package/lib/goog/dom/tagname.js +0 -160
  405. package/lib/goog/dom/tags.js +0 -42
  406. package/lib/goog/dom/vendor.js +0 -96
  407. package/lib/goog/events/browserevent.js +0 -386
  408. package/lib/goog/events/browserfeature.js +0 -85
  409. package/lib/goog/events/event.js +0 -143
  410. package/lib/goog/events/eventid.js +0 -47
  411. package/lib/goog/events/events.js +0 -984
  412. package/lib/goog/events/eventtarget.js +0 -394
  413. package/lib/goog/events/eventtype.js +0 -233
  414. package/lib/goog/events/keycodes.js +0 -420
  415. package/lib/goog/events/listenable.js +0 -335
  416. package/lib/goog/events/listener.js +0 -131
  417. package/lib/goog/events/listenermap.js +0 -308
  418. package/lib/goog/fs/url.js +0 -105
  419. package/lib/goog/functions/functions.js +0 -332
  420. package/lib/goog/html/safehtml.js +0 -756
  421. package/lib/goog/html/safescript.js +0 -234
  422. package/lib/goog/html/safestyle.js +0 -442
  423. package/lib/goog/html/safestylesheet.js +0 -276
  424. package/lib/goog/html/safeurl.js +0 -431
  425. package/lib/goog/html/trustedresourceurl.js +0 -224
  426. package/lib/goog/html/uncheckedconversions.js +0 -231
  427. package/lib/goog/i18n/bidi.js +0 -908
  428. package/lib/goog/iter/iter.js +0 -1305
  429. package/lib/goog/json/json.js +0 -365
  430. package/lib/goog/labs/testing/assertthat.js +0 -58
  431. package/lib/goog/labs/testing/logicmatcher.js +0 -212
  432. package/lib/goog/labs/testing/matcher.js +0 -80
  433. package/lib/goog/labs/testing/numbermatcher.js +0 -346
  434. package/lib/goog/labs/testing/objectmatcher.js +0 -317
  435. package/lib/goog/labs/testing/stringmatcher.js +0 -415
  436. package/lib/goog/labs/useragent/browser.js +0 -327
  437. package/lib/goog/labs/useragent/engine.js +0 -160
  438. package/lib/goog/labs/useragent/platform.js +0 -160
  439. package/lib/goog/labs/useragent/util.js +0 -148
  440. package/lib/goog/math/box.js +0 -389
  441. package/lib/goog/math/coordinate.js +0 -268
  442. package/lib/goog/math/math.js +0 -451
  443. package/lib/goog/math/rect.js +0 -476
  444. package/lib/goog/math/size.js +0 -227
  445. package/lib/goog/net/wrapperxmlhttpfactory.js +0 -71
  446. package/lib/goog/net/xhrlike.js +0 -124
  447. package/lib/goog/net/xmlhttp.js +0 -246
  448. package/lib/goog/net/xmlhttpfactory.js +0 -67
  449. package/lib/goog/object/object.js +0 -686
  450. package/lib/goog/promise/promise.js +0 -1310
  451. package/lib/goog/promise/resolver.js +0 -48
  452. package/lib/goog/promise/thenable.js +0 -126
  453. package/lib/goog/reflect/reflect.js +0 -78
  454. package/lib/goog/string/const.js +0 -182
  455. package/lib/goog/string/string.js +0 -1565
  456. package/lib/goog/string/typedstring.js +0 -48
  457. package/lib/goog/structs/collection.js +0 -56
  458. package/lib/goog/structs/map.js +0 -456
  459. package/lib/goog/structs/set.js +0 -279
  460. package/lib/goog/structs/structs.js +0 -354
  461. package/lib/goog/style/style.js +0 -2054
  462. package/lib/goog/testing/asserts.js +0 -1265
  463. package/lib/goog/testing/events/events.js +0 -727
  464. package/lib/goog/testing/functionmock.js +0 -176
  465. package/lib/goog/testing/jsunit.js +0 -162
  466. package/lib/goog/testing/loosemock.js +0 -242
  467. package/lib/goog/testing/mock.js +0 -645
  468. package/lib/goog/testing/mockclock.js +0 -617
  469. package/lib/goog/testing/mockcontrol.js +0 -220
  470. package/lib/goog/testing/mockinterface.js +0 -45
  471. package/lib/goog/testing/mockmatchers.js +0 -400
  472. package/lib/goog/testing/objectpropertystring.js +0 -68
  473. package/lib/goog/testing/propertyreplacer.js +0 -245
  474. package/lib/goog/testing/recordfunction.js +0 -215
  475. package/lib/goog/testing/stacktrace.js +0 -594
  476. package/lib/goog/testing/strictmock.js +0 -130
  477. package/lib/goog/testing/testcase.js +0 -1569
  478. package/lib/goog/testing/testrunner.js +0 -440
  479. package/lib/goog/testing/watchers.js +0 -46
  480. package/lib/goog/uri/uri.js +0 -1507
  481. package/lib/goog/uri/utils.js +0 -1116
  482. package/lib/goog/useragent/product.js +0 -175
  483. package/lib/goog/useragent/product_isversion.js +0 -143
  484. package/lib/goog/useragent/useragent.js +0 -538
  485. package/lib/webdriver/actionsequence.js +0 -356
  486. package/lib/webdriver/builder.js +0 -208
  487. package/lib/webdriver/capabilities.js +0 -411
  488. package/lib/webdriver/events.js +0 -179
  489. package/lib/webdriver/firefoxdomexecutor.js +0 -175
  490. package/lib/webdriver/http/corsclient.js +0 -133
  491. package/lib/webdriver/http/http.js +0 -523
  492. package/lib/webdriver/http/xhrclient.js +0 -67
  493. package/lib/webdriver/locators.js +0 -257
  494. package/lib/webdriver/logging.js +0 -347
  495. package/lib/webdriver/promise.js +0 -2609
  496. package/lib/webdriver/serializable.js +0 -41
  497. package/lib/webdriver/session.js +0 -74
  498. package/lib/webdriver/stacktrace.js +0 -619
  499. package/lib/webdriver/test/builder_test.js +0 -53
  500. package/lib/webdriver/test/capabilities_test.js +0 -72
  501. package/lib/webdriver/test/events_test.js +0 -203
  502. package/lib/webdriver/test/http/corsclient_test.js +0 -151
  503. package/lib/webdriver/test/http/http_test.js +0 -428
  504. package/lib/webdriver/test/http/xhrclient_test.js +0 -196
  505. package/lib/webdriver/test/locators_test.js +0 -59
  506. package/lib/webdriver/test/logging_test.js +0 -85
  507. package/lib/webdriver/test/promise_error_test.js +0 -719
  508. package/lib/webdriver/test/promise_flow_test.js +0 -1957
  509. package/lib/webdriver/test/promise_generator_test.js +0 -251
  510. package/lib/webdriver/test/promise_test.js +0 -1981
  511. package/lib/webdriver/test/stacktrace_test.js +0 -480
  512. package/lib/webdriver/test/test_bootstrap.js +0 -67
  513. package/lib/webdriver/test/testing/asserts_test.js +0 -117
  514. package/lib/webdriver/test/testing/client_test.js +0 -88
  515. package/lib/webdriver/test/testing/testcase_test.js +0 -229
  516. package/lib/webdriver/test/testutil.js +0 -209
  517. package/lib/webdriver/test/testutil_test.js +0 -104
  518. package/lib/webdriver/test/until_test.js +0 -411
  519. package/lib/webdriver/test/webdriver_generator_test.js +0 -92
  520. package/lib/webdriver/test/webdriver_test.js +0 -2369
  521. package/lib/webdriver/testing/asserts.js +0 -487
  522. package/lib/webdriver/testing/client.js +0 -179
  523. package/lib/webdriver/testing/jsunit.js +0 -363
  524. package/lib/webdriver/testing/testcase.js +0 -168
  525. package/lib/webdriver/testing/window.js +0 -244
  526. package/lib/webdriver/touchsequence.js +0 -248
  527. package/lib/webdriver/until.js +0 -412
  528. package/lib/webdriver/webdriver.js +0 -2492
  529. package/test/_base_test.js +0 -129
@@ -1,1265 +0,0 @@
1
- // Copyright 2010 The Closure Library Authors. All Rights Reserved.
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS-IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
- goog.provide('goog.testing.JsUnitException');
15
- goog.provide('goog.testing.asserts');
16
- goog.provide('goog.testing.asserts.ArrayLike');
17
-
18
- goog.require('goog.testing.stacktrace');
19
-
20
- // TODO(user): Copied from JsUnit with some small modifications, we should
21
- // reimplement the asserters.
22
-
23
-
24
- /**
25
- * @typedef {Array|NodeList|Arguments|{length: number}}
26
- */
27
- goog.testing.asserts.ArrayLike;
28
-
29
- var DOUBLE_EQUALITY_PREDICATE = function(var1, var2) {
30
- return var1 == var2;
31
- };
32
- var JSUNIT_UNDEFINED_VALUE;
33
- var TO_STRING_EQUALITY_PREDICATE = function(var1, var2) {
34
- return var1.toString() === var2.toString();
35
- };
36
-
37
- var PRIMITIVE_EQUALITY_PREDICATES = {
38
- 'String': DOUBLE_EQUALITY_PREDICATE,
39
- 'Number': DOUBLE_EQUALITY_PREDICATE,
40
- 'Boolean': DOUBLE_EQUALITY_PREDICATE,
41
- 'Date': function(date1, date2) {
42
- return date1.getTime() == date2.getTime();
43
- },
44
- 'RegExp': TO_STRING_EQUALITY_PREDICATE,
45
- 'Function': TO_STRING_EQUALITY_PREDICATE
46
- };
47
-
48
-
49
- /**
50
- * Compares equality of two numbers, allowing them to differ up to a given
51
- * tolerance.
52
- * @param {number} var1 A number.
53
- * @param {number} var2 A number.
54
- * @param {number} tolerance the maximum allowed difference.
55
- * @return {boolean} Whether the two variables are sufficiently close.
56
- * @private
57
- */
58
- goog.testing.asserts.numberRoughEqualityPredicate_ = function(
59
- var1, var2, tolerance) {
60
- return Math.abs(var1 - var2) <= tolerance;
61
- };
62
-
63
-
64
- /**
65
- * @type {Object<string, function(*, *, number): boolean>}
66
- * @private
67
- */
68
- goog.testing.asserts.primitiveRoughEqualityPredicates_ = {
69
- 'Number': goog.testing.asserts.numberRoughEqualityPredicate_
70
- };
71
-
72
-
73
- var _trueTypeOf = function(something) {
74
- var result = typeof something;
75
- try {
76
- switch (result) {
77
- case 'string':
78
- break;
79
- case 'boolean':
80
- break;
81
- case 'number':
82
- break;
83
- case 'object':
84
- if (something == null) {
85
- result = 'null';
86
- break;
87
- }
88
- case 'function':
89
- switch (something.constructor) {
90
- case new String('').constructor:
91
- result = 'String';
92
- break;
93
- case new Boolean(true).constructor:
94
- result = 'Boolean';
95
- break;
96
- case new Number(0).constructor:
97
- result = 'Number';
98
- break;
99
- case new Array().constructor:
100
- result = 'Array';
101
- break;
102
- case new RegExp().constructor:
103
- result = 'RegExp';
104
- break;
105
- case new Date().constructor:
106
- result = 'Date';
107
- break;
108
- case Function:
109
- result = 'Function';
110
- break;
111
- default:
112
- var m = something.constructor.toString().match(
113
- /function\s*([^( ]+)\(/);
114
- if (m) {
115
- result = m[1];
116
- } else {
117
- break;
118
- }
119
- }
120
- break;
121
- }
122
- } catch (e) {
123
-
124
- } finally {
125
- result = result.substr(0, 1).toUpperCase() + result.substr(1);
126
- }
127
- return result;
128
- };
129
-
130
- var _displayStringForValue = function(aVar) {
131
- var result;
132
- try {
133
- result = '<' + String(aVar) + '>';
134
- } catch (ex) {
135
- result = '<toString failed: ' + ex.message + '>';
136
- // toString does not work on this object :-(
137
- }
138
- if (!(aVar === null || aVar === JSUNIT_UNDEFINED_VALUE)) {
139
- result += ' (' + _trueTypeOf(aVar) + ')';
140
- }
141
- return result;
142
- };
143
-
144
- var fail = function(failureMessage) {
145
- goog.testing.asserts.raiseException('Call to fail()', failureMessage);
146
- };
147
-
148
- var argumentsIncludeComments = function(expectedNumberOfNonCommentArgs, args) {
149
- return args.length == expectedNumberOfNonCommentArgs + 1;
150
- };
151
-
152
- var commentArg = function(expectedNumberOfNonCommentArgs, args) {
153
- if (argumentsIncludeComments(expectedNumberOfNonCommentArgs, args)) {
154
- return args[0];
155
- }
156
-
157
- return null;
158
- };
159
-
160
- var nonCommentArg = function(desiredNonCommentArgIndex,
161
- expectedNumberOfNonCommentArgs, args) {
162
- return argumentsIncludeComments(expectedNumberOfNonCommentArgs, args) ?
163
- args[desiredNonCommentArgIndex] :
164
- args[desiredNonCommentArgIndex - 1];
165
- };
166
-
167
- var _validateArguments = function(expectedNumberOfNonCommentArgs, args) {
168
- var valid = args.length == expectedNumberOfNonCommentArgs ||
169
- args.length == expectedNumberOfNonCommentArgs + 1 &&
170
- goog.isString(args[0]);
171
- _assert(null, valid, 'Incorrect arguments passed to assert function');
172
- };
173
-
174
- var _assert = function(comment, booleanValue, failureMessage) {
175
- if (!booleanValue) {
176
- goog.testing.asserts.raiseException(comment, failureMessage);
177
- }
178
- };
179
-
180
-
181
- /**
182
- * @param {*} expected The expected value.
183
- * @param {*} actual The actual value.
184
- * @return {string} A failure message of the values don't match.
185
- * @private
186
- */
187
- goog.testing.asserts.getDefaultErrorMsg_ = function(expected, actual) {
188
- var msg = 'Expected ' + _displayStringForValue(expected) + ' but was ' +
189
- _displayStringForValue(actual);
190
- if ((typeof expected == 'string') && (typeof actual == 'string')) {
191
- // Try to find a human-readable difference.
192
- var limit = Math.min(expected.length, actual.length);
193
- var commonPrefix = 0;
194
- while (commonPrefix < limit &&
195
- expected.charAt(commonPrefix) == actual.charAt(commonPrefix)) {
196
- commonPrefix++;
197
- }
198
-
199
- var commonSuffix = 0;
200
- while (commonSuffix < limit &&
201
- expected.charAt(expected.length - commonSuffix - 1) ==
202
- actual.charAt(actual.length - commonSuffix - 1)) {
203
- commonSuffix++;
204
- }
205
-
206
- if (commonPrefix + commonSuffix > limit) {
207
- commonSuffix = 0;
208
- }
209
-
210
- if (commonPrefix > 2 || commonSuffix > 2) {
211
- var printString = function(str) {
212
- var startIndex = Math.max(0, commonPrefix - 2);
213
- var endIndex = Math.min(str.length, str.length - (commonSuffix - 2));
214
- return (startIndex > 0 ? '...' : '') +
215
- str.substring(startIndex, endIndex) +
216
- (endIndex < str.length ? '...' : '');
217
- };
218
-
219
- msg += '\nDifference was at position ' + commonPrefix +
220
- '. Expected [' + printString(expected) +
221
- '] vs. actual [' + printString(actual) + ']';
222
- }
223
- }
224
- return msg;
225
- };
226
-
227
-
228
- /**
229
- * @param {*} a The value to assert (1 arg) or debug message (2 args).
230
- * @param {*=} opt_b The value to assert (2 args only).
231
- */
232
- var assert = function(a, opt_b) {
233
- _validateArguments(1, arguments);
234
- var comment = commentArg(1, arguments);
235
- var booleanValue = nonCommentArg(1, 1, arguments);
236
-
237
- _assert(comment, goog.isBoolean(booleanValue),
238
- 'Bad argument to assert(boolean)');
239
- _assert(comment, booleanValue, 'Call to assert(boolean) with false');
240
- };
241
-
242
-
243
- /**
244
- * Asserts that the function throws an error.
245
- *
246
- * @param {!(string|Function)} a The assertion comment or the function to call.
247
- * @param {!Function=} opt_b The function to call (if the first argument of
248
- * {@code assertThrows} was the comment).
249
- * @return {*} The error thrown by the function.
250
- * @throws {goog.testing.JsUnitException} If the assertion failed.
251
- */
252
- var assertThrows = function(a, opt_b) {
253
- _validateArguments(1, arguments);
254
- var func = nonCommentArg(1, 1, arguments);
255
- var comment = commentArg(1, arguments);
256
- _assert(comment, typeof func == 'function',
257
- 'Argument passed to assertThrows is not a function');
258
-
259
- try {
260
- func();
261
- } catch (e) {
262
- if (e && goog.isString(e['stacktrace']) && goog.isString(e['message'])) {
263
- // Remove the stack trace appended to the error message by Opera 10.0
264
- var startIndex = e['message'].length - e['stacktrace'].length;
265
- if (e['message'].indexOf(e['stacktrace'], startIndex) == startIndex) {
266
- e['message'] = e['message'].substr(0, startIndex - 14);
267
- }
268
- }
269
- return e;
270
- }
271
- goog.testing.asserts.raiseException(comment,
272
- 'No exception thrown from function passed to assertThrows');
273
- };
274
-
275
-
276
- /**
277
- * Asserts that the function does not throw an error.
278
- *
279
- * @param {!(string|Function)} a The assertion comment or the function to call.
280
- * @param {!Function=} opt_b The function to call (if the first argument of
281
- * {@code assertNotThrows} was the comment).
282
- * @return {*} The return value of the function.
283
- * @throws {goog.testing.JsUnitException} If the assertion failed.
284
- */
285
- var assertNotThrows = function(a, opt_b) {
286
- _validateArguments(1, arguments);
287
- var comment = commentArg(1, arguments);
288
- var func = nonCommentArg(1, 1, arguments);
289
- _assert(comment, typeof func == 'function',
290
- 'Argument passed to assertNotThrows is not a function');
291
-
292
- try {
293
- return func();
294
- } catch (e) {
295
- comment = comment ? (comment + '\n') : '';
296
- comment += 'A non expected exception was thrown from function passed to ' +
297
- 'assertNotThrows';
298
- // Some browsers don't have a stack trace so at least have the error
299
- // description.
300
- var stackTrace = e['stack'] || e['stacktrace'] || e.toString();
301
- goog.testing.asserts.raiseException(comment, stackTrace);
302
- }
303
- };
304
-
305
-
306
- /**
307
- * Asserts that the given callback function results in a JsUnitException when
308
- * called, and that the resulting failure message matches the given expected
309
- * message.
310
- * @param {function() : void} callback Function to be run expected to result
311
- * in a JsUnitException (usually contains a call to an assert).
312
- * @param {string=} opt_expectedMessage Failure message expected to be given
313
- * with the exception.
314
- */
315
- var assertThrowsJsUnitException = function(callback, opt_expectedMessage) {
316
- var failed = false;
317
- try {
318
- goog.testing.asserts.callWithoutLogging(callback);
319
- } catch (ex) {
320
- if (!ex.isJsUnitException) {
321
- fail('Expected a JsUnitException');
322
- }
323
- if (typeof opt_expectedMessage != 'undefined' &&
324
- ex.message != opt_expectedMessage) {
325
- fail('Expected message [' + opt_expectedMessage + '] but got [' +
326
- ex.message + ']');
327
- }
328
- failed = true;
329
- }
330
- if (!failed) {
331
- fail('Expected a failure: ' + opt_expectedMessage);
332
- }
333
- };
334
-
335
-
336
- /**
337
- * @param {*} a The value to assert (1 arg) or debug message (2 args).
338
- * @param {*=} opt_b The value to assert (2 args only).
339
- */
340
- var assertTrue = function(a, opt_b) {
341
- _validateArguments(1, arguments);
342
- var comment = commentArg(1, arguments);
343
- var booleanValue = nonCommentArg(1, 1, arguments);
344
-
345
- _assert(comment, goog.isBoolean(booleanValue),
346
- 'Bad argument to assertTrue(boolean)');
347
- _assert(comment, booleanValue, 'Call to assertTrue(boolean) with false');
348
- };
349
-
350
-
351
- /**
352
- * @param {*} a The value to assert (1 arg) or debug message (2 args).
353
- * @param {*=} opt_b The value to assert (2 args only).
354
- */
355
- var assertFalse = function(a, opt_b) {
356
- _validateArguments(1, arguments);
357
- var comment = commentArg(1, arguments);
358
- var booleanValue = nonCommentArg(1, 1, arguments);
359
-
360
- _assert(comment, goog.isBoolean(booleanValue),
361
- 'Bad argument to assertFalse(boolean)');
362
- _assert(comment, !booleanValue, 'Call to assertFalse(boolean) with true');
363
- };
364
-
365
-
366
- /**
367
- * @param {*} a The expected value (2 args) or the debug message (3 args).
368
- * @param {*} b The actual value (2 args) or the expected value (3 args).
369
- * @param {*=} opt_c The actual value (3 args only).
370
- */
371
- var assertEquals = function(a, b, opt_c) {
372
- _validateArguments(2, arguments);
373
- var var1 = nonCommentArg(1, 2, arguments);
374
- var var2 = nonCommentArg(2, 2, arguments);
375
- _assert(commentArg(2, arguments), var1 === var2,
376
- goog.testing.asserts.getDefaultErrorMsg_(var1, var2));
377
- };
378
-
379
-
380
- /**
381
- * @param {*} a The expected value (2 args) or the debug message (3 args).
382
- * @param {*} b The actual value (2 args) or the expected value (3 args).
383
- * @param {*=} opt_c The actual value (3 args only).
384
- */
385
- var assertNotEquals = function(a, b, opt_c) {
386
- _validateArguments(2, arguments);
387
- var var1 = nonCommentArg(1, 2, arguments);
388
- var var2 = nonCommentArg(2, 2, arguments);
389
- _assert(commentArg(2, arguments), var1 !== var2,
390
- 'Expected not to be ' + _displayStringForValue(var2));
391
- };
392
-
393
-
394
- /**
395
- * @param {*} a The value to assert (1 arg) or debug message (2 args).
396
- * @param {*=} opt_b The value to assert (2 args only).
397
- */
398
- var assertNull = function(a, opt_b) {
399
- _validateArguments(1, arguments);
400
- var aVar = nonCommentArg(1, 1, arguments);
401
- _assert(commentArg(1, arguments), aVar === null,
402
- goog.testing.asserts.getDefaultErrorMsg_(null, aVar));
403
- };
404
-
405
-
406
- /**
407
- * @param {*} a The value to assert (1 arg) or debug message (2 args).
408
- * @param {*=} opt_b The value to assert (2 args only).
409
- */
410
- var assertNotNull = function(a, opt_b) {
411
- _validateArguments(1, arguments);
412
- var aVar = nonCommentArg(1, 1, arguments);
413
- _assert(commentArg(1, arguments), aVar !== null,
414
- 'Expected not to be ' + _displayStringForValue(null));
415
- };
416
-
417
-
418
- /**
419
- * @param {*} a The value to assert (1 arg) or debug message (2 args).
420
- * @param {*=} opt_b The value to assert (2 args only).
421
- */
422
- var assertUndefined = function(a, opt_b) {
423
- _validateArguments(1, arguments);
424
- var aVar = nonCommentArg(1, 1, arguments);
425
- _assert(commentArg(1, arguments), aVar === JSUNIT_UNDEFINED_VALUE,
426
- goog.testing.asserts.getDefaultErrorMsg_(JSUNIT_UNDEFINED_VALUE, aVar));
427
- };
428
-
429
-
430
- /**
431
- * @param {*} a The value to assert (1 arg) or debug message (2 args).
432
- * @param {*=} opt_b The value to assert (2 args only).
433
- */
434
- var assertNotUndefined = function(a, opt_b) {
435
- _validateArguments(1, arguments);
436
- var aVar = nonCommentArg(1, 1, arguments);
437
- _assert(commentArg(1, arguments), aVar !== JSUNIT_UNDEFINED_VALUE,
438
- 'Expected not to be ' + _displayStringForValue(JSUNIT_UNDEFINED_VALUE));
439
- };
440
-
441
-
442
- /**
443
- * @param {*} a The value to assert (1 arg) or debug message (2 args).
444
- * @param {*=} opt_b The value to assert (2 args only).
445
- */
446
- var assertNotNullNorUndefined = function(a, opt_b) {
447
- _validateArguments(1, arguments);
448
- assertNotNull.apply(null, arguments);
449
- assertNotUndefined.apply(null, arguments);
450
- };
451
-
452
-
453
- /**
454
- * @param {*} a The value to assert (1 arg) or debug message (2 args).
455
- * @param {*=} opt_b The value to assert (2 args only).
456
- */
457
- var assertNonEmptyString = function(a, opt_b) {
458
- _validateArguments(1, arguments);
459
- var aVar = nonCommentArg(1, 1, arguments);
460
- _assert(commentArg(1, arguments),
461
- aVar !== JSUNIT_UNDEFINED_VALUE && aVar !== null &&
462
- typeof aVar == 'string' && aVar !== '',
463
- 'Expected non-empty string but was ' + _displayStringForValue(aVar));
464
- };
465
-
466
-
467
- /**
468
- * @param {*} a The value to assert (1 arg) or debug message (2 args).
469
- * @param {*=} opt_b The value to assert (2 args only).
470
- */
471
- var assertNaN = function(a, opt_b) {
472
- _validateArguments(1, arguments);
473
- var aVar = nonCommentArg(1, 1, arguments);
474
- _assert(commentArg(1, arguments), isNaN(aVar), 'Expected NaN');
475
- };
476
-
477
-
478
- /**
479
- * @param {*} a The value to assert (1 arg) or debug message (2 args).
480
- * @param {*=} opt_b The value to assert (2 args only).
481
- */
482
- var assertNotNaN = function(a, opt_b) {
483
- _validateArguments(1, arguments);
484
- var aVar = nonCommentArg(1, 1, arguments);
485
- _assert(commentArg(1, arguments), !isNaN(aVar), 'Expected not NaN');
486
- };
487
-
488
-
489
- /**
490
- * Runs a function in an environment where test failures are not logged. This is
491
- * useful for testing test code, where failures can be a normal part of a test.
492
- * @param {function() : void} fn Function to run without logging failures.
493
- */
494
- goog.testing.asserts.callWithoutLogging = function(fn) {
495
- var testRunner = goog.global['G_testRunner'];
496
- var oldLogTestFailure = testRunner['logTestFailure'];
497
- try {
498
- // Any failures in the callback shouldn't be recorded.
499
- testRunner['logTestFailure'] = undefined;
500
- fn();
501
- } finally {
502
- testRunner['logTestFailure'] = oldLogTestFailure;
503
- }
504
- };
505
-
506
-
507
- /**
508
- * The return value of the equality predicate passed to findDifferences below,
509
- * in cases where the predicate can't test the input variables for equality.
510
- * @type {?string}
511
- */
512
- goog.testing.asserts.EQUALITY_PREDICATE_CANT_PROCESS = null;
513
-
514
-
515
- /**
516
- * The return value of the equality predicate passed to findDifferences below,
517
- * in cases where the input vriables are equal.
518
- * @type {?string}
519
- */
520
- goog.testing.asserts.EQUALITY_PREDICATE_VARS_ARE_EQUAL = '';
521
-
522
-
523
- /**
524
- * Determines if two items of any type match, and formulates an error message
525
- * if not.
526
- * @param {*} expected Expected argument to match.
527
- * @param {*} actual Argument as a result of performing the test.
528
- * @param {(function(string, *, *): ?string)=} opt_equalityPredicate An optional
529
- * function that can be used to check equality of variables. It accepts 3
530
- * arguments: type-of-variables, var1, var2 (in that order) and returns an
531
- * error message if the variables are not equal,
532
- * goog.testing.asserts.EQUALITY_PREDICATE_VARS_ARE_EQUAL if the variables
533
- * are equal, or
534
- * goog.testing.asserts.EQUALITY_PREDICATE_CANT_PROCESS if the predicate
535
- * couldn't check the input variables. The function will be called only if
536
- * the types of var1 and var2 are identical.
537
- * @return {?string} Null on success, error message on failure.
538
- */
539
- goog.testing.asserts.findDifferences = function(expected, actual,
540
- opt_equalityPredicate) {
541
- var failures = [];
542
- var seen1 = [];
543
- var seen2 = [];
544
-
545
- // To avoid infinite recursion when the two parameters are self-referential
546
- // along the same path of properties, keep track of the object pairs already
547
- // seen in this call subtree, and abort when a cycle is detected.
548
- function innerAssertWithCycleCheck(var1, var2, path) {
549
- // This is used for testing, so we can afford to be slow (but more
550
- // accurate). So we just check whether var1 is in seen1. If we
551
- // found var1 in index i, we simply need to check whether var2 is
552
- // in seen2[i]. If it is, we do not recurse to check var1/var2. If
553
- // it isn't, we know that the structures of the two objects must be
554
- // different.
555
- //
556
- // This is based on the fact that values at index i in seen1 and
557
- // seen2 will be checked for equality eventually (when
558
- // innerAssertImplementation(seen1[i], seen2[i], path) finishes).
559
- for (var i = 0; i < seen1.length; ++i) {
560
- var match1 = seen1[i] === var1;
561
- var match2 = seen2[i] === var2;
562
- if (match1 || match2) {
563
- if (!match1 || !match2) {
564
- // Asymmetric cycles, so the objects have different structure.
565
- failures.push('Asymmetric cycle detected at ' + path);
566
- }
567
- return;
568
- }
569
- }
570
-
571
- seen1.push(var1);
572
- seen2.push(var2);
573
- innerAssertImplementation(var1, var2, path);
574
- seen1.pop();
575
- seen2.pop();
576
- }
577
-
578
- var equalityPredicate = opt_equalityPredicate || function(type, var1, var2) {
579
- var typedPredicate = PRIMITIVE_EQUALITY_PREDICATES[type];
580
- if (!typedPredicate) {
581
- return goog.testing.asserts.EQUALITY_PREDICATE_CANT_PROCESS;
582
- }
583
- var equal = typedPredicate(var1, var2);
584
- return equal ? goog.testing.asserts.EQUALITY_PREDICATE_VARS_ARE_EQUAL :
585
- goog.testing.asserts.getDefaultErrorMsg_(var1, var2);
586
- };
587
-
588
- /**
589
- * @param {*} var1 An item in the expected object.
590
- * @param {*} var2 The corresponding item in the actual object.
591
- * @param {string} path Their path in the objects.
592
- * @suppress {missingProperties} The map_ property is unknown to the compiler
593
- * unless goog.structs.Map is loaded.
594
- */
595
- function innerAssertImplementation(var1, var2, path) {
596
- if (var1 === var2) {
597
- return;
598
- }
599
-
600
- var typeOfVar1 = _trueTypeOf(var1);
601
- var typeOfVar2 = _trueTypeOf(var2);
602
-
603
- if (typeOfVar1 == typeOfVar2) {
604
- var isArray = typeOfVar1 == 'Array';
605
- var errorMessage = equalityPredicate(typeOfVar1, var1, var2);
606
- if (errorMessage !=
607
- goog.testing.asserts.EQUALITY_PREDICATE_CANT_PROCESS) {
608
- if (errorMessage !=
609
- goog.testing.asserts.EQUALITY_PREDICATE_VARS_ARE_EQUAL) {
610
- failures.push(path + ': ' + errorMessage);
611
- }
612
- } else if (isArray && var1.length != var2.length) {
613
- failures.push(path + ': Expected ' + var1.length + '-element array ' +
614
- 'but got a ' + var2.length + '-element array');
615
- } else {
616
- var childPath = path + (isArray ? '[%s]' : (path ? '.%s' : '%s'));
617
-
618
- // if an object has an __iterator__ property, we have no way of
619
- // actually inspecting its raw properties, and JS 1.7 doesn't
620
- // overload [] to make it possible for someone to generically
621
- // use what the iterator returns to compare the object-managed
622
- // properties. This gets us into deep poo with things like
623
- // goog.structs.Map, at least on systems that support iteration.
624
- if (!var1['__iterator__']) {
625
- for (var prop in var1) {
626
- if (isArray && goog.testing.asserts.isArrayIndexProp_(prop)) {
627
- // Skip array indices for now. We'll handle them later.
628
- continue;
629
- }
630
-
631
- if (prop in var2) {
632
- innerAssertWithCycleCheck(var1[prop], var2[prop],
633
- childPath.replace('%s', prop));
634
- } else {
635
- failures.push('property ' + prop +
636
- ' not present in actual ' + (path || typeOfVar2));
637
- }
638
- }
639
- // make sure there aren't properties in var2 that are missing
640
- // from var1. if there are, then by definition they don't
641
- // match.
642
- for (var prop in var2) {
643
- if (isArray && goog.testing.asserts.isArrayIndexProp_(prop)) {
644
- // Skip array indices for now. We'll handle them later.
645
- continue;
646
- }
647
-
648
- if (!(prop in var1)) {
649
- failures.push('property ' + prop +
650
- ' not present in expected ' +
651
- (path || typeOfVar1));
652
- }
653
- }
654
-
655
- // Handle array indices by iterating from 0 to arr.length.
656
- //
657
- // Although all browsers allow holes in arrays, browsers
658
- // are inconsistent in what they consider a hole. For example,
659
- // "[0,undefined,2]" has a hole on IE but not on Firefox.
660
- //
661
- // Because our style guide bans for...in iteration over arrays,
662
- // we assume that most users don't care about holes in arrays,
663
- // and that it is ok to say that a hole is equivalent to a slot
664
- // populated with 'undefined'.
665
- if (isArray) {
666
- for (prop = 0; prop < var1.length; prop++) {
667
- innerAssertWithCycleCheck(var1[prop], var2[prop],
668
- childPath.replace('%s', String(prop)));
669
- }
670
- }
671
- } else {
672
- // special-case for closure objects that have iterators
673
- if (goog.isFunction(var1.equals)) {
674
- // use the object's own equals function, assuming it accepts an
675
- // object and returns a boolean
676
- if (!var1.equals(var2)) {
677
- failures.push('equals() returned false for ' +
678
- (path || typeOfVar1));
679
- }
680
- } else if (var1.map_) {
681
- // assume goog.structs.Map or goog.structs.Set, where comparing
682
- // their private map_ field is sufficient
683
- innerAssertWithCycleCheck(var1.map_, var2.map_,
684
- childPath.replace('%s', 'map_'));
685
- } else {
686
- // else die, so user knows we can't do anything
687
- failures.push('unable to check ' + (path || typeOfVar1) +
688
- ' for equality: it has an iterator we do not ' +
689
- 'know how to handle. please add an equals method');
690
- }
691
- }
692
- }
693
- } else {
694
- failures.push(path + ' ' +
695
- goog.testing.asserts.getDefaultErrorMsg_(var1, var2));
696
- }
697
- }
698
-
699
- innerAssertWithCycleCheck(expected, actual, '');
700
- return failures.length == 0 ? null :
701
- goog.testing.asserts.getDefaultErrorMsg_(expected, actual) +
702
- '\n ' + failures.join('\n ');
703
- };
704
-
705
-
706
- /**
707
- * Notes:
708
- * Object equality has some nasty browser quirks, and this implementation is
709
- * not 100% correct. For example,
710
- *
711
- * <code>
712
- * var a = [0, 1, 2];
713
- * var b = [0, 1, 2];
714
- * delete a[1];
715
- * b[1] = undefined;
716
- * assertObjectEquals(a, b); // should fail, but currently passes
717
- * </code>
718
- *
719
- * See asserts_test.html for more interesting edge cases.
720
- *
721
- * The first comparison object provided is the expected value, the second is
722
- * the actual.
723
- *
724
- * @param {*} a Assertion message or comparison object.
725
- * @param {*} b Comparison object.
726
- * @param {*=} opt_c Comparison object, if an assertion message was provided.
727
- */
728
- var assertObjectEquals = function(a, b, opt_c) {
729
- _validateArguments(2, arguments);
730
- var v1 = nonCommentArg(1, 2, arguments);
731
- var v2 = nonCommentArg(2, 2, arguments);
732
- var failureMessage = commentArg(2, arguments) ? commentArg(2, arguments) : '';
733
- var differences = goog.testing.asserts.findDifferences(v1, v2);
734
-
735
- _assert(failureMessage, !differences, differences);
736
- };
737
-
738
-
739
- /**
740
- * Similar to assertObjectEquals above, but accepts a tolerance margin.
741
- *
742
- * @param {*} a Assertion message or comparison object.
743
- * @param {*} b Comparison object.
744
- * @param {*} c Comparison object or tolerance.
745
- * @param {*=} opt_d Tolerance, if an assertion message was provided.
746
- */
747
- var assertObjectRoughlyEquals = function(a, b, c, opt_d) {
748
- _validateArguments(3, arguments);
749
- var v1 = nonCommentArg(1, 3, arguments);
750
- var v2 = nonCommentArg(2, 3, arguments);
751
- var tolerance = nonCommentArg(3, 3, arguments);
752
- var failureMessage = commentArg(3, arguments) ? commentArg(3, arguments) : '';
753
- var equalityPredicate = function(type, var1, var2) {
754
- var typedPredicate =
755
- goog.testing.asserts.primitiveRoughEqualityPredicates_[type];
756
- if (!typedPredicate) {
757
- return goog.testing.asserts.EQUALITY_PREDICATE_CANT_PROCESS;
758
- }
759
- var equal = typedPredicate(var1, var2, tolerance);
760
- return equal ? goog.testing.asserts.EQUALITY_PREDICATE_VARS_ARE_EQUAL :
761
- goog.testing.asserts.getDefaultErrorMsg_(var1, var2) +
762
- ' which was more than ' + tolerance + ' away';
763
- };
764
- var differences = goog.testing.asserts.findDifferences(
765
- v1, v2, equalityPredicate);
766
-
767
- _assert(failureMessage, !differences, differences);
768
- };
769
-
770
-
771
- /**
772
- * Compares two arbitrary objects for non-equalness.
773
- *
774
- * All the same caveats as for assertObjectEquals apply here:
775
- * Undefined values may be confused for missing values, or vice versa.
776
- *
777
- * @param {*} a Assertion message or comparison object.
778
- * @param {*} b Comparison object.
779
- * @param {*=} opt_c Comparison object, if an assertion message was provided.
780
- */
781
- var assertObjectNotEquals = function(a, b, opt_c) {
782
- _validateArguments(2, arguments);
783
- var v1 = nonCommentArg(1, 2, arguments);
784
- var v2 = nonCommentArg(2, 2, arguments);
785
- var failureMessage = commentArg(2, arguments) ? commentArg(2, arguments) : '';
786
- var differences = goog.testing.asserts.findDifferences(v1, v2);
787
-
788
- _assert(failureMessage, differences, 'Objects should not be equal');
789
- };
790
-
791
-
792
- /**
793
- * Compares two arrays ignoring negative indexes and extra properties on the
794
- * array objects. Use case: Internet Explorer adds the index, lastIndex and
795
- * input enumerable fields to the result of string.match(/regexp/g), which makes
796
- * assertObjectEquals fail.
797
- * @param {*} a The expected array (2 args) or the debug message (3 args).
798
- * @param {*} b The actual array (2 args) or the expected array (3 args).
799
- * @param {*=} opt_c The actual array (3 args only).
800
- */
801
- var assertArrayEquals = function(a, b, opt_c) {
802
- _validateArguments(2, arguments);
803
- var v1 = nonCommentArg(1, 2, arguments);
804
- var v2 = nonCommentArg(2, 2, arguments);
805
- var failureMessage = commentArg(2, arguments) ? commentArg(2, arguments) : '';
806
-
807
- var typeOfVar1 = _trueTypeOf(v1);
808
- _assert(failureMessage,
809
- typeOfVar1 == 'Array',
810
- 'Expected an array for assertArrayEquals but found a ' + typeOfVar1);
811
-
812
- var typeOfVar2 = _trueTypeOf(v2);
813
- _assert(failureMessage,
814
- typeOfVar2 == 'Array',
815
- 'Expected an array for assertArrayEquals but found a ' + typeOfVar2);
816
-
817
- assertObjectEquals(failureMessage,
818
- Array.prototype.concat.call(v1), Array.prototype.concat.call(v2));
819
- };
820
-
821
-
822
- /**
823
- * Compares two objects that can be accessed like an array and assert that
824
- * each element is equal.
825
- * @param {string|Object} a Failure message (3 arguments)
826
- * or object #1 (2 arguments).
827
- * @param {Object} b Object #1 (2 arguments) or object #2 (3 arguments).
828
- * @param {Object=} opt_c Object #2 (3 arguments).
829
- */
830
- var assertElementsEquals = function(a, b, opt_c) {
831
- _validateArguments(2, arguments);
832
-
833
- var v1 = nonCommentArg(1, 2, arguments);
834
- var v2 = nonCommentArg(2, 2, arguments);
835
- var failureMessage = commentArg(2, arguments) ? commentArg(2, arguments) : '';
836
-
837
- if (!v1) {
838
- assert(failureMessage, !v2);
839
- } else {
840
- assertEquals('length mismatch: ' + failureMessage, v1.length, v2.length);
841
- for (var i = 0; i < v1.length; ++i) {
842
- assertEquals(
843
- 'mismatch at index ' + i + ': ' + failureMessage, v1[i], v2[i]);
844
- }
845
- }
846
- };
847
-
848
-
849
- /**
850
- * Compares two objects that can be accessed like an array and assert that
851
- * each element is roughly equal.
852
- * @param {string|Object} a Failure message (4 arguments)
853
- * or object #1 (3 arguments).
854
- * @param {Object} b Object #1 (4 arguments) or object #2 (3 arguments).
855
- * @param {Object|number} c Object #2 (4 arguments) or tolerance (3 arguments).
856
- * @param {number=} opt_d tolerance (4 arguments).
857
- */
858
- var assertElementsRoughlyEqual = function(a, b, c, opt_d) {
859
- _validateArguments(3, arguments);
860
-
861
- var v1 = nonCommentArg(1, 3, arguments);
862
- var v2 = nonCommentArg(2, 3, arguments);
863
- var tolerance = nonCommentArg(3, 3, arguments);
864
- var failureMessage = commentArg(3, arguments) ? commentArg(3, arguments) : '';
865
-
866
- if (!v1) {
867
- assert(failureMessage, !v2);
868
- } else {
869
- assertEquals('length mismatch: ' + failureMessage, v1.length, v2.length);
870
- for (var i = 0; i < v1.length; ++i) {
871
- assertRoughlyEquals(failureMessage, v1[i], v2[i], tolerance);
872
- }
873
- }
874
- };
875
-
876
-
877
- /**
878
- * Compares two array-like objects without taking their order into account.
879
- * @param {string|goog.testing.asserts.ArrayLike} a Assertion message or the
880
- * expected elements.
881
- * @param {goog.testing.asserts.ArrayLike} b Expected elements or the actual
882
- * elements.
883
- * @param {goog.testing.asserts.ArrayLike=} opt_c Actual elements.
884
- */
885
- var assertSameElements = function(a, b, opt_c) {
886
- _validateArguments(2, arguments);
887
- var expected = nonCommentArg(1, 2, arguments);
888
- var actual = nonCommentArg(2, 2, arguments);
889
- var message = commentArg(2, arguments);
890
-
891
- assertTrue('Bad arguments to assertSameElements(opt_message, expected: ' +
892
- 'ArrayLike, actual: ArrayLike)',
893
- goog.isArrayLike(expected) && goog.isArrayLike(actual));
894
-
895
- // Clones expected and actual and converts them to real arrays.
896
- expected = goog.testing.asserts.toArray_(expected);
897
- actual = goog.testing.asserts.toArray_(actual);
898
- // TODO(user): It would be great to show only the difference
899
- // between the expected and actual elements.
900
- _assert(message, expected.length == actual.length,
901
- 'Expected ' + expected.length + ' elements: [' + expected + '], ' +
902
- 'got ' + actual.length + ' elements: [' + actual + ']');
903
-
904
- var toFind = goog.testing.asserts.toArray_(expected);
905
- for (var i = 0; i < actual.length; i++) {
906
- var index = goog.testing.asserts.indexOf_(toFind, actual[i]);
907
- _assert(message, index != -1, 'Expected [' + expected + '], got [' +
908
- actual + ']');
909
- toFind.splice(index, 1);
910
- }
911
- };
912
-
913
-
914
- /**
915
- * @param {*} a The value to assert (1 arg) or debug message (2 args).
916
- * @param {*=} opt_b The value to assert (2 args only).
917
- */
918
- var assertEvaluatesToTrue = function(a, opt_b) {
919
- _validateArguments(1, arguments);
920
- var value = nonCommentArg(1, 1, arguments);
921
- if (!value) {
922
- _assert(commentArg(1, arguments), false, 'Expected to evaluate to true');
923
- }
924
- };
925
-
926
-
927
- /**
928
- * @param {*} a The value to assert (1 arg) or debug message (2 args).
929
- * @param {*=} opt_b The value to assert (2 args only).
930
- */
931
- var assertEvaluatesToFalse = function(a, opt_b) {
932
- _validateArguments(1, arguments);
933
- var value = nonCommentArg(1, 1, arguments);
934
- if (value) {
935
- _assert(commentArg(1, arguments), false, 'Expected to evaluate to false');
936
- }
937
- };
938
-
939
-
940
- /**
941
- * Compares two HTML snippets.
942
- *
943
- * Take extra care if attributes are involved. {@code assertHTMLEquals}'s
944
- * implementation isn't prepared for complex cases. For example, the following
945
- * comparisons erroneously fail:
946
- * <pre>
947
- * assertHTMLEquals('<a href="x" target="y">', '<a target="y" href="x">');
948
- * assertHTMLEquals('<div classname="a b">', '<div classname="b a">');
949
- * assertHTMLEquals('<input disabled>', '<input disabled="disabled">');
950
- * </pre>
951
- *
952
- * When in doubt, use {@code goog.testing.dom.assertHtmlMatches}.
953
- *
954
- * @param {*} a The expected value (2 args) or the debug message (3 args).
955
- * @param {*} b The actual value (2 args) or the expected value (3 args).
956
- * @param {*=} opt_c The actual value (3 args only).
957
- */
958
- var assertHTMLEquals = function(a, b, opt_c) {
959
- _validateArguments(2, arguments);
960
- var var1 = nonCommentArg(1, 2, arguments);
961
- var var2 = nonCommentArg(2, 2, arguments);
962
- var var1Standardized = standardizeHTML(var1);
963
- var var2Standardized = standardizeHTML(var2);
964
-
965
- _assert(commentArg(2, arguments), var1Standardized === var2Standardized,
966
- goog.testing.asserts.getDefaultErrorMsg_(
967
- var1Standardized, var2Standardized));
968
- };
969
-
970
-
971
- /**
972
- * Compares two CSS property values to make sure that they represent the same
973
- * things. This will normalize values in the browser. For example, in Firefox,
974
- * this assertion will consider "rgb(0, 0, 255)" and "#0000ff" to be identical
975
- * values for the "color" property. This function won't normalize everything --
976
- * for example, in most browsers, "blue" will not match "#0000ff". It is
977
- * intended only to compensate for unexpected normalizations performed by
978
- * the browser that should also affect your expected value.
979
- * @param {string} a Assertion message, or the CSS property name.
980
- * @param {string} b CSS property name, or the expected value.
981
- * @param {string} c The expected value, or the actual value.
982
- * @param {string=} opt_d The actual value.
983
- */
984
- var assertCSSValueEquals = function(a, b, c, opt_d) {
985
- _validateArguments(3, arguments);
986
- var propertyName = nonCommentArg(1, 3, arguments);
987
- var expectedValue = nonCommentArg(2, 3, arguments);
988
- var actualValue = nonCommentArg(3, 3, arguments);
989
- var expectedValueStandardized =
990
- standardizeCSSValue(propertyName, expectedValue);
991
- var actualValueStandardized =
992
- standardizeCSSValue(propertyName, actualValue);
993
-
994
- _assert(commentArg(3, arguments),
995
- expectedValueStandardized == actualValueStandardized,
996
- goog.testing.asserts.getDefaultErrorMsg_(
997
- expectedValueStandardized, actualValueStandardized));
998
- };
999
-
1000
-
1001
- /**
1002
- * @param {*} a The expected value (2 args) or the debug message (3 args).
1003
- * @param {*} b The actual value (2 args) or the expected value (3 args).
1004
- * @param {*=} opt_c The actual value (3 args only).
1005
- */
1006
- var assertHashEquals = function(a, b, opt_c) {
1007
- _validateArguments(2, arguments);
1008
- var var1 = nonCommentArg(1, 2, arguments);
1009
- var var2 = nonCommentArg(2, 2, arguments);
1010
- var message = commentArg(2, arguments);
1011
- for (var key in var1) {
1012
- _assert(message,
1013
- key in var2, 'Expected hash had key ' + key + ' that was not found');
1014
- _assert(message, var1[key] == var2[key], 'Value for key ' + key +
1015
- ' mismatch - expected = ' + var1[key] + ', actual = ' + var2[key]);
1016
- }
1017
-
1018
- for (var key in var2) {
1019
- _assert(message, key in var1, 'Actual hash had key ' + key +
1020
- ' that was not expected');
1021
- }
1022
- };
1023
-
1024
-
1025
- /**
1026
- * @param {*} a The expected value (3 args) or the debug message (4 args).
1027
- * @param {*} b The actual value (3 args) or the expected value (4 args).
1028
- * @param {*} c The tolerance (3 args) or the actual value (4 args).
1029
- * @param {*=} opt_d The tolerance (4 args only).
1030
- */
1031
- var assertRoughlyEquals = function(a, b, c, opt_d) {
1032
- _validateArguments(3, arguments);
1033
- var expected = nonCommentArg(1, 3, arguments);
1034
- var actual = nonCommentArg(2, 3, arguments);
1035
- var tolerance = nonCommentArg(3, 3, arguments);
1036
- _assert(commentArg(3, arguments),
1037
- goog.testing.asserts.numberRoughEqualityPredicate_(
1038
- expected, actual, tolerance),
1039
- 'Expected ' + expected + ', but got ' + actual +
1040
- ' which was more than ' + tolerance + ' away');
1041
- };
1042
-
1043
-
1044
- /**
1045
- * Checks if the test value is a member of the given container. Uses
1046
- * container.indexOf as the underlying function, so this works for strings
1047
- * and arrays.
1048
- * @param {*} a Failure message (3 arguments) or the test value
1049
- * (2 arguments).
1050
- * @param {*} b The test value (3 arguments) or the container
1051
- * (2 arguments).
1052
- * @param {*=} opt_c The container.
1053
- */
1054
- var assertContains = function(a, b, opt_c) {
1055
- _validateArguments(2, arguments);
1056
- var contained = nonCommentArg(1, 2, arguments);
1057
- var container = nonCommentArg(2, 2, arguments);
1058
- _assert(commentArg(2, arguments),
1059
- goog.testing.asserts.contains_(container, contained),
1060
- 'Expected \'' + container + '\' to contain \'' + contained + '\'');
1061
- };
1062
-
1063
-
1064
- /**
1065
- * Checks if the given element is not the member of the given container.
1066
- * @param {*} a Failure message (3 arguments) or the contained element
1067
- * (2 arguments).
1068
- * @param {*} b The contained element (3 arguments) or the container
1069
- * (2 arguments).
1070
- * @param {*=} opt_c The container.
1071
- */
1072
- var assertNotContains = function(a, b, opt_c) {
1073
- _validateArguments(2, arguments);
1074
- var contained = nonCommentArg(1, 2, arguments);
1075
- var container = nonCommentArg(2, 2, arguments);
1076
- _assert(commentArg(2, arguments),
1077
- !goog.testing.asserts.contains_(container, contained),
1078
- 'Expected \'' + container + '\' not to contain \'' + contained + '\'');
1079
- };
1080
-
1081
-
1082
- /**
1083
- * Checks if the given string matches the given regular expression.
1084
- * @param {*} a Failure message (3 arguments) or the expected regular
1085
- * expression as a string or RegExp (2 arguments).
1086
- * @param {*} b The regular expression (3 arguments) or the string to test
1087
- * (2 arguments).
1088
- * @param {*=} opt_c The string to test.
1089
- */
1090
- var assertRegExp = function(a, b, opt_c) {
1091
- _validateArguments(2, arguments);
1092
- var regexp = nonCommentArg(1, 2, arguments);
1093
- var string = nonCommentArg(2, 2, arguments);
1094
- if (typeof(regexp) == 'string') {
1095
- regexp = new RegExp(regexp);
1096
- }
1097
- _assert(commentArg(2, arguments),
1098
- regexp.test(string),
1099
- 'Expected \'' + string + '\' to match RegExp ' + regexp.toString());
1100
- };
1101
-
1102
-
1103
- /**
1104
- * Converts an array like object to array or clones it if it's already array.
1105
- * @param {goog.testing.asserts.ArrayLike} arrayLike The collection.
1106
- * @return {!Array<?>} Copy of the collection as array.
1107
- * @private
1108
- */
1109
- goog.testing.asserts.toArray_ = function(arrayLike) {
1110
- var ret = [];
1111
- for (var i = 0; i < arrayLike.length; i++) {
1112
- ret[i] = arrayLike[i];
1113
- }
1114
- return ret;
1115
- };
1116
-
1117
-
1118
- /**
1119
- * Finds the position of the first occurrence of an element in a container.
1120
- * @param {goog.testing.asserts.ArrayLike} container
1121
- * The array to find the element in.
1122
- * @param {*} contained Element to find.
1123
- * @return {number} Index of the first occurrence or -1 if not found.
1124
- * @private
1125
- */
1126
- goog.testing.asserts.indexOf_ = function(container, contained) {
1127
- if (container.indexOf) {
1128
- return container.indexOf(contained);
1129
- } else {
1130
- // IE6/7 do not have indexOf so do a search.
1131
- for (var i = 0; i < container.length; i++) {
1132
- if (container[i] === contained) {
1133
- return i;
1134
- }
1135
- }
1136
- return -1;
1137
- }
1138
- };
1139
-
1140
-
1141
- /**
1142
- * Tells whether the array contains the given element.
1143
- * @param {goog.testing.asserts.ArrayLike} container The array to
1144
- * find the element in.
1145
- * @param {*} contained Element to find.
1146
- * @return {boolean} Whether the element is in the array.
1147
- * @private
1148
- */
1149
- goog.testing.asserts.contains_ = function(container, contained) {
1150
- // TODO(user): Can we check for container.contains as well?
1151
- // That would give us support for most goog.structs (though weird results
1152
- // with anything else with a contains method, like goog.math.Range). Falling
1153
- // back with container.some would catch all iterables, too.
1154
- return goog.testing.asserts.indexOf_(container, contained) != -1;
1155
- };
1156
-
1157
- var standardizeHTML = function(html) {
1158
- var translator = document.createElement('DIV');
1159
- translator.innerHTML = html;
1160
-
1161
- // Trim whitespace from result (without relying on goog.string)
1162
- return translator.innerHTML.replace(/^\s+|\s+$/g, '');
1163
- };
1164
-
1165
-
1166
- /**
1167
- * Standardizes a CSS value for a given property by applying it to an element
1168
- * and then reading it back.
1169
- * @param {string} propertyName CSS property name.
1170
- * @param {string} value CSS value.
1171
- * @return {string} Normalized CSS value.
1172
- */
1173
- var standardizeCSSValue = function(propertyName, value) {
1174
- var styleDeclaration = document.createElement('DIV').style;
1175
- styleDeclaration[propertyName] = value;
1176
- return styleDeclaration[propertyName];
1177
- };
1178
-
1179
-
1180
- /**
1181
- * Raises a JsUnit exception with the given comment.
1182
- * @param {string} comment A summary for the exception.
1183
- * @param {string=} opt_message A description of the exception.
1184
- */
1185
- goog.testing.asserts.raiseException = function(comment, opt_message) {
1186
- throw new goog.testing.JsUnitException(comment, opt_message);
1187
- };
1188
-
1189
-
1190
- /**
1191
- * Helper function for assertObjectEquals.
1192
- * @param {string} prop A property name.
1193
- * @return {boolean} If the property name is an array index.
1194
- * @private
1195
- */
1196
- goog.testing.asserts.isArrayIndexProp_ = function(prop) {
1197
- return (prop | 0) == prop;
1198
- };
1199
-
1200
-
1201
-
1202
- /**
1203
- * @param {string} comment A summary for the exception.
1204
- * @param {?string=} opt_message A description of the exception.
1205
- * @constructor
1206
- * @extends {Error}
1207
- * @final
1208
- */
1209
- goog.testing.JsUnitException = function(comment, opt_message) {
1210
- this.isJsUnitException = true;
1211
- this.message = (comment ? comment : '') +
1212
- (comment && opt_message ? '\n' : '') +
1213
- (opt_message ? opt_message : '');
1214
- this.stackTrace = goog.testing.stacktrace.get();
1215
- // These fields are for compatibility with jsUnitTestManager.
1216
- this.comment = comment || null;
1217
- this.jsUnitMessage = opt_message || '';
1218
-
1219
- // Ensure there is a stack trace.
1220
- if (Error.captureStackTrace) {
1221
- Error.captureStackTrace(this, goog.testing.JsUnitException);
1222
- } else {
1223
- this.stack = new Error().stack || '';
1224
- }
1225
- };
1226
- goog.inherits(goog.testing.JsUnitException, Error);
1227
-
1228
-
1229
- /** @override */
1230
- goog.testing.JsUnitException.prototype.toString = function() {
1231
- return this.message;
1232
- };
1233
-
1234
-
1235
- goog.exportSymbol('fail', fail);
1236
- goog.exportSymbol('assert', assert);
1237
- goog.exportSymbol('assertThrows', assertThrows);
1238
- goog.exportSymbol('assertNotThrows', assertNotThrows);
1239
- goog.exportSymbol('assertTrue', assertTrue);
1240
- goog.exportSymbol('assertFalse', assertFalse);
1241
- goog.exportSymbol('assertEquals', assertEquals);
1242
- goog.exportSymbol('assertNotEquals', assertNotEquals);
1243
- goog.exportSymbol('assertNull', assertNull);
1244
- goog.exportSymbol('assertNotNull', assertNotNull);
1245
- goog.exportSymbol('assertUndefined', assertUndefined);
1246
- goog.exportSymbol('assertNotUndefined', assertNotUndefined);
1247
- goog.exportSymbol('assertNotNullNorUndefined', assertNotNullNorUndefined);
1248
- goog.exportSymbol('assertNonEmptyString', assertNonEmptyString);
1249
- goog.exportSymbol('assertNaN', assertNaN);
1250
- goog.exportSymbol('assertNotNaN', assertNotNaN);
1251
- goog.exportSymbol('assertObjectEquals', assertObjectEquals);
1252
- goog.exportSymbol('assertObjectRoughlyEquals', assertObjectRoughlyEquals);
1253
- goog.exportSymbol('assertObjectNotEquals', assertObjectNotEquals);
1254
- goog.exportSymbol('assertArrayEquals', assertArrayEquals);
1255
- goog.exportSymbol('assertElementsEquals', assertElementsEquals);
1256
- goog.exportSymbol('assertElementsRoughlyEqual', assertElementsRoughlyEqual);
1257
- goog.exportSymbol('assertSameElements', assertSameElements);
1258
- goog.exportSymbol('assertEvaluatesToTrue', assertEvaluatesToTrue);
1259
- goog.exportSymbol('assertEvaluatesToFalse', assertEvaluatesToFalse);
1260
- goog.exportSymbol('assertHTMLEquals', assertHTMLEquals);
1261
- goog.exportSymbol('assertHashEquals', assertHashEquals);
1262
- goog.exportSymbol('assertRoughlyEquals', assertRoughlyEquals);
1263
- goog.exportSymbol('assertContains', assertContains);
1264
- goog.exportSymbol('assertNotContains', assertNotContains);
1265
- goog.exportSymbol('assertRegExp', assertRegExp);