Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@axe-core/watcher

Package Overview
Dependencies
Maintainers
0
Versions
897
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@axe-core/watcher - npm Package Compare versions

Comparing version 3.16.0-next.5077328b to 3.16.0-next.51372f65

dist/utils/assertVariablesWereWritten.d.ts

2

dist/Controller.d.ts

@@ -11,3 +11,3 @@ import type { Debugger } from 'debug';

constructor({ debugLoggerName }: ControllerParams);
start(): Promise<void>;
start(): void;
stop(): Promise<void>;

@@ -14,0 +14,0 @@ analyze({ __Method, __UserRequestedAnalyze }?: {

@@ -6,3 +6,2 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const updateAutoAnalyze_1 = __importDefault(require("./utils/updateAutoAnalyze"));
const sendResultsToServer_1 = __importDefault(require("./sendResultsToServer"));

@@ -15,40 +14,35 @@ const createDebugger_1 = __importDefault(require("./createDebugger"));

}
async start() {
(0, updateAutoAnalyze_1.default)(true);
start() {
this.debugLogger(`Start: Invoked`);
this.isStopped = false;
await this.executeScript(() => {
if (!['http:', 'https:', 'file:'].includes(window.location.protocol)) {
return Promise.resolve();
}
return new Promise(resolve => {
const fn = () => {
window.removeEventListener('axe:start-auto-mode-done', fn);
resolve();
};
window.addEventListener('axe:start-auto-mode-done', fn);
const event = new CustomEvent('axe:start-auto-mode');
window.dispatchEvent(event);
});
});
}
async stop() {
(0, updateAutoAnalyze_1.default)(false);
this.isStopped = true;
await this.executeScript(() => {
this.debugLogger(`Stop: Invoked (${this.isStopped ? 'not analyzing' : 'may analyze implicitly'})`);
if (this.isStopped) {
return;
}
const result = await this.executeScript(() => {
if (!['http:', 'https:', 'file:'].includes(window.location.protocol)) {
return Promise.resolve();
return Promise.resolve({ message: 'Skipped - Invalid protocol' });
}
return new Promise(resolve => {
const fn = () => {
window.removeEventListener('axe:stop-auto-mode-done', fn);
resolve();
const fn = (event) => {
window.removeEventListener('axe:manual-mode-analyze-done', fn);
resolve(event.detail);
};
window.addEventListener('axe:stop-auto-mode-done', fn);
const event = new CustomEvent('axe:stop-auto-mode');
window.addEventListener('axe:manual-mode-analyze-done', fn);
const event = new CustomEvent('axe:manual-mode-analyze', {
detail: { userRequestedAnalyze: false }
});
window.dispatchEvent(event);
});
});
this.debugLogger(`Stop: ${result.message}`);
this.isStopped = true;
}
async analyze({ __Method, __UserRequestedAnalyze = true } = {}) {
this.debugLogger(`Analyze: Invoked${__Method ? ` - ${__Method}` : ''}`);
this.debugLogger(`Analyze: Invoked${__Method ? ` - ${__Method}` : ''}`, {
isStopped: this.isStopped,
__UserRequestedAnalyze
});
if (this.isStopped && !__UserRequestedAnalyze) {

@@ -61,4 +55,10 @@ this.debugLogger('Analyze: Skipped', {

}
const result = await this.executeScript((userRequestedAnalyze) => {
const result = await this.executeScript(({ userRequestedAnalyze, isStopped }) => {
if (!['http:', 'https:', 'file:'].includes(window.location.protocol)) {
if (userRequestedAnalyze) {
return Promise.resolve({
message: `Cannot perform analysis - invalid protocol: ${window.location.protocol}`,
error: true
});
}
return Promise.resolve({ message: 'Skipped - Invalid protocol' });

@@ -73,12 +73,18 @@ }

const event = new CustomEvent('axe:manual-mode-analyze', {
detail: { userRequestedAnalyze }
detail: { userRequestedAnalyze, isStopped }
});
window.dispatchEvent(event);
});
}, __UserRequestedAnalyze);
}, {
userRequestedAnalyze: __UserRequestedAnalyze,
isStopped: this.isStopped
});
this.debugLogger(`Analyze: ${result.message}`);
if (result.error) {
throw new Error(result.message);
}
}
async flush() {
this.debugLogger('Flush: Invoked (may analyze implicitly)');
const results = await this.executeScript(() => {
this.debugLogger(`Flush: Invoked (${this.isStopped ? 'auto-analysis stopped' : 'may analyze implicitly'})`);
const results = await this.executeScript((isStopped) => {
if (!['http:', 'https:', 'file:'].includes(window.location.protocol)) {

@@ -99,6 +105,8 @@ return Promise.resolve([]);

window.addEventListener('axe:flush-end', onFlushEnd);
const event = new CustomEvent('axe:flush-start');
const event = new CustomEvent('axe:flush-start', {
detail: { isStopped }
});
window.dispatchEvent(event);
});
});
}, this.isStopped);
this.debugLogger(`Flush: Received ${results.length} results`);

@@ -105,0 +113,0 @@ await (0, sendResultsToServer_1.default)({

@@ -14,2 +14,3 @@ "use strict";

const createDebugger_1 = __importDefault(require("./createDebugger"));
const checkUserArgs_1 = require("./utils/checkUserArgs");
const debugLogger = (0, createDebugger_1.default)('CypressController');

@@ -92,2 +93,3 @@ exports.cypressConfigRunFlag = '__AXE_WATCHER_CYPRESS_CONFIG_RUN';

const existingArgs = launchOptions.args;
(0, checkUserArgs_1.checkUserArgs)(existingArgs);
launchOptions.args = (0, mergeChromeArgs_1.default)(existingArgs, {

@@ -94,0 +96,0 @@ disableOtherExtensions: false

@@ -124,2 +124,5 @@ "use strict";

});
if (userRequestedAnalyze) {
return Promise.reject(new Error(`Cannot perform manual analysis - invalid protocol: ${win.location.protocol}`));
}
return Promise.resolve({

@@ -126,0 +129,0 @@ message: `Skipped - Invalid protocol`,

@@ -6,3 +6,3 @@ /*! Copyright Deque 2021-2023 All Rights Reserved */

export { playwrightConfig, PlaywrightController, wrapPlaywright, wrapPlaywrightPage } from './playwright';
export { default as playwrightTest } from './playwrightTest';
export { default as playwrightTest, type PageWithAxeWatcher as PlaywrightTestPageWithAxeWatcher } from './playwrightTest';
export { cypressConfig } from './cypress';

@@ -14,3 +14,3 @@ import type { LaunchOptions, Page, BrowserContext } from 'playwright-core';

private driver;
constructor(driver: Page);
constructor(driver: Page, isStopped?: boolean);
protected executeScript<T>(fn: string | (() => Promise<T>), ...args: unknown[]): Promise<T>;

@@ -17,0 +17,0 @@ }

@@ -12,5 +12,8 @@ "use strict";

const writeVariables_1 = __importDefault(require("./utils/writeVariables"));
const checkUserArgs_1 = require("./utils/checkUserArgs");
const assertVariablesWereWritten_1 = require("./utils/assertVariablesWereWritten");
function playwrightConfig(opts) {
const { axe, ...config } = opts;
let { args = [] } = config;
(0, checkUserArgs_1.checkUserArgs)(args);
(0, writeVariables_1.default)(axe);

@@ -29,5 +32,7 @@ if (config.headless) {

class PlaywrightController extends Controller_1.default {
constructor(driver) {
constructor(driver, isStopped = false) {
super({ debugLoggerName: 'PlaywrightController' });
(0, assertVariablesWereWritten_1.assertVariablesWereWritten)('Playwright', 'playwrightConfig()');
this.driver = driver;
this.isStopped = isStopped;
}

@@ -34,0 +39,0 @@ async executeScript(fn, ...args) {

@@ -1,4 +0,10 @@

import type { TestType, PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions, Expect } from '@playwright/test';
import { type Options } from './playwright';
type Test = TestType<PlaywrightTestArgs & PlaywrightTestOptions, PlaywrightWorkerArgs & PlaywrightWorkerOptions>;
import type { TestType, Page, PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions, Expect } from '@playwright/test';
import { PlaywrightController, type Options } from './playwright';
export type PageWithAxeWatcher = Page & {
axeWatcher: PlaywrightController;
};
type Test = TestType<PlaywrightTestArgs & PlaywrightTestOptions & Fixtures, PlaywrightWorkerArgs & PlaywrightWorkerOptions>;
type Fixtures = {
page: PageWithAxeWatcher;
};
interface ReturnValue {

@@ -5,0 +11,0 @@ test: Test;

@@ -9,2 +9,3 @@ "use strict";

const writeVariables_1 = __importDefault(require("./utils/writeVariables"));
const checkUserArgs_1 = require("./utils/checkUserArgs");
const playwrightTest = (options) => {

@@ -22,2 +23,4 @@ let controller = null;

}
const isStopped = typeof axe.autoAnalyze === 'undefined' ? false : !axe.autoAnalyze;
(0, checkUserArgs_1.checkUserArgs)(config.args || []);
(0, writeVariables_1.default)(axe);

@@ -36,10 +39,12 @@ const test = base.extend({

page: async ({ page }, use) => {
controller = new playwright_1.PlaywrightController(page);
page = (0, playwright_1.wrapPlaywrightPage)(page, controller);
controller = page.axeWatcher;
if (!controller) {
controller = new playwright_1.PlaywrightController(page, isStopped);
page.axeWatcher = controller;
page = (0, playwright_1.wrapPlaywrightPage)(page, controller);
}
await use(page);
await controller.flush();
}
});
test.afterEach(async () => {
await (controller === null || controller === void 0 ? void 0 : controller.flush());
});
const expect = test.expect;

@@ -46,0 +51,0 @@ return { test, expect };

@@ -12,2 +12,4 @@ "use strict";

const writeVariables_1 = __importDefault(require("./utils/writeVariables"));
const checkUserArgs_1 = require("./utils/checkUserArgs");
const assertVariablesWereWritten_1 = require("./utils/assertVariablesWereWritten");
function headlessNotSupportedError(config) {

@@ -25,2 +27,3 @@ if (!(config === null || config === void 0 ? void 0 : config.headless) || config.headless === 'new') {

let { args = [] } = config;
(0, checkUserArgs_1.checkUserArgs)(args);
(0, writeVariables_1.default)(axe);

@@ -39,2 +42,3 @@ headlessNotSupportedError(config);

super({ debugLoggerName: 'PuppeteerController' });
(0, assertVariablesWereWritten_1.assertVariablesWereWritten)('Puppeteer', 'puppeteerConfig()');
this.driver = driver;

@@ -41,0 +45,0 @@ }

@@ -15,2 +15,4 @@ "use strict";

const mergeChromeArgs_1 = __importDefault(require("./utils/mergeChromeArgs"));
const checkUserArgs_1 = require("./utils/checkUserArgs");
const assertVariablesWereWritten_1 = require("./utils/assertVariablesWereWritten");
const noop = () => {

@@ -26,2 +28,3 @@ };

}
(0, checkUserArgs_1.checkUserArgs)(args);
return {

@@ -62,2 +65,3 @@ ...options,

}
(0, checkUserArgs_1.checkUserArgs)(args);
chromeOpts.args = (0, mergeChromeArgs_1.default)(args, { disableOtherExtensions: false });

@@ -89,2 +93,3 @@ const { onPrepare = noop, onComplete = noop } = config;

super({ debugLoggerName: 'WdioController' });
(0, assertVariablesWereWritten_1.assertVariablesWereWritten)('WDIO', 'wdioConfig()');
this.driver = driver;

@@ -91,0 +96,0 @@ }

@@ -12,2 +12,4 @@ "use strict";

const mergeChromeArgs_1 = __importDefault(require("./utils/mergeChromeArgs"));
const checkUserArgs_1 = require("./utils/checkUserArgs");
const assertVariablesWereWritten_1 = require("./utils/assertVariablesWereWritten");
var webdriverWrapping_1 = require("./webdriverWrapping");

@@ -22,2 +24,3 @@ Object.defineProperty(exports, "wrapWebdriver", { enumerable: true, get: function () { return webdriverWrapping_1.wrapDriver; } });

const existingArgs = (((_a = opts === null || opts === void 0 ? void 0 : opts.options_) === null || _a === void 0 ? void 0 : _a.args) || []);
(0, checkUserArgs_1.checkUserArgs)(existingArgs);
opts.options_.args = (0, mergeChromeArgs_1.default)(existingArgs, {

@@ -34,2 +37,3 @@ disableOtherExtensions: false

super({ debugLoggerName: 'WebdriverController' });
(0, assertVariablesWereWritten_1.assertVariablesWereWritten)('WebDriver', 'webdriverConfig()');
this.driver = driver;

@@ -36,0 +40,0 @@ }

@@ -1,2 +0,2 @@

/*! axe v4.10.0
/*! axe v4.10.2
* Copyright (c) 2015 - 2024 Deque Systems, Inc.

@@ -3,0 +3,0 @@ *

{
"name": "@axe-core/watcher",
"version": "3.16.0-next.5077328b",
"version": "3.16.0-next.51372f65",
"description": "",

@@ -9,3 +9,4 @@ "license": "UNLICENSED",

"dist",
"extension"
"extension",
"LICENSES-3RD-PARTY.md"
],

@@ -45,3 +46,3 @@ "scripts": {

"@wdio/types": "^9.0.4",
"axe-core": "^4.10.0",
"axe-core": "^4.10.2",
"axe-test-fixtures": "github:dequelabs/axe-test-fixtures#v1",

@@ -48,0 +49,0 @@ "body-parser": "^1.20.1",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc