From 399bbc93250c4e9e2bfba6acbf18cb5144603bea Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Sun, 3 Mar 2019 13:21:03 +0000 Subject: [PATCH 01/50] chore(package): update globby to version 9.1.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 783a0d6fb4..b29c937ae2 100644 --- a/package.json +++ b/package.json @@ -92,7 +92,7 @@ "eslint-config-prettier": "^3.4.0", "execa": "^1.0.0", "fs-extra": "^7.0.0", - "globby": "^8.0.1", + "globby": "^9.1.0", "grunt": "^1.0.3", "grunt-babel": "^7.0.0", "grunt-contrib-clean": "^2.0.0", From caf976e817796e49408c9385ae81f0cbdff8f84d Mon Sep 17 00:00:00 2001 From: Wilco Fiers Date: Tue, 5 Mar 2019 20:27:49 +0100 Subject: [PATCH 02/50] chore: Simplify codeowner stuff (#1409) --- .github/CODEOWNERS | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index be72705884..65bf2675ae 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -5,9 +5,3 @@ # Localisation locales/ja.json @mlca11y/mlca11y @dequelabs/axe-codeowners - -# Core features -lib/core/* @stephenmathieson @dequelabs/axe-codeowners -test/core/* @stephenmathieson @dequelabs/axe-codeowners -build/* @stephenmathieson @dequelabs/axe-codeowners -Gruntfile.js @stephenmathieson @dequelabs/axe-codeowners \ No newline at end of file From 6bd78aafa0a60ecfe9e2bbd48e124ba675d1a568 Mon Sep 17 00:00:00 2001 From: Wilco Fiers Date: Tue, 5 Mar 2019 20:37:08 +0100 Subject: [PATCH 03/50] chore(eslint): Ignore built files (#1407) --- .eslintignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.eslintignore b/.eslintignore index 488138ec63..ce6d1364d7 100644 --- a/.eslintignore +++ b/.eslintignore @@ -6,3 +6,5 @@ doc/api/* doc/examples/jest_react/*.js lib/core/imports/*.js +axe.js +axe.min.js \ No newline at end of file From 0d3d26757b7b787c21d57e1ebdeea17a902723db Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Tue, 5 Mar 2019 16:12:24 -0500 Subject: [PATCH 04/50] chore(package): update emoji-regex to version 8.0.0 (#1410) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 23c5ac604b..2ac8e49387 100644 --- a/package.json +++ b/package.json @@ -86,7 +86,7 @@ "clone": "~2.1.1", "css-selector-parser": "^1.3.0", "dot": "~1.1.2", - "emoji-regex": "7.0.3", + "emoji-regex": "8.0.0", "es6-promise": "^4.2.6", "eslint": "^5.14.0", "eslint-config-prettier": "^3.4.0", From 30aa57065d53ad048411e406c27ed18f95435f66 Mon Sep 17 00:00:00 2001 From: Wilco Fiers Date: Wed, 6 Mar 2019 11:32:02 +0100 Subject: [PATCH 05/50] fix: Avoid require conflict with Cypress [#1405] (#1406) Use derequire the rename all uses of `require` to `_dereq_` to avoid the problem of Cypress overloading the `require` method. Closes #1405 ## Reviewer checks **Required fields, to be filled out by PR reviewer(s)** - [x] Follows the commit message policy, appropriate for next version - [x] Has documentation updated, a DU ticket, or requires no documentation change - [x] Includes new tests, or was unnecessary - [x] Code is reviewed for security by: Stephen --- build/imports-generator.js | 3 +++ package.json | 1 + test/integration/full/umd/umd-module-exports.js | 10 ++++++++++ 3 files changed, 14 insertions(+) diff --git a/build/imports-generator.js b/build/imports-generator.js index f4a1ddfec4..c50fe831c6 100644 --- a/build/imports-generator.js +++ b/build/imports-generator.js @@ -1,5 +1,6 @@ const path = require('path'); const browserify = require('browserify'); +const derequire = require('derequire'); const createFile = require('./shared/create-file'); const inputFile = path.join( @@ -25,6 +26,8 @@ async function run() { throw new Error('Cannot browserify axe.imports', err); } try { + // Replace `require` calls with `_dereq_` in order not to confuse Cypress.js + result = derequire(result); await createFile(outputFile, result); } catch (error) { throw new Error('Cannot write browserify generated axe.imports', error); diff --git a/package.json b/package.json index 2ac8e49387..788c6ea108 100644 --- a/package.json +++ b/package.json @@ -85,6 +85,7 @@ "chai": "~4.1.2", "clone": "~2.1.1", "css-selector-parser": "^1.3.0", + "derequire": "^2.0.6", "dot": "~1.1.2", "emoji-regex": "8.0.0", "es6-promise": "^4.2.6", diff --git a/test/integration/full/umd/umd-module-exports.js b/test/integration/full/umd/umd-module-exports.js index 3de63c54ef..440c9fcb20 100644 --- a/test/integration/full/umd/umd-module-exports.js +++ b/test/integration/full/umd/umd-module-exports.js @@ -6,6 +6,16 @@ describe('UMD module.export', function() { assert.strictEqual(module.exports, axe); }); + it('does not use `require` functions', function() { + // This is to avoid colliding with Cypress.js which overloads all + // uses of variables named `require`. + assert.notMatch( + axe.source, + /[^.]require\(/, + 'Axe source should not contain `require` variables' + ); + }); + it('should ensure axe source includes axios', function() { assert.isTrue(axe.source.includes(axe.imports.axios.toString())); }); From ca67296bd38e1ede15ba37a016576f47a07bde70 Mon Sep 17 00:00:00 2001 From: jkodu Date: Wed, 6 Mar 2019 10:42:51 +0000 Subject: [PATCH 06/50] chore: release 321 --- CHANGELOG.md | 6 ++++++ bower.json | 10 ++-------- package.json | 2 +- sri-history.json | 6 +++++- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b9768552f2..d113d922a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ 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. +## [3.2.1](https://github.com/dequelabs/axe-core/compare/v3.2.0...v3.2.1) (2019-03-06) + +### Bug Fixes + +- Avoid require conflict with Cypress [[#1405](https://github.com/dequelabs/axe-core/issues/1405)](<[#1406](https://github.com/dequelabs/axe-core/issues/1406)>) ([30aa570](https://github.com/dequelabs/axe-core/commit/30aa570)) + # [3.2.0](https://github.com/dequelabs/axe-core/compare/v3.0.3...v3.2.0) (2019-03-04) ### Bug Fixes diff --git a/bower.json b/bower.json index fab12e3824..aca3e7aa3c 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "axe-core", - "version": "3.2.0", + "version": "3.2.1", "contributors": [ { "name": "David Sturley", @@ -35,12 +35,6 @@ "main": "axe.js", "typings": "axe.d.ts", "license": "MPL-2.0", - "ignore": [ - "**/.*", - "node_modules", - "test", - "build", - "typings" - ], + "ignore": ["**/.*", "node_modules", "test", "build", "typings"], "devDependencies": {} } diff --git a/package.json b/package.json index 788c6ea108..6eb1ff76c1 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "axe-core", "description": "Accessibility engine for automated Web UI testing", - "version": "3.2.0", + "version": "3.2.1", "license": "MPL-2.0", "engines": { "node": ">=4" diff --git a/sri-history.json b/sri-history.json index 58b2c0b571..1952b456e1 100644 --- a/sri-history.json +++ b/sri-history.json @@ -126,5 +126,9 @@ "3.2.0": { "axe.js": "sha256-wdCvSfDepBhwcvTqB0gm586ywpla6Yi81qLCHjegILM=", "axe.min.js": "sha256-Tvf4toyAt1NFmmkuLsgStXW+4pcG5GG9ugopPoOvOwg=" + }, + "3.2.1": { + "axe.js": "sha256-VPX1ngRx0XWqC5BP9XdHoDd8YlbgXGK39cz14GBL9bg=", + "axe.min.js": "sha256-ynN9JxvxoI9VpL7IbdTVCUCLhy3N7Ygrnit2r7a2vK8=" } -} \ No newline at end of file +} From 594f91eadc049e83b15793ccd0dcd8029619ec4c Mon Sep 17 00:00:00 2001 From: Stephen Mathieson Date: Wed, 6 Mar 2019 07:39:33 -0500 Subject: [PATCH 07/50] ci: do not run the tests unless "lint" passes (#1411) This patch prevents our `test` CircleCI job from running until both `lint` and `dependencies` have passed. This ensures we "fail fast", which should (in theory) free up _some_ time with our limited container count. ## Reviewer checks **Required fields, to be filled out by PR reviewer(s)** - [x] Follows the commit message policy, appropriate for next version - [x] Has documentation updated, a DU ticket, or requires no documentation change - [x] Includes new tests, or was unnecessary - [x] Code is reviewed for security by: @jkodu --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8c198ac8d8..89f251332e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -91,6 +91,7 @@ workflows: - test: requires: - dependencies + - lint # Hold for approval - hold: type: approval From 1da0eb8f273b480bc6e490103f05e00b4245b413 Mon Sep 17 00:00:00 2001 From: Wilco Fiers Date: Wed, 6 Mar 2019 18:11:58 +0100 Subject: [PATCH 08/50] chore: Update from master (#1414) --- CHANGELOG.md | 6 ++++++ bower.json | 10 ++-------- package.json | 2 +- sri-history.json | 6 +++++- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b9768552f2..d113d922a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ 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. +## [3.2.1](https://github.com/dequelabs/axe-core/compare/v3.2.0...v3.2.1) (2019-03-06) + +### Bug Fixes + +- Avoid require conflict with Cypress [[#1405](https://github.com/dequelabs/axe-core/issues/1405)](<[#1406](https://github.com/dequelabs/axe-core/issues/1406)>) ([30aa570](https://github.com/dequelabs/axe-core/commit/30aa570)) + # [3.2.0](https://github.com/dequelabs/axe-core/compare/v3.0.3...v3.2.0) (2019-03-04) ### Bug Fixes diff --git a/bower.json b/bower.json index fab12e3824..aca3e7aa3c 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "axe-core", - "version": "3.2.0", + "version": "3.2.1", "contributors": [ { "name": "David Sturley", @@ -35,12 +35,6 @@ "main": "axe.js", "typings": "axe.d.ts", "license": "MPL-2.0", - "ignore": [ - "**/.*", - "node_modules", - "test", - "build", - "typings" - ], + "ignore": ["**/.*", "node_modules", "test", "build", "typings"], "devDependencies": {} } diff --git a/package.json b/package.json index 788c6ea108..6eb1ff76c1 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "axe-core", "description": "Accessibility engine for automated Web UI testing", - "version": "3.2.0", + "version": "3.2.1", "license": "MPL-2.0", "engines": { "node": ">=4" diff --git a/sri-history.json b/sri-history.json index 58b2c0b571..1952b456e1 100644 --- a/sri-history.json +++ b/sri-history.json @@ -126,5 +126,9 @@ "3.2.0": { "axe.js": "sha256-wdCvSfDepBhwcvTqB0gm586ywpla6Yi81qLCHjegILM=", "axe.min.js": "sha256-Tvf4toyAt1NFmmkuLsgStXW+4pcG5GG9ugopPoOvOwg=" + }, + "3.2.1": { + "axe.js": "sha256-VPX1ngRx0XWqC5BP9XdHoDd8YlbgXGK39cz14GBL9bg=", + "axe.min.js": "sha256-ynN9JxvxoI9VpL7IbdTVCUCLhy3N7Ygrnit2r7a2vK8=" } -} \ No newline at end of file +} From 0999d7a0cf50fc8233693637f60fcb1a047ecac9 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Wed, 6 Mar 2019 19:03:21 +0100 Subject: [PATCH 09/50] chore(package): update eslint-config-prettier to version 4.1.0 (#1392) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit chore: Update eslint-config-prettier to the latest version 🚀 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6eb1ff76c1..6d20891131 100644 --- a/package.json +++ b/package.json @@ -90,7 +90,7 @@ "emoji-regex": "8.0.0", "es6-promise": "^4.2.6", "eslint": "^5.14.0", - "eslint-config-prettier": "^3.4.0", + "eslint-config-prettier": "^4.1.0", "execa": "^1.0.0", "fs-extra": "^7.0.0", "globby": "^8.0.1", From 11aa039012b624b5f465d966d86ffc97dde4d9e7 Mon Sep 17 00:00:00 2001 From: Wilco Fiers Date: Wed, 6 Mar 2019 21:55:17 +0100 Subject: [PATCH 10/50] chore: Avoid publishing unnecessary files to NPM (#1408) --- .npmignore | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.npmignore b/.npmignore index 600d2f48db..a3e29a0ff2 100644 --- a/.npmignore +++ b/.npmignore @@ -1,4 +1,23 @@ tmp dist +build +test node_modules *.tgz +.npmignore +.circleci +.github +.babelrc +.editorconfig +.eslintignore +.eslintrc +.gitattributes +.huskyrc +.jsdoc.json +.prettierignore +.prettierrc +.retireignore.json +appveyor.yml +greenkeeper.json +Gruntfile.js +tsconfig.json From 58acd4218d974a9f2729acb605ffc4331430237a Mon Sep 17 00:00:00 2001 From: Jey Date: Wed, 6 Mar 2019 21:51:35 +0000 Subject: [PATCH 11/50] refactor: preloadCssom (#1364) --- lib/core/utils/preload-cssom.js | 663 +++++++++++++++++++------------- 1 file changed, 405 insertions(+), 258 deletions(-) diff --git a/lib/core/utils/preload-cssom.js b/lib/core/utils/preload-cssom.js index a62cdf1b24..c95f12181c 100644 --- a/lib/core/utils/preload-cssom.js +++ b/lib/core/utils/preload-cssom.js @@ -1,208 +1,63 @@ /** - * Make an axios get request to fetch a given resource and resolve - * @method getExternalStylesheet - * @param {Object} options an object with properties to configure the external XHR - * @property {Object} options.resolve resolve callback on queue - * @property {Object} options.reject reject callback on queue - * @property {String} options.url string representing the url of the resource to load - * @property {Object} options.rootNode document or shadowDOM root document for which to process CSSOM - * @property {Number} options.timeout timeout to about network call - * @property {Function} options.getStyleSheet a utility function to generate a style sheet for a given text content - * @property {String} options.shadowId an id if undefined denotes that given root is a shadowRoot - * @property {Number} options.priority css applied priority - * @returns resolve with stylesheet object - * @private + * NOTE: + * this `eslint` rule is disabled because of calling `getStyleSheetFactory` before it is defined (further below). */ -function getExternalStylesheet(options) { - const { - resolve, - reject, - url, - rootNode, - timeout, - getStyleSheet, - shadowId, - priority - } = options; - axe.imports - .axios({ - method: 'get', - url, - timeout - }) - .then(({ data }) => { - const sheet = getStyleSheet({ - data, - isExternal: true, - shadowId, - root: rootNode, - priority - }); - resolve(sheet); - }) - .catch(reject); -} +/* eslint no-use-before-define: 0 */ -/** - * Get stylesheet(s) from shadowDOM - * @param {Object} documentFragment document fragment node - * @param {Function} getStyleSheet helper function to get stylesheet object - * @returns an array of stylesheet objects - */ -function getSheetsFromShadowDom(documentFragment, getStyleSheet) { - return Array.from(documentFragment.children).reduce((out, node) => { - const nodeName = node.nodeName.toUpperCase(); - if (nodeName !== 'STYLE' && nodeName !== 'LINK') { - return out; - } - if (nodeName === 'STYLE') { - const dynamicSheet = getStyleSheet({ data: node.textContent }); - out.push(dynamicSheet.sheet); - } - if (nodeName === 'LINK' && !node.media.includes('print')) { - const dynamicSheet = getStyleSheet({ data: node, isLink: true }); - out.push(dynamicSheet.sheet); - } - return out; - }, []); -} /** - * Filter a given array of stylesheet objects - * @param {Array} styleSheets array of stylesheets - * @returns an filtered array of stylesheets + * Given a rootNode - construct CSSOM + * -> get all source nodes (document & document fragments) within given root node + * -> recursively call `loadCssom` to resolve styles + * + * @method preloadCssom + * @memberof `axe.utils` + * + * @param {Object} object argument which is a composite object, with attributes timeout, treeRoot(optional), resolve & reject + * @property {Number} timeout timeout for any network calls made + * @property {Object} treeRoot the DOM tree to be inspected + * @returns {Object} `axe.utils.queue` with CSSOM assets */ -function filterStyleSheets(styleSheets) { - let sheetHrefs = []; - - return styleSheets.filter(sheet => { - // 1) FILTER > sheets with the same href - let sheetAlreadyExists = false; - if (sheet.href) { - if (!sheetHrefs.includes(sheet.href)) { - sheetHrefs.push(sheet.href); - } else { - sheetAlreadyExists = true; - } - } - // 2) FILTER > media='print' - const isPrintMedia = Array.from(sheet.media).includes('print'); - - return !isPrintMedia && !sheetAlreadyExists; - }); -} +axe.utils.preloadCssom = function preloadCssom({ + timeout, + treeRoot = axe._tree[0] +}) { + /** + * get all `document` and `documentFragment` with in given `tree` + */ + const rootNodes = getAllRootNodesInTree(treeRoot); -/** - * Returns a then(able) queue of CSSStyleSheet(s) - * @method loadCssom - * @private - * @param {Object} options an object with attributes essential to load CSSOM - * @property {Object} options.rootNode document or shadowDOM root document for which to process CSSOM - * @property {Number} options.rootIndex a number representing the index of the document or shadowDOM, used for priority - * @property {String} options.shadowId an id if undefined denotes that given root is a shadowRoot - * @property {Number} options.timeout abort duration for network request - * @param {Function} options.getStyleSheet a utility function to generate a style sheet for a given text content - * @return {Object} queue - */ -function loadCssom(options) { - const { rootNode, rootIndex, shadowId, getStyleSheet } = options; const q = axe.utils.queue(); - const styleSheets = - rootNode.nodeType === 11 && shadowId - ? getSheetsFromShadowDom(rootNode, getStyleSheet) - : Array.from(rootNode.styleSheets); - const sheets = filterStyleSheets(styleSheets); - - sheets.forEach((sheet, sheetIndex) => { - /* eslint max-statements: ["error", 20] */ - const priority = [rootIndex, sheetIndex]; - - try { - // The following line throws an error on cross-origin style sheets: - const cssRules = sheet.cssRules; - const rules = Array.from(cssRules); - if (!rules.length) { - return; - } - - // filter rules that are included by way of @import or nested link - const importRules = rules.filter(r => r.href); - if (!importRules.length) { - q.defer(resolve => - resolve({ - sheet, - isExternal: false, - shadowId, - root: rootNode, - priority - }) - ); - return; - } - // for import rules, fetch via `href` - importRules.forEach(rule => { - q.defer((resolve, reject) => { - getExternalStylesheet({ - resolve, - reject, - url: rule.href, - priority, - ...options - }); - }); - }); + if (!rootNodes.length) { + return q; + } - // in the same sheet - get inline rules in ` and `` references to `CSSStyleSheet` object + .reduce((out, node) => { + const nodeName = node.nodeName.toUpperCase(); + const data = nodeName === 'STYLE' ? node.textContent : node; + const isLink = nodeName === 'LINK'; + const stylesheet = convertDataToStylesheet({ + data, + isLink, + root: rootNode + }); + out.push(stylesheet.sheet); + return out; + }, []) + ); +} + +/** + * Get stylesheets from `document` + * -> filter out stylesheet that are `media=print` + * + * @param {Object} rootNode `document` + * @returns {Array} + */ +function getStylesheetsFromDocument(rootNode) { + return Array.from(rootNode.styleSheets).filter(sheet => + filterMediaIsPrint(sheet.media.mediaText) + ); +} + +/** + * Get all `` and `` attributes + * -> limit to only `style` or `link` attributes with `rel=stylesheet` and `media != print` + * + * @param {Object} node HTMLElement + * @returns {Boolean} + */ +function filerStyleAndLinkAttributesInDocumentFragment(node) { + const nodeName = node.nodeName.toUpperCase(); + const linkHref = node.getAttribute('href'); + const linkRel = node.getAttribute('rel'); + const isLink = + nodeName === 'LINK' && + linkHref && + linkRel && + node.rel.toUpperCase().includes('STYLESHEET'); + const isStyle = nodeName === 'STYLE'; + return isStyle || (isLink && filterMediaIsPrint(node.media)); +} + +/** + * Exclude `link[rel='stylesheet]` attributes where `media=print` + * + * @param {String} media media value eg: 'print' + * @returns {Boolean} + */ +function filterMediaIsPrint(media) { + if (!media) { + return true; + } + return !media.toUpperCase().includes('PRINT'); +} + +/** + * Exclude any duplicate `stylesheets`, that share the same `href` + * + * @param {Array} sheets stylesheets + * @returns {Array} + */ +function filterStylesheetsWithSameHref(sheets) { + let hrefs = []; + return sheets.filter(sheet => { + if (!sheet.href) { + // include sheets without `href` + return true; + } + // if `href` is present, ensure they are not duplicates + if (hrefs.includes(sheet.href)) { + return false; + } + hrefs.push(sheet.href); + return true; + }); +} From c9653a5bce2b3e092f5662b4eb87dbcc9d70c57f Mon Sep 17 00:00:00 2001 From: Wilco Fiers Date: Thu, 7 Mar 2019 19:01:15 +0100 Subject: [PATCH 12/50] fix: Avoid "screen is not defined" error [#1404] (#1415) * fix: Avoid "screen is not defined" error (#1404) * add comments for temp solution --- .../reporters/helpers/get-environment-data.js | 25 ++++++---- .../reporters/helpers/get-environment-data.js | 50 +++++++++++++++++++ 2 files changed, 66 insertions(+), 9 deletions(-) diff --git a/lib/core/reporters/helpers/get-environment-data.js b/lib/core/reporters/helpers/get-environment-data.js index 6284a5cc25..dcce379d60 100644 --- a/lib/core/reporters/helpers/get-environment-data.js +++ b/lib/core/reporters/helpers/get-environment-data.js @@ -4,12 +4,19 @@ * Add information about the environment axe was run in. * @return {Object} */ -helpers.getEnvironmentData = function getEnvironmentData() { - 'use strict'; - var orientation = window.screen - ? screen.msOrientation || - (screen.orientation || screen.mozOrientation || {}) - : {}; +helpers.getEnvironmentData = function getEnvironmentData(win = window) { + // TODO: remove parameter once we are testing axe-core in jsdom and other + // supported environments + const { + screen = {}, + navigator = {}, + location = {}, + innerHeight, + innerWidth + } = win; + + const orientation = + screen.msOrientation || screen.orientation || screen.mozOrientation || {}; return { testEngine: { @@ -21,12 +28,12 @@ helpers.getEnvironmentData = function getEnvironmentData() { }, testEnvironment: { userAgent: navigator.userAgent, - windowWidth: window.innerWidth, - windowHeight: window.innerHeight, + windowWidth: innerWidth, + windowHeight: innerHeight, orientationAngle: orientation.angle, orientationType: orientation.type }, timestamp: new Date().toISOString(), - url: window.location.href + url: location.href }; }; diff --git a/test/core/reporters/helpers/get-environment-data.js b/test/core/reporters/helpers/get-environment-data.js index 315390c469..16f2b7b8be 100644 --- a/test/core/reporters/helpers/get-environment-data.js +++ b/test/core/reporters/helpers/get-environment-data.js @@ -1,5 +1,14 @@ describe('helpers.getEnvironmentData', function() { 'use strict'; + var __audit; + before(function() { + __audit = axe._audit; + axe._audit = { brand: 'Deque' }; + }); + + after(function() { + axe._audit = __audit; + }); it('should return a `testEngine` property', function() { var data = helpers.getEnvironmentData(); @@ -33,4 +42,45 @@ describe('helpers.getEnvironmentData', function() { var data = helpers.getEnvironmentData(); assert.isDefined(data.url); }); + + // TODO: remove or update test once we are testing axe-core in jsdom and + // other supported environments as what this is testing should be done in + // those environment tests + it('gets data from the `win` parameter when passed', function() { + var data = helpers.getEnvironmentData({ + screen: { + orientation: { + type: 'fictional', + angle: 'slanted' + } + }, + navigator: { + userAgent: 'foo' + }, + location: { + href: 'foo://' + }, + innerWidth: 321, + innerHeight: 123 + }); + + delete data.timestamp; + assert.deepEqual(data, { + testEngine: { + name: 'axe-core', + version: axe.version + }, + testRunner: { + name: axe._audit.brand + }, + testEnvironment: { + userAgent: 'foo', + windowWidth: 321, + windowHeight: 123, + orientationAngle: 'slanted', + orientationType: 'fictional' + }, + url: 'foo://' + }); + }); }); From 9556393cab10e2836b1cd6cd0c59bb4c1f231222 Mon Sep 17 00:00:00 2001 From: Stephen Mathieson Date: Thu, 7 Mar 2019 13:09:05 -0500 Subject: [PATCH 13/50] chore(release): 3.2.2 --- CHANGELOG.md | 7 +++++++ bower.json | 2 +- package.json | 2 +- sri-history.json | 4 ++++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d113d922a2..5d28bd68c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. +## [3.2.2](https://github.com/dequelabs/axe-core/compare/v3.2.0...v3.2.2) (2019-03-07) + +### Bug Fixes + +- Avoid "screen is not defined" error [[#1404](https://github.com/dequelabs/axe-core/issues/1404)](<[#1415](https://github.com/dequelabs/axe-core/issues/1415)>) ([c9653a5](https://github.com/dequelabs/axe-core/commit/c9653a5)) +- Avoid require conflict with Cypress [[#1405](https://github.com/dequelabs/axe-core/issues/1405)](<[#1406](https://github.com/dequelabs/axe-core/issues/1406)>) ([30aa570](https://github.com/dequelabs/axe-core/commit/30aa570)) + ## [3.2.1](https://github.com/dequelabs/axe-core/compare/v3.2.0...v3.2.1) (2019-03-06) ### Bug Fixes diff --git a/bower.json b/bower.json index aca3e7aa3c..6ce6f3e522 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "axe-core", - "version": "3.2.1", + "version": "3.2.2", "contributors": [ { "name": "David Sturley", diff --git a/package.json b/package.json index 6d20891131..a77e7d1b80 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "axe-core", "description": "Accessibility engine for automated Web UI testing", - "version": "3.2.1", + "version": "3.2.2", "license": "MPL-2.0", "engines": { "node": ">=4" diff --git a/sri-history.json b/sri-history.json index 1952b456e1..0340e4e847 100644 --- a/sri-history.json +++ b/sri-history.json @@ -130,5 +130,9 @@ "3.2.1": { "axe.js": "sha256-VPX1ngRx0XWqC5BP9XdHoDd8YlbgXGK39cz14GBL9bg=", "axe.min.js": "sha256-ynN9JxvxoI9VpL7IbdTVCUCLhy3N7Ygrnit2r7a2vK8=" + }, + "3.2.2": { + "axe.js": "sha256-ekZaZcmreeOq0/Hm0MYYpjK2k/HfLIBchbdzynX2s1A=", + "axe.min.js": "sha256-WUsm7HQhfTPm48UUbRuQCZ6mXZXpO+trPivOXYelKM0=" } } From 5ecec27ad60ff4666f430b68786edad8e6f458ea Mon Sep 17 00:00:00 2001 From: Stephen Mathieson Date: Thu, 7 Mar 2019 13:11:05 -0500 Subject: [PATCH 14/50] chore: remove extra changelog entry --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d28bd68c4..63587ce5a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,6 @@ All notable changes to this project will be documented in this file. See [standa ### Bug Fixes - Avoid "screen is not defined" error [[#1404](https://github.com/dequelabs/axe-core/issues/1404)](<[#1415](https://github.com/dequelabs/axe-core/issues/1415)>) ([c9653a5](https://github.com/dequelabs/axe-core/commit/c9653a5)) -- Avoid require conflict with Cypress [[#1405](https://github.com/dequelabs/axe-core/issues/1405)](<[#1406](https://github.com/dequelabs/axe-core/issues/1406)>) ([30aa570](https://github.com/dequelabs/axe-core/commit/30aa570)) ## [3.2.1](https://github.com/dequelabs/axe-core/compare/v3.2.0...v3.2.1) (2019-03-06) From e7bebc4b893ee9c65054a4465175c69d730541d2 Mon Sep 17 00:00:00 2001 From: Jey Date: Tue, 12 Mar 2019 14:46:20 +0000 Subject: [PATCH 15/50] chore: run prettier (#1426) --- lib/commons/text/label-text.js | 2 +- lib/commons/text/native-text-methods.js | 2 +- lib/commons/text/subtree-text.js | 6 +- lib/core/utils/preload-cssom.js | 3 +- test/commons/text/label-text.js | 169 +++++++++++------------ test/commons/text/native-text-methods.js | 4 +- test/commons/text/subtree-text.js | 6 +- 7 files changed, 93 insertions(+), 99 deletions(-) diff --git a/lib/commons/text/label-text.js b/lib/commons/text/label-text.js index 8274916559..1954900262 100644 --- a/lib/commons/text/label-text.js +++ b/lib/commons/text/label-text.js @@ -9,7 +9,7 @@ * @return {String} Label text */ text.labelText = function labelText(virtualNode, context = {}) { - const { alreadyProcessed } = text.accessibleTextVirtual + const { alreadyProcessed } = text.accessibleTextVirtual; if ( context.inControlContext || context.inLabelledByContext || diff --git a/lib/commons/text/native-text-methods.js b/lib/commons/text/native-text-methods.js index a4a14d09ad..f588cf3232 100644 --- a/lib/commons/text/native-text-methods.js +++ b/lib/commons/text/native-text-methods.js @@ -95,7 +95,7 @@ text.nativeTextMethods = { * @return {String} Returns ` ` */ singleSpace: function singleSpace() { - return ' ' + return ' '; } }; diff --git a/lib/commons/text/subtree-text.js b/lib/commons/text/subtree-text.js index f1c4c38b75..5818a02d8a 100644 --- a/lib/commons/text/subtree-text.js +++ b/lib/commons/text/subtree-text.js @@ -8,11 +8,11 @@ * @return {String} Accessible text */ text.subtreeText = function subtreeText(virtualNode, context = {}) { - const { alreadyProcessed } = text.accessibleTextVirtual + const { alreadyProcessed } = text.accessibleTextVirtual; context.startNode = context.startNode || virtualNode; const { strict } = context; if ( - alreadyProcessed(virtualNode, context ) || + alreadyProcessed(virtualNode, context) || !aria.namedFromContents(virtualNode, { strict }) ) { return ''; @@ -72,7 +72,7 @@ function appendAccessibleText(contentText, virtualNode, context) { const nodeName = virtualNode.actualNode.nodeName.toUpperCase(); let contentTextAdd = text.accessibleTextVirtual(virtualNode, context); if (!contentTextAdd) { - return contentText + return contentText; } if (!phrasingElements.includes(nodeName)) { diff --git a/lib/core/utils/preload-cssom.js b/lib/core/utils/preload-cssom.js index c95f12181c..180a502360 100644 --- a/lib/core/utils/preload-cssom.js +++ b/lib/core/utils/preload-cssom.js @@ -1,10 +1,9 @@ /** - * NOTE: + * NOTE: * this `eslint` rule is disabled because of calling `getStyleSheetFactory` before it is defined (further below). */ /* eslint no-use-before-define: 0 */ - /** * Given a rootNode - construct CSSOM * -> get all source nodes (document & document fragments) within given root node diff --git a/test/commons/text/label-text.js b/test/commons/text/label-text.js index efb763fe2a..2d5ac9ef9e 100644 --- a/test/commons/text/label-text.js +++ b/test/commons/text/label-text.js @@ -1,125 +1,120 @@ describe('text.labelText', function() { - var labelText = axe.commons.text.labelText; var queryFixture = axe.testUtils.queryFixture; - it('returns the text of an implicit label', function () { + it('returns the text of an implicit label', function() { var target = queryFixture( - '' - ) - assert.equal(labelText(target), 'My implicit label') - }) + '' + ); + assert.equal(labelText(target), 'My implicit label'); + }); - it('returns the text of an explicit label', function () { + it('returns the text of an explicit label', function() { var target = queryFixture( - '' + - '' - ) - assert.equal(labelText(target), 'My explicit label') - }) + '' + '' + ); + assert.equal(labelText(target), 'My explicit label'); + }); - it('ignores the text of nested implicit labels', function () { + it('ignores the text of nested implicit labels', function() { var target = queryFixture( '' - ) - assert.equal(labelText(target), 'My inner label') - }) + '' + + '' + ); + assert.equal(labelText(target), 'My inner label'); + }); - it('concatinates multiple explicit labels', function () { + it('concatinates multiple explicit labels', function() { var target = queryFixture( '' + - '' + - '' - ) - assert.equal(labelText(target), 'My label 1 My label 2') - }) + '' + + '' + ); + assert.equal(labelText(target), 'My label 1 My label 2'); + }); - it('concatinates explicit and implicit labels', function () { + it('concatinates explicit and implicit labels', function() { var target = queryFixture( '' + - '' - ) - assert.equal(labelText(target), 'My explicit label My implicit label') - }) + '' + ); + assert.equal(labelText(target), 'My explicit label My implicit label'); + }); - it('returns label text in the DOM order', function () { + it('returns label text in the DOM order', function() { var target = queryFixture( '' + - '' + - '' - ) - assert.equal(labelText(target), 'Label 1 My implicit Label 2 Label 3') - }) + '' + + '' + ); + assert.equal(labelText(target), 'Label 1 My implicit Label 2 Label 3'); + }); - it('does not return the same label twice', function () { + it('does not return the same label twice', function() { var target = queryFixture( '' - ) - assert.equal(labelText(target), 'My implicit and explicit label') - }) + 'My implicit and explicit label' + + '' + + '' + ); + assert.equal(labelText(target), 'My implicit and explicit label'); + }); - it('ignores the value of a textbox', function () { + it('ignores the value of a textbox', function() { var target = queryFixture( '' - ) - assert.equal(labelText(target), 'My label') - }) + '' + + '' + ); + assert.equal(labelText(target), 'My label'); + }); - it('ignores the content of a textarea', function () { + it('ignores the content of a textarea', function() { var target = queryFixture( '