From b98c156a11f149bf2faa8d3124367e13164e3db4 Mon Sep 17 00:00:00 2001 From: michael-siek Date: Thu, 9 Jul 2020 19:13:59 -0400 Subject: [PATCH 1/3] fix(cli): pass in string into `executeAsyncScript` instead of function --- packages/cli/lib/axe-test-urls.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/cli/lib/axe-test-urls.js b/packages/cli/lib/axe-test-urls.js index 3132a4e5..c010b5b8 100644 --- a/packages/cli/lib/axe-test-urls.js +++ b/packages/cli/lib/axe-test-urls.js @@ -28,13 +28,14 @@ function testPages(urls, config, events) { .get(currentUrl) .then(function () { // Wait for the page to be loaded - return driver.executeAsyncScript(function (callback) { - const script = document.createElement('script'); - script.innerHTML = - 'document.documentElement.classList.add("deque-axe-is-ready");'; + // https://github.com/vercel/pkg/issues/676 + return driver.executeAsyncScript(` + const callback = arguments[arguments.length-1] + const script = document.createElement('script') + script.innerHTML = 'document.documentElement.classList.add("deque-axe-is-ready");' document.documentElement.appendChild(script); callback(); - }); + `); }) .then(function () { return driver.wait( From 54e80ca1be5b228a5b93648029ab68fa05356290 Mon Sep 17 00:00:00 2001 From: michael-siek Date: Sun, 12 Jul 2020 21:14:06 -0400 Subject: [PATCH 2/3] add comment to function#toString --- packages/cli/lib/axe-test-urls.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/cli/lib/axe-test-urls.js b/packages/cli/lib/axe-test-urls.js index c010b5b8..4e97b7c6 100644 --- a/packages/cli/lib/axe-test-urls.js +++ b/packages/cli/lib/axe-test-urls.js @@ -27,8 +27,8 @@ function testPages(urls, config, events) { driver .get(currentUrl) .then(function () { - // Wait for the page to be loaded - // https://github.com/vercel/pkg/issues/676 + // https://github.com/vercel/pkg/issues/676 + // we need to pass a string vs a function so we manually stringified the function return driver.executeAsyncScript(` const callback = arguments[arguments.length-1] const script = document.createElement('script') From c5bf5780510ff379a24cc6a969b2444b72ba244b Mon Sep 17 00:00:00 2001 From: Michael <45568605+michael-siek@users.noreply.github.com> Date: Mon, 13 Jul 2020 10:37:22 -0400 Subject: [PATCH 3/3] Update packages/cli/lib/axe-test-urls.js Co-authored-by: Stephen Mathieson --- packages/cli/lib/axe-test-urls.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/cli/lib/axe-test-urls.js b/packages/cli/lib/axe-test-urls.js index 4e97b7c6..18c65392 100644 --- a/packages/cli/lib/axe-test-urls.js +++ b/packages/cli/lib/axe-test-urls.js @@ -30,8 +30,8 @@ function testPages(urls, config, events) { // https://github.com/vercel/pkg/issues/676 // we need to pass a string vs a function so we manually stringified the function return driver.executeAsyncScript(` - const callback = arguments[arguments.length-1] - const script = document.createElement('script') + const callback = arguments[arguments.length - 1]; + const script = document.createElement('script'); script.innerHTML = 'document.documentElement.classList.add("deque-axe-is-ready");' document.documentElement.appendChild(script); callback();