diff --git a/.circleci/config.yml b/.circleci/config.yml index a83d5c73..ca99bf54 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -74,7 +74,9 @@ workflows: - dependencies_npm filters: branches: - only: develop + only: + - develop + - release - release: context: html-tools requires: diff --git a/.github/dependabot.yml b/.github/dependabot.yml index c9b6a5a0..598effd4 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -48,4 +48,4 @@ updates: maven-low-risk: update-types: - "minor" - - "patch" + - "patch" \ No newline at end of file diff --git a/.github/scripts/prepare_release.sh b/.github/scripts/prepare_release.sh old mode 100644 new mode 100755 diff --git a/.github/workflows/auto-patch-release.yml b/.github/workflows/auto-patch-release.yml deleted file mode 100644 index 2fee1c93..00000000 --- a/.github/workflows/auto-patch-release.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Automatically create patch release every 2 weeks -on: - workflow_dispatch: -jobs: - create_patch_release: - name: Create release - runs-on: ubuntu-latest - steps: - - name: Determine if we skip cancel checks - id: skip-checks - shell: bash - # Skip checks if we are not a scheduled run - run: echo value=$(test ${{ github.event_name }} != schedule && echo true || echo false) >> "$GITHUB_OUTPUT" - - - - name: Create release - uses: dequelabs/axe-api-team-public/.github/actions/auto-patch-release-v1@main - with: - token: ${{ secrets.GITHUB_TOKEN }} - project_token: ${{ secrets.GH_PROJECT_TOKEN }} - skip_checks: ${{ steps.skip-checks.outputs.value }} - slack_webhook: ${{ secrets.SLACK_WEBHOOK }} - odd_release: 'true' - release-command: bash .github/scripts/prepare_release.sh - release-branch: master - default-branch: develop diff --git a/.github/workflows/create-release-candidate.yml b/.github/workflows/create-release-candidate.yml new file mode 100644 index 00000000..6321f034 --- /dev/null +++ b/.github/workflows/create-release-candidate.yml @@ -0,0 +1,24 @@ +name: Create release candidate + +on: + workflow_dispatch: + inputs: + version-locked: + type: boolean + description: Prevent this action from creating a minor or major release + default: true + +jobs: + create-release-candidate: + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - uses: dequelabs/axe-api-team-public/.github/actions/create-release-candidate-v1@main + with: + token: ${{ secrets.GITHUB_TOKEN }} + base: "master" + head: "develop" + release-script-path: "./.github/scripts/prepare_release.sh" + version-locked: ${{ inputs.version-locked }} + env: + GH_TOKEN: ${{ secrets.GH_PROJECT_TOKEN }} diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml deleted file mode 100644 index da77e23a..00000000 --- a/.github/workflows/create-release.yml +++ /dev/null @@ -1,51 +0,0 @@ -name: Create release candidate - -on: - workflow_dispatch: - inputs: - releaseLevel: - description: "Release level: major, minor, or patch." - required: true - default: "patch" - -jobs: - create_release: - name: Create release - runs-on: ubuntu-latest - steps: - - name: Checkout repo - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Cache node_modules - uses: actions/cache@v3 - with: - path: ./node_modules - key: npm-cache-${{ runner.os }}-${{ hashFiles('./package-lock.json') }} - - uses: actions/setup-node@v3 - with: - node-version: 16 - - run: npm ci - - name: Configure git - run: | - git config user.name "API Team CI User" - git config user.email "aciattestteamci@deque.com" - - id: release - name: Release - run: | - npx standard-version --release-as="${{ github.event.inputs.releaseLevel }}" - Version=$(jq -r .version package.json) - echo "::set-output name=Version::$Version" - - name: Create pull request - uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38 # tag=v5 - with: - token: ${{ secrets.GITHUB_TOKEN }} - branch: release - branch-suffix: timestamp - title: "chore: release v${{ steps.release.outputs.Version }}" - # If there are any changes not already committed, they will be added to - # a commit with this as the message. - # If there are no changes no commit will be created. - commit-message: "chore: applying release changes" - # Our default branch is `develop` but we want to create a PR into `master` - base: master diff --git a/.github/workflows/semantic-pr-footer.yml b/.github/workflows/semantic-pr-footer.yml new file mode 100644 index 00000000..d5e35af0 --- /dev/null +++ b/.github/workflows/semantic-pr-footer.yml @@ -0,0 +1,16 @@ +name: Semantic PR footer + +on: + pull_request: + types: + - opened + - reopened + - edited + - synchronize + +jobs: + semantic-pr-footer: + runs-on: ubuntu-latest + timeout-minutes: 1 + steps: + - uses: dequelabs/axe-api-team-public/.github/actions/semantic-pr-footer-v1@main diff --git a/.github/workflows/semantic-pr-title.yml b/.github/workflows/semantic-pr-title.yml index 181cd239..99eeeaf9 100644 --- a/.github/workflows/semantic-pr-title.yml +++ b/.github/workflows/semantic-pr-title.yml @@ -11,5 +11,6 @@ on: jobs: semantic-pr-title: runs-on: ubuntu-latest + timeout-minutes: 1 steps: - uses: dequelabs/semantic-pr-title@v1 diff --git a/.github/workflows/sync-master-develop.yml b/.github/workflows/sync-master-develop.yml index 31038394..938ff994 100644 --- a/.github/workflows/sync-master-develop.yml +++ b/.github/workflows/sync-master-develop.yml @@ -1,12 +1,15 @@ name: Sync master/develop branches + on: pull_request: - types: [closed] branches: master + types: closed + jobs: create_sync_pull_request: + if: github.event.pull_request.merged == true runs-on: ubuntu-latest - if: github.event.pull_request.merged == 'true' + timeout-minutes: 1 steps: - uses: dequelabs/action-sync-branches@v1 with: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d4d39c29..082ee5a1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,17 +1,23 @@ name: Tests -on: - push: - branches: - - "**" # all branches - - "!master" # except master - - "!develop" # except develop +on: push jobs: build: runs-on: ubuntu-latest + strategy: + matrix: + java: [8, 11, 17] + timeout-minutes: 5 steps: - uses: actions/checkout@v4 + + - name: Set up JDK ${{ matrix.java }} + uses: actions/setup-java@v4 + with: + java-version: ${{ matrix.java }} + distribution: "temurin" + - name: Cache npm dependencies uses: actions/cache@v3 id: npm-cache @@ -25,29 +31,27 @@ jobs: id: maven-cache with: path: ~/.m2/repository - key: maven-cache-v1-${{ runner.os }}-${{ hashFiles('**/pom.xml') }} + key: maven-cache-v1-${{ runner.os }}-${{ hashFiles('**/pom.xml') }}-${{ matrix.java }} restore-keys: | - maven-cache-v1-${{ runner.os }}- - - name: Set up JDK 8 - uses: actions/setup-java@v3 - with: - java-version: "8" - distribution: "temurin" + maven-cache-v1-${{ runner.os }}-${{ matrix.java }} + - name: Install Maven dependencies # https://github.com/actions/cache#skipping-steps-based-on-cache-hit if: steps.maven-cache.outputs.cache-hit != 'true' run: mvn clean install -DskipTests + - name: Install NPM dependencies # https://github.com/actions/cache#skipping-steps-based-on-cache-hit if: steps.npm-cache.outputs.cache-hit != 'true' run: | - npm install && - npm --prefix=selenium install && - npm --prefix=playwright install + npm ci && + npm --prefix=selenium ci && + npm --prefix=playwright ci license-check: needs: build runs-on: ubuntu-latest + timeout-minutes: 2 steps: - uses: actions/checkout@v4 - name: Maven compile licenses @@ -60,6 +64,10 @@ jobs: playwright-tests: needs: [license-check, build] runs-on: ubuntu-latest + timeout-minutes: 5 + strategy: + matrix: + java: [8, 11, 17] steps: - uses: actions/checkout@v4 - uses: actions/cache@v3 @@ -75,9 +83,9 @@ jobs: id: maven-cache with: path: ~/.m2/repository - key: maven-cache-v1-${{ runner.os }}-${{ hashFiles('**/pom.xml') }} + key: maven-cache-v1-${{ runner.os }}-${{ hashFiles('**/pom.xml') }}-${{ matrix.java }} restore-keys: | - maven-cache-v1-${{ runner.os }}- + maven-cache-v1-${{ runner.os }}-${{ matrix.java }} - name: Start fixture server run: npm --prefix=playwright start & - name: Run Playwright tests @@ -86,9 +94,13 @@ jobs: selenium-tests: needs: [license-check, build] runs-on: ubuntu-latest + timeout-minutes: 5 + strategy: + matrix: + java: [8, 11, 17] steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 - uses: actions/cache@v3 name: Restore npm cache id: npm-cache @@ -102,9 +114,9 @@ jobs: id: maven-cache with: path: ~/.m2/repository - key: maven-cache-v1-${{ runner.os }}-${{ hashFiles('**/pom.xml') }} + key: maven-cache-v1-${{ runner.os }}-${{ hashFiles('**/pom.xml') }}-${{ matrix.java }} restore-keys: | - maven-cache-v1-${{ runner.os }}- + maven-cache-v1-${{ runner.os }}-${{ matrix.java }} - name: Start fixture server run: python -m http.server 8001 & working-directory: selenium/node_modules/axe-test-fixtures/fixtures diff --git a/.github/workflows/update-axe-core.yml b/.github/workflows/update-axe-core.yml index d04da897..6b0bfd09 100644 --- a/.github/workflows/update-axe-core.yml +++ b/.github/workflows/update-axe-core.yml @@ -6,41 +6,15 @@ on: - cron: "0 0 * * *" workflow_dispatch: -#TODO: This entire flow will be replaced with https://github.com/dequelabs/axe-api-team-public/issues/30 once it's ready jobs: build: runs-on: ubuntu-latest + timeout-minutes: 1 steps: - uses: actions/checkout@v4 - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v4 with: node-version: 16 - - id: update - uses: dequelabs/update-axe-core@v1 - - id: type - run: | - CommitType="" - if [ "${{ steps.update.outputs.patch_version_updated }}" == "true" ]; then - CommitType="fix" - elif [ "${{ steps.update.outputs.minor_version_updated }}" == "true" ]; then - CommitType="feat" - elif [ "${{ steps.update.outputs.major_version_updated }}" == "true" ]; then - CommitType="feat" - else - echo "No axe-core update available. Cancelling." - gh run cancel ${{ github.run_id }}; - gh run watch ${{ github.run_id }}; - fi - echo "type=$CommitType" >>"$GITHUB_OUTPUT" - - name: Open PR - uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38 # tag=v5 + - uses: dequelabs/axe-api-team-public/.github/actions/create-update-axe-core-pull-request-v1@main with: - token: ${{ secrets.PAT }} - commit-message: "${{ steps.type.outputs.type }}: Update axe-core to v${{ steps.update.outputs.version }}" - branch: auto-update-axe-core - base: develop - title: "${{ steps.type.outputs.type }}: Update axe-core to v${{ steps.update.outputs.version }}" - body: | - This patch updates version of [`axe-core`](https://npmjs.org/axe-core) to v${{ steps.update.outputs.version }}. - - This PR was opened by a robot :robot: :tada:. + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 54d219dd..3db0a4fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,31 @@ +## [4.8.1](https://github.com/dequelabs/axe-core-maven-html/compare/v4.8.0...v4.8.1) (2024-01-09) + + +### Bug Fixes + +* **selenium:** apply Selenium 3 and 4 workaround for `switchTo()` when using Safari Driver ([#412](https://github.com/dequelabs/axe-core-maven-html/issues/412)) ([e701429](https://github.com/dequelabs/axe-core-maven-html/commit/e70142932a067e6e9f05f74982d6bb5faa043b58)) +* skip unloaded iframes ([#330](https://github.com/dequelabs/axe-core-maven-html/issues/330)) ([66ff5bd](https://github.com/dequelabs/axe-core-maven-html/commit/66ff5bdaed903d4dc2f166313a8dd47260c05291)), closes [#323](https://github.com/dequelabs/axe-core-maven-html/issues/323) +* Update axe-core to v4.8.3 ([#415](https://github.com/dequelabs/axe-core-maven-html/issues/415)) ([453dd25](https://github.com/dequelabs/axe-core-maven-html/commit/453dd2541379cae1dfbf1addab16c5dfe6d4a6aa)) + + + # Changelog 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.8.0](https://github.com/dequelabs/axe-core-maven-html/compare/v4.7.0...v4.8.0) (2023-09-27) + + +### Features + +* Update axe-core to v4.8.1 ([#349](https://github.com/dequelabs/axe-core-maven-html/issues/349)) ([bfb4928](https://github.com/dequelabs/axe-core-maven-html/commit/bfb4928a498cd56069b504ed8527e9d7f8311d39)) + + +### Bug Fixes + +* **playwright,selenium:** pin axe-core version to accept patch updates only ([#362](https://github.com/dequelabs/axe-core-maven-html/issues/362)) ([0b529fd](https://github.com/dequelabs/axe-core-maven-html/commit/0b529fd43772bffbb28a2317c0e959dc8407807c)) +* Update axe-core to v4.8.2 ([#361](https://github.com/dequelabs/axe-core-maven-html/issues/361)) ([29df855](https://github.com/dequelabs/axe-core-maven-html/commit/29df855d0d25f7f08a3f8ac4672b3a2f7290bb7b)) + ## [4.7.0](https://github.com/dequelabs/axe-core-maven-html/compare/v4.5.1...v4.7.0) (2023-04-26) diff --git a/README.md b/README.md index aa73855b..e8c38e7b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ # axe-core-maven-html -[![CircleCI](https://circleci.com/gh/dequelabs/axe-core-maven-html.svg?style=svg&circle-token=5bd96056d8ab9f52737de9b5d7cc614decbb9819)](https://circleci.com/gh/dequelabs/axe-core-maven-html) [![Join our Slack chat](https://img.shields.io/badge/slack-chat-purple.svg?logo=slack)](https://accessibility.deque.com/axe-community) This repository contains 2 packages, which can be used for automated accessibility testing powered by [axe core][axe-core]. diff --git a/assembly-descriptor.xml b/assembly-descriptor.xml deleted file mode 100644 index 37b2d809..00000000 --- a/assembly-descriptor.xml +++ /dev/null @@ -1,27 +0,0 @@ - - with-dependencies - - jar - - false - - - - / - true - true - runtime - - - - - * - / - true - true - test - - - \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index a74a8d1d..eda014d0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,19 +1,18 @@ { "name": "axe-core-maven-html", - "version": "4.7.0", + "version": "4.8.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "axe-core-maven-html", - "version": "4.7.0", + "version": "4.8.0", "license": "ISC", "devDependencies": { "conventional-changelog-cli": "^4.1.0", "copyfiles": "^2.4.1", "del-cli": "^5.1.0", "husky": "^8.0.3", - "jfrog-cli-go": "^1.54.1", "standard-version": "^9.5.0", "xml-js": "^1.6.11" } @@ -2160,39 +2159,6 @@ "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", "dev": true }, - "node_modules/jfrog-cli-go": { - "version": "1.54.1", - "resolved": "https://registry.npmjs.org/jfrog-cli-go/-/jfrog-cli-go-1.54.1.tgz", - "integrity": "sha512-UgCOJ1zg9kG+twA7WuMYm/h/5LBQeCzZnS1OQS27ZMMf5AdbOCA/tGOtvyCt0rPvHWaVv5NS+EkuTguXcfEuhg==", - "bundleDependencies": [ - "ms", - "debug" - ], - "dev": true, - "hasInstallScript": true, - "dependencies": { - "debug": "3.1.0", - "ms": "2.0.0" - }, - "bin": { - "jfrog": "bin/jfrog" - } - }, - "node_modules/jfrog-cli-go/node_modules/debug": { - "version": "3.1.0", - "dev": true, - "inBundle": true, - "license": "MIT", - "dependencies": { - "ms": "2.0.0" - } - }, - "node_modules/jfrog-cli-go/node_modules/ms": { - "version": "2.0.0", - "dev": true, - "inBundle": true, - "license": "MIT" - }, "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -5119,31 +5085,6 @@ "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", "dev": true }, - "jfrog-cli-go": { - "version": "1.54.1", - "resolved": "https://registry.npmjs.org/jfrog-cli-go/-/jfrog-cli-go-1.54.1.tgz", - "integrity": "sha512-UgCOJ1zg9kG+twA7WuMYm/h/5LBQeCzZnS1OQS27ZMMf5AdbOCA/tGOtvyCt0rPvHWaVv5NS+EkuTguXcfEuhg==", - "dev": true, - "requires": { - "debug": "3.1.0", - "ms": "2.0.0" - }, - "dependencies": { - "debug": { - "version": "3.1.0", - "bundled": true, - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "ms": { - "version": "2.0.0", - "bundled": true, - "dev": true - } - } - }, "js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", diff --git a/package.json b/package.json index e581c63f..3ef678cc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "axe-core-maven-html", - "version": "4.7.0", + "version": "4.8.1", "license": "ISC", "repository": "dequelabs/axe-core-maven-html", "scripts": { @@ -15,7 +15,6 @@ "copyfiles": "^2.4.1", "del-cli": "^5.1.0", "husky": "^8.0.3", - "jfrog-cli-go": "^1.54.1", "standard-version": "^9.5.0", "xml-js": "^1.6.11" } diff --git a/playwright/package-lock.json b/playwright/package-lock.json index 7a6ea1e3..4d95ec0d 100644 --- a/playwright/package-lock.json +++ b/playwright/package-lock.json @@ -1,15 +1,15 @@ { "name": "axe-core-maven-html-playwright", - "version": "4.7.0", + "version": "4.8.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "axe-core-maven-html-playwright", - "version": "4.7.0", + "version": "4.8.0", "license": "MPL", "dependencies": { - "axe-core": "4.8.2" + "axe-core": "^4.8.3" }, "devDependencies": { "axe-test-fixtures": "github:dequelabs/axe-test-fixtures#v1", @@ -41,9 +41,9 @@ } }, "node_modules/axe-core": { - "version": "4.8.2", - "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.8.2.tgz", - "integrity": "sha512-/dlp0fxyM3R8YW7MFzaHWXrf4zzbr0vaYb23VBFCl83R7nWNPg/yaQw2Dc8jzCMmDVLhSdzH8MjrsuIUuvX+6g==", + "version": "4.8.3", + "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.8.3.tgz", + "integrity": "sha512-d5ZQHPSPkF9Tw+yfyDcRoUOc4g/8UloJJe5J8m4L5+c7AtDdjDLRxew/knnI4CxvtdxEUVgWz4x3OIQUIFiMfw==", "engines": { "node": ">=4" } @@ -477,9 +477,9 @@ } }, "axe-core": { - "version": "4.8.2", - "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.8.2.tgz", - "integrity": "sha512-/dlp0fxyM3R8YW7MFzaHWXrf4zzbr0vaYb23VBFCl83R7nWNPg/yaQw2Dc8jzCMmDVLhSdzH8MjrsuIUuvX+6g==" + "version": "4.8.3", + "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.8.3.tgz", + "integrity": "sha512-d5ZQHPSPkF9Tw+yfyDcRoUOc4g/8UloJJe5J8m4L5+c7AtDdjDLRxew/knnI4CxvtdxEUVgWz4x3OIQUIFiMfw==" }, "axe-test-fixtures": { "version": "git+ssh://git@github.com/dequelabs/axe-test-fixtures.git#09469d613991c108cd76f070839cc46f59668ebb", diff --git a/playwright/package.json b/playwright/package.json index 44377668..f6c9017c 100644 --- a/playwright/package.json +++ b/playwright/package.json @@ -1,6 +1,6 @@ { "name": "axe-core-maven-html-playwright", - "version": "4.7.0", + "version": "4.8.1", "license": "MPL", "private": true, "repository": "dequelabs/axe-core-maven-html", @@ -8,7 +8,7 @@ "start": "http-server ./node_modules/axe-test-fixtures/fixtures -a \"\" -p 1337 --silent" }, "dependencies": { - "axe-core": "4.8.2" + "axe-core": "^4.8.3" }, "devDependencies": { "axe-test-fixtures": "github:dequelabs/axe-test-fixtures#v1", diff --git a/playwright/pom.xml b/playwright/pom.xml index a69e7b0c..02c106c7 100644 --- a/playwright/pom.xml +++ b/playwright/pom.xml @@ -2,12 +2,12 @@ 4.0.0 playwright - 4.7.0 + 4.8.1 jar com.deque.html.axe-core virtual-superpackage - 4.7.0 + 4.8.1 ../pom.xml Axe-core Playwright Java @@ -61,29 +61,12 @@ - - maven-assembly-plugin - - assembly-descriptor.xml - - - - make-assembly - - package - - - single - - - - com.github.eirslett frontend-maven-plugin - 1.14.0 + 1.15.0 install node and npm @@ -107,7 +90,7 @@ org.jacoco jacoco-maven-plugin - 0.8.10 + 0.8.11 @@ -156,7 +139,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.6.0 + 3.6.3 attach-javadocs @@ -169,7 +152,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.11.0 + 3.12.1 1.8 1.8 @@ -178,7 +161,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.1.2 + 3.2.3 @{argLine} -more -arguments alphabetical @@ -237,7 +220,7 @@ com.microsoft.playwright playwright - 1.38.0 + 1.40.0 @@ -249,7 +232,7 @@ org.apache.commons commons-compress - 1.24.0 + 1.25.0 junit @@ -272,25 +255,25 @@ com.fasterxml.jackson.core jackson-annotations - 2.15.2 + 2.16.1 compile com.fasterxml.jackson.core jackson-databind - 2.15.2 + 2.16.1 compile commons-io commons-io - 2.14.0 + 2.15.1 compile com.deque.html.axe-core dequeutilites - 4.7.0 + 4.8.1 compile diff --git a/pom.xml b/pom.xml index 011e6692..8b7939c5 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.deque.html.axe-core virtual-superpackage - 4.7.0 + 4.8.1 pom Axe-core-maven-html Superpackage axe-core-maven-html superpackage containing; selenium, playwright, and, utilities @@ -55,7 +55,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.6.0 + 3.6.3 attach-javadocs @@ -68,7 +68,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.11.0 + 3.12.1 1.8 1.8 @@ -77,7 +77,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.1.2 + 3.2.3 alphabetical diff --git a/selenium/package-lock.json b/selenium/package-lock.json index f12e999e..6975b97e 100644 --- a/selenium/package-lock.json +++ b/selenium/package-lock.json @@ -1,15 +1,15 @@ { "name": "axe-core-maven-html-selenium", - "version": "4.7.0", + "version": "4.8.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "axe-core-maven-html-selenium", - "version": "4.7.0", + "version": "4.8.0", "license": "UNLICENSED", "dependencies": { - "axe-core": "4.8.2" + "axe-core": "^4.8.3" }, "devDependencies": { "axe-test-fixtures": "github:dequelabs/axe-test-fixtures#v1", @@ -39,9 +39,9 @@ } }, "node_modules/axe-core": { - "version": "4.8.2", - "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.8.2.tgz", - "integrity": "sha512-/dlp0fxyM3R8YW7MFzaHWXrf4zzbr0vaYb23VBFCl83R7nWNPg/yaQw2Dc8jzCMmDVLhSdzH8MjrsuIUuvX+6g==", + "version": "4.8.3", + "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.8.3.tgz", + "integrity": "sha512-d5ZQHPSPkF9Tw+yfyDcRoUOc4g/8UloJJe5J8m4L5+c7AtDdjDLRxew/knnI4CxvtdxEUVgWz4x3OIQUIFiMfw==", "engines": { "node": ">=4" } @@ -445,9 +445,9 @@ } }, "axe-core": { - "version": "4.8.2", - "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.8.2.tgz", - "integrity": "sha512-/dlp0fxyM3R8YW7MFzaHWXrf4zzbr0vaYb23VBFCl83R7nWNPg/yaQw2Dc8jzCMmDVLhSdzH8MjrsuIUuvX+6g==" + "version": "4.8.3", + "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.8.3.tgz", + "integrity": "sha512-d5ZQHPSPkF9Tw+yfyDcRoUOc4g/8UloJJe5J8m4L5+c7AtDdjDLRxew/knnI4CxvtdxEUVgWz4x3OIQUIFiMfw==" }, "axe-test-fixtures": { "version": "git+ssh://git@github.com/dequelabs/axe-test-fixtures.git#23f638c574dd9be2a725fa81854f1560d858dcce", diff --git a/selenium/package.json b/selenium/package.json index 45334bbb..0109df05 100644 --- a/selenium/package.json +++ b/selenium/package.json @@ -1,6 +1,6 @@ { "name": "axe-core-maven-html-selenium", - "version": "4.7.0", + "version": "4.8.1", "license": "UNLICENSED", "private": true, "repository": "dequelabs/axe-core-maven-html", @@ -8,7 +8,7 @@ "start": "http-server ./node_modules/axe-test-fixtures/fixtures -a \"\" -p 8001 --silent" }, "dependencies": { - "axe-core": "4.8.2" + "axe-core": "^4.8.3" }, "devDependencies": { "axe-test-fixtures": "github:dequelabs/axe-test-fixtures#v1", diff --git a/selenium/pom.xml b/selenium/pom.xml index c55f2d08..f4c27120 100644 --- a/selenium/pom.xml +++ b/selenium/pom.xml @@ -2,12 +2,12 @@ 4.0.0 selenium - 4.7.0 + 4.8.1 jar com.deque.html.axe-core virtual-superpackage - 4.7.0 + 4.8.1 ../pom.xml @@ -27,7 +27,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.11.0 + 3.12.1 8 8 @@ -38,7 +38,7 @@ frontend-maven-plugin - 1.14.0 + 1.15.0 install node and npm @@ -118,7 +118,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.6.0 + 3.6.3 attach-javadocs @@ -170,7 +170,7 @@ commons-io commons-io - 2.14.0 + 2.15.1 org.seleniumhq.selenium @@ -180,22 +180,22 @@ io.github.bonigarcia webdrivermanager - 5.5.3 + 5.6.3 org.apache.commons commons-lang3 - 3.13.0 + 3.14.0 com.fasterxml.jackson.core jackson-databind - 2.15.2 + 2.16.1 org.junit.vintage junit-vintage-engine - 5.10.0 + 5.10.1 test @@ -208,7 +208,7 @@ com.deque.html.axe-core dequeutilites - 4.7.0 + 4.8.1 compile diff --git a/selenium/src/main/java/com/deque/html/axecore/extensions/WebDriverExtensions.java b/selenium/src/main/java/com/deque/html/axecore/extensions/WebDriverExtensions.java index 9c680ae2..b7b80f62 100644 --- a/selenium/src/main/java/com/deque/html/axecore/extensions/WebDriverExtensions.java +++ b/selenium/src/main/java/com/deque/html/axecore/extensions/WebDriverExtensions.java @@ -17,6 +17,7 @@ import com.deque.html.axecore.selenium.AxeBuilderOptions; import java.io.IOException; import java.util.ArrayList; +import java.util.Set; import javax.naming.OperationNotSupportedException; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebDriver; @@ -122,10 +123,26 @@ public static String openAboutBlank(final WebDriver webDriver) { try { JavascriptExecutor driver = (JavascriptExecutor) webDriver; + Set beforeHandles = webDriver.getWindowHandles(); driver.executeScript("window.open('about:blank', '_blank')"); - ArrayList handles = new ArrayList(webDriver.getWindowHandles()); - String abHandle = handles.get(handles.size() - 1); - webDriver.switchTo().window(abHandle); + Set afterHandles = webDriver.getWindowHandles(); + + // Note: this is a work around for handling opening about:blank within the Safari driver. + // As we need to support Selenium 3 and 4, we cannot use the new window API. + // However, we compare the handles before and after opening about:blank and find the new + // handle. + // This is not ideal, but it is the best we can do for now. + // TODO: Remove this workaround if/when we drop support for Selenium 3 + // https://github.com/dequelabs/axe-core-maven-html/issues/411 + ArrayList newHandles = new ArrayList<>(afterHandles); + newHandles.removeAll(beforeHandles); + + if (newHandles.size() != 1) { + throw new RuntimeException("Unable to determine window handle"); + } + + String aboutBlankHandle = newHandles.get(0); + webDriver.switchTo().window(aboutBlankHandle); webDriver.get("about:blank"); } catch (Exception e) { throw new RuntimeException( diff --git a/selenium/src/main/java/com/deque/html/axecore/selenium/AxeBuilder.java b/selenium/src/main/java/com/deque/html/axecore/selenium/AxeBuilder.java index a0dddc3e..9d33be5e 100644 --- a/selenium/src/main/java/com/deque/html/axecore/selenium/AxeBuilder.java +++ b/selenium/src/main/java/com/deque/html/axecore/selenium/AxeBuilder.java @@ -31,10 +31,6 @@ import java.util.Map; import java.util.Stack; import java.util.StringJoiner; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; import java.util.function.Consumer; import org.openqa.selenium.InvalidArgumentException; import org.openqa.selenium.JavascriptException; @@ -863,27 +859,7 @@ private Results analyzePre43x(final WebDriver webDriver, final Object rawContext return results; } - private void assertFrameReady(final WebDriver webDriver) { - // Wait so that we know there is an execution context. - // Assume that if we have an html node we have an execution context. - try { - boolean ready = - CompletableFuture.supplyAsync( - () -> - (boolean) - WebDriverInjectorExtensions.executeScript( - webDriver, "return document.readyState === 'complete'")) - .get(FRAME_LOAD_TIMEOUT.toMillis(), TimeUnit.MILLISECONDS); - if (!ready) { - throw new RuntimeException("Page/frame is not ready"); - } - } catch (TimeoutException | InterruptedException | ExecutionException e) { - throw new RuntimeException("Page/frame is not ready"); - } - } - private void injectAxe(final WebDriver webDriver) { - assertFrameReady(webDriver); if (!doNotInjectAxe) { try { WebDriverInjectorExtensions.executeScript( diff --git a/selenium/src/test/java/com/deque/html/axecore/selenium/WebDriverExtensionsTest.java b/selenium/src/test/java/com/deque/html/axecore/selenium/WebDriverExtensionsTest.java new file mode 100644 index 00000000..075069b7 --- /dev/null +++ b/selenium/src/test/java/com/deque/html/axecore/selenium/WebDriverExtensionsTest.java @@ -0,0 +1,155 @@ +package com.deque.html.axecore.selenium; + +import com.deque.html.axecore.extensions.WebDriverExtensions; +import java.util.ArrayList; +import org.junit.Assert; +import org.junit.Assume; +import org.junit.Test; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.chrome.ChromeDriver; +import org.openqa.selenium.chrome.ChromeOptions; +import org.openqa.selenium.firefox.FirefoxDriver; +import org.openqa.selenium.firefox.FirefoxOptions; +import org.openqa.selenium.safari.SafariDriver; + +public class WebDriverExtensionsTest { + private enum Browser { + CHROME, + FIREFOX, + SAFARI + } + + private ArrayList tryOpenAboutBlank(Browser browser) { + WebDriver webDriver = null; + switch (browser) { + case CHROME: + webDriver = new ChromeDriver(new ChromeOptions().addArguments("--headless")); + break; + case FIREFOX: + webDriver = new FirefoxDriver(new FirefoxOptions().addArguments("--headless")); + break; + case SAFARI: + // SafariDriver does not support headless mode + webDriver = new SafariDriver(); + break; + } + + Exception exception = null; + + String addr = "http://localhost:8001"; + webDriver.get(addr + "/index.html"); + + try { + WebDriverExtensions.openAboutBlank(webDriver); + } catch (Exception e) { + exception = e; + } + + // store exception and the current url in the webDriver to be checked later + ArrayList exceptionAndUrl = new ArrayList<>(); + + exceptionAndUrl.add(exception); + exceptionAndUrl.add(webDriver.getCurrentUrl()); + + webDriver.quit(); + + return exceptionAndUrl; + } + + @Test + public void shouldNotThrowGivenChromedriver() { + ArrayList exceptionAndUrl = tryOpenAboutBlank(Browser.CHROME); + + Exception exception = (Exception) exceptionAndUrl.get(0); + String url = (String) exceptionAndUrl.get(1); + + Assert.assertNull(exception); + Assert.assertEquals(url, "about:blank"); + } + + @Test + public void shouldNotThrowGivenGeckodriver() { + ArrayList exceptionAndUrl = tryOpenAboutBlank(Browser.FIREFOX); + + Exception exception = (Exception) exceptionAndUrl.get(0); + String url = (String) exceptionAndUrl.get(1); + + Assert.assertNull(exception); + Assert.assertEquals(url, "about:blank"); + } + + @Test + public void shouldNotThrowGivenSafariDriver() { + // if OS is windows or linux, skip this test as Safari is not available + String os = System.getProperty("os.name").toLowerCase(); + Assume.assumeFalse(os.contains("windows")); + Assume.assumeFalse(os.contains("linux")); + + ArrayList exceptionAndUrl = tryOpenAboutBlank(Browser.SAFARI); + + Exception exception = (Exception) exceptionAndUrl.get(0); + String url = (String) exceptionAndUrl.get(1); + + Assert.assertNull(exception); + Assert.assertEquals(url, "about:blank"); + } + + @Test + public void shouldThrowWhenSwitchToFails() { + // Create a mock driver to throw an exception when switchTo() is called + // This is to simulate `switchTo()` failing and throwing an exception + // We expect the exception to be caught and handled correctly. + class MockedDriver extends ChromeDriver { + public MockedDriver(ChromeOptions chromeOptions) { + super(chromeOptions); + } + + @Override + public WebDriver.TargetLocator switchTo() { + throw new RuntimeException("BOOM!"); + } + } + + MockedDriver webDriver = new MockedDriver(new ChromeOptions().addArguments("--headless")); + webDriver.get("http://localhost:8001/index.html"); + + Exception exception = + Assert.assertThrows( + Exception.class, + () -> { + WebDriverExtensions.openAboutBlank(webDriver); + }); + + Assert.assertTrue(exception.getMessage().contains("switchToWindow failed.")); + } + + @Test + public void shouldThrowWhenUnableToDetermineWindowHandle() { + class MockedDriver extends ChromeDriver { + public MockedDriver(ChromeOptions chromeOptions) { + super(chromeOptions); + } + + @Override + public Object executeScript(String script, Object... args) { + // Note: This is to simulate another window being created along with the about:blank + // window. This is to simulate the case where the about:blank window is not the + // only window being created and the window handle cannot be determined. + super.executeScript(script, args); + return super.executeScript(script, args); + } + } + + MockedDriver webDriver = new MockedDriver(new ChromeOptions().addArguments("--headless")); + webDriver.get("http://localhost:8001/index.html"); + + RuntimeException exception = + Assert.assertThrows( + RuntimeException.class, + () -> { + WebDriverExtensions.openAboutBlank(webDriver); + }); + + Assert.assertEquals(exception.getCause().getMessage(), "Unable to determine window handle"); + } +} diff --git a/utilities/pom.xml b/utilities/pom.xml index 02e30915..2a5e3085 100644 --- a/utilities/pom.xml +++ b/utilities/pom.xml @@ -4,14 +4,14 @@ com.deque.html.axe-core virtual-superpackage - 4.7.0 + 4.8.1 ../pom.xml Axe-core maven utilities axe-core-maven-html utility classes used in all packages https://github.com/dequelabs/axe-core-maven-html dequeutilites - 4.7.0 + 4.8.1 jar @@ -46,7 +46,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.6.0 + 3.6.3 attach-javadocs @@ -59,7 +59,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.11.0 + 3.12.1 1.8 1.8 @@ -117,7 +117,7 @@ com.fasterxml.jackson.core jackson-annotations - 2.15.2 + 2.16.1 compile