axe-core-api 4.2.0.pre.6beb600 → 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: 93fdbc2f4d06b670e6a36caa7489196b44f3b2a09e939ec16b541ae7c45c47d9
4
- data.tar.gz: 7dcc16ad9bd768830d7a5a227ba72af18e7ec67d0612397cd8cd391547049c0d
3
+ metadata.gz: 63ae938fa9b0c8bdf71e552a7ceb3c0d4ee92618725ed44c0092786f452212fc
4
+ data.tar.gz: 2210a9a032d3bab1a7c8791499725025fb108ca23339b02560b0286596c80ee3
5
5
  SHA512:
6
- metadata.gz: e359e128c431a0345906f64bdf29444f35f5128cb67c728cf4af58bbbe55e88b6d600b4766800e886e16d225f6746f3e0c31f911e9fd21e895f9de740356e13b
7
- data.tar.gz: daa3fcd4f2c12b81e560e19771151ae3010977153f74423b31b16e5567dac224ce89825ed53da5556ea56bf5991a8db4120f144a333e983b29870ba6ea4fd6d9
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,7 +14,7 @@ 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
@@ -27,11 +27,15 @@ module Axe
27
27
 
28
28
  private
29
29
 
30
+ def use_run_partial
31
+ has_run_partial? and not Axe::Configuration.instance.legacy_mode
32
+ end
33
+
30
34
  def load_axe_core(source)
31
35
  return if already_loaded?
32
36
  loader = Common::Loader.new(@page, self)
33
37
  loader.load_top_level source
34
- return if has_run_partial?
38
+ return if use_run_partial
35
39
 
36
40
  loader.call source
37
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.6beb600
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-07 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