Skip to content

Commit

Permalink
Merge pull request #293 from dequelabs/release-1681144013
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-siek authored Apr 11, 2023
2 parents f321596 + fa465d1 commit 35aee8d
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 12 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [4.6.1](https://github.com/dequelabs/axe-core-gems/compare/v4.6.0...v4.6.1) (2023-04-10)


### Bug Fixes

* **api:** properly set timestamp ([#292](https://github.com/dequelabs/axe-core-gems/issues/292)) ([47f4589](https://github.com/dequelabs/axe-core-gems/commit/47f458921615995b4f27dab581438498c5623348))
* work with extremely large results ([#291](https://github.com/dequelabs/axe-core-gems/issues/291)) ([761c828](https://github.com/dequelabs/axe-core-gems/commit/761c828cd0c61ad7fdb524d422ccb9c399571bea))

## [4.6.0](https://github.com/dequelabs/axe-core-gems/compare/v4.5.1...v4.6.0) (2023-01-19)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "axe-core-gems",
"version": "4.6.0",
"version": "4.6.1",
"license": "MPL-2.0",
"private": true,
"repository": {
Expand Down
21 changes: 16 additions & 5 deletions packages/axe-core-api/e2e/selenium/spec/api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
require "axe/core"
require "axe/api/run"

options = Selenium::WebDriver::Firefox::Options.new
options.add_argument('--headless')
$driver = Selenium::WebDriver.for :firefox, options: options
options = Selenium::WebDriver::Chrome::Options.new
# options.add_argument('--headless')
$driver = Selenium::WebDriver.for :chrome, options: options

Run = Axe::API::Run

Expand All @@ -20,6 +20,7 @@ def run_axe(run = Run.new)
$axe_post_43x = Axe::Configuration.instance.jslib
$crasher_js = File.read File.join($fixture_root, "axe-crasher.js")
$force_legacy_js = File.read File.join($fixture_root, "axe-force-legacy.js")
$large_partial_js = File.read File.join($fixture_root, "axe-large-partial.js")

def fixture(filename)
"http://localhost:8000" + filename
Expand Down Expand Up @@ -56,7 +57,7 @@ def recursive_compact(thing)
elsif thing.is_a?(Hash)
thing.each_with_object({}) do |(k,v), h|
v = recursive_compact(v)
h[k] = v unless [nil, [], {}].include?(v)
h[k] = v unless ([nil, [], {}].include?(v) or k == :html)
end
else
thing
Expand Down Expand Up @@ -92,7 +93,7 @@ def recursive_compact(thing)
end

describe "frame tests" do
it "injects into nested iframes" do
it "injects into nested iframes", :fo => true do
$driver.get fixture "/nested-iframes.html"
res = run_axe
expect(res.results.violations).not_to be_empty
Expand Down Expand Up @@ -236,6 +237,7 @@ def recursive_compact(thing)
res = run_axe
expect(res.results.testEngine["name"]).not_to be_nil
expect(res.results.testEngine["version"]).not_to be_nil
expect(res.results.timestamp).not_to be_nil

expect(res.results.testEnvironment["orientationAngle"]).not_to be_nil
expect(res.results.testEnvironment["orientationType"]).not_to be_nil
Expand Down Expand Up @@ -268,6 +270,15 @@ def recursive_compact(thing)
expect { run_axe }.to raise_error /finishRun failed/
}
end

it "works with large results", :nt => true do
$driver.get fixture "/index.html"
res = with_js($axe_post_43x + $large_partial_js) { run_axe }


expect(res.results.passes.length).to eq 1
expect(res.results.passes[0].id).to eq :'duplicate-id'
end
end


Expand Down
2 changes: 1 addition & 1 deletion packages/axe-core-api/lib/axe/api/results.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def to_h
end

def timestamp=(ts)
timestamp = ts
@timestamp = ts
end


Expand Down
26 changes: 22 additions & 4 deletions packages/axe-core-api/lib/axe/api/run.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,19 @@ def analyze_post_43x(page, lib)
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 = 20_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, partial_results
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
Expand Down Expand Up @@ -138,12 +148,20 @@ def run_partial_recursive(page, context, lib, top_level = false)
return results
end

def axe_finish_run(page, partial_results)
def store_chunk(page, chunk)
script = <<-JS
const chunk = arguments[0];
window.partialResults ??= '';
window.partialResults += chunk;
JS
page.execute_script_fixed script, chunk
end
def axe_finish_run(page)
script = <<-JS
const partialResults = arguments[0];
const partialResults = JSON.parse(window.partialResults || '[]');
return axe.finishRun(partialResults);
JS
page.execute_script_fixed script, partial_results
page.execute_script_fixed script
end

def axe_shadow_select(page, frame_selector)
Expand Down
2 changes: 1 addition & 1 deletion version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# this version is used by all the packages

module AxeCoreGems
VERSION = "4.6.0"
VERSION = "4.6.1"
end

0 comments on commit 35aee8d

Please sign in to comment.