Sha256: 8d1b2c27aef4b61607314dfab6044e7aea9a780918ca2e0c2cc87fe35c182ea4

Contents?: true

Size: 1.1 KB

Versions: 98

Compression:

Stored size: 1.1 KB

Contents

require_relative "./axe/configuration"
require_relative "./axe/core"
require_relative "./hooks"

module Common
  class Loader
    def initialize(page, lib)
      @page = page
      @lib = lib
      @loaded_top_level = false
    end

    def load_top_level(source)
      @page.execute_script source
      @loaded_top_level = true
      Common::Hooks.run_after_load @lib
    end

    def call(source, is_top_level = true)
      @page.execute_script source unless (@loaded_top_level and is_top_level)
      set_allowed_origins
      Common::Hooks.run_after_load @lib
      load_into_iframes(source) unless Axe::Configuration.instance.skip_iframes
    end

    private

    def set_allowed_origins
      allowed_origins = "<same_origin>"
      allowed_origins = "<unsafe_all_origins>" if !Axe::Configuration.instance.legacy_mode && !Axe::Core::has_run_partial?(@page)
      @page.execute_script "axe.configure({ allowedOrigins: ['#{allowed_origins}'] });"
    end

    def load_into_iframes(source)
      @page.find_frames.each do |iframe|
        @page.within_frame(iframe) { call source, false }
      end
    end
  end
end

Version data entries

98 entries across 98 versions & 1 rubygems

Version Path
axe-core-api-4.10.1.pre.5294583 lib/loader.rb
axe-core-api-4.10.2 lib/loader.rb
axe-core-api-4.10.2.pre.2cca230 lib/loader.rb
axe-core-api-4.10.1.pre.46a0052 lib/loader.rb
axe-core-api-4.10.1.pre.7e72b19 lib/loader.rb
axe-core-api-4.10.1.pre.5e15f96 lib/loader.rb
axe-core-api-4.10.2.pre.5bd4e5c lib/loader.rb
axe-core-api-4.10.1.pre.7bf959f lib/loader.rb
axe-core-api-4.10.1 lib/loader.rb
axe-core-api-4.10.0.pre.53569f6 lib/loader.rb
axe-core-api-4.10.1.pre.7a3723a lib/loader.rb
axe-core-api-4.10.0.pre.d102edb lib/loader.rb
axe-core-api-4.9.1.pre.7a03090 lib/loader.rb
axe-core-api-4.9.1.pre.1a5838a lib/loader.rb
axe-core-api-4.10.0 lib/loader.rb
axe-core-api-4.10.0.pre.5d7eac5 lib/loader.rb
axe-core-api-4.9.1.pre.f16172e lib/loader.rb
axe-core-api-4.9.1.pre.09e659e lib/loader.rb
axe-core-api-4.9.1.pre.a80eeee lib/loader.rb
axe-core-api-4.9.0.pre.a02013a lib/loader.rb