Class: Axe::API::Run

Inherits:
Object
  • Object
show all
Extended by:
ChainMail::Chainable, Forwardable
Defined in:
lib/axe/api/run.rb

Constant Summary collapse

JS_NAME =
"run"
METHOD_NAME =
"#{Core::JS_NAME}.#{JS_NAME}"

Instance Method Summary collapse

Methods included from ChainMail::Chainable

chainable

Constructor Details

#initializeRun

Returns a new instance of Run.



24
25
26
27
# File 'lib/axe/api/run.rb', line 24

def initialize
  @context = Context.new
  @options = Options.new
end

Instance Method Details

#analyze_post_43x(page, lib) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/axe/api/run.rb', line 34

def analyze_post_43x(page, lib)
  user_page_load = (get_selenium page).manage.timeouts.page_load
  (get_selenium page).manage.timeouts.page_load = 1
  begin
    @original_window = window_handle page
    partial_results = run_partial_recursive(page, @context, lib, true)
    throw partial_results if partial_results.respond_to?("key?") and partial_results.key?("errorMessage")
    results = within_about_blank_context(page) { |page|
      partial_res_str = partial_results.to_json
      size_limit = 10_000_000
      while not partial_res_str.empty? do
        chunk_size = size_limit
        chunk_size = partial_res_str.length if chunk_size > partial_res_str.length
        chunk = partial_res_str[0..chunk_size-1]
        partial_res_str = partial_res_str[chunk_size..-1]
        store_chunk page, chunk
      end
  
      Common::Loader.new(page, lib).load_top_level Axe::Configuration.instance.jslib
      begin
        axe_finish_run page
      rescue
        raise StandardError.new "axe.finishRun failed. Please check out https://github.com/dequelabs/axe-core-gems/blob/develop/error-handling.md"
      end
  
    }
  ensure
    (get_selenium page).manage.timeouts.page_load = user_page_load
  end
  Audit.new to_js, Results.new(results)
end

#call(page) ⇒ Object



29
30
31
32
# File 'lib/axe/api/run.rb', line 29

def call(page)
  results = audit page
  Audit.new to_js, Results.new(results)
end