axe-core-api 4.2.0.pre.edcd659 → 4.2.0.pre.4575cbd

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e3964599a863f53179b8b189e6fa60e4d220240fe362c7b3aa6263bb4686b366
4
- data.tar.gz: '0558215cb31d486cd8383118e63c0a1c29de40c4aabdbc5c29f8c791aa86037e'
3
+ metadata.gz: 63ae938fa9b0c8bdf71e552a7ceb3c0d4ee92618725ed44c0092786f452212fc
4
+ data.tar.gz: 2210a9a032d3bab1a7c8791499725025fb108ca23339b02560b0286596c80ee3
5
5
  SHA512:
6
- metadata.gz: 06de18b3a8137ca0f65cec3e9c9c72637854ce5339df2ce2569460bf9cb50c603e703631333204db45ff0b50266b7dcc27ed1812627cd9120d1906c1bf040993
7
- data.tar.gz: 47f7aeb22a09792f63b4be4f2429be0ef0f03a8c06aaed5e33cd94b80c9d25822841ca9c8d5bc0963e1e5d1c21b7c0ccf027e14bbcac7c0485aedd78656d5718
6
+ metadata.gz: 4e94415243f47672e0c32803e9364be14e54c2e3337986d0d4565ec657a7766067c990459df8023f0ba50f3d163d8fd25f453091e544e6688f0602fa79bda735
7
+ data.tar.gz: 54b8e2d0a840c6d43426a28414d42dde39b5444083508c0f44a62e84b6b6a0bf9a665539091d7c126be2db303af2d5fb8bb0823a734265f7f4ada752b1739fae
data/lib/axe/api/run.rb CHANGED
@@ -37,7 +37,11 @@ module Axe
37
37
  throw partial_results if partial_results.respond_to?("key?") and partial_results.key?("errorMessage")
38
38
  results = within_about_blank_context(page) { |page|
39
39
  Common::Loader.new(page, lib).load_top_level Axe::Configuration.instance.jslib
40
- axe_finish_run page, partial_results
40
+ begin
41
+ axe_finish_run page, partial_results
42
+ rescue
43
+ raise StandardError.new "axe.finishRun failed. Please check out https://github.com/dequelabs/axe-core-gems/error-handling.md`"
44
+ end
41
45
  }
42
46
  Audit.new to_js, Results.new(results)
43
47
  end
@@ -67,8 +71,16 @@ module Axe
67
71
  def within_about_blank_context(page)
68
72
  driver = get_selenium page
69
73
 
70
- driver.execute_script("window.open('about:blank'), '_blank'")
71
- driver.switch_to.window page.window_handles[-1]
74
+ num_handles = page.window_handles.length
75
+ begin
76
+ driver.execute_script("window.open('about:blank'), '_blank'")
77
+ if num_handles == page.window_handles.length
78
+ raise StandardError.new "Could not open new window. Please make sure that you have popup blockers disabled."
79
+ end
80
+ driver.switch_to.window page.window_handles[-1]
81
+ rescue
82
+ raise StandardError.new "switchToWindow failed. Are you using updated browser drivers?"
83
+ end
72
84
  driver.get "about:blank"
73
85
 
74
86
  ret = yield page
@@ -14,7 +14,8 @@ module Axe
14
14
  attr_writer :jslib
15
15
  attr_accessor :page,
16
16
  :jslib_path,
17
- :skip_iframes
17
+ :skip_iframes,
18
+ :legacy_mode
18
19
  def_delegators ::WebDriverScriptAdapter,
19
20
  :async_results_identifier,
20
21
  :async_results_identifier=,
data/lib/axe/core.rb CHANGED
@@ -14,20 +14,28 @@ module Axe
14
14
  end
15
15
 
16
16
  def call(callable)
17
- if has_run_partial?
17
+ if use_run_partial
18
18
  callable.analyze_post_43x @page, self
19
19
  else
20
20
  callable.call @page
21
21
  end
22
22
  end
23
23
 
24
+ def call_verbatim(callable)
25
+ callable.call @page
26
+ end
27
+
24
28
  private
25
29
 
30
+ def use_run_partial
31
+ has_run_partial? and not Axe::Configuration.instance.legacy_mode
32
+ end
33
+
26
34
  def load_axe_core(source)
27
35
  return if already_loaded?
28
36
  loader = Common::Loader.new(@page, self)
29
37
  loader.load_top_level source
30
- return if has_run_partial?
38
+ return if use_run_partial
31
39
 
32
40
  loader.call source
33
41
  end
data/lib/loader.rb CHANGED
@@ -17,13 +17,19 @@ module Common
17
17
 
18
18
  def call(source, is_top_level = true)
19
19
  @page.execute_script source unless (@loaded_top_level and is_top_level)
20
- @page.execute_script "axe.configure({ allowedOrigins: ['<unsafe_all_origins>'] });"
20
+ set_allowed_origins
21
21
  Common::Hooks.run_after_load @lib
22
22
  load_into_iframes(source) unless Axe::Configuration.instance.skip_iframes
23
23
  end
24
24
 
25
25
  private
26
26
 
27
+ def set_allowed_origins
28
+ allowed_origins = "<unsafe_all_origins>"
29
+ allowed_origins = "<same_origin>" if Axe::Configuration.instance.legacy_mode
30
+ @page.execute_script "axe.configure({ allowedOrigins: ['#{allowed_origins}'] });"
31
+ end
32
+
27
33
  def load_into_iframes(source)
28
34
  @page.find_frames.each do |iframe|
29
35
  @page.within_frame(iframe) { call source, false }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: axe-core-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.0.pre.edcd659
4
+ version: 4.2.0.pre.4575cbd
5
5
  platform: ruby
6
6
  authors:
7
7
  - Deque Systems
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-02 00:00:00.000000000 Z
11
+ date: 2021-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dumb_delegator