@axe-core/watcher 3.16.0-next.acef2936 → 3.16.0-next.b08463c8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. package/dist/Controller.d.ts +1 -1
  2. package/dist/Controller.js +33 -34
  3. package/dist/Controller.js.map +1 -1
  4. package/dist/index.d.ts +1 -1
  5. package/dist/index.js.map +1 -1
  6. package/dist/playwright.d.ts +1 -1
  7. package/dist/playwright.js +2 -1
  8. package/dist/playwright.js.map +1 -1
  9. package/dist/playwrightTest.d.ts +9 -3
  10. package/dist/playwrightTest.js +8 -5
  11. package/dist/playwrightTest.js.map +1 -1
  12. package/extension/background.js +1 -1
  13. package/extension/content.js +1 -1
  14. package/package.json +1 -1
  15. package/dist/testutils.d.ts +0 -13
  16. package/dist/testutils.js +0 -50
  17. package/dist/testutils.js.map +0 -1
  18. package/dist/utils/assertVariablesWereWritten.test.d.ts +0 -1
  19. package/dist/utils/assertVariablesWereWritten.test.js +0 -31
  20. package/dist/utils/assertVariablesWereWritten.test.js.map +0 -1
  21. package/dist/utils/headlessNotSupportedError.test.d.ts +0 -1
  22. package/dist/utils/headlessNotSupportedError.test.js +0 -21
  23. package/dist/utils/headlessNotSupportedError.test.js.map +0 -1
  24. package/dist/utils/initializeSession.test.d.ts +0 -1
  25. package/dist/utils/initializeSession.test.js +0 -177
  26. package/dist/utils/initializeSession.test.js.map +0 -1
  27. package/dist/utils/isValidExcludePattern.test.d.ts +0 -1
  28. package/dist/utils/isValidExcludePattern.test.js +0 -17
  29. package/dist/utils/isValidExcludePattern.test.js.map +0 -1
  30. package/dist/utils/mergeChromeArgs.test.d.ts +0 -1
  31. package/dist/utils/mergeChromeArgs.test.js +0 -257
  32. package/dist/utils/mergeChromeArgs.test.js.map +0 -1
  33. package/dist/utils/proxyHandlers.test.d.ts +0 -1
  34. package/dist/utils/proxyHandlers.test.js +0 -27
  35. package/dist/utils/proxyHandlers.test.js.map +0 -1
  36. package/dist/utils/validateAxeRunContext.test.d.ts +0 -1
  37. package/dist/utils/validateAxeRunContext.test.js +0 -97
  38. package/dist/utils/validateAxeRunContext.test.js.map +0 -1
  39. package/dist/utils/validateAxeRunOptions.test.d.ts +0 -1
  40. package/dist/utils/validateAxeRunOptions.test.js +0 -215
  41. package/dist/utils/validateAxeRunOptions.test.js.map +0 -1
  42. package/dist/utils/writeVariables.test.d.ts +0 -1
  43. package/dist/utils/writeVariables.test.js +0 -200
  44. package/dist/utils/writeVariables.test.js.map +0 -1
@@ -8,7 +8,7 @@ declare abstract class Controller {
8
8
  protected isStopped: boolean;
9
9
  protected debugLogger: Debugger;
10
10
  constructor({ debugLoggerName }: ControllerParams);
11
- start(): Promise<void>;
11
+ start(): void;
12
12
  stop(): Promise<void>;
13
13
  analyze({ __Method, __UserRequestedAnalyze }?: {
14
14
  __Method?: string;
@@ -3,7 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const updateAutoAnalyze_1 = __importDefault(require("./utils/updateAutoAnalyze"));
7
6
  const sendResultsToServer_1 = __importDefault(require("./sendResultsToServer"));
8
7
  const createDebugger_1 = __importDefault(require("./createDebugger"));
9
8
  class Controller {
@@ -11,44 +10,39 @@ class Controller {
11
10
  this.isStopped = false;
12
11
  this.debugLogger = (0, createDebugger_1.default)(debugLoggerName);
13
12
  }
14
- async start() {
15
- (0, updateAutoAnalyze_1.default)(true);
13
+ start() {
14
+ this.debugLogger(`Start: Invoked`);
16
15
  this.isStopped = false;
17
- await this.executeScript(() => {
18
- if (!['http:', 'https:', 'file:'].includes(window.location.protocol)) {
19
- return Promise.resolve();
20
- }
21
- return new Promise(resolve => {
22
- const fn = () => {
23
- window.removeEventListener('axe:start-auto-mode-done', fn);
24
- resolve();
25
- };
26
- window.addEventListener('axe:start-auto-mode-done', fn);
27
- const event = new CustomEvent('axe:start-auto-mode');
28
- window.dispatchEvent(event);
29
- });
30
- });
31
16
  }
32
17
  async stop() {
33
- (0, updateAutoAnalyze_1.default)(false);
34
- this.isStopped = true;
35
- await this.executeScript(() => {
18
+ this.debugLogger(`Stop: Invoked (${this.isStopped ? 'not analyzing' : 'may analyze implicitly'})`);
19
+ if (this.isStopped) {
20
+ return;
21
+ }
22
+ const result = await this.executeScript(() => {
36
23
  if (!['http:', 'https:', 'file:'].includes(window.location.protocol)) {
37
- return Promise.resolve();
24
+ return Promise.resolve({ message: 'Skipped - Invalid protocol' });
38
25
  }
39
26
  return new Promise(resolve => {
40
- const fn = () => {
41
- window.removeEventListener('axe:stop-auto-mode-done', fn);
42
- resolve();
27
+ const fn = (event) => {
28
+ window.removeEventListener('axe:manual-mode-analyze-done', fn);
29
+ resolve(event.detail);
43
30
  };
44
- window.addEventListener('axe:stop-auto-mode-done', fn);
45
- const event = new CustomEvent('axe:stop-auto-mode');
31
+ window.addEventListener('axe:manual-mode-analyze-done', fn);
32
+ const event = new CustomEvent('axe:manual-mode-analyze', {
33
+ detail: { userRequestedAnalyze: false }
34
+ });
46
35
  window.dispatchEvent(event);
47
36
  });
48
37
  });
38
+ this.debugLogger(`Stop: ${result.message}`);
39
+ this.isStopped = true;
49
40
  }
50
41
  async analyze({ __Method, __UserRequestedAnalyze = true } = {}) {
51
- this.debugLogger(`Analyze: Invoked${__Method ? ` - ${__Method}` : ''}`);
42
+ this.debugLogger(`Analyze: Invoked${__Method ? ` - ${__Method}` : ''}`, {
43
+ isStopped: this.isStopped,
44
+ __UserRequestedAnalyze
45
+ });
52
46
  if (this.isStopped && !__UserRequestedAnalyze) {
53
47
  this.debugLogger('Analyze: Skipped', {
54
48
  isStopped: this.isStopped,
@@ -56,7 +50,7 @@ class Controller {
56
50
  });
57
51
  return;
58
52
  }
59
- const result = await this.executeScript((userRequestedAnalyze) => {
53
+ const result = await this.executeScript(({ userRequestedAnalyze, isStopped }) => {
60
54
  if (!['http:', 'https:', 'file:'].includes(window.location.protocol)) {
61
55
  return Promise.resolve({ message: 'Skipped - Invalid protocol' });
62
56
  }
@@ -67,16 +61,19 @@ class Controller {
67
61
  };
68
62
  window.addEventListener('axe:manual-mode-analyze-done', fn);
69
63
  const event = new CustomEvent('axe:manual-mode-analyze', {
70
- detail: { userRequestedAnalyze }
64
+ detail: { userRequestedAnalyze, isStopped }
71
65
  });
72
66
  window.dispatchEvent(event);
73
67
  });
74
- }, __UserRequestedAnalyze);
68
+ }, {
69
+ userRequestedAnalyze: __UserRequestedAnalyze,
70
+ isStopped: this.isStopped
71
+ });
75
72
  this.debugLogger(`Analyze: ${result.message}`);
76
73
  }
77
74
  async flush() {
78
- this.debugLogger('Flush: Invoked (may analyze implicitly)');
79
- const results = await this.executeScript(() => {
75
+ this.debugLogger(`Flush: Invoked (${this.isStopped ? 'auto-analysis stopped' : 'may analyze implicitly'})`);
76
+ const results = await this.executeScript((isStopped) => {
80
77
  if (!['http:', 'https:', 'file:'].includes(window.location.protocol)) {
81
78
  return Promise.resolve([]);
82
79
  }
@@ -92,10 +89,12 @@ class Controller {
92
89
  };
93
90
  window.addEventListener('axe:result', onAxeResult);
94
91
  window.addEventListener('axe:flush-end', onFlushEnd);
95
- const event = new CustomEvent('axe:flush-start');
92
+ const event = new CustomEvent('axe:flush-start', {
93
+ detail: { isStopped }
94
+ });
96
95
  window.dispatchEvent(event);
97
96
  });
98
- });
97
+ }, this.isStopped);
99
98
  this.debugLogger(`Flush: Received ${results.length} results`);
100
99
  await (0, sendResultsToServer_1.default)({
101
100
  results,
@@ -1 +1 @@
1
- {"version":3,"file":"Controller.js","sourceRoot":"","sources":["../src/Controller.ts"],"names":[],"mappings":";;;;;AAAA,kFAAyD;AACzD,gFAAwE;AACxE,sEAA6C;AAQ7C,MAAe,UAAU;IASvB,YAAY,EAAE,eAAe,EAAoB;QAHvC,cAAS,GAAG,KAAK,CAAA;QAIzB,IAAI,CAAC,WAAW,GAAG,IAAA,wBAAc,EAAC,eAAe,CAAC,CAAA;IACpD,CAAC;IAEM,KAAK,CAAC,KAAK;QAChB,IAA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W;SAC9B,CAAC,CAAA;QACF,IAAI,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAA;IACrC,CAAC;CACF;AAED,kBAAe,UAAU,CAAA"}
package/dist/index.d.ts CHANGED
@@ -3,5 +3,5 @@ export { puppeteerConfig, PuppeteerController, wrapPuppeteer, wrapPuppeteerPage
3
3
  export { wdioConfig, wdioTestRunner, WdioController, wrapWdio } from './wdio';
4
4
  export { webdriverConfig, WebdriverController, wrapWebdriver } from './webdriver';
5
5
  export { playwrightConfig, PlaywrightController, wrapPlaywright, wrapPlaywrightPage } from './playwright';
6
- export { default as playwrightTest } from './playwrightTest';
6
+ export { default as playwrightTest, type PageWithAxeWatcher as PlaywrightTestPageWithAxeWatcher } from './playwrightTest';
7
7
  export { cypressConfig } from './cypress';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,oDAAoD;;;;;;AAEpD,yCAKoB;AAJlB,4GAAA,eAAe,OAAA;AACf,gHAAA,mBAAmB,OAAA;AACnB,0GAAA,aAAa,OAAA;AACb,8GAAA,iBAAiB,OAAA;AAEnB,+BAA6E;AAApE,kGAAA,UAAU,OAAA;AAAE,sGAAA,cAAc,OAAA;AAAE,sGAAA,cAAc,OAAA;AAAE,gGAAA,QAAQ,OAAA;AAC7D,yCAIoB;AAHlB,4GAAA,eAAe,OAAA;AACf,gHAAA,mBAAmB,OAAA;AACnB,0GAAA,aAAa,OAAA;AAEf,2CAKqB;AAJnB,8GAAA,gBAAgB,OAAA;AAChB,kHAAA,oBAAoB,OAAA;AACpB,4GAAA,cAAc,OAAA;AACd,gHAAA,kBAAkB,OAAA;AAEpB,mDAA4D;AAAnD,iIAAA,OAAO,OAAkB;AAClC,qCAAyC;AAAhC,wGAAA,aAAa,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,oDAAoD;;;;;;AAEpD,yCAKoB;AAJlB,4GAAA,eAAe,OAAA;AACf,gHAAA,mBAAmB,OAAA;AACnB,0GAAA,aAAa,OAAA;AACb,8GAAA,iBAAiB,OAAA;AAEnB,+BAA6E;AAApE,kGAAA,UAAU,OAAA;AAAE,sGAAA,cAAc,OAAA;AAAE,sGAAA,cAAc,OAAA;AAAE,gGAAA,QAAQ,OAAA;AAC7D,yCAIoB;AAHlB,4GAAA,eAAe,OAAA;AACf,gHAAA,mBAAmB,OAAA;AACnB,0GAAA,aAAa,OAAA;AAEf,2CAKqB;AAJnB,8GAAA,gBAAgB,OAAA;AAChB,kHAAA,oBAAoB,OAAA;AACpB,4GAAA,cAAc,OAAA;AACd,gHAAA,kBAAkB,OAAA;AAEpB,mDAGyB;AAFvB,iIAAA,OAAO,OAAkB;AAG3B,qCAAyC;AAAhC,wGAAA,aAAa,OAAA"}
@@ -11,7 +11,7 @@ export type Options = Configuration & LaunchOptions;
11
11
  export declare function playwrightConfig(opts: Options): LaunchOptions;
12
12
  export declare class PlaywrightController extends Controller {
13
13
  private driver;
14
- constructor(driver: Page);
14
+ constructor(driver: Page, isStopped?: boolean);
15
15
  protected executeScript<T>(fn: string | (() => Promise<T>), ...args: unknown[]): Promise<T>;
16
16
  }
17
17
  /**
@@ -26,10 +26,11 @@ function playwrightConfig(opts) {
26
26
  };
27
27
  }
28
28
  class PlaywrightController extends Controller_1.default {
29
- constructor(driver) {
29
+ constructor(driver, isStopped = false) {
30
30
  super({ debugLoggerName: 'PlaywrightController' });
31
31
  (0, assertVariablesWereWritten_1.assertVariablesWereWritten)('Playwright', 'playwrightConfig()');
32
32
  this.driver = driver;
33
+ this.isStopped = isStopped;
33
34
  }
34
35
  async executeScript(fn, ...args) {
35
36
  const [arg] = args || [];
@@ -1 +1 @@
1
- {"version":3,"file":"playwright.js","sourceRoot":"","sources":["../src/playwright.ts"],"names":[],"mappings":";;;;;;AAgBA,4CAoBC;AAnCD,8DAAqC;AACrC,iFAA6E;AAC7E,8EAAqD;AAC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CAAC,CAAA;QACrD,OAAO,MAAM,CAAA;IACf,CAAC;CACF;AApBD,oDAoBC;AAKM,MAAM,cAAc,GAAG,CAE5B,cAA8B,EAE9B,oBAA0C,EAC1B,EAAE;IAClB,MAAM,IAAI,KAAK,CAAC;;;;;;GAMf,CAAC,CAAA;AACJ,CAAC,CAAA;AAbY,QAAA,cAAc,kBAa1B;AAED,2DAAqE;AAA5D,wHAAA,QAAQ,OAAsB"}
@@ -1,6 +1,12 @@
1
- import type { TestType, PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions, Expect } from '@playwright/test';
2
- import { type Options } from './playwright';
3
- type Test = TestType<PlaywrightTestArgs & PlaywrightTestOptions, PlaywrightWorkerArgs & PlaywrightWorkerOptions>;
1
+ import type { TestType, Page, PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions, Expect } from '@playwright/test';
2
+ import { PlaywrightController, type Options } from './playwright';
3
+ export type PageWithAxeWatcher = Page & {
4
+ axeWatcher: PlaywrightController;
5
+ };
6
+ type Test = TestType<PlaywrightTestArgs & PlaywrightTestOptions & Fixtures, PlaywrightWorkerArgs & PlaywrightWorkerOptions>;
7
+ type Fixtures = {
8
+ page: PageWithAxeWatcher;
9
+ };
4
10
  interface ReturnValue {
5
11
  test: Test;
6
12
  expect: Expect;
@@ -18,6 +18,7 @@ const playwrightTest = (options) => {
18
18
  catch (error) {
19
19
  throw new Error('Unable to load @playwright/test: ' + error.message);
20
20
  }
21
+ const isStopped = typeof axe.autoAnalyze === 'undefined' ? false : !axe.autoAnalyze;
21
22
  (0, writeVariables_1.default)(axe);
22
23
  const test = base.extend({
23
24
  context: async ({}, use) => {
@@ -31,14 +32,16 @@ const playwrightTest = (options) => {
31
32
  await context.close();
32
33
  },
33
34
  page: async ({ page }, use) => {
34
- controller = new playwright_1.PlaywrightController(page);
35
- page = (0, playwright_1.wrapPlaywrightPage)(page, controller);
35
+ controller = page.axeWatcher;
36
+ if (!controller) {
37
+ controller = new playwright_1.PlaywrightController(page, isStopped);
38
+ page.axeWatcher = controller;
39
+ page = (0, playwright_1.wrapPlaywrightPage)(page, controller);
40
+ }
36
41
  await use(page);
42
+ await controller.flush();
37
43
  }
38
44
  });
39
- test.afterEach(async () => {
40
- await (controller === null || controller === void 0 ? void 0 : controller.flush());
41
- });
42
45
  const expect = test.expect;
43
46
  return { test, expect };
44
47
  };
@@ -1 +1 @@
1
- {"version":3,"file":"playwrightTest.js","sourceRoot":"","sources":["../src/playwrightTest.ts"],"names":[],"mappings":";;;;;AAUA,6CAIqB;AACrB,8EAAqD;AACrD,4EAAmD;AAoBnD,MAAM,cAAc,GAAG,CAAC,OAAgB,EAAe,EAAE;IACvD,IAAI,UAAU,GAAgC,IAAI,CAAA;IAClD,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,EAAE,GAAG,OAAO,CAAA;IAIlC,IAAI,IAAU,CAAA;IACd,IAAI,QAAsC,CAAA;IAC1C,IAAI,CAAC;QAEH,CAAC;QAAA,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAA;IAC3D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,mCAAmC,GAAI,KAAe,CAAC,OAAO,CAC/D,CAAA;IACH,CAAC;IAED,IAAA,wBAAc,EAAC,GAAG,CAAC,CAAA;IAEnB,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC;QAMvB,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE;YACzB,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,uBAAuB,CAAC,EAAE,EAAE;gBACzD,GAAG,MAAM;gBACT,IAAI,EAAE,IAAA,yBAAe,EAAC,MAAM,CAAC,IAAI,IAAI,EAAE,EAAE;oBACvC,sBAAsB,EAAE,IAAI;iBAC7B,CAAC;aACH,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