axe-core-api 4.5.1 → 4.7.0

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: 855680bb403cceb1eed265773f3697b92b784af839d4c35b379da6d94d1ad730
4
- data.tar.gz: 8a22df8e11835506cc51e2c6e8b257b523cffd140009f55242e494a654c6324a
3
+ metadata.gz: 175a4db67c7f727a73321be7d3e31e7dbf7002b1ebe134a21b072a0b2c14fd27
4
+ data.tar.gz: 8678aa9c23634486b2c02fb91537b21e60610b84e45672d881bc3db1d5bc4402
5
5
  SHA512:
6
- metadata.gz: 636c56da57308e948dca2ebba6db5435329d40353ad8d7e59e4e0630df83992117640b0c2b876250644c6b227943d9d9daf62b91ad0d0af5389457d2c907b33c
7
- data.tar.gz: '0995cfc1871a631cea5459c249dda586be7038349cd866d715f30030b0640a33648b4c59f7dab5b790a960af4217ecf7177fc0e840e437327cd988ab7c5abf52'
6
+ metadata.gz: d244ea40f73c3fab3cab9d6919b2017c7f7a4c6a934737ce5c2f89a48a5c5bb31c408a769418b2f39bd2a40824727f9d3c2b9a8e9e02f9992e642ff9b0b04a7a
7
+ data.tar.gz: c4695b7c8f54e16a55cd22f792bd55dbfab3422277e5ce8a3a836deea67c7240ad9a31dd118cd496e7c098bfaee430534b68e7123c27e4c74c623c142c5ff44a
@@ -9,11 +9,11 @@ module Axe
9
9
  end
10
10
 
11
11
  def within(*selectors)
12
- @inclusion.concat selectors.map { |s| Array(Selector.new s) }
12
+ @inclusion.concat selectors.map { |s| Selector::normalize s }
13
13
  end
14
14
 
15
15
  def excluding(*selectors)
16
- @exclusion.concat selectors.map { |s| Array(Selector.new s) }
16
+ @exclusion.concat selectors.map { |s| Selector::normalize s }
17
17
  end
18
18
 
19
19
  def to_h
@@ -40,7 +40,7 @@ module Axe
40
40
  end
41
41
 
42
42
  def timestamp=(ts)
43
- timestamp = ts
43
+ @timestamp = ts
44
44
  end
45
45
 
46
46
 
data/lib/axe/api/run.rb CHANGED
@@ -36,9 +36,19 @@ module Axe
36
36
  partial_results = run_partial_recursive(page, @context, lib, true)
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
+ partial_res_str = partial_results.to_json
40
+ size_limit = 20_000_000
41
+ while not partial_res_str.empty? do
42
+ chunk_size = size_limit
43
+ chunk_size = partial_res_str.length if chunk_size > partial_res_str.length
44
+ chunk = partial_res_str[0..chunk_size-1]
45
+ partial_res_str = partial_res_str[chunk_size..-1]
46
+ store_chunk page, chunk
47
+ end
48
+
39
49
  Common::Loader.new(page, lib).load_top_level Axe::Configuration.instance.jslib
40
50
  begin
41
- axe_finish_run page, partial_results
51
+ axe_finish_run page
42
52
  rescue
43
53
  raise StandardError.new "axe.finishRun failed. Please check out https://github.com/dequelabs/axe-core-gems/blob/develop/error-handling.md"
44
54
  end
@@ -138,12 +148,20 @@ module Axe
138
148
  return results
139
149
  end
140
150
 
141
- def axe_finish_run(page, partial_results)
151
+ def store_chunk(page, chunk)
152
+ script = <<-JS
153
+ const chunk = arguments[0];
154
+ window.partialResults ??= '';
155
+ window.partialResults += chunk;
156
+ JS
157
+ page.execute_script_fixed script, chunk
158
+ end
159
+ def axe_finish_run(page)
142
160
  script = <<-JS
143
- const partialResults = arguments[0];
161
+ const partialResults = JSON.parse(window.partialResults || '[]');
144
162
  return axe.finishRun(partialResults);
145
163
  JS
146
- page.execute_script_fixed script, partial_results
164
+ page.execute_script_fixed script
147
165
  end
148
166
 
149
167
  def axe_shadow_select(page, frame_selector)
@@ -1,6 +1,18 @@
1
1
  module Axe
2
2
  module API
3
3
  class Selector
4
+ def self.normalize(s)
5
+ if s.is_a? Hash
6
+ if s.key? :iframe and s.key? :selector
7
+ Array(Selector.new s)
8
+ else
9
+ s
10
+ end
11
+ else
12
+ Array(Selector.new s)
13
+ end
14
+ end
15
+
4
16
  def initialize(s)
5
17
  @selector = case s
6
18
  when Array then s