zena 1.2.7 → 1.2.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (407) hide show
  1. data/History.txt +80 -25
  2. data/Rakefile +2 -2
  3. data/app/controllers/columns_controller.rb +2 -2
  4. data/app/controllers/nodes_controller.rb +22 -29
  5. data/app/controllers/user_sessions_controller.rb +35 -10
  6. data/app/controllers/users_controller.rb +2 -2
  7. data/app/controllers/versions_controller.rb +2 -2
  8. data/app/models/group.rb +15 -1
  9. data/app/models/node.rb +109 -8
  10. data/app/models/role.rb +4 -0
  11. data/app/models/site.rb +64 -58
  12. data/app/models/template.rb +1 -1
  13. data/app/models/user.rb +135 -29
  14. data/app/models/user_session.rb +0 -1
  15. data/app/models/virtual_class.rb +11 -6
  16. data/app/views/columns/_form.html.erb +3 -1
  17. data/app/views/columns/_li.html.erb +1 -1
  18. data/app/views/columns/create.rjs +1 -1
  19. data/app/views/groups/_form.rhtml +16 -13
  20. data/app/views/relations/_form.erb +18 -6
  21. data/app/views/sites/_form.erb +12 -6
  22. data/app/views/users/_form.rhtml +23 -8
  23. data/app/views/users/_li.rhtml +14 -3
  24. data/app/views/users/index.rhtml +1 -1
  25. data/app/views/virtual_classes/_form.erb +12 -2
  26. data/app/views/zafu/default/Node-+login.zafu +8 -1
  27. data/app/views/zafu/default/Node-+search.zafu +1 -1
  28. data/bricks/acls/lib/bricks/acls.rb +1 -0
  29. data/bricks/acls/zena/migrate/20130903150356_longer_names_for_acl.rb +9 -0
  30. data/bricks/acls/zena/test/integration/acl_integration_test.rb +2 -2
  31. data/bricks/currency/lib/bricks/currency.rb +120 -0
  32. data/bricks/currency/zena/test/unit/currency_test.rb +43 -0
  33. data/bricks/fs_skin/lib/bricks/fs_skin.rb +1 -1
  34. data/bricks/fs_skin/zena/skins/blog/Node-+search.zafu +1 -1
  35. data/bricks/fs_skin/zena/skins/blog/Node.zafu +1 -1
  36. data/bricks/fs_skin/zena/test/unit/fs_skin_view_test.rb +35 -0
  37. data/bricks/pdf/lib/bricks/pdf.rb +1 -1
  38. data/bricks/sphinx/lib/bricks/sphinx.rb +2 -0
  39. data/bricks/sphinx/zena/init.rb +14 -0
  40. data/bricks/tags/zena/test/zafu/tags.yml +5 -1
  41. data/bricks/worker/lib/bricks/worker.rb +3 -2
  42. data/bricks/zena/zena/migrate/20130829093753_add_versioned_flag_to_column.rb +10 -0
  43. data/bricks/zena/zena/migrate/20130903084909_count_login_attempts.rb +11 -0
  44. data/bricks/zena/zena/migrate/20131104153126_index_fullpath.rb +10 -0
  45. data/bricks/zena/zena/migrate/20131104210011_rebuild_fullpath_after_change.rb +10 -0
  46. data/bricks/zena/zena/migrate/20131105160420_add_skin_id_to_sites.rb +9 -0
  47. data/bricks/zena/zena/migrate/20131105175822_add_profile_to_users.rb +11 -0
  48. data/bricks/zena/zena/migrate/20140213120038_fix_idx_scope.rb +13 -0
  49. data/bricks/zena/zena/migrate/20140628140247_add_site_readonly.rb +9 -0
  50. data/config/bricks.yml +8 -4
  51. data/config/gems.yml +5 -3
  52. data/db/init/base/skins/default/Node-+login.zafu +8 -1
  53. data/db/init/base/skins/default/Node-+search.zafu +1 -1
  54. data/lib/bricks/loader.rb +5 -5
  55. data/lib/gettext_strings.rb +3 -0
  56. data/lib/tasks/zena.rake +25 -22
  57. data/lib/zafu/process/context.rb +4 -0
  58. data/lib/zena/acts/secure_node.rb +3 -3
  59. data/lib/zena/app.rb +1 -0
  60. data/lib/zena/deploy.rb +1 -1
  61. data/lib/zena/deploy/template.rb +1 -1
  62. data/lib/zena/foxy_parser.rb +5 -2
  63. data/lib/zena/info.rb +1 -1
  64. data/lib/zena/site_worker.rb +2 -2
  65. data/lib/zena/test_controller.rb +5 -2
  66. data/lib/zena/use/action.rb +9 -2
  67. data/lib/zena/use/ajax.rb +20 -4
  68. data/lib/zena/use/ancestry.rb +89 -15
  69. data/lib/zena/use/authlogic.rb +8 -2
  70. data/lib/zena/use/context.rb +1 -0
  71. data/lib/zena/use/display.rb +1 -97
  72. data/lib/zena/use/forms.rb +28 -8
  73. data/lib/zena/use/html_tags.rb +16 -7
  74. data/lib/zena/use/i18n.rb +1 -1
  75. data/lib/zena/use/prop_eval.rb +6 -1
  76. data/lib/zena/use/query_node.rb +69 -4
  77. data/lib/zena/use/recursion.rb +1 -1
  78. data/lib/zena/use/refactor.rb +5 -2
  79. data/lib/zena/use/relations.rb +1 -0
  80. data/lib/zena/use/rendering.rb +7 -4
  81. data/lib/zena/use/test_helper.rb +8 -4
  82. data/lib/zena/use/upload.rb +14 -0
  83. data/lib/zena/use/urls.rb +39 -23
  84. data/lib/zena/use/version_hash.rb +5 -2
  85. data/lib/zena/use/workflow.rb +116 -70
  86. data/lib/zena/use/zafu_eval.rb +41 -0
  87. data/lib/zena/use/zafu_safe_definitions.rb +1 -0
  88. data/lib/zena/use/zafu_templates.rb +32 -26
  89. data/lib/zena/use/zazen.rb +8 -7
  90. data/locale/app.pot +5 -1
  91. data/locale/de/LC_MESSAGES/zena.mo +0 -0
  92. data/locale/de/zena.po +385 -281
  93. data/locale/en/LC_MESSAGES/zena.mo +0 -0
  94. data/locale/en/zena.po +378 -271
  95. data/locale/fr/LC_MESSAGES/zena.mo +0 -0
  96. data/locale/fr/zena.po +387 -272
  97. data/locale/it/LC_MESSAGES/zena.mo +0 -0
  98. data/locale/it/zena.po +433 -404
  99. data/locale/zena.pot +362 -268
  100. data/public/javascripts/grid.js +280 -104
  101. data/public/javascripts/zena.js +43 -15
  102. data/public/stylesheets/admin.css +8 -2
  103. data/public/stylesheets/grid.css +5 -2
  104. data/public/stylesheets/popup.css +1 -1
  105. data/test/fixtures/files/TestNode.zafu +51 -0
  106. data/test/functional/nodes_controller_test.rb +20 -5
  107. data/test/functional/user_sessions_controller_test.rb +41 -6
  108. data/test/functional/users_controller_test.rb +1 -2
  109. data/test/integration/navigation_test.rb +22 -4
  110. data/test/integration/query_node/basic.yml +7 -0
  111. data/test/integration/query_node/complex.yml +1 -1
  112. data/test/integration/query_node/errors.yml +1 -1
  113. data/test/integration/query_node/filters.yml +34 -1
  114. data/test/integration/query_node/relations.yml +6 -13
  115. data/test/integration/query_node_test.rb +22 -3
  116. data/test/integration/zafu_compiler/action.yml +1 -1
  117. data/test/integration/zafu_compiler/alias_site.yml +52 -0
  118. data/test/integration/zafu_compiler/complex.yml +1 -1
  119. data/test/integration/zafu_compiler/complex_ok.yml +5 -5
  120. data/test/integration/zafu_compiler/context.yml +1 -1
  121. data/test/integration/zafu_compiler/display.yml +56 -5
  122. data/test/integration/zafu_compiler/forms.yml +35 -2
  123. data/test/integration/zafu_compiler/meta.yml +4 -0
  124. data/test/integration/zafu_compiler/rubyless.yml +1 -1
  125. data/test/integration/zafu_compiler/safe_definitions.yml +4 -0
  126. data/test/integration/zafu_compiler/security.yml +10 -0
  127. data/test/integration/zafu_compiler/site.yml +5 -1
  128. data/test/integration/zafu_compiler/urls.yml +8 -2
  129. data/test/integration/zafu_compiler/zafu_attributes.yml +2 -1
  130. data/test/integration/zafu_compiler/zazen.yml +4 -0
  131. data/test/integration/zafu_compiler_test.rb +47 -4
  132. data/test/selenium/Grid/grid1.rsel +8 -8
  133. data/test/sites/complex/sites.yml +2 -2
  134. data/test/sites/complex/users.yml +1 -0
  135. data/test/sites/zena/columns.yml +4 -0
  136. data/test/sites/zena/sites.yml +1 -0
  137. data/test/sites/zena/users.yml +1 -0
  138. data/test/unit/node_test.rb +53 -5
  139. data/test/unit/note_test.rb +1 -1
  140. data/test/unit/relation_proxy_test.rb +20 -0
  141. data/test/unit/role_test.rb +2 -0
  142. data/test/unit/site_test.rb +28 -6
  143. data/test/unit/user_test.rb +332 -1
  144. data/test/unit/virtual_class_test.rb +55 -0
  145. data/test/unit/workflow_test.rb +175 -0
  146. data/test/unit/zena/use/ancestry_test.rb +52 -10
  147. data/test/unit/zena/use/prop_eval_test.rb +44 -0
  148. data/test/unit/zena/use/rendering_test.rb +48 -2
  149. data/test/unit/zena/use/upload_test.rb +15 -13
  150. data/test/unit/zena/use/urls_test.rb +1 -0
  151. data/vendor/plugins/ar_mysql_full_text/lib/ar_mysql_full_text.rb +39 -25
  152. data/zena.gemspec +69 -307
  153. metadata +143 -368
  154. data/vendor/TextMate/Ruby Shoulda.tmbundle/Commands/Run 2.tmCommand +0 -24
  155. data/vendor/TextMate/Ruby Shoulda.tmbundle/Commands/Run Context.tmCommand +0 -58
  156. data/vendor/TextMate/Ruby Shoulda.tmbundle/Commands/Run Focused Should.tmCommand +0 -88
  157. data/vendor/TextMate/Ruby Shoulda.tmbundle/Commands/Run.tmCommand +0 -27
  158. data/vendor/TextMate/Ruby Shoulda.tmbundle/Commands/YAML to Shoulda.tmCommand +0 -23
  159. data/vendor/TextMate/Ruby Shoulda.tmbundle/Preferences/Symbol List: Context.tmPreferences +0 -19
  160. data/vendor/TextMate/Ruby Shoulda.tmbundle/Preferences/Symbol List: Should.tmPreferences +0 -19
  161. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/Factory attributes for.tmSnippet +0 -16
  162. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/Factory build.tmSnippet +0 -16
  163. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/Factory.tmSnippet +0 -16
  164. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/Factory_define with class.tmSnippet +0 -18
  165. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/Factory_define.tmSnippet +0 -18
  166. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/Factory_next.tmSnippet +0 -16
  167. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/Factory_sequence.tmSnippet +0 -18
  168. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/assert_bad_value.tmSnippet +0 -16
  169. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/assert_contains.tmSnippet +0 -16
  170. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/assert_does_not_contain.tmSnippet +0 -16
  171. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/assert_good_value.tmSnippet +0 -16
  172. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/assert_same_elements.tmSnippet +0 -16
  173. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/assert_save.tmSnippet +0 -16
  174. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/assert_sent_email.tmSnippet +0 -18
  175. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/assert_valid.tmSnippet +0 -16
  176. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/association.tmSnippet +0 -17
  177. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/attribute.tmSnippet +0 -17
  178. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/before_should block.tmSnippet +0 -18
  179. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/context block get.tmSnippet +0 -22
  180. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/context block post.tmSnippet +0 -23
  181. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/context block with setup.tmSnippet +0 -25
  182. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/setup.tmSnippet +0 -18
  183. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should block with before proc.tmSnippet +0 -18
  184. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should block.tmSnippet +0 -18
  185. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_allow_values_for.tmSnippet +0 -16
  186. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_assign_to.tmSnippet +0 -16
  187. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_be_restful denied.tmSnippet +0 -20
  188. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_be_restful.tmSnippet +0 -20
  189. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_belong_to.tmSnippet +0 -16
  190. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_change by.tmSnippet +0 -16
  191. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_change from to.tmSnippet +0 -16
  192. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_ensure_length_at_least.tmSnippet +0 -16
  193. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_ensure_length_in_range.tmSnippet +0 -16
  194. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_ensure_length_is.tmSnippet +0 -16
  195. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_ensure_value_in_range.tmSnippet +0 -16
  196. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_eventually.tmSnippet +0 -18
  197. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_filter_params.tmSnippet +0 -16
  198. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_have_and_belong_to_many.tmSnippet +0 -16
  199. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_have_class_methods.tmSnippet +0 -16
  200. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_have_db_column.tmSnippet +0 -16
  201. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_have_db_columns.tmSnippet +0 -16
  202. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_have_index.tmSnippet +0 -16
  203. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_have_indices.tmSnippet +0 -16
  204. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_have_instance_methods.tmSnippet +0 -16
  205. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_have_many.tmSnippet +0 -16
  206. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_have_named_scope.tmSnippet +0 -16
  207. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_have_one.tmSnippet +0 -16
  208. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_have_readonly_attributes.tmSnippet +0 -16
  209. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_not_allow_mass_assignment_of.tmSnippet +0 -16
  210. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_not_allow_values_for.tmSnippet +0 -16
  211. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_not_assign_to.tmSnippet +0 -16
  212. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_not_change.tmSnippet +0 -16
  213. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_not_set_the_flash.tmSnippet +0 -16
  214. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_redirect_to.tmSnippet +0 -16
  215. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_render_a_form.tmSnippet +0 -16
  216. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_render_template.tmSnippet +0 -16
  217. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_render_with_layout.tmSnippet +0 -16
  218. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_render_without_layout.tmSnippet +0 -16
  219. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_respond_with.tmSnippet +0 -16
  220. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_respond_with_content_type.tmSnippet +0 -16
  221. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_return_from_session.tmSnippet +0 -16
  222. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_route.tmSnippet +0 -16
  223. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_set_the_flash_to.tmSnippet +0 -16
  224. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_validate_acceptance_of.tmSnippet +0 -16
  225. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_validate_numericality_of.tmSnippet +0 -16
  226. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_validate_presence_of.tmSnippet +0 -16
  227. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_validate_uniqueness_of with scope.tmSnippet +0 -16
  228. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_validate_uniqueness_of.tmSnippet +0 -16
  229. data/vendor/TextMate/Ruby Shoulda.tmbundle/Support/RubyMate/catch_exception.rb +0 -39
  230. data/vendor/TextMate/Ruby Shoulda.tmbundle/Support/RubyMate/run_script.rb +0 -104
  231. data/vendor/TextMate/Ruby Shoulda.tmbundle/Support/RubyMate/stdin_dialog.rb +0 -14
  232. data/vendor/TextMate/Ruby Shoulda.tmbundle/Support/RubyMate/test.rb +0 -17
  233. data/vendor/TextMate/Ruby Shoulda.tmbundle/Support/RubyMate/todo.txt +0 -13
  234. data/vendor/TextMate/Ruby Shoulda.tmbundle/Support/bin/yaml_to_shoulda.rb +0 -25
  235. data/vendor/TextMate/Ruby Shoulda.tmbundle/Syntaxes/Ruby on Rails (Shoulda).tmLanguage +0 -166
  236. data/vendor/TextMate/Ruby Shoulda.tmbundle/info.plist +0 -304
  237. data/vendor/TextMate/Zena.tmbundle/Commands/Run all yaml tests.tmCommand +0 -37
  238. data/vendor/TextMate/Zena.tmbundle/Commands/Run focused yaml test.tmCommand +0 -52
  239. data/vendor/TextMate/Zena.tmbundle/Support/RubyMate/catch_exception.rb +0 -39
  240. data/vendor/TextMate/Zena.tmbundle/Support/RubyMate/run_script.rb +0 -118
  241. data/vendor/TextMate/Zena.tmbundle/Support/RubyMate/stdin_dialog.rb +0 -14
  242. data/vendor/TextMate/Zena.tmbundle/info.plist +0 -17
  243. data/vendor/plugins/selenium-on-rails/CHANGELOG +0 -125
  244. data/vendor/plugins/selenium-on-rails/LICENSE-2.0.txt +0 -202
  245. data/vendor/plugins/selenium-on-rails/README.md +0 -202
  246. data/vendor/plugins/selenium-on-rails/Rakefile +0 -38
  247. data/vendor/plugins/selenium-on-rails/doc/classes/SeleniumController.html +0 -265
  248. data/vendor/plugins/selenium-on-rails/doc/classes/SeleniumHelper.html +0 -148
  249. data/vendor/plugins/selenium-on-rails/doc/classes/SeleniumOnRails.html +0 -126
  250. data/vendor/plugins/selenium-on-rails/doc/classes/SeleniumOnRails/FixtureLoader.html +0 -231
  251. data/vendor/plugins/selenium-on-rails/doc/classes/SeleniumOnRails/PartialsSupport.html +0 -195
  252. data/vendor/plugins/selenium-on-rails/doc/classes/SeleniumOnRails/Paths.html +0 -295
  253. data/vendor/plugins/selenium-on-rails/doc/classes/SeleniumOnRails/RSelenese.html +0 -219
  254. data/vendor/plugins/selenium-on-rails/doc/classes/SeleniumOnRails/Renderer.html +0 -156
  255. data/vendor/plugins/selenium-on-rails/doc/classes/SeleniumOnRails/Selenese.html +0 -179
  256. data/vendor/plugins/selenium-on-rails/doc/classes/SeleniumOnRails/SuiteRenderer.html +0 -223
  257. data/vendor/plugins/selenium-on-rails/doc/classes/SeleniumOnRails/TestBuilder.html +0 -441
  258. data/vendor/plugins/selenium-on-rails/doc/classes/SeleniumOnRails/TestBuilderAccessors.html +0 -3098
  259. data/vendor/plugins/selenium-on-rails/doc/classes/SeleniumOnRails/TestBuilderActions.html +0 -2080
  260. data/vendor/plugins/selenium-on-rails/doc/classes/SeleniumOnRails/TestBuilderUserAccessors.html +0 -116
  261. data/vendor/plugins/selenium-on-rails/doc/classes/SeleniumOnRails/TestBuilderUserActions.html +0 -116
  262. data/vendor/plugins/selenium-on-rails/doc/classes/SeleniumOnRailsConfig.html +0 -150
  263. data/vendor/plugins/selenium-on-rails/doc/files/CHANGELOG.html +0 -422
  264. data/vendor/plugins/selenium-on-rails/doc/files/README.html +0 -321
  265. data/vendor/plugins/selenium-on-rails/doc/files/lib/controllers/selenium_controller_rb.html +0 -108
  266. data/vendor/plugins/selenium-on-rails/doc/files/lib/selenium_helper_rb.html +0 -101
  267. data/vendor/plugins/selenium-on-rails/doc/files/lib/selenium_on_rails/acceptance_test_runner_rb.html +0 -222
  268. data/vendor/plugins/selenium-on-rails/doc/files/lib/selenium_on_rails/fixture_loader_rb.html +0 -109
  269. data/vendor/plugins/selenium-on-rails/doc/files/lib/selenium_on_rails/partials_support_rb.html +0 -111
  270. data/vendor/plugins/selenium-on-rails/doc/files/lib/selenium_on_rails/paths_rb.html +0 -101
  271. data/vendor/plugins/selenium-on-rails/doc/files/lib/selenium_on_rails/renderer_rb.html +0 -101
  272. data/vendor/plugins/selenium-on-rails/doc/files/lib/selenium_on_rails/rselenese_rb.html +0 -118
  273. data/vendor/plugins/selenium-on-rails/doc/files/lib/selenium_on_rails/selenese_rb.html +0 -101
  274. data/vendor/plugins/selenium-on-rails/doc/files/lib/selenium_on_rails/suite_renderer_rb.html +0 -101
  275. data/vendor/plugins/selenium-on-rails/doc/files/lib/selenium_on_rails/test_builder_accessors_rb.html +0 -114
  276. data/vendor/plugins/selenium-on-rails/doc/files/lib/selenium_on_rails/test_builder_actions_rb.html +0 -113
  277. data/vendor/plugins/selenium-on-rails/doc/files/lib/selenium_on_rails/test_builder_rb.html +0 -120
  278. data/vendor/plugins/selenium-on-rails/doc/files/lib/selenium_on_rails_config_rb.html +0 -108
  279. data/vendor/plugins/selenium-on-rails/doc/files/lib/selenium_on_rails_rb.html +0 -115
  280. data/vendor/plugins/selenium-on-rails/doc/fr_class_index.html +0 -42
  281. data/vendor/plugins/selenium-on-rails/doc/fr_file_index.html +0 -43
  282. data/vendor/plugins/selenium-on-rails/doc/fr_method_index.html +0 -182
  283. data/vendor/plugins/selenium-on-rails/doc/index.html +0 -24
  284. data/vendor/plugins/selenium-on-rails/doc/rdoc-style.css +0 -208
  285. data/vendor/plugins/selenium-on-rails/generators/selenium/USAGE +0 -19
  286. data/vendor/plugins/selenium-on-rails/generators/selenium/selenium_generator.rb +0 -50
  287. data/vendor/plugins/selenium-on-rails/generators/selenium/templates/rhtml.rhtml +0 -16
  288. data/vendor/plugins/selenium-on-rails/generators/selenium/templates/rselenese.rhtml +0 -14
  289. data/vendor/plugins/selenium-on-rails/generators/selenium/templates/selenese.rhtml +0 -11
  290. data/vendor/plugins/selenium-on-rails/init.rb +0 -15
  291. data/vendor/plugins/selenium-on-rails/lib/controllers/selenium_controller.rb +0 -122
  292. data/vendor/plugins/selenium-on-rails/lib/controllers/switch_environment_controller.rb +0 -16
  293. data/vendor/plugins/selenium-on-rails/lib/selenium_helper.rb +0 -8
  294. data/vendor/plugins/selenium-on-rails/lib/selenium_on_rails.rb +0 -11
  295. data/vendor/plugins/selenium-on-rails/lib/selenium_on_rails/acceptance_test_runner.rb +0 -215
  296. data/vendor/plugins/selenium-on-rails/lib/selenium_on_rails/fixture_loader.rb +0 -57
  297. data/vendor/plugins/selenium-on-rails/lib/selenium_on_rails/partials_support.rb +0 -36
  298. data/vendor/plugins/selenium-on-rails/lib/selenium_on_rails/paths.rb +0 -61
  299. data/vendor/plugins/selenium-on-rails/lib/selenium_on_rails/renderer.rb +0 -20
  300. data/vendor/plugins/selenium-on-rails/lib/selenium_on_rails/rselenese.rb +0 -44
  301. data/vendor/plugins/selenium-on-rails/lib/selenium_on_rails/selenese.rb +0 -87
  302. data/vendor/plugins/selenium-on-rails/lib/selenium_on_rails/suite_renderer.rb +0 -56
  303. data/vendor/plugins/selenium-on-rails/lib/selenium_on_rails/test_builder.rb +0 -116
  304. data/vendor/plugins/selenium-on-rails/lib/selenium_on_rails/test_builder_accessors.rb +0 -1002
  305. data/vendor/plugins/selenium-on-rails/lib/selenium_on_rails/test_builder_actions.rb +0 -514
  306. data/vendor/plugins/selenium-on-rails/lib/selenium_on_rails/test_builder_user_accessors.rb.example +0 -91
  307. data/vendor/plugins/selenium-on-rails/lib/selenium_on_rails/test_builder_user_actions.rb.example +0 -24
  308. data/vendor/plugins/selenium-on-rails/lib/selenium_on_rails_config.rb +0 -30
  309. data/vendor/plugins/selenium-on-rails/lib/views/layouts/layout.rhtml +0 -18
  310. data/vendor/plugins/selenium-on-rails/lib/views/record.rhtml +0 -5
  311. data/vendor/plugins/selenium-on-rails/lib/views/selenium_helper.rb +0 -9
  312. data/vendor/plugins/selenium-on-rails/lib/views/setup.rhtml +0 -67
  313. data/vendor/plugins/selenium-on-rails/lib/views/test_suite.rhtml +0 -26
  314. data/vendor/plugins/selenium-on-rails/routes.rb +0 -24
  315. data/vendor/plugins/selenium-on-rails/selenium-core/Blank.html +0 -7
  316. data/vendor/plugins/selenium-on-rails/selenium-core/InjectedRemoteRunner.html +0 -8
  317. data/vendor/plugins/selenium-on-rails/selenium-core/RemoteRunner.html +0 -110
  318. data/vendor/plugins/selenium-on-rails/selenium-core/SeleniumLog.html +0 -109
  319. data/vendor/plugins/selenium-on-rails/selenium-core/TestPrompt.html +0 -145
  320. data/vendor/plugins/selenium-on-rails/selenium-core/TestRunner-splash.html +0 -55
  321. data/vendor/plugins/selenium-on-rails/selenium-core/TestRunner.hta +0 -177
  322. data/vendor/plugins/selenium-on-rails/selenium-core/TestRunner.html +0 -177
  323. data/vendor/plugins/selenium-on-rails/selenium-core/domviewer/butmin.gif +0 -0
  324. data/vendor/plugins/selenium-on-rails/selenium-core/domviewer/butplus.gif +0 -0
  325. data/vendor/plugins/selenium-on-rails/selenium-core/domviewer/domviewer.css +0 -298
  326. data/vendor/plugins/selenium-on-rails/selenium-core/domviewer/domviewer.html +0 -16
  327. data/vendor/plugins/selenium-on-rails/selenium-core/domviewer/selenium-domviewer.js +0 -205
  328. data/vendor/plugins/selenium-on-rails/selenium-core/icons/all.png +0 -0
  329. data/vendor/plugins/selenium-on-rails/selenium-core/icons/continue.png +0 -0
  330. data/vendor/plugins/selenium-on-rails/selenium-core/icons/continue_disabled.png +0 -0
  331. data/vendor/plugins/selenium-on-rails/selenium-core/icons/pause.png +0 -0
  332. data/vendor/plugins/selenium-on-rails/selenium-core/icons/pause_disabled.png +0 -0
  333. data/vendor/plugins/selenium-on-rails/selenium-core/icons/selected.png +0 -0
  334. data/vendor/plugins/selenium-on-rails/selenium-core/icons/step.png +0 -0
  335. data/vendor/plugins/selenium-on-rails/selenium-core/icons/step_disabled.png +0 -0
  336. data/vendor/plugins/selenium-on-rails/selenium-core/iedoc-core.xml +0 -1759
  337. data/vendor/plugins/selenium-on-rails/selenium-core/iedoc.xml +0 -1800
  338. data/vendor/plugins/selenium-on-rails/selenium-core/lib/cssQuery/cssQuery-p.js +0 -6
  339. data/vendor/plugins/selenium-on-rails/selenium-core/lib/cssQuery/src/cssQuery-level2.js +0 -142
  340. data/vendor/plugins/selenium-on-rails/selenium-core/lib/cssQuery/src/cssQuery-level3.js +0 -150
  341. data/vendor/plugins/selenium-on-rails/selenium-core/lib/cssQuery/src/cssQuery-standard.js +0 -53
  342. data/vendor/plugins/selenium-on-rails/selenium-core/lib/cssQuery/src/cssQuery.js +0 -356
  343. data/vendor/plugins/selenium-on-rails/selenium-core/lib/prototype.js +0 -2006
  344. data/vendor/plugins/selenium-on-rails/selenium-core/lib/scriptaculous/builder.js +0 -101
  345. data/vendor/plugins/selenium-on-rails/selenium-core/lib/scriptaculous/controls.js +0 -815
  346. data/vendor/plugins/selenium-on-rails/selenium-core/lib/scriptaculous/dragdrop.js +0 -915
  347. data/vendor/plugins/selenium-on-rails/selenium-core/lib/scriptaculous/effects.js +0 -958
  348. data/vendor/plugins/selenium-on-rails/selenium-core/lib/scriptaculous/scriptaculous.js +0 -47
  349. data/vendor/plugins/selenium-on-rails/selenium-core/lib/scriptaculous/slider.js +0 -283
  350. data/vendor/plugins/selenium-on-rails/selenium-core/lib/scriptaculous/unittest.js +0 -383
  351. data/vendor/plugins/selenium-on-rails/selenium-core/lib/snapsie.js +0 -91
  352. data/vendor/plugins/selenium-on-rails/selenium-core/scripts/find_matching_child.js +0 -69
  353. data/vendor/plugins/selenium-on-rails/selenium-core/scripts/htmlutils.js +0 -1616
  354. data/vendor/plugins/selenium-on-rails/selenium-core/scripts/injection.html +0 -72
  355. data/vendor/plugins/selenium-on-rails/selenium-core/scripts/selenium-api.js +0 -3184
  356. data/vendor/plugins/selenium-on-rails/selenium-core/scripts/selenium-browserbot.js +0 -2300
  357. data/vendor/plugins/selenium-on-rails/selenium-core/scripts/selenium-browserdetect.js +0 -153
  358. data/vendor/plugins/selenium-on-rails/selenium-core/scripts/selenium-commandhandlers.js +0 -377
  359. data/vendor/plugins/selenium-on-rails/selenium-core/scripts/selenium-executionloop.js +0 -175
  360. data/vendor/plugins/selenium-on-rails/selenium-core/scripts/selenium-logging.js +0 -148
  361. data/vendor/plugins/selenium-on-rails/selenium-core/scripts/selenium-remoterunner.js +0 -695
  362. data/vendor/plugins/selenium-on-rails/selenium-core/scripts/selenium-testrunner.js +0 -1362
  363. data/vendor/plugins/selenium-on-rails/selenium-core/scripts/selenium-version.js +0 -5
  364. data/vendor/plugins/selenium-on-rails/selenium-core/scripts/ui-doc.html +0 -803
  365. data/vendor/plugins/selenium-on-rails/selenium-core/scripts/ui-element.js +0 -1537
  366. data/vendor/plugins/selenium-on-rails/selenium-core/scripts/ui-map-sample.js +0 -979
  367. data/vendor/plugins/selenium-on-rails/selenium-core/scripts/user-extensions.js +0 -3
  368. data/vendor/plugins/selenium-on-rails/selenium-core/scripts/user-extensions.js.sample +0 -75
  369. data/vendor/plugins/selenium-on-rails/selenium-core/scripts/xmlextras.js +0 -153
  370. data/vendor/plugins/selenium-on-rails/selenium-core/selenium-logo.png +0 -0
  371. data/vendor/plugins/selenium-on-rails/selenium-core/selenium-test.css +0 -43
  372. data/vendor/plugins/selenium-on-rails/selenium-core/selenium.css +0 -316
  373. data/vendor/plugins/selenium-on-rails/selenium-core/xpath/dom.js +0 -566
  374. data/vendor/plugins/selenium-on-rails/selenium-core/xpath/javascript-xpath-0.1.11.js +0 -2816
  375. data/vendor/plugins/selenium-on-rails/selenium-core/xpath/util.js +0 -549
  376. data/vendor/plugins/selenium-on-rails/selenium-core/xpath/xmltoken.js +0 -149
  377. data/vendor/plugins/selenium-on-rails/selenium-core/xpath/xpath.js +0 -2450
  378. data/vendor/plugins/selenium-on-rails/tasks/test_acceptance.rake +0 -8
  379. data/vendor/plugins/selenium-on-rails/test/fixtures/config.yml +0 -37
  380. data/vendor/plugins/selenium-on-rails/test/fixtures/selenium.yml +0 -27
  381. data/vendor/plugins/selenium-on-rails/test/paths_test.rb +0 -72
  382. data/vendor/plugins/selenium-on-rails/test/renderer_test.rb +0 -157
  383. data/vendor/plugins/selenium-on-rails/test/rselenese_test.rb +0 -708
  384. data/vendor/plugins/selenium-on-rails/test/selenese_test.rb +0 -242
  385. data/vendor/plugins/selenium-on-rails/test/selenium_controller_test.rb +0 -67
  386. data/vendor/plugins/selenium-on-rails/test/selenium_on_rails_config_test.rb +0 -43
  387. data/vendor/plugins/selenium-on-rails/test/selenium_support_test.rb +0 -35
  388. data/vendor/plugins/selenium-on-rails/test/setup_test.rb +0 -31
  389. data/vendor/plugins/selenium-on-rails/test/suite_renderer_test.rb +0 -109
  390. data/vendor/plugins/selenium-on-rails/test/switch_environment_controller_test.rb +0 -17
  391. data/vendor/plugins/selenium-on-rails/test/test_builder_functions_authortest.rb +0 -51
  392. data/vendor/plugins/selenium-on-rails/test/test_helper.rb +0 -101
  393. data/vendor/plugins/selenium-on-rails/test_data/_partial.rsel +0 -1
  394. data/vendor/plugins/selenium-on-rails/test_data/own_layout.html +0 -12
  395. data/vendor/plugins/selenium-on-rails/test_data/partials/_html.html +0 -6
  396. data/vendor/plugins/selenium-on-rails/test_data/partials/_nesting.rsel +0 -2
  397. data/vendor/plugins/selenium-on-rails/test_data/partials/_rhtml.rhtml +0 -6
  398. data/vendor/plugins/selenium-on-rails/test_data/partials/_rsel.rsel +0 -1
  399. data/vendor/plugins/selenium-on-rails/test_data/partials/_sel.sel +0 -5
  400. data/vendor/plugins/selenium-on-rails/test_data/partials/all_partials.rsel +0 -5
  401. data/vendor/plugins/selenium-on-rails/test_data/rhtml.rhtml +0 -7
  402. data/vendor/plugins/selenium-on-rails/test_data/rselenese.rsel +0 -8
  403. data/vendor/plugins/selenium-on-rails/test_data/selenese.sel +0 -7
  404. data/vendor/plugins/selenium-on-rails/test_data/suite_one/subsuite/suite_one_subsuite_testcase.sel +0 -1
  405. data/vendor/plugins/selenium-on-rails/test_data/suite_one/suite_one_testcase1.sel +0 -1
  406. data/vendor/plugins/selenium-on-rails/test_data/suite_one/suite_one_testcase2.sel +0 -1
  407. data/vendor/plugins/selenium-on-rails/test_data/suite_two/suite_two_testcase.sel +0 -1
@@ -1,2300 +0,0 @@
1
- /*
2
- * Copyright 2004 ThoughtWorks, Inc
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- *
16
- */
17
-
18
- /*
19
- * This script provides the Javascript API to drive the test application contained within
20
- * a Browser Window.
21
- * TODO:
22
- * Add support for more events (keyboard and mouse)
23
- * Allow to switch "user-entry" mode from mouse-based to keyboard-based, firing different
24
- * events in different modes.
25
- */
26
-
27
- // The window to which the commands will be sent. For example, to click on a
28
- // popup window, first select that window, and then do a normal click command.
29
- var BrowserBot = function(topLevelApplicationWindow) {
30
- this.topWindow = topLevelApplicationWindow;
31
- this.topFrame = this.topWindow;
32
- this.baseUrl=window.location.href;
33
-
34
- // the buttonWindow is the Selenium window
35
- // it contains the Run/Pause buttons... this should *not* be the AUT window
36
- this.buttonWindow = window;
37
- this.currentWindow = this.topWindow;
38
- this.currentWindowName = null;
39
- this.allowNativeXpath = true;
40
- this.xpathLibrary = this.defaultXpathLibrary = 'ajaxslt' // change to "javascript-xpath" for the newer, faster engine
41
-
42
- // We need to know this in advance, in case the frame closes unexpectedly
43
- this.isSubFrameSelected = false;
44
-
45
- this.altKeyDown = false;
46
- this.controlKeyDown = false;
47
- this.shiftKeyDown = false;
48
- this.metaKeyDown = false;
49
-
50
- this.modalDialogTest = null;
51
- this.recordedAlerts = new Array();
52
- this.recordedConfirmations = new Array();
53
- this.recordedPrompts = new Array();
54
- this.openedWindows = {};
55
- this.nextConfirmResult = true;
56
- this.nextPromptResult = '';
57
- this.newPageLoaded = false;
58
- this.pageLoadError = null;
59
-
60
- this.shouldHighlightLocatedElement = false;
61
-
62
- this.uniqueId = "seleniumMarker" + new Date().getTime();
63
- this.pollingForLoad = new Object();
64
- this.permDeniedCount = new Object();
65
- this.windowPollers = new Array();
66
- // DGF for backwards compatibility
67
- this.browserbot = this;
68
-
69
- var self = this;
70
-
71
- objectExtend(this, PageBot.prototype);
72
- this._registerAllLocatorFunctions();
73
-
74
- this.recordPageLoad = function(elementOrWindow) {
75
- LOG.debug("Page load detected");
76
- try {
77
- if (elementOrWindow.location && elementOrWindow.location.href) {
78
- LOG.debug("Page load location=" + elementOrWindow.location.href);
79
- } else if (elementOrWindow.contentWindow && elementOrWindow.contentWindow.location && elementOrWindow.contentWindow.location.href) {
80
- LOG.debug("Page load location=" + elementOrWindow.contentWindow.location.href);
81
- } else {
82
- LOG.debug("Page load location unknown, current window location=" + this.getCurrentWindow(true).location);
83
- }
84
- } catch (e) {
85
- LOG.error("Caught an exception attempting to log location; this should get noticed soon!");
86
- LOG.exception(e);
87
- self.pageLoadError = e;
88
- return;
89
- }
90
- self.newPageLoaded = true;
91
- };
92
-
93
- this.isNewPageLoaded = function() {
94
- if (this.pageLoadError) {
95
- LOG.error("isNewPageLoaded found an old pageLoadError");
96
- var e = this.pageLoadError;
97
- this.pageLoadError = null;
98
- throw e;
99
- }
100
- return self.newPageLoaded;
101
- };
102
-
103
- };
104
-
105
- // DGF PageBot exists for backwards compatibility with old user-extensions
106
- var PageBot = function(){};
107
-
108
- BrowserBot.createForWindow = function(window, proxyInjectionMode) {
109
- var browserbot;
110
- LOG.debug('createForWindow');
111
- LOG.debug("browserName: " + browserVersion.name);
112
- LOG.debug("userAgent: " + navigator.userAgent);
113
- if (browserVersion.isIE) {
114
- browserbot = new IEBrowserBot(window);
115
- }
116
- else if (browserVersion.isKonqueror) {
117
- browserbot = new KonquerorBrowserBot(window);
118
- }
119
- else if (browserVersion.isOpera) {
120
- browserbot = new OperaBrowserBot(window);
121
- }
122
- else if (browserVersion.isSafari) {
123
- browserbot = new SafariBrowserBot(window);
124
- }
125
- else {
126
- // Use mozilla by default
127
- browserbot = new MozillaBrowserBot(window);
128
- }
129
- // getCurrentWindow has the side effect of modifying it to handle page loads etc
130
- browserbot.proxyInjectionMode = proxyInjectionMode;
131
- browserbot.getCurrentWindow(); // for modifyWindow side effect. This is not a transparent style
132
- return browserbot;
133
- };
134
-
135
- // todo: rename? This doesn't actually "do" anything.
136
- BrowserBot.prototype.doModalDialogTest = function(test) {
137
- this.modalDialogTest = test;
138
- };
139
-
140
- BrowserBot.prototype.cancelNextConfirmation = function(result) {
141
- this.nextConfirmResult = result;
142
- };
143
-
144
- BrowserBot.prototype.setNextPromptResult = function(result) {
145
- this.nextPromptResult = result;
146
- };
147
-
148
- BrowserBot.prototype.hasAlerts = function() {
149
- return (this.recordedAlerts.length > 0);
150
- };
151
-
152
- BrowserBot.prototype.relayBotToRC = function(s) {
153
- // DGF need to do this funny trick to see if we're in PI mode, because
154
- // "this" might be the window, rather than the browserbot (e.g. during window.alert)
155
- var piMode = this.proxyInjectionMode;
156
- if (!piMode) {
157
- if (typeof(selenium) != "undefined") {
158
- piMode = selenium.browserbot && selenium.browserbot.proxyInjectionMode;
159
- }
160
- }
161
- if (piMode) {
162
- this.relayToRC("selenium." + s);
163
- }
164
- };
165
-
166
- BrowserBot.prototype.relayToRC = function(name) {
167
- var object = eval(name);
168
- var s = 'state:' + serializeObject(name, object) + "\n";
169
- sendToRC(s,"state=true");
170
- }
171
-
172
- BrowserBot.prototype.resetPopups = function() {
173
- this.recordedAlerts = [];
174
- this.recordedConfirmations = [];
175
- this.recordedPrompts = [];
176
- }
177
-
178
- BrowserBot.prototype.getNextAlert = function() {
179
- var t = this.recordedAlerts.shift();
180
- if (t) {
181
- t = t.replace(/\n/g, " "); // because Selenese loses \n's when retrieving text from HTML table
182
- }
183
- this.relayBotToRC("browserbot.recordedAlerts");
184
- return t;
185
- };
186
-
187
- BrowserBot.prototype.hasConfirmations = function() {
188
- return (this.recordedConfirmations.length > 0);
189
- };
190
-
191
- BrowserBot.prototype.getNextConfirmation = function() {
192
- var t = this.recordedConfirmations.shift();
193
- this.relayBotToRC("browserbot.recordedConfirmations");
194
- return t;
195
- };
196
-
197
- BrowserBot.prototype.hasPrompts = function() {
198
- return (this.recordedPrompts.length > 0);
199
- };
200
-
201
- BrowserBot.prototype.getNextPrompt = function() {
202
- var t = this.recordedPrompts.shift();
203
- this.relayBotToRC("browserbot.recordedPrompts");
204
- return t;
205
- };
206
-
207
- /* Fire a mouse event in a browser-compatible manner */
208
-
209
- BrowserBot.prototype.triggerMouseEvent = function(element, eventType, canBubble, clientX, clientY, button) {
210
- clientX = clientX ? clientX : 0;
211
- clientY = clientY ? clientY : 0;
212
-
213
- LOG.debug("triggerMouseEvent assumes setting screenX and screenY to 0 is ok");
214
- var screenX = 0;
215
- var screenY = 0;
216
-
217
- canBubble = (typeof(canBubble) == undefined) ? true : canBubble;
218
- if (element.fireEvent && element.ownerDocument && element.ownerDocument.createEventObject) { //IE
219
- var evt = createEventObject(element, this.controlKeyDown, this.altKeyDown, this.shiftKeyDown, this.metaKeyDown);
220
- evt.detail = 0;
221
- evt.button = button ? button : 1; // default will be the left mouse click ( http://www.javascriptkit.com/jsref/event.shtml )
222
- evt.relatedTarget = null;
223
- if (!screenX && !screenY && !clientX && !clientY && !this.controlKeyDown && !this.altKeyDown && !this.shiftKeyDown && !this.metaKeyDown) {
224
- element.fireEvent('on' + eventType);
225
- }
226
- else {
227
- evt.screenX = screenX;
228
- evt.screenY = screenY;
229
- evt.clientX = clientX;
230
- evt.clientY = clientY;
231
-
232
- // when we go this route, window.event is never set to contain the event we have just created.
233
- // ideally we could just slide it in as follows in the try-block below, but this normally
234
- // doesn't work. This is why I try to avoid this code path, which is only required if we need to
235
- // set attributes on the event (e.g., clientX).
236
- try {
237
- window.event = evt;
238
- }
239
- catch(e) {
240
- // getting an "Object does not support this action or property" error. Save the event away
241
- // for future reference.
242
- // TODO: is there a way to update window.event?
243
-
244
- // work around for http://jira.openqa.org/browse/SEL-280 -- make the event available somewhere:
245
- selenium.browserbot.getCurrentWindow().selenium_event = evt;
246
- }
247
- element.fireEvent('on' + eventType, evt);
248
- }
249
- }
250
- else {
251
- var evt = document.createEvent('MouseEvents');
252
- if (evt.initMouseEvent)
253
- {
254
- // see http://developer.mozilla.org/en/docs/DOM:event.button and
255
- // http://developer.mozilla.org/en/docs/DOM:event.initMouseEvent for button ternary logic logic
256
- //Safari
257
- evt.initMouseEvent(eventType, canBubble, true, document.defaultView, 1, screenX, screenY, clientX, clientY,
258
- this.controlKeyDown, this.altKeyDown, this.shiftKeyDown, this.metaKeyDown, button ? button : 0, null);
259
- }
260
- else {
261
- LOG.warn("element doesn't have initMouseEvent; firing an event which should -- but doesn't -- have other mouse-event related attributes here, as well as controlKeyDown, altKeyDown, shiftKeyDown, metaKeyDown");
262
- evt.initEvent(eventType, canBubble, true);
263
-
264
- evt.shiftKey = this.shiftKeyDown;
265
- evt.metaKey = this.metaKeyDown;
266
- evt.altKey = this.altKeyDown;
267
- evt.ctrlKey = this.controlKeyDown;
268
- if(button)
269
- {
270
- evt.button = button;
271
- }
272
- }
273
- element.dispatchEvent(evt);
274
- }
275
- }
276
-
277
- BrowserBot.prototype._windowClosed = function(win) {
278
- var c = win.closed;
279
- if (c == null) return true;
280
- return c;
281
- };
282
-
283
- BrowserBot.prototype._modifyWindow = function(win) {
284
- // In proxyInjectionMode, have to suppress LOG calls in _modifyWindow to avoid an infinite loop
285
- if (this._windowClosed(win)) {
286
- if (!this.proxyInjectionMode) {
287
- LOG.error("modifyWindow: Window was closed!");
288
- }
289
- return null;
290
- }
291
- if (!this.proxyInjectionMode) {
292
- LOG.debug('modifyWindow ' + this.uniqueId + ":" + win[this.uniqueId]);
293
- }
294
- if (!win[this.uniqueId]) {
295
- win[this.uniqueId] = 1;
296
- this.modifyWindowToRecordPopUpDialogs(win, this);
297
- }
298
- // In proxyInjection mode, we have our own mechanism for detecting page loads
299
- if (!this.proxyInjectionMode) {
300
- this.modifySeparateTestWindowToDetectPageLoads(win);
301
- }
302
- if (win.frames && win.frames.length && win.frames.length > 0) {
303
- for (var i = 0; i < win.frames.length; i++) {
304
- try {
305
- this._modifyWindow(win.frames[i]);
306
- } catch (e) {} // we're just trying to be opportunistic; don't worry if this doesn't work out
307
- }
308
- }
309
- return win;
310
- };
311
-
312
- BrowserBot.prototype.selectWindow = function(target) {
313
- if (!target || target == "null") {
314
- this._selectTopWindow();
315
- return;
316
- }
317
- var result = target.match(/^([a-zA-Z]+)=(.*)/);
318
- if (!result) {
319
- try {
320
- this._selectWindowByName(target);
321
- }
322
- catch (e) {
323
- this._selectWindowByTitle(target);
324
- }
325
- return;
326
- }
327
- locatorType = result[1];
328
- locatorValue = result[2];
329
- if (locatorType == "title") {
330
- this._selectWindowByTitle(locatorValue);
331
- }
332
- // TODO separate name and var into separate functions
333
- else if (locatorType == "name") {
334
- this._selectWindowByName(locatorValue);
335
- } else if (locatorType == "var") {
336
- this._selectWindowByName(locatorValue);
337
- } else {
338
- throw new SeleniumError("Window locator not recognized: " + locatorType);
339
- }
340
- };
341
-
342
- BrowserBot.prototype._selectTopWindow = function() {
343
- this.currentWindowName = null;
344
- this.currentWindow = this.topWindow;
345
- this.topFrame = this.topWindow;
346
- this.isSubFrameSelected = false;
347
- }
348
-
349
- BrowserBot.prototype._selectWindowByName = function(target) {
350
- this.currentWindow = this.getWindowByName(target, false);
351
- this.topFrame = this.currentWindow;
352
- this.currentWindowName = target;
353
- this.isSubFrameSelected = false;
354
- }
355
-
356
- BrowserBot.prototype._selectWindowByTitle = function(target) {
357
- var windowName = this.getWindowNameByTitle(target);
358
- if (!windowName) {
359
- this._selectTopWindow();
360
- } else {
361
- this._selectWindowByName(windowName);
362
- }
363
- }
364
-
365
- BrowserBot.prototype.selectFrame = function(target) {
366
- if (target.indexOf("index=") == 0) {
367
- target = target.substr(6);
368
- var frame = this.getCurrentWindow().frames[target];
369
- if (frame == null) {
370
- throw new SeleniumError("Not found: frames["+index+"]");
371
- }
372
- if (!frame.document) {
373
- throw new SeleniumError("frames["+index+"] is not a frame");
374
- }
375
- this.currentWindow = frame;
376
- this.isSubFrameSelected = true;
377
- }
378
- else if (target == "relative=up" || target == "relative=parent") {
379
- this.currentWindow = this.getCurrentWindow().parent;
380
- this.isSubFrameSelected = (this._getFrameElement(this.currentWindow) != null);
381
- } else if (target == "relative=top") {
382
- this.currentWindow = this.topFrame;
383
- this.isSubFrameSelected = false;
384
- } else {
385
- var frame = this.findElement(target);
386
- if (frame == null) {
387
- throw new SeleniumError("Not found: " + target);
388
- }
389
- // now, did they give us a frame or a frame ELEMENT?
390
- var match = false;
391
- if (frame.contentWindow) {
392
- // this must be a frame element
393
- if (browserVersion.isHTA) {
394
- // stupid HTA bug; can't get in the front door
395
- target = frame.contentWindow.name;
396
- } else {
397
- this.currentWindow = frame.contentWindow;
398
- this.isSubFrameSelected = true;
399
- match = true;
400
- }
401
- } else if (frame.document && frame.location) {
402
- // must be an actual window frame
403
- this.currentWindow = frame;
404
- this.isSubFrameSelected = true;
405
- match = true;
406
- }
407
-
408
- if (!match) {
409
- // neither, let's loop through the frame names
410
- var win = this.getCurrentWindow();
411
-
412
- if (win && win.frames && win.frames.length) {
413
- for (var i = 0; i < win.frames.length; i++) {
414
- if (win.frames[i].name == target) {
415
- this.currentWindow = win.frames[i];
416
- this.isSubFrameSelected = true;
417
- match = true;
418
- break;
419
- }
420
- }
421
- }
422
- if (!match) {
423
- throw new SeleniumError("Not a frame: " + target);
424
- }
425
- }
426
- }
427
- // modifies the window
428
- this.getCurrentWindow();
429
- };
430
-
431
- BrowserBot.prototype.doesThisFrameMatchFrameExpression = function(currentFrameString, target) {
432
- var isDom = false;
433
- if (target.indexOf("dom=") == 0) {
434
- target = target.substr(4);
435
- isDom = true;
436
- } else if (target.indexOf("index=") == 0) {
437
- target = "frames[" + target.substr(6) + "]";
438
- isDom = true;
439
- }
440
- var t;
441
- try {
442
- eval("t=" + currentFrameString + "." + target);
443
- } catch (e) {
444
- }
445
- var autWindow = this.browserbot.getCurrentWindow();
446
- if (t != null) {
447
- try {
448
- if (t.window == autWindow) {
449
- return true;
450
- }
451
- if (t.window.uniqueId == autWindow.uniqueId) {
452
- return true;
453
- }
454
- return false;
455
- } catch (permDenied) {
456
- // DGF if the windows are incomparable, they're probably not the same...
457
- }
458
- }
459
- if (isDom) {
460
- return false;
461
- }
462
- var currentFrame;
463
- eval("currentFrame=" + currentFrameString);
464
- if (target == "relative=up") {
465
- if (currentFrame.window.parent == autWindow) {
466
- return true;
467
- }
468
- return false;
469
- }
470
- if (target == "relative=top") {
471
- if (currentFrame.window.top == autWindow) {
472
- return true;
473
- }
474
- return false;
475
- }
476
- if (currentFrame.window == autWindow.parent) {
477
- if (autWindow.name == target) {
478
- return true;
479
- }
480
- try {
481
- var element = this.findElement(target, currentFrame.window);
482
- if (element.contentWindow == autWindow) {
483
- return true;
484
- }
485
- } catch (e) {}
486
- }
487
- return false;
488
- };
489
-
490
- BrowserBot.prototype.openLocation = function(target) {
491
- // We're moving to a new page - clear the current one
492
- var win = this.getCurrentWindow();
493
- LOG.debug("openLocation newPageLoaded = false");
494
- this.newPageLoaded = false;
495
-
496
- this.setOpenLocation(win, target);
497
- };
498
-
499
- BrowserBot.prototype.openWindow = function(url, windowID) {
500
- if (url != "") {
501
- url = absolutify(url, this.baseUrl);
502
- }
503
- if (browserVersion.isHTA) {
504
- // in HTA mode, calling .open on the window interprets the url relative to that window
505
- // we need to absolute-ize the URL to make it consistent
506
- var child = this.getCurrentWindow().open(url, windowID);
507
- selenium.browserbot.openedWindows[windowID] = child;
508
- } else {
509
- this.getCurrentWindow().open(url, windowID);
510
- }
511
- };
512
-
513
- BrowserBot.prototype.setIFrameLocation = function(iframe, location) {
514
- iframe.src = location;
515
- };
516
-
517
- BrowserBot.prototype.setOpenLocation = function(win, loc) {
518
- loc = absolutify(loc, this.baseUrl);
519
- if (browserVersion.isHTA) {
520
- var oldHref = win.location.href;
521
- win.location.href = loc;
522
- var marker = null;
523
- try {
524
- marker = this.isPollingForLoad(win);
525
- if (marker && win.location[marker]) {
526
- win.location[marker] = false;
527
- }
528
- } catch (e) {} // DGF don't know why, but this often fails
529
- } else {
530
- win.location.href = loc;
531
- }
532
- };
533
-
534
- BrowserBot.prototype.getCurrentPage = function() {
535
- return this;
536
- };
537
-
538
- BrowserBot.prototype.modifyWindowToRecordPopUpDialogs = function(windowToModify, browserBot) {
539
- var self = this;
540
-
541
- windowToModify.seleniumAlert = windowToModify.alert;
542
-
543
- windowToModify.alert = function(alert) {
544
- browserBot.recordedAlerts.push(alert);
545
- self.relayBotToRC.call(self, "browserbot.recordedAlerts");
546
- };
547
-
548
- windowToModify.confirm = function(message) {
549
- browserBot.recordedConfirmations.push(message);
550
- var result = browserBot.nextConfirmResult;
551
- browserBot.nextConfirmResult = true;
552
- self.relayBotToRC.call(self, "browserbot.recordedConfirmations");
553
- return result;
554
- };
555
-
556
- windowToModify.prompt = function(message) {
557
- browserBot.recordedPrompts.push(message);
558
- var result = !browserBot.nextConfirmResult ? null : browserBot.nextPromptResult;
559
- browserBot.nextConfirmResult = true;
560
- browserBot.nextPromptResult = '';
561
- self.relayBotToRC.call(self, "browserbot.recordedPrompts");
562
- return result;
563
- };
564
-
565
- // Keep a reference to all popup windows by name
566
- // note that in IE the "windowName" argument must be a valid javascript identifier, it seems.
567
- var originalOpen = windowToModify.open;
568
- var originalOpenReference;
569
- if (browserVersion.isHTA) {
570
- originalOpenReference = 'selenium_originalOpen' + new Date().getTime();
571
- windowToModify[originalOpenReference] = windowToModify.open;
572
- }
573
-
574
- var isHTA = browserVersion.isHTA;
575
-
576
- var newOpen = function(url, windowName, windowFeatures, replaceFlag) {
577
- var myOriginalOpen = originalOpen;
578
- if (isHTA) {
579
- myOriginalOpen = this[originalOpenReference];
580
- }
581
- if (windowName == "" || windowName == "_blank") {
582
- windowName = "selenium_blank" + Math.round(100000 * Math.random());
583
- LOG.warn("Opening window '_blank', which is not a real window name. Randomizing target to be: " + windowName);
584
- }
585
- var openedWindow = myOriginalOpen(url, windowName, windowFeatures, replaceFlag);
586
- LOG.debug("window.open call intercepted; window ID (which you can use with selectWindow()) is \"" + windowName + "\"");
587
- if (windowName!=null) {
588
- openedWindow["seleniumWindowName"] = windowName;
589
- }
590
- selenium.browserbot.openedWindows[windowName] = openedWindow;
591
- return openedWindow;
592
- };
593
-
594
- if (browserVersion.isHTA) {
595
- originalOpenReference = 'selenium_originalOpen' + new Date().getTime();
596
- newOpenReference = 'selenium_newOpen' + new Date().getTime();
597
- var setOriginalRef = "this['" + originalOpenReference + "'] = this.open;";
598
-
599
- if (windowToModify.eval) {
600
- windowToModify.eval(setOriginalRef);
601
- windowToModify.open = newOpen;
602
- } else {
603
- // DGF why can't I eval here? Seems like I'm querying the window at a bad time, maybe?
604
- setOriginalRef += "this.open = this['" + newOpenReference + "'];";
605
- windowToModify[newOpenReference] = newOpen;
606
- windowToModify.setTimeout(setOriginalRef, 0);
607
- }
608
- } else {
609
- windowToModify.open = newOpen;
610
- }
611
- };
612
-
613
- /**
614
- * Call the supplied function when a the current page unloads and a new one loads.
615
- * This is done by polling continuously until the document changes and is fully loaded.
616
- */
617
- BrowserBot.prototype.modifySeparateTestWindowToDetectPageLoads = function(windowObject) {
618
- // Since the unload event doesn't fire in Safari 1.3, we start polling immediately
619
- if (!windowObject) {
620
- LOG.warn("modifySeparateTestWindowToDetectPageLoads: no windowObject!");
621
- return;
622
- }
623
- if (this._windowClosed(windowObject)) {
624
- LOG.info("modifySeparateTestWindowToDetectPageLoads: windowObject was closed");
625
- return;
626
- }
627
- var oldMarker = this.isPollingForLoad(windowObject);
628
- if (oldMarker) {
629
- LOG.debug("modifySeparateTestWindowToDetectPageLoads: already polling this window: " + oldMarker);
630
- return;
631
- }
632
-
633
- var marker = 'selenium' + new Date().getTime();
634
- LOG.debug("Starting pollForLoad (" + marker + "): " + windowObject.location);
635
- this.pollingForLoad[marker] = true;
636
- // if this is a frame, add a load listener, otherwise, attach a poller
637
- var frameElement = this._getFrameElement(windowObject);
638
- // DGF HTA mode can't attach load listeners to subframes (yuk!)
639
- var htaSubFrame = this._isHTASubFrame(windowObject);
640
- if (frameElement && !htaSubFrame) {
641
- LOG.debug("modifySeparateTestWindowToDetectPageLoads: this window is a frame; attaching a load listener");
642
- addLoadListener(frameElement, this.recordPageLoad);
643
- frameElement[marker] = true;
644
- frameElement["frame"+this.uniqueId] = marker;
645
- LOG.debug("dgf this.uniqueId="+this.uniqueId);
646
- LOG.debug("dgf marker="+marker);
647
- LOG.debug("dgf frameElement['frame'+this.uniqueId]="+frameElement['frame'+this.uniqueId]);
648
- frameElement[this.uniqueId] = marker;
649
- LOG.debug("dgf frameElement[this.uniqueId]="+frameElement[this.uniqueId]);
650
- } else {
651
- windowObject.location[marker] = true;
652
- windowObject[this.uniqueId] = marker;
653
- this.pollForLoad(this.recordPageLoad, windowObject, windowObject.document, windowObject.location, windowObject.location.href, marker);
654
- }
655
- };
656
-
657
- BrowserBot.prototype._isHTASubFrame = function(win) {
658
- if (!browserVersion.isHTA) return false;
659
- // DGF this is wrong! what if "win" isn't the selected window?
660
- return this.isSubFrameSelected;
661
- }
662
-
663
- BrowserBot.prototype._getFrameElement = function(win) {
664
- var frameElement = null;
665
- var caught;
666
- try {
667
- frameElement = win.frameElement;
668
- } catch (e) {
669
- caught = true;
670
- }
671
- if (caught) {
672
- // on IE, checking frameElement in a pop-up results in a "No such interface supported" exception
673
- // but it might have a frame element anyway!
674
- var parentContainsIdenticallyNamedFrame = false;
675
- try {
676
- parentContainsIdenticallyNamedFrame = win.parent.frames[win.name];
677
- } catch (e) {} // this may fail if access is denied to the parent; in that case, assume it's not a pop-up
678
-
679
- if (parentContainsIdenticallyNamedFrame) {
680
- // it can't be a coincidence that the parent has a frame with the same name as myself!
681
- var result;
682
- try {
683
- result = parentContainsIdenticallyNamedFrame.frameElement;
684
- if (result) {
685
- return result;
686
- }
687
- } catch (e) {} // it was worth a try! _getFrameElementsByName is often slow
688
- result = this._getFrameElementByName(win.name, win.parent.document, win);
689
- return result;
690
- }
691
- }
692
- LOG.debug("_getFrameElement: frameElement="+frameElement);
693
- if (frameElement) {
694
- LOG.debug("frameElement.name="+frameElement.name);
695
- }
696
- return frameElement;
697
- }
698
-
699
- BrowserBot.prototype._getFrameElementByName = function(name, doc, win) {
700
- var frames;
701
- var frame;
702
- var i;
703
- frames = doc.getElementsByTagName("iframe");
704
- for (i = 0; i < frames.length; i++) {
705
- frame = frames[i];
706
- if (frame.name === name) {
707
- return frame;
708
- }
709
- }
710
- frames = doc.getElementsByTagName("frame");
711
- for (i = 0; i < frames.length; i++) {
712
- frame = frames[i];
713
- if (frame.name === name) {
714
- return frame;
715
- }
716
- }
717
- // DGF weird; we only call this function when we know the doc contains the frame
718
- LOG.warn("_getFrameElementByName couldn't find a frame or iframe; checking every element for the name " + name);
719
- return BrowserBot.prototype.locateElementByName(win.name, win.parent.document);
720
- }
721
-
722
-
723
- /**
724
- * Set up a polling timer that will keep checking the readyState of the document until it's complete.
725
- * Since we might call this before the original page is unloaded, we first check to see that the current location
726
- * or href is different from the original one.
727
- */
728
- BrowserBot.prototype.pollForLoad = function(loadFunction, windowObject, originalDocument, originalLocation, originalHref, marker) {
729
- LOG.debug("pollForLoad original (" + marker + "): " + originalHref);
730
- try {
731
- if (this._windowClosed(windowObject)) {
732
- LOG.debug("pollForLoad WINDOW CLOSED (" + marker + ")");
733
- delete this.pollingForLoad[marker];
734
- return;
735
- }
736
-
737
- var isSamePage = this._isSamePage(windowObject, originalDocument, originalLocation, originalHref, marker);
738
- var rs = this.getReadyState(windowObject, windowObject.document);
739
-
740
- if (!isSamePage && rs == 'complete') {
741
- var currentHref = windowObject.location.href;
742
- LOG.debug("pollForLoad FINISHED (" + marker + "): " + rs + " (" + currentHref + ")");
743
- delete this.pollingForLoad[marker];
744
- this._modifyWindow(windowObject);
745
- var newMarker = this.isPollingForLoad(windowObject);
746
- if (!newMarker) {
747
- LOG.debug("modifyWindow didn't start new poller: " + newMarker);
748
- this.modifySeparateTestWindowToDetectPageLoads(windowObject);
749
- }
750
- newMarker = this.isPollingForLoad(windowObject);
751
- var currentlySelectedWindow;
752
- var currentlySelectedWindowMarker;
753
- currentlySelectedWindow =this.getCurrentWindow(true);
754
- currentlySelectedWindowMarker = currentlySelectedWindow[this.uniqueId];
755
-
756
- LOG.debug("pollForLoad (" + marker + ") restarting " + newMarker);
757
- if (/(TestRunner-splash|Blank)\.html\?start=true$/.test(currentHref)) {
758
- LOG.debug("pollForLoad Oh, it's just the starting page. Never mind!");
759
- } else if (currentlySelectedWindowMarker == newMarker) {
760
- loadFunction(currentlySelectedWindow);
761
- } else {
762
- LOG.debug("pollForLoad page load detected in non-current window; ignoring (currentlySelected="+currentlySelectedWindowMarker+", detection in "+newMarker+")");
763
- }
764
- return;
765
- }
766
- LOG.debug("pollForLoad continue (" + marker + "): " + currentHref);
767
- this.reschedulePoller(loadFunction, windowObject, originalDocument, originalLocation, originalHref, marker);
768
- } catch (e) {
769
- LOG.debug("Exception during pollForLoad; this should get noticed soon (" + e.message + ")!");
770
- //DGF this is supposed to get logged later; log it at debug just in case
771
- //LOG.exception(e);
772
- this.pageLoadError = e;
773
- }
774
- };
775
-
776
- BrowserBot.prototype._isSamePage = function(windowObject, originalDocument, originalLocation, originalHref, marker) {
777
- var currentDocument = windowObject.document;
778
- var currentLocation = windowObject.location;
779
- var currentHref = currentLocation.href
780
-
781
- var sameDoc = this._isSameDocument(originalDocument, currentDocument);
782
-
783
- var sameLoc = (originalLocation === currentLocation);
784
-
785
- // hash marks don't meant the page has loaded, so we need to strip them off if they exist...
786
- var currentHash = currentHref.indexOf('#');
787
- if (currentHash > 0) {
788
- currentHref = currentHref.substring(0, currentHash);
789
- }
790
- var originalHash = originalHref.indexOf('#');
791
- if (originalHash > 0) {
792
- originalHref = originalHref.substring(0, originalHash);
793
- }
794
- LOG.debug("_isSamePage: currentHref: " + currentHref);
795
- LOG.debug("_isSamePage: originalHref: " + originalHref);
796
-
797
- var sameHref = (originalHref === currentHref);
798
- var markedLoc = currentLocation[marker];
799
-
800
- if (browserVersion.isKonqueror || browserVersion.isSafari) {
801
- // the mark disappears too early on these browsers
802
- markedLoc = true;
803
- }
804
-
805
- // since this is some _very_ important logic, especially for PI and multiWindow mode, we should log all these out
806
- LOG.debug("_isSamePage: sameDoc: " + sameDoc);
807
- LOG.debug("_isSamePage: sameLoc: " + sameLoc);
808
- LOG.debug("_isSamePage: sameHref: " + sameHref);
809
- LOG.debug("_isSamePage: markedLoc: " + markedLoc);
810
-
811
- return sameDoc && sameLoc && sameHref && markedLoc
812
- };
813
-
814
- BrowserBot.prototype._isSameDocument = function(originalDocument, currentDocument) {
815
- return originalDocument === currentDocument;
816
- };
817
-
818
-
819
- BrowserBot.prototype.getReadyState = function(windowObject, currentDocument) {
820
- var rs = currentDocument.readyState;
821
- if (rs == null) {
822
- if ((this.buttonWindow!=null && this.buttonWindow.document.readyState == null) // not proxy injection mode (and therefore buttonWindow isn't null)
823
- || (top.document.readyState == null)) { // proxy injection mode (and therefore everything's in the top window, but buttonWindow doesn't exist)
824
- // uh oh! we're probably on Firefox with no readyState extension installed!
825
- // We'll have to just take a guess as to when the document is loaded; this guess
826
- // will never be perfect. :-(
827
- if (typeof currentDocument.getElementsByTagName != 'undefined'
828
- && typeof currentDocument.getElementById != 'undefined'
829
- && ( currentDocument.getElementsByTagName('body')[0] != null
830
- || currentDocument.body != null )) {
831
- if (windowObject.frameElement && windowObject.location.href == "about:blank" && windowObject.frameElement.src != "about:blank") {
832
- LOG.info("getReadyState not loaded, frame location was about:blank, but frame src = " + windowObject.frameElement.src);
833
- return null;
834
- }
835
- LOG.debug("getReadyState = windowObject.frames.length = " + windowObject.frames.length);
836
- for (var i = 0; i < windowObject.frames.length; i++) {
837
- LOG.debug("i = " + i);
838
- if (this.getReadyState(windowObject.frames[i], windowObject.frames[i].document) != 'complete') {
839
- LOG.debug("getReadyState aha! the nested frame " + windowObject.frames[i].name + " wasn't ready!");
840
- return null;
841
- }
842
- }
843
-
844
- rs = 'complete';
845
- } else {
846
- LOG.debug("pollForLoad readyState was null and DOM appeared to not be ready yet");
847
- }
848
- }
849
- }
850
- else if (rs == "loading" && browserVersion.isIE) {
851
- LOG.debug("pageUnloading = true!!!!");
852
- this.pageUnloading = true;
853
- }
854
- LOG.debug("getReadyState returning " + rs);
855
- return rs;
856
- };
857
-
858
- /** This function isn't used normally, but was the way we used to schedule pollers:
859
- asynchronously executed autonomous units. This is deprecated, but remains here
860
- for future reference.
861
- */
862
- BrowserBot.prototype.XXXreschedulePoller = function(loadFunction, windowObject, originalDocument, originalLocation, originalHref, marker) {
863
- var self = this;
864
- window.setTimeout(function() {
865
- self.pollForLoad(loadFunction, windowObject, originalDocument, originalLocation, originalHref, marker);
866
- }, 500);
867
- };
868
-
869
- /** This function isn't used normally, but is useful for debugging asynchronous pollers
870
- * To enable it, rename it to "reschedulePoller", so it will override the
871
- * existing reschedulePoller function
872
- */
873
- BrowserBot.prototype.XXXreschedulePoller = function(loadFunction, windowObject, originalDocument, originalLocation, originalHref, marker) {
874
- var doc = this.buttonWindow.document;
875
- var button = doc.createElement("button");
876
- var buttonName = doc.createTextNode(marker + " - " + windowObject.name);
877
- button.appendChild(buttonName);
878
- var tools = doc.getElementById("tools");
879
- var self = this;
880
- button.onclick = function() {
881
- tools.removeChild(button);
882
- self.pollForLoad(loadFunction, windowObject, originalDocument, originalLocation, originalHref, marker);
883
- };
884
- tools.appendChild(button);
885
- window.setTimeout(button.onclick, 500);
886
- };
887
-
888
- BrowserBot.prototype.reschedulePoller = function(loadFunction, windowObject, originalDocument, originalLocation, originalHref, marker) {
889
- var self = this;
890
- var pollerFunction = function() {
891
- self.pollForLoad(loadFunction, windowObject, originalDocument, originalLocation, originalHref, marker);
892
- };
893
- this.windowPollers.push(pollerFunction);
894
- };
895
-
896
- BrowserBot.prototype.runScheduledPollers = function() {
897
- LOG.debug("runScheduledPollers");
898
- var oldPollers = this.windowPollers;
899
- this.windowPollers = new Array();
900
- for (var i = 0; i < oldPollers.length; i++) {
901
- oldPollers[i].call();
902
- }
903
- LOG.debug("runScheduledPollers DONE");
904
- };
905
-
906
- BrowserBot.prototype.isPollingForLoad = function(win) {
907
- var marker;
908
- var frameElement = this._getFrameElement(win);
909
- var htaSubFrame = this._isHTASubFrame(win);
910
- if (frameElement && !htaSubFrame) {
911
- marker = frameElement["frame"+this.uniqueId];
912
- } else {
913
- marker = win[this.uniqueId];
914
- }
915
- if (!marker) {
916
- LOG.debug("isPollingForLoad false, missing uniqueId " + this.uniqueId + ": " + marker);
917
- return false;
918
- }
919
- if (!this.pollingForLoad[marker]) {
920
- LOG.debug("isPollingForLoad false, this.pollingForLoad[" + marker + "]: " + this.pollingForLoad[marker]);
921
- return false;
922
- }
923
- return marker;
924
- };
925
-
926
- BrowserBot.prototype.getWindowByName = function(windowName, doNotModify) {
927
- LOG.debug("getWindowByName(" + windowName + ")");
928
- // First look in the map of opened windows
929
- var targetWindow = this.openedWindows[windowName];
930
- if (!targetWindow) {
931
- targetWindow = this.topWindow[windowName];
932
- }
933
- if (!targetWindow && windowName == "_blank") {
934
- for (var winName in this.openedWindows) {
935
- // _blank can match selenium_blank*, if it looks like it's OK (valid href, not closed)
936
- if (/^selenium_blank/.test(winName)) {
937
- targetWindow = this.openedWindows[winName];
938
- var ok;
939
- try {
940
- if (!this._windowClosed(targetWindow)) {
941
- ok = targetWindow.location.href;
942
- }
943
- } catch (e) {}
944
- if (ok) break;
945
- }
946
- }
947
- }
948
- if (!targetWindow) {
949
- throw new SeleniumError("Window does not exist. If this looks like a Selenium bug, make sure to read http://selenium-core.openqa.org/reference.html#openWindow for potential workarounds.");
950
- }
951
- if (browserVersion.isHTA) {
952
- try {
953
- targetWindow.location.href;
954
- } catch (e) {
955
- targetWindow = window.open("", targetWindow.name);
956
- this.openedWindows[targetWindow.name] = targetWindow;
957
- }
958
- }
959
- if (!doNotModify) {
960
- this._modifyWindow(targetWindow);
961
- }
962
- return targetWindow;
963
- };
964
-
965
- /**
966
- * Find a window name from the window title.
967
- */
968
- BrowserBot.prototype.getWindowNameByTitle = function(windowTitle) {
969
- LOG.debug("getWindowNameByTitle(" + windowTitle + ")");
970
-
971
- // First look in the map of opened windows and iterate them
972
- for (var windowName in this.openedWindows) {
973
- var targetWindow = this.openedWindows[windowName];
974
-
975
- // If the target window's title is our title
976
- try {
977
- // TODO implement Pattern Matching here
978
- if (!this._windowClosed(targetWindow) &&
979
- targetWindow.document.title == windowTitle) {
980
- return windowName;
981
- }
982
- } catch (e) {
983
- // You'll often get Permission Denied errors here in IE
984
- // eh, if we can't read this window's title,
985
- // it's probably not available to us right now anyway
986
- }
987
- }
988
-
989
- try {
990
- if (this.topWindow.document.title == windowTitle) {
991
- return "";
992
- }
993
- } catch (e) {} // IE Perm denied
994
-
995
- throw new SeleniumError("Could not find window with title " + windowTitle);
996
- };
997
-
998
- BrowserBot.prototype.getCurrentWindow = function(doNotModify) {
999
- if (this.proxyInjectionMode) {
1000
- return window;
1001
- }
1002
- var testWindow = this.currentWindow;
1003
- if (!doNotModify) {
1004
- this._modifyWindow(testWindow);
1005
- LOG.debug("getCurrentWindow newPageLoaded = false");
1006
- this.newPageLoaded = false;
1007
- }
1008
- testWindow = this._handleClosedSubFrame(testWindow, doNotModify);
1009
- return testWindow;
1010
- };
1011
-
1012
- /**
1013
- * Offer a method the end-user can reliably use to retrieve the current window.
1014
- * This should work even for windows with an XPCNativeWrapper. Returns the
1015
- * current window object.
1016
- */
1017
- BrowserBot.prototype.getUserWindow = function() {
1018
- var userWindow = this.getCurrentWindow(true);
1019
-
1020
- if (userWindow.wrappedJSObject) {
1021
- userWindow = userWindow.wrappedJSObject;
1022
- }
1023
-
1024
- return userWindow;
1025
- };
1026
-
1027
- BrowserBot.prototype._handleClosedSubFrame = function(testWindow, doNotModify) {
1028
- if (this.proxyInjectionMode) {
1029
- return testWindow;
1030
- }
1031
-
1032
- if (this.isSubFrameSelected) {
1033
- var missing = true;
1034
- if (testWindow.parent && testWindow.parent.frames && testWindow.parent.frames.length) {
1035
- for (var i = 0; i < testWindow.parent.frames.length; i++) {
1036
- if (testWindow.parent.frames[i] == testWindow) {
1037
- missing = false;
1038
- break;
1039
- }
1040
- }
1041
- }
1042
- if (missing) {
1043
- LOG.warn("Current subframe appears to have closed; selecting top frame");
1044
- this.selectFrame("relative=top");
1045
- return this.getCurrentWindow(doNotModify);
1046
- }
1047
- } else if (this._windowClosed(testWindow)) {
1048
- var closedError = new SeleniumError("Current window or frame is closed!");
1049
- closedError.windowClosed = true;
1050
- throw closedError;
1051
- }
1052
- return testWindow;
1053
- };
1054
-
1055
- BrowserBot.prototype.highlight = function (element, force) {
1056
- if (force || this.shouldHighlightLocatedElement) {
1057
- try {
1058
- highlight(element);
1059
- } catch (e) {} // DGF element highlighting is low-priority and possibly dangerous
1060
- }
1061
- return element;
1062
- }
1063
-
1064
- BrowserBot.prototype.setShouldHighlightElement = function (shouldHighlight) {
1065
- this.shouldHighlightLocatedElement = shouldHighlight;
1066
- }
1067
-
1068
- /*****************************************************************/
1069
- /* BROWSER-SPECIFIC FUNCTIONS ONLY AFTER THIS LINE */
1070
-
1071
-
1072
- BrowserBot.prototype._registerAllLocatorFunctions = function() {
1073
- // TODO - don't do this in the constructor - only needed once ever
1074
- this.locationStrategies = {};
1075
- for (var functionName in this) {
1076
- var result = /^locateElementBy([A-Z].+)$/.exec(functionName);
1077
- if (result != null) {
1078
- var locatorFunction = this[functionName];
1079
- if (typeof(locatorFunction) != 'function') {
1080
- continue;
1081
- }
1082
- // Use a specified prefix in preference to one generated from
1083
- // the function name
1084
- var locatorPrefix = locatorFunction.prefix || result[1].toLowerCase();
1085
- this.locationStrategies[locatorPrefix] = locatorFunction;
1086
- }
1087
- }
1088
-
1089
- /**
1090
- * Find a locator based on a prefix.
1091
- */
1092
- this.findElementBy = function(locatorType, locator, inDocument, inWindow) {
1093
- var locatorFunction = this.locationStrategies[locatorType];
1094
- if (! locatorFunction) {
1095
- throw new SeleniumError("Unrecognised locator type: '" + locatorType + "'");
1096
- }
1097
- return locatorFunction.call(this, locator, inDocument, inWindow);
1098
- };
1099
-
1100
- /**
1101
- * The implicit locator, that is used when no prefix is supplied.
1102
- */
1103
- this.locationStrategies['implicit'] = function(locator, inDocument, inWindow) {
1104
- if (locator.startsWith('//')) {
1105
- return this.locateElementByXPath(locator, inDocument, inWindow);
1106
- }
1107
- if (locator.startsWith('document.')) {
1108
- return this.locateElementByDomTraversal(locator, inDocument, inWindow);
1109
- }
1110
- return this.locateElementByIdentifier(locator, inDocument, inWindow);
1111
- };
1112
- }
1113
-
1114
- BrowserBot.prototype.getDocument = function() {
1115
- return this.getCurrentWindow().document;
1116
- }
1117
-
1118
- BrowserBot.prototype.getTitle = function() {
1119
- var t = this.getDocument().title;
1120
- if (typeof(t) == "string") {
1121
- t = t.trim();
1122
- }
1123
- return t;
1124
- }
1125
-
1126
- BrowserBot.prototype.getCookieByName = function(cookieName, doc) {
1127
- if (!doc) doc = this.getDocument();
1128
- var ck = doc.cookie;
1129
- if (!ck) return null;
1130
- var ckPairs = ck.split(/;/);
1131
- for (var i = 0; i < ckPairs.length; i++) {
1132
- var ckPair = ckPairs[i].trim();
1133
- var ckNameValue = ckPair.split(/=/);
1134
- var ckName = decodeURIComponent(ckNameValue[0]);
1135
- if (ckName === cookieName) {
1136
- return decodeURIComponent(ckNameValue[1]);
1137
- }
1138
- }
1139
- return null;
1140
- }
1141
-
1142
- BrowserBot.prototype.getAllCookieNames = function(doc) {
1143
- if (!doc) doc = this.getDocument();
1144
- var ck = doc.cookie;
1145
- if (!ck) return [];
1146
- var cookieNames = [];
1147
- var ckPairs = ck.split(/;/);
1148
- for (var i = 0; i < ckPairs.length; i++) {
1149
- var ckPair = ckPairs[i].trim();
1150
- var ckNameValue = ckPair.split(/=/);
1151
- var ckName = decodeURIComponent(ckNameValue[0]);
1152
- cookieNames.push(ckName);
1153
- }
1154
- return cookieNames;
1155
- }
1156
-
1157
- BrowserBot.prototype.deleteCookie = function(cookieName, domain, path, doc) {
1158
- if (!doc) doc = this.getDocument();
1159
- var expireDateInMilliseconds = (new Date()).getTime() + (-1 * 1000);
1160
- var cookie = cookieName + "=deleted; ";
1161
- if (path) {
1162
- cookie += "path=" + path + "; ";
1163
- }
1164
- if (domain) {
1165
- cookie += "domain=" + domain + "; ";
1166
- }
1167
- cookie += "expires=" + new Date(expireDateInMilliseconds).toGMTString();
1168
- LOG.debug("Setting cookie to: " + cookie);
1169
- doc.cookie = cookie;
1170
- }
1171
-
1172
- /** Try to delete cookie, return false if it didn't work */
1173
- BrowserBot.prototype._maybeDeleteCookie = function(cookieName, domain, path, doc) {
1174
- this.deleteCookie(cookieName, domain, path, doc);
1175
- return (!this.getCookieByName(cookieName, doc));
1176
- }
1177
-
1178
-
1179
- BrowserBot.prototype._recursivelyDeleteCookieDomains = function(cookieName, domain, path, doc) {
1180
- var deleted = this._maybeDeleteCookie(cookieName, domain, path, doc);
1181
- if (deleted) return true;
1182
- var dotIndex = domain.indexOf(".");
1183
- if (dotIndex == 0) {
1184
- return this._recursivelyDeleteCookieDomains(cookieName, domain.substring(1), path, doc);
1185
- } else if (dotIndex != -1) {
1186
- return this._recursivelyDeleteCookieDomains(cookieName, domain.substring(dotIndex), path, doc);
1187
- } else {
1188
- // No more dots; try just not passing in a domain at all
1189
- return this._maybeDeleteCookie(cookieName, null, path, doc);
1190
- }
1191
- }
1192
-
1193
- BrowserBot.prototype._recursivelyDeleteCookie = function(cookieName, domain, path, doc) {
1194
- var slashIndex = path.lastIndexOf("/");
1195
- var finalIndex = path.length-1;
1196
- if (slashIndex == finalIndex) {
1197
- slashIndex--;
1198
- }
1199
- if (slashIndex != -1) {
1200
- deleted = this._recursivelyDeleteCookie(cookieName, domain, path.substring(0, slashIndex+1), doc);
1201
- if (deleted) return true;
1202
- }
1203
- return this._recursivelyDeleteCookieDomains(cookieName, domain, path, doc);
1204
- }
1205
-
1206
- BrowserBot.prototype.recursivelyDeleteCookie = function(cookieName, domain, path, win) {
1207
- if (!win) win = this.getCurrentWindow();
1208
- var doc = win.document;
1209
- if (!domain) {
1210
- domain = doc.domain;
1211
- }
1212
- if (!path) {
1213
- path = win.location.pathname;
1214
- }
1215
- var deleted = this._recursivelyDeleteCookie(cookieName, "." + domain, path, doc);
1216
- if (deleted) return;
1217
- // Finally try a null path (Try it last because it's uncommon)
1218
- deleted = this._recursivelyDeleteCookieDomains(cookieName, "." + domain, null, doc);
1219
- if (deleted) return;
1220
- throw new SeleniumError("Couldn't delete cookie " + cookieName);
1221
- }
1222
-
1223
- /*
1224
- * Finds an element recursively in frames and nested frames
1225
- * in the specified document, using various lookup protocols
1226
- */
1227
- BrowserBot.prototype.findElementRecursive = function(locatorType, locatorString, inDocument, inWindow) {
1228
-
1229
- var element = this.findElementBy(locatorType, locatorString, inDocument, inWindow);
1230
- if (element != null) {
1231
- return element;
1232
- }
1233
-
1234
- for (var i = 0; i < inWindow.frames.length; i++) {
1235
- // On some browsers, the document object is undefined for third-party
1236
- // frames. Make sure the document is valid before continuing.
1237
- if (inWindow.frames[i].document) {
1238
- element = this.findElementRecursive(locatorType, locatorString, inWindow.frames[i].document, inWindow.frames[i]);
1239
-
1240
- if (element != null) {
1241
- return element;
1242
- }
1243
- }
1244
- }
1245
- };
1246
-
1247
- /*
1248
- * Finds an element on the current page, using various lookup protocols
1249
- */
1250
- BrowserBot.prototype.findElementOrNull = function(locator, win) {
1251
- locator = parse_locator(locator);
1252
-
1253
- if (win == null) {
1254
- win = this.getCurrentWindow();
1255
- }
1256
- var element = this.findElementRecursive(locator.type, locator.string, win.document, win);
1257
-
1258
- if (element != null) {
1259
- return this.browserbot.highlight(element);
1260
- }
1261
-
1262
- // Element was not found by any locator function.
1263
- return null;
1264
- };
1265
-
1266
- BrowserBot.prototype.findElement = function(locator, win) {
1267
- var element = this.findElementOrNull(locator, win);
1268
- if (element == null) throw new SeleniumError("Element " + locator + " not found");
1269
- return element;
1270
- }
1271
-
1272
- /**
1273
- * In non-IE browsers, getElementById() does not search by name. Instead, we
1274
- * we search separately by id and name.
1275
- */
1276
- BrowserBot.prototype.locateElementByIdentifier = function(identifier, inDocument, inWindow) {
1277
- return BrowserBot.prototype.locateElementById(identifier, inDocument, inWindow)
1278
- || BrowserBot.prototype.locateElementByName(identifier, inDocument, inWindow)
1279
- || null;
1280
- };
1281
-
1282
- /**
1283
- * Find the element with id - can't rely on getElementById, coz it returns by name as well in IE..
1284
- */
1285
- BrowserBot.prototype.locateElementById = function(identifier, inDocument, inWindow) {
1286
- var element = inDocument.getElementById(identifier);
1287
- if (element && element.getAttribute('id') === identifier) {
1288
- return element;
1289
- }
1290
- else if (browserVersion.isIE || browserVersion.isOpera) {
1291
- // SEL-484
1292
- var xpath = '/descendant::*[@id=' + identifier.quoteForXPath() + ']';
1293
- return BrowserBot.prototype
1294
- .locateElementByXPath(xpath, inDocument, inWindow);
1295
- }
1296
- else {
1297
- return null;
1298
- }
1299
- };
1300
-
1301
- /**
1302
- * Find an element by name, refined by (optional) element-filter
1303
- * expressions.
1304
- */
1305
- BrowserBot.prototype.locateElementByName = function(locator, document, inWindow) {
1306
- var elements = document.getElementsByTagName("*");
1307
-
1308
- var filters = locator.split(' ');
1309
- filters[0] = 'name=' + filters[0];
1310
-
1311
- while (filters.length) {
1312
- var filter = filters.shift();
1313
- elements = this.selectElements(filter, elements, 'value');
1314
- }
1315
-
1316
- if (elements.length > 0) {
1317
- return elements[0];
1318
- }
1319
- return null;
1320
- };
1321
-
1322
- /**
1323
- * Finds an element using by evaluating the specfied string.
1324
- */
1325
- BrowserBot.prototype.locateElementByDomTraversal = function(domTraversal, document, window) {
1326
-
1327
- var browserbot = this.browserbot;
1328
- var element = null;
1329
- try {
1330
- element = eval(domTraversal);
1331
- } catch (e) {
1332
- return null;
1333
- }
1334
-
1335
- if (!element) {
1336
- return null;
1337
- }
1338
-
1339
- return element;
1340
- };
1341
- BrowserBot.prototype.locateElementByDomTraversal.prefix = "dom";
1342
-
1343
- /**
1344
- * Finds an element identified by the xpath expression. Expressions _must_
1345
- * begin with "//".
1346
- */
1347
- BrowserBot.prototype.locateElementByXPath = function(xpath, inDocument, inWindow) {
1348
- var results = eval_xpath(xpath, inDocument, {
1349
- returnOnFirstMatch : true,
1350
- ignoreAttributesWithoutValue: this.ignoreAttributesWithoutValue,
1351
- allowNativeXpath : this.allowNativeXpath,
1352
- xpathLibrary : this.xpathLibrary,
1353
- namespaceResolver : this._namespaceResolver
1354
- });
1355
- return (results.length > 0) ? results[0] : null;
1356
- };
1357
-
1358
- BrowserBot.prototype._namespaceResolver = function(prefix) {
1359
- if (prefix == 'html' || prefix == 'xhtml' || prefix == 'x') {
1360
- return 'http://www.w3.org/1999/xhtml';
1361
- } else if (prefix == 'mathml') {
1362
- return 'http://www.w3.org/1998/Math/MathML';
1363
- } else {
1364
- throw new Error("Unknown namespace: " + prefix + ".");
1365
- }
1366
- }
1367
-
1368
- /**
1369
- * Returns the number of xpath results.
1370
- */
1371
- BrowserBot.prototype.evaluateXPathCount = function(xpath, inDocument) {
1372
- var results = eval_xpath(xpath, inDocument, {
1373
- ignoreAttributesWithoutValue: this.ignoreAttributesWithoutValue,
1374
- allowNativeXpath : this.allowNativeXpath,
1375
- xpathLibrary : this.xpathLibrary,
1376
- namespaceResolver : this._namespaceResolver
1377
- });
1378
- return results.length;
1379
- };
1380
-
1381
- /**
1382
- * Finds a link element with text matching the expression supplied. Expressions must
1383
- * begin with "link:".
1384
- */
1385
- BrowserBot.prototype.locateElementByLinkText = function(linkText, inDocument, inWindow) {
1386
- var links = inDocument.getElementsByTagName('a');
1387
- for (var i = 0; i < links.length; i++) {
1388
- var element = links[i];
1389
- if (PatternMatcher.matches(linkText, getText(element))) {
1390
- return element;
1391
- }
1392
- }
1393
- return null;
1394
- };
1395
- BrowserBot.prototype.locateElementByLinkText.prefix = "link";
1396
-
1397
- /**
1398
- * Returns an attribute based on an attribute locator. This is made up of an element locator
1399
- * suffixed with @attribute-name.
1400
- */
1401
- BrowserBot.prototype.findAttribute = function(locator) {
1402
- // Split into locator + attributeName
1403
- var attributePos = locator.lastIndexOf("@");
1404
- var elementLocator = locator.slice(0, attributePos);
1405
- var attributeName = locator.slice(attributePos + 1);
1406
-
1407
- // Find the element.
1408
- var element = this.findElement(elementLocator);
1409
-
1410
- // Handle missing "class" attribute in IE.
1411
- if (browserVersion.isIE && attributeName == "class") {
1412
- attributeName = "className";
1413
- }
1414
-
1415
- // Get the attribute value.
1416
- var attributeValue = element.getAttribute(attributeName);
1417
-
1418
- // IE returns an object for the "style" attribute
1419
- if (attributeName == 'style' && typeof(attributeValue) != 'string') {
1420
- attributeValue = attributeValue.cssText;
1421
- }
1422
-
1423
- return attributeValue ? attributeValue.toString() : null;
1424
- };
1425
-
1426
- /*
1427
- * Select the specified option and trigger the relevant events of the element.
1428
- */
1429
- BrowserBot.prototype.selectOption = function(element, optionToSelect) {
1430
- triggerEvent(element, 'focus', false);
1431
- var changed = false;
1432
- for (var i = 0; i < element.options.length; i++) {
1433
- var option = element.options[i];
1434
- if (option.selected && option != optionToSelect) {
1435
- option.selected = false;
1436
- changed = true;
1437
- }
1438
- else if (!option.selected && option == optionToSelect) {
1439
- option.selected = true;
1440
- changed = true;
1441
- }
1442
- }
1443
-
1444
- if (changed) {
1445
- triggerEvent(element, 'change', true);
1446
- }
1447
- };
1448
-
1449
- /*
1450
- * Select the specified option and trigger the relevant events of the element.
1451
- */
1452
- BrowserBot.prototype.addSelection = function(element, option) {
1453
- this.checkMultiselect(element);
1454
- triggerEvent(element, 'focus', false);
1455
- if (!option.selected) {
1456
- option.selected = true;
1457
- triggerEvent(element, 'change', true);
1458
- }
1459
- };
1460
-
1461
- /*
1462
- * Select the specified option and trigger the relevant events of the element.
1463
- */
1464
- BrowserBot.prototype.removeSelection = function(element, option) {
1465
- this.checkMultiselect(element);
1466
- triggerEvent(element, 'focus', false);
1467
- if (option.selected) {
1468
- option.selected = false;
1469
- triggerEvent(element, 'change', true);
1470
- }
1471
- };
1472
-
1473
- BrowserBot.prototype.checkMultiselect = function(element) {
1474
- if (!element.multiple)
1475
- {
1476
- throw new SeleniumError("Not a multi-select");
1477
- }
1478
-
1479
- };
1480
-
1481
- BrowserBot.prototype.replaceText = function(element, stringValue) {
1482
- triggerEvent(element, 'focus', false);
1483
- triggerEvent(element, 'select', true);
1484
- var maxLengthAttr = element.getAttribute("maxLength");
1485
- var actualValue = stringValue;
1486
- if (maxLengthAttr != null) {
1487
- var maxLength = parseInt(maxLengthAttr);
1488
- if (stringValue.length > maxLength) {
1489
- actualValue = stringValue.substr(0, maxLength);
1490
- }
1491
- }
1492
-
1493
- if (getTagName(element) == "body") {
1494
- if (element.ownerDocument && element.ownerDocument.designMode) {
1495
- var designMode = new String(element.ownerDocument.designMode).toLowerCase();
1496
- if (designMode = "on") {
1497
- // this must be a rich text control!
1498
- element.innerHTML = actualValue;
1499
- }
1500
- }
1501
- } else {
1502
- element.value = actualValue;
1503
- }
1504
- // DGF this used to be skipped in chrome URLs, but no longer. Is xpcnativewrappers to blame?
1505
- try {
1506
- triggerEvent(element, 'change', true);
1507
- } catch (e) {}
1508
- };
1509
-
1510
- BrowserBot.prototype.submit = function(formElement) {
1511
- var actuallySubmit = true;
1512
- this._modifyElementTarget(formElement);
1513
- if (formElement.onsubmit) {
1514
- if (browserVersion.isHTA) {
1515
- // run the code in the correct window so alerts are handled correctly even in HTA mode
1516
- var win = this.browserbot.getCurrentWindow();
1517
- var now = new Date().getTime();
1518
- var marker = 'marker' + now;
1519
- win[marker] = formElement;
1520
- win.setTimeout("var actuallySubmit = "+marker+".onsubmit();" +
1521
- "if (actuallySubmit) { " +
1522
- marker+".submit(); " +
1523
- "if ("+marker+".target && !/^_/.test("+marker+".target)) {"+
1524
- "window.open('', "+marker+".target);"+
1525
- "}"+
1526
- "};"+
1527
- marker+"=null", 0);
1528
- // pause for up to 2s while this command runs
1529
- var terminationCondition = function () {
1530
- return !win[marker];
1531
- }
1532
- return Selenium.decorateFunctionWithTimeout(terminationCondition, 2000);
1533
- } else {
1534
- actuallySubmit = formElement.onsubmit();
1535
- if (actuallySubmit) {
1536
- formElement.submit();
1537
- if (formElement.target && !/^_/.test(formElement.target)) {
1538
- this.browserbot.openWindow('', formElement.target);
1539
- }
1540
- }
1541
- }
1542
- } else {
1543
- formElement.submit();
1544
- }
1545
- }
1546
-
1547
- BrowserBot.prototype.clickElement = function(element, clientX, clientY) {
1548
- this._fireEventOnElement("click", element, clientX, clientY);
1549
- };
1550
-
1551
- BrowserBot.prototype.doubleClickElement = function(element, clientX, clientY) {
1552
- this._fireEventOnElement("dblclick", element, clientX, clientY);
1553
- };
1554
-
1555
- // The contextmenu event is fired when the user right-clicks to open the context menu
1556
- BrowserBot.prototype.contextMenuOnElement = function(element, clientX, clientY) {
1557
- this._fireEventOnElement("contextmenu", element, clientX, clientY);
1558
- };
1559
-
1560
- BrowserBot.prototype._modifyElementTarget = function(element) {
1561
- if (element.target) {
1562
- if (element.target == "_blank" || /^selenium_blank/.test(element.target) ) {
1563
- var tagName = getTagName(element);
1564
- if (tagName == "a" || tagName == "form") {
1565
- var newTarget = "selenium_blank" + Math.round(100000 * Math.random());
1566
- LOG.warn("Link has target '_blank', which is not supported in Selenium! Randomizing target to be: " + newTarget);
1567
- this.browserbot.openWindow('', newTarget);
1568
- element.target = newTarget;
1569
- }
1570
- }
1571
- }
1572
- }
1573
-
1574
-
1575
- BrowserBot.prototype._handleClickingImagesInsideLinks = function(targetWindow, element) {
1576
- var itrElement = element;
1577
- while (itrElement != null) {
1578
- if (itrElement.href) {
1579
- targetWindow.location.href = itrElement.href;
1580
- break;
1581
- }
1582
- itrElement = itrElement.parentNode;
1583
- }
1584
- }
1585
-
1586
- BrowserBot.prototype._getTargetWindow = function(element) {
1587
- var targetWindow = element.ownerDocument.defaultView;
1588
- if (element.target) {
1589
- targetWindow = this._getFrameFromGlobal(element.target);
1590
- }
1591
- return targetWindow;
1592
- }
1593
-
1594
- BrowserBot.prototype._getFrameFromGlobal = function(target) {
1595
-
1596
- if (target == "_self") {
1597
- return this.getCurrentWindow();
1598
- }
1599
- if (target == "_top") {
1600
- return this.topFrame;
1601
- } else if (target == "_parent") {
1602
- return this.getCurrentWindow().parent;
1603
- } else if (target == "_blank") {
1604
- // TODO should this set cleverer window defaults?
1605
- return this.getCurrentWindow().open('', '_blank');
1606
- }
1607
- var frameElement = this.findElementBy("implicit", target, this.topFrame.document, this.topFrame);
1608
- if (frameElement) {
1609
- return frameElement.contentWindow;
1610
- }
1611
- var win = this.getWindowByName(target);
1612
- if (win) return win;
1613
- return this.getCurrentWindow().open('', target);
1614
- }
1615
-
1616
-
1617
- BrowserBot.prototype.bodyText = function() {
1618
- if (!this.getDocument().body) {
1619
- throw new SeleniumError("Couldn't access document.body. Is this HTML page fully loaded?");
1620
- }
1621
- return getText(this.getDocument().body);
1622
- };
1623
-
1624
- BrowserBot.prototype.getAllButtons = function() {
1625
- var elements = this.getDocument().getElementsByTagName('input');
1626
- var result = [];
1627
-
1628
- for (var i = 0; i < elements.length; i++) {
1629
- if (elements[i].type == 'button' || elements[i].type == 'submit' || elements[i].type == 'reset') {
1630
- result.push(elements[i].id);
1631
- }
1632
- }
1633
-
1634
- return result;
1635
- };
1636
-
1637
-
1638
- BrowserBot.prototype.getAllFields = function() {
1639
- var elements = this.getDocument().getElementsByTagName('input');
1640
- var result = [];
1641
-
1642
- for (var i = 0; i < elements.length; i++) {
1643
- if (elements[i].type == 'text') {
1644
- result.push(elements[i].id);
1645
- }
1646
- }
1647
-
1648
- return result;
1649
- };
1650
-
1651
- BrowserBot.prototype.getAllLinks = function() {
1652
- var elements = this.getDocument().getElementsByTagName('a');
1653
- var result = [];
1654
-
1655
- for (var i = 0; i < elements.length; i++) {
1656
- result.push(elements[i].id);
1657
- }
1658
-
1659
- return result;
1660
- };
1661
-
1662
- function isDefined(value) {
1663
- return typeof(value) != undefined;
1664
- }
1665
-
1666
- BrowserBot.prototype.goBack = function() {
1667
- this.getCurrentWindow().history.back();
1668
- };
1669
-
1670
- BrowserBot.prototype.goForward = function() {
1671
- this.getCurrentWindow().history.forward();
1672
- };
1673
-
1674
- BrowserBot.prototype.close = function() {
1675
- if (browserVersion.isIE) {
1676
- // fix "do you want to close this window" warning in IE
1677
- // You can only close windows that you have opened.
1678
- // So, let's "open" it.
1679
- try {
1680
- this.topFrame.name=new Date().getTime();
1681
- window.open("", this.topFrame.name, "");
1682
- this.topFrame.close();
1683
- return;
1684
- } catch (e) {}
1685
- }
1686
- if (browserVersion.isChrome || browserVersion.isSafari || browserVersion.isOpera) {
1687
- this.topFrame.close();
1688
- } else {
1689
- this.getCurrentWindow().eval("window.top.close();");
1690
- }
1691
- };
1692
-
1693
- BrowserBot.prototype.refresh = function() {
1694
- this.getCurrentWindow().location.reload(true);
1695
- };
1696
-
1697
- /**
1698
- * Refine a list of elements using a filter.
1699
- */
1700
- BrowserBot.prototype.selectElementsBy = function(filterType, filter, elements) {
1701
- var filterFunction = BrowserBot.filterFunctions[filterType];
1702
- if (! filterFunction) {
1703
- throw new SeleniumError("Unrecognised element-filter type: '" + filterType + "'");
1704
- }
1705
-
1706
- return filterFunction(filter, elements);
1707
- };
1708
-
1709
- BrowserBot.filterFunctions = {};
1710
-
1711
- BrowserBot.filterFunctions.name = function(name, elements) {
1712
- var selectedElements = [];
1713
- for (var i = 0; i < elements.length; i++) {
1714
- if (elements[i].name === name) {
1715
- selectedElements.push(elements[i]);
1716
- }
1717
- }
1718
- return selectedElements;
1719
- };
1720
-
1721
- BrowserBot.filterFunctions.value = function(value, elements) {
1722
- var selectedElements = [];
1723
- for (var i = 0; i < elements.length; i++) {
1724
- if (elements[i].value === value) {
1725
- selectedElements.push(elements[i]);
1726
- }
1727
- }
1728
- return selectedElements;
1729
- };
1730
-
1731
- BrowserBot.filterFunctions.index = function(index, elements) {
1732
- index = Number(index);
1733
- if (isNaN(index) || index < 0) {
1734
- throw new SeleniumError("Illegal Index: " + index);
1735
- }
1736
- if (elements.length <= index) {
1737
- throw new SeleniumError("Index out of range: " + index);
1738
- }
1739
- return [elements[index]];
1740
- };
1741
-
1742
- BrowserBot.prototype.selectElements = function(filterExpr, elements, defaultFilterType) {
1743
-
1744
- var filterType = (defaultFilterType || 'value');
1745
-
1746
- // If there is a filter prefix, use the specified strategy
1747
- var result = filterExpr.match(/^([A-Za-z]+)=(.+)/);
1748
- if (result) {
1749
- filterType = result[1].toLowerCase();
1750
- filterExpr = result[2];
1751
- }
1752
-
1753
- return this.selectElementsBy(filterType, filterExpr, elements);
1754
- };
1755
-
1756
- /**
1757
- * Find an element by class
1758
- */
1759
- BrowserBot.prototype.locateElementByClass = function(locator, document) {
1760
- return elementFindFirstMatchingChild(document,
1761
- function(element) {
1762
- return element.className == locator
1763
- }
1764
- );
1765
- }
1766
-
1767
- /**
1768
- * Find an element by alt
1769
- */
1770
- BrowserBot.prototype.locateElementByAlt = function(locator, document) {
1771
- return elementFindFirstMatchingChild(document,
1772
- function(element) {
1773
- return element.alt == locator
1774
- }
1775
- );
1776
- }
1777
-
1778
- /**
1779
- * Find an element by css selector
1780
- */
1781
- BrowserBot.prototype.locateElementByCss = function(locator, document) {
1782
- var elements = eval_css(locator, document);
1783
- if (elements.length != 0)
1784
- return elements[0];
1785
- return null;
1786
- }
1787
-
1788
- /**
1789
- * This function is responsible for mapping a UI specifier string to an element
1790
- * on the page, and returning it. If no element is found, null is returned.
1791
- * Returning null on failure to locate the element is part of the undocumented
1792
- * API for locator strategies.
1793
- */
1794
- BrowserBot.prototype.locateElementByUIElement = function(locator, inDocument) {
1795
- // offset locators are delimited by "->", which is much simpler than the
1796
- // previous scheme involving detecting the close-paren.
1797
- var locators = locator.split(/->/, 2);
1798
-
1799
- var locatedElement = null;
1800
- var pageElements = UIMap.getInstance()
1801
- .getPageElements(locators[0], inDocument);
1802
-
1803
- if (locators.length > 1) {
1804
- for (var i = 0; i < pageElements.length; ++i) {
1805
- var locatedElements = eval_locator(locators[1], inDocument,
1806
- pageElements[i]);
1807
- if (locatedElements.length) {
1808
- locatedElement = locatedElements[0];
1809
- break;
1810
- }
1811
- }
1812
- }
1813
- else if (pageElements.length) {
1814
- locatedElement = pageElements[0];
1815
- }
1816
-
1817
- return locatedElement;
1818
- }
1819
-
1820
- BrowserBot.prototype.locateElementByUIElement.prefix = 'ui';
1821
-
1822
- // define a function used to compare the result of a close UI element
1823
- // match with the actual interacted element. If they are close enough
1824
- // according to the heuristic, consider them a match.
1825
- /**
1826
- * A heuristic function for comparing a node with a target node. Typically the
1827
- * node is specified in a UI element definition, while the target node is
1828
- * returned by the recorder as the leaf element which had some event enacted
1829
- * upon it. This particular heuristic covers the case where the anchor element
1830
- * contains other inline tags, such as "em" or "img".
1831
- *
1832
- * @param node the node being compared to the target node
1833
- * @param target the target node
1834
- * @return true if node equals target, or if node is a link
1835
- * element and target is its descendant, or if node has
1836
- * an onclick attribute and target is its descendant.
1837
- * False otherwise.
1838
- */
1839
- BrowserBot.prototype.locateElementByUIElement.is_fuzzy_match = function(node, target) {
1840
- try {
1841
- var isMatch = (
1842
- (node == target) ||
1843
- ((node.nodeName == 'A' || node.onclick) && is_ancestor(node, target))
1844
- );
1845
- return isMatch;
1846
- }
1847
- catch (e) {
1848
- return false;
1849
- }
1850
- };
1851
-
1852
- /*****************************************************************/
1853
- /* BROWSER-SPECIFIC FUNCTIONS ONLY AFTER THIS LINE */
1854
-
1855
- function MozillaBrowserBot(frame) {
1856
- BrowserBot.call(this, frame);
1857
- }
1858
- objectExtend(MozillaBrowserBot.prototype, BrowserBot.prototype);
1859
-
1860
- function KonquerorBrowserBot(frame) {
1861
- BrowserBot.call(this, frame);
1862
- }
1863
- objectExtend(KonquerorBrowserBot.prototype, BrowserBot.prototype);
1864
-
1865
- KonquerorBrowserBot.prototype.setIFrameLocation = function(iframe, location) {
1866
- // Window doesn't fire onload event when setting src to the current value,
1867
- // so we set it to blank first.
1868
- iframe.src = "about:blank";
1869
- iframe.src = location;
1870
- };
1871
-
1872
- KonquerorBrowserBot.prototype.setOpenLocation = function(win, loc) {
1873
- // Window doesn't fire onload event when setting src to the current value,
1874
- // so we just refresh in that case instead.
1875
- loc = absolutify(loc, this.baseUrl);
1876
- loc = canonicalize(loc);
1877
- var startUrl = win.location.href;
1878
- if ("about:blank" != win.location.href) {
1879
- var startLoc = parseUrl(win.location.href);
1880
- startLoc.hash = null;
1881
- var startUrl = reassembleLocation(startLoc);
1882
- }
1883
- LOG.debug("startUrl="+startUrl);
1884
- LOG.debug("win.location.href="+win.location.href);
1885
- LOG.debug("loc="+loc);
1886
- if (startUrl == loc) {
1887
- LOG.debug("opening exact same location");
1888
- this.refresh();
1889
- } else {
1890
- LOG.debug("locations differ");
1891
- win.location.href = loc;
1892
- }
1893
- // force the current polling thread to detect a page load
1894
- var marker = this.isPollingForLoad(win);
1895
- if (marker) {
1896
- delete win.location[marker];
1897
- }
1898
- };
1899
-
1900
- KonquerorBrowserBot.prototype._isSameDocument = function(originalDocument, currentDocument) {
1901
- // under Konqueror, there may be this case:
1902
- // originalDocument and currentDocument are different objects
1903
- // while their location are same.
1904
- if (originalDocument) {
1905
- return originalDocument.location == currentDocument.location
1906
- } else {
1907
- return originalDocument === currentDocument;
1908
- }
1909
- };
1910
-
1911
- function SafariBrowserBot(frame) {
1912
- BrowserBot.call(this, frame);
1913
- }
1914
- objectExtend(SafariBrowserBot.prototype, BrowserBot.prototype);
1915
-
1916
- SafariBrowserBot.prototype.setIFrameLocation = KonquerorBrowserBot.prototype.setIFrameLocation;
1917
- SafariBrowserBot.prototype.setOpenLocation = KonquerorBrowserBot.prototype.setOpenLocation;
1918
-
1919
-
1920
- function OperaBrowserBot(frame) {
1921
- BrowserBot.call(this, frame);
1922
- }
1923
- objectExtend(OperaBrowserBot.prototype, BrowserBot.prototype);
1924
- OperaBrowserBot.prototype.setIFrameLocation = function(iframe, location) {
1925
- if (iframe.src == location) {
1926
- iframe.src = location + '?reload';
1927
- } else {
1928
- iframe.src = location;
1929
- }
1930
- }
1931
-
1932
- function IEBrowserBot(frame) {
1933
- BrowserBot.call(this, frame);
1934
- }
1935
- objectExtend(IEBrowserBot.prototype, BrowserBot.prototype);
1936
-
1937
- IEBrowserBot.prototype._handleClosedSubFrame = function(testWindow, doNotModify) {
1938
- if (this.proxyInjectionMode) {
1939
- return testWindow;
1940
- }
1941
-
1942
- try {
1943
- testWindow.location.href;
1944
- this.permDenied = 0;
1945
- } catch (e) {
1946
- this.permDenied++;
1947
- }
1948
- if (this._windowClosed(testWindow) || this.permDenied > 4) {
1949
- if (this.isSubFrameSelected) {
1950
- LOG.warn("Current subframe appears to have closed; selecting top frame");
1951
- this.selectFrame("relative=top");
1952
- return this.getCurrentWindow(doNotModify);
1953
- } else {
1954
- var closedError = new SeleniumError("Current window or frame is closed!");
1955
- closedError.windowClosed = true;
1956
- throw closedError;
1957
- }
1958
- }
1959
- return testWindow;
1960
- };
1961
-
1962
- IEBrowserBot.prototype.modifyWindowToRecordPopUpDialogs = function(windowToModify, browserBot) {
1963
- BrowserBot.prototype.modifyWindowToRecordPopUpDialogs(windowToModify, browserBot);
1964
-
1965
- // we will call the previous version of this method from within our own interception
1966
- oldShowModalDialog = windowToModify.showModalDialog;
1967
-
1968
- windowToModify.showModalDialog = function(url, args, features) {
1969
- // Get relative directory to where TestRunner.html lives
1970
- // A risky assumption is that the user's TestRunner is named TestRunner.html
1971
- var doc_location = document.location.toString();
1972
- var end_of_base_ref = doc_location.indexOf('TestRunner.html');
1973
- var base_ref = doc_location.substring(0, end_of_base_ref);
1974
- var runInterval = '';
1975
-
1976
- // Only set run interval if options is defined
1977
- if (typeof(window.runOptions) != 'undefined') {
1978
- runInterval = "&runInterval=" + runOptions.runInterval;
1979
- }
1980
-
1981
- var testRunnerURL = "TestRunner.html?auto=true&singletest="
1982
- + escape(browserBot.modalDialogTest)
1983
- + "&autoURL="
1984
- + escape(url)
1985
- + runInterval;
1986
- var fullURL = base_ref + testRunnerURL;
1987
- browserBot.modalDialogTest = null;
1988
-
1989
- // If using proxy injection mode
1990
- if (this.proxyInjectionMode) {
1991
- var sessionId = runOptions.getSessionId();
1992
- if (sessionId == undefined) {
1993
- sessionId = injectedSessionId;
1994
- }
1995
- if (sessionId != undefined) {
1996
- LOG.debug("Invoking showModalDialog and injecting URL " + fullURL);
1997
- }
1998
- fullURL = url;
1999
- }
2000
- var returnValue = oldShowModalDialog(fullURL, args, features);
2001
- return returnValue;
2002
- };
2003
- };
2004
-
2005
- IEBrowserBot.prototype.modifySeparateTestWindowToDetectPageLoads = function(windowObject) {
2006
- this.pageUnloading = false;
2007
- var self = this;
2008
- var pageUnloadDetector = function() {
2009
- self.pageUnloading = true;
2010
- };
2011
- windowObject.attachEvent("onbeforeunload", pageUnloadDetector);
2012
- BrowserBot.prototype.modifySeparateTestWindowToDetectPageLoads.call(this, windowObject);
2013
- };
2014
-
2015
- IEBrowserBot.prototype.pollForLoad = function(loadFunction, windowObject, originalDocument, originalLocation, originalHref, marker) {
2016
- LOG.debug("IEBrowserBot.pollForLoad: " + marker);
2017
- if (!this.permDeniedCount[marker]) this.permDeniedCount[marker] = 0;
2018
- BrowserBot.prototype.pollForLoad.call(this, loadFunction, windowObject, originalDocument, originalLocation, originalHref, marker);
2019
- if (this.pageLoadError) {
2020
- if (this.pageUnloading) {
2021
- var self = this;
2022
- LOG.debug("pollForLoad UNLOADING (" + marker + "): caught exception while firing events on unloading page: " + this.pageLoadError.message);
2023
- this.reschedulePoller(loadFunction, windowObject, originalDocument, originalLocation, originalHref, marker);
2024
- this.pageLoadError = null;
2025
- return;
2026
- } else if (((this.pageLoadError.message == "Permission denied") || (/^Access is denied/.test(this.pageLoadError.message)))
2027
- && this.permDeniedCount[marker]++ < 8) {
2028
- if (this.permDeniedCount[marker] > 4) {
2029
- var canAccessThisWindow;
2030
- var canAccessCurrentlySelectedWindow;
2031
- try {
2032
- windowObject.location.href;
2033
- canAccessThisWindow = true;
2034
- } catch (e) {}
2035
- try {
2036
- this.getCurrentWindow(true).location.href;
2037
- canAccessCurrentlySelectedWindow = true;
2038
- } catch (e) {}
2039
- if (canAccessCurrentlySelectedWindow & !canAccessThisWindow) {
2040
- LOG.debug("pollForLoad (" + marker + ") ABORTING: " + this.pageLoadError.message + " (" + this.permDeniedCount[marker] + "), but the currently selected window is fine");
2041
- // returning without rescheduling
2042
- this.pageLoadError = null;
2043
- return;
2044
- }
2045
- }
2046
-
2047
- var self = this;
2048
- LOG.debug("pollForLoad (" + marker + "): " + this.pageLoadError.message + " (" + this.permDeniedCount[marker] + "), waiting to see if it goes away");
2049
- this.reschedulePoller(loadFunction, windowObject, originalDocument, originalLocation, originalHref, marker);
2050
- this.pageLoadError = null;
2051
- return;
2052
- }
2053
- //handy for debugging!
2054
- //throw this.pageLoadError;
2055
- }
2056
- };
2057
-
2058
- IEBrowserBot.prototype._windowClosed = function(win) {
2059
- try {
2060
- var c = win.closed;
2061
- // frame windows claim to be non-closed when their parents are closed
2062
- // but you can't access their document objects in that case
2063
- if (!c) {
2064
- try {
2065
- win.document;
2066
- } catch (de) {
2067
- if (de.message == "Permission denied") {
2068
- // the window is probably unloading, which means it's probably not closed yet
2069
- return false;
2070
- }
2071
- else if (/^Access is denied/.test(de.message)) {
2072
- // rare variation on "Permission denied"?
2073
- LOG.debug("IEBrowserBot.windowClosed: got " + de.message + " (this.pageUnloading=" + this.pageUnloading + "); assuming window is unloading, probably not closed yet");
2074
- return false;
2075
- } else {
2076
- // this is probably one of those frame window situations
2077
- LOG.debug("IEBrowserBot.windowClosed: couldn't read win.document, assume closed: " + de.message + " (this.pageUnloading=" + this.pageUnloading + ")");
2078
- return true;
2079
- }
2080
- }
2081
- }
2082
- if (c == null) {
2083
- LOG.debug("IEBrowserBot.windowClosed: win.closed was null, assuming closed");
2084
- return true;
2085
- }
2086
- return c;
2087
- } catch (e) {
2088
- LOG.debug("IEBrowserBot._windowClosed: Got an exception trying to read win.closed; we'll have to take a guess!");
2089
-
2090
- if (browserVersion.isHTA) {
2091
- if (e.message == "Permission denied") {
2092
- // the window is probably unloading, which means it's not closed yet
2093
- return false;
2094
- } else {
2095
- // there's a good chance that we've lost contact with the window object if it is closed
2096
- return true;
2097
- }
2098
- } else {
2099
- // the window is probably unloading, which means it's not closed yet
2100
- return false;
2101
- }
2102
- }
2103
- };
2104
-
2105
- /**
2106
- * In IE, getElementById() also searches by name - this is an optimisation for IE.
2107
- */
2108
- IEBrowserBot.prototype.locateElementByIdentifer = function(identifier, inDocument, inWindow) {
2109
- return inDocument.getElementById(identifier);
2110
- };
2111
-
2112
- SafariBrowserBot.prototype.modifyWindowToRecordPopUpDialogs = function(windowToModify, browserBot) {
2113
- BrowserBot.prototype.modifyWindowToRecordPopUpDialogs(windowToModify, browserBot);
2114
-
2115
- var originalOpen = windowToModify.open;
2116
- /*
2117
- * Safari seems to be broken, so that when we manually trigger the onclick method
2118
- * of a button/href, any window.open calls aren't resolved relative to the app location.
2119
- * So here we replace the open() method with one that does resolve the url correctly.
2120
- */
2121
- windowToModify.open = function(url, windowName, windowFeatures, replaceFlag) {
2122
-
2123
- if (url.startsWith("http://") || url.startsWith("https://") || url.startsWith("/")) {
2124
- return originalOpen(url, windowName, windowFeatures, replaceFlag);
2125
- }
2126
-
2127
- // Reduce the current path to the directory
2128
- var currentPath = windowToModify.location.pathname || "/";
2129
- currentPath = currentPath.replace(/\/[^\/]*$/, "/");
2130
-
2131
- // Remove any leading "./" from the new url.
2132
- url = url.replace(/^\.\//, "");
2133
-
2134
- newUrl = currentPath + url;
2135
-
2136
- var openedWindow = originalOpen(newUrl, windowName, windowFeatures, replaceFlag);
2137
- LOG.debug("window.open call intercepted; window ID (which you can use with selectWindow()) is \"" + windowName + "\"");
2138
- if (windowName!=null) {
2139
- openedWindow["seleniumWindowName"] = windowName;
2140
- }
2141
- return openedWindow;
2142
- };
2143
- };
2144
-
2145
- MozillaBrowserBot.prototype._fireEventOnElement = function(eventType, element, clientX, clientY) {
2146
- var win = this.getCurrentWindow();
2147
- triggerEvent(element, 'focus', false);
2148
-
2149
- // Add an event listener that detects if the default action has been prevented.
2150
- // (This is caused by a javascript onclick handler returning false)
2151
- // we capture the whole event, rather than the getPreventDefault() state at the time,
2152
- // because we need to let the entire event bubbling and capturing to go through
2153
- // before making a decision on whether we should force the href
2154
- var savedEvent = null;
2155
-
2156
- element.addEventListener(eventType, function(evt) {
2157
- savedEvent = evt;
2158
- }, false);
2159
-
2160
- this._modifyElementTarget(element);
2161
-
2162
- // Trigger the event.
2163
- this.browserbot.triggerMouseEvent(element, eventType, true, clientX, clientY);
2164
-
2165
- if (this._windowClosed(win)) {
2166
- return;
2167
- }
2168
-
2169
- // Perform the link action if preventDefault was set.
2170
- // In chrome URL, the link action is already executed by triggerMouseEvent.
2171
- if (!browserVersion.isChrome && savedEvent != null && !savedEvent.getPreventDefault()) {
2172
- var targetWindow = this.browserbot._getTargetWindow(element);
2173
- if (element.href) {
2174
- targetWindow.location.href = element.href;
2175
- } else {
2176
- this.browserbot._handleClickingImagesInsideLinks(targetWindow, element);
2177
- }
2178
- }
2179
-
2180
- };
2181
-
2182
-
2183
- OperaBrowserBot.prototype._fireEventOnElement = function(eventType, element, clientX, clientY) {
2184
- var win = this.getCurrentWindow();
2185
- triggerEvent(element, 'focus', false);
2186
-
2187
- this._modifyElementTarget(element);
2188
-
2189
- // Trigger the click event.
2190
- this.browserbot.triggerMouseEvent(element, eventType, true, clientX, clientY);
2191
-
2192
- if (this._windowClosed(win)) {
2193
- return;
2194
- }
2195
-
2196
- };
2197
-
2198
-
2199
- KonquerorBrowserBot.prototype._fireEventOnElement = function(eventType, element, clientX, clientY) {
2200
- var win = this.getCurrentWindow();
2201
- triggerEvent(element, 'focus', false);
2202
-
2203
- this._modifyElementTarget(element);
2204
-
2205
- if (element[eventType]) {
2206
- element[eventType]();
2207
- }
2208
- else {
2209
- this.browserbot.triggerMouseEvent(element, eventType, true, clientX, clientY);
2210
- }
2211
-
2212
- if (this._windowClosed(win)) {
2213
- return;
2214
- }
2215
-
2216
- };
2217
-
2218
- SafariBrowserBot.prototype._fireEventOnElement = function(eventType, element, clientX, clientY) {
2219
- triggerEvent(element, 'focus', false);
2220
- var wasChecked = element.checked;
2221
-
2222
- this._modifyElementTarget(element);
2223
-
2224
- // For form element it is simple.
2225
- if (element[eventType]) {
2226
- element[eventType]();
2227
- }
2228
- // For links and other elements, event emulation is required.
2229
- else {
2230
- var targetWindow = this.browserbot._getTargetWindow(element);
2231
- // todo: deal with anchors?
2232
- this.browserbot.triggerMouseEvent(element, eventType, true, clientX, clientY);
2233
-
2234
- }
2235
-
2236
- };
2237
-
2238
- SafariBrowserBot.prototype.refresh = function() {
2239
- var win = this.getCurrentWindow();
2240
- if (win.location.hash) {
2241
- // DGF Safari refuses to refresh when there's a hash symbol in the URL
2242
- win.location.hash = "";
2243
- var actuallyReload = function() {
2244
- win.location.reload(true);
2245
- }
2246
- window.setTimeout(actuallyReload, 1);
2247
- } else {
2248
- win.location.reload(true);
2249
- }
2250
- };
2251
-
2252
- IEBrowserBot.prototype._fireEventOnElement = function(eventType, element, clientX, clientY) {
2253
- var win = this.getCurrentWindow();
2254
- triggerEvent(element, 'focus', false);
2255
-
2256
- var wasChecked = element.checked;
2257
-
2258
- // Set a flag that records if the page will unload - this isn't always accurate, because
2259
- // <a href="javascript:alert('foo'):"> triggers the onbeforeunload event, even thought the page won't unload
2260
- var pageUnloading = false;
2261
- var pageUnloadDetector = function() {
2262
- pageUnloading = true;
2263
- };
2264
- win.attachEvent("onbeforeunload", pageUnloadDetector);
2265
- this._modifyElementTarget(element);
2266
- if (element[eventType]) {
2267
- element[eventType]();
2268
- }
2269
- else {
2270
- this.browserbot.triggerMouseEvent(element, eventType, true, clientX, clientY);
2271
- }
2272
-
2273
-
2274
- // If the page is going to unload - still attempt to fire any subsequent events.
2275
- // However, we can't guarantee that the page won't unload half way through, so we need to handle exceptions.
2276
- try {
2277
- win.detachEvent("onbeforeunload", pageUnloadDetector);
2278
-
2279
- if (this._windowClosed(win)) {
2280
- return;
2281
- }
2282
-
2283
- // Onchange event is not triggered automatically in IE.
2284
- if (isDefined(element.checked) && wasChecked != element.checked) {
2285
- triggerEvent(element, 'change', true);
2286
- }
2287
-
2288
- }
2289
- catch (e) {
2290
- // If the page is unloading, we may get a "Permission denied" or "Unspecified error".
2291
- // Just ignore it, because the document may have unloaded.
2292
- if (pageUnloading) {
2293
- LOG.logHook = function() {
2294
- };
2295
- LOG.warn("Caught exception when firing events on unloading page: " + e.message);
2296
- return;
2297
- }
2298
- throw e;
2299
- }
2300
- };