@axe-core/watcher
Advanced tools
Comparing version 3.16.0-next.8dea0e82 to 3.16.0-next.acef2936
@@ -79,3 +79,5 @@ "use strict"; | ||
function axeWatcherFlushCommand() { | ||
logDebugAxeWatcher({ message: 'Flush: Invoked' }); | ||
logDebugAxeWatcher({ | ||
message: `Flush: Invoked (${isStopped ? 'will not' : 'may'} analyze implicitly)` | ||
}); | ||
cy.window().then(win => { | ||
@@ -123,3 +125,6 @@ if (!shouldAnalyzeLocation(win.location)) { | ||
}); | ||
return Promise.resolve({ message: `Skipped - Invalid protocol`, subject }); | ||
return Promise.resolve({ | ||
message: `Skipped - Invalid protocol`, | ||
subject | ||
}); | ||
} | ||
@@ -152,2 +157,3 @@ if (isStopped && !userRequestedAnalyze) { | ||
cy.window().then(() => { | ||
logDebugAxeWatcher({ message: `Start: Invoked` }); | ||
isStopped = false; | ||
@@ -158,5 +164,30 @@ return Promise.resolve(subject); | ||
function axeWatcherStopCommand(subject) { | ||
cy.window().then(() => { | ||
isStopped = true; | ||
return Promise.resolve(subject); | ||
logDebugAxeWatcher({ message: `Stop: Invoked` }); | ||
cy.window().then(win => { | ||
if (!shouldAnalyzeLocation(win.location)) { | ||
logDebugAxeWatcher({ | ||
message: `Stop: Skipped - invalid protocol` | ||
}); | ||
return Promise.resolve({ | ||
message: `Skipped - Invalid protocol`, | ||
subject | ||
}); | ||
} | ||
return new Promise(resolve => { | ||
const fn = (event) => { | ||
win.removeEventListener('axe:manual-mode-analyze-done', fn); | ||
resolve({ message: event.detail.message, subject }); | ||
}; | ||
win.addEventListener('axe:manual-mode-analyze-done', fn); | ||
const event = new CustomEvent('axe:manual-mode-analyze', { | ||
detail: { isCypress: true } | ||
}); | ||
win.dispatchEvent(event); | ||
}).then(result => { | ||
logDebugAxeWatcher({ message: `Stop: ${result === null || result === void 0 ? void 0 : result.message}` }); | ||
isStopped = true; | ||
if (result === null || result === void 0 ? void 0 : result.subject) { | ||
return result.subject; | ||
} | ||
}); | ||
}); | ||
@@ -163,0 +194,0 @@ } |
@@ -12,2 +12,3 @@ "use strict"; | ||
const writeVariables_1 = __importDefault(require("./utils/writeVariables")); | ||
const assertVariablesWereWritten_1 = require("./utils/assertVariablesWereWritten"); | ||
function playwrightConfig(opts) { | ||
@@ -31,2 +32,3 @@ const { axe, ...config } = opts; | ||
super({ debugLoggerName: 'PlaywrightController' }); | ||
(0, assertVariablesWereWritten_1.assertVariablesWereWritten)('Playwright', 'playwrightConfig()'); | ||
this.driver = driver; | ||
@@ -33,0 +35,0 @@ } |
@@ -12,4 +12,5 @@ import type { Browser, BrowserContext, ElementHandle, Frame, FrameLocator, JSHandle, Keyboard, Locator, Mouse, Page, Touchscreen } from 'playwright-core'; | ||
export declare const wrapJSHandle: (jsHandle: PossiblyWrapped<JSHandle>, controller: PlaywrightController) => JSHandle; | ||
export declare const wrapSmartHandle: (smartHandle: PossiblyWrapped<JSHandle | ElementHandle>, controller: PlaywrightController) => JSHandle | ElementHandle; | ||
export declare const wrapKeyboard: (keyboard: PossiblyWrapped<Keyboard>, controller: PlaywrightController) => Keyboard; | ||
export declare const wrapMouse: (mouse: PossiblyWrapped<Mouse>, controller: PlaywrightController) => Mouse; | ||
export declare const wrapTouchscreen: (touchscreen: PossiblyWrapped<Touchscreen>, controller: PlaywrightController) => Touchscreen; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.wrapTouchscreen = exports.wrapMouse = exports.wrapKeyboard = exports.wrapJSHandle = exports.wrapLocator = exports.wrapFrameLocator = exports.wrapFrame = exports.wrapElementHandle = exports.wrapPage = exports.wrapBrowser = exports.wrapBrowserContext = void 0; | ||
exports.wrapTouchscreen = exports.wrapMouse = exports.wrapKeyboard = exports.wrapSmartHandle = exports.wrapJSHandle = exports.wrapLocator = exports.wrapFrameLocator = exports.wrapFrame = exports.wrapElementHandle = exports.wrapPage = exports.wrapBrowser = exports.wrapBrowserContext = void 0; | ||
const proxyHandlers_1 = require("./utils/proxyHandlers"); | ||
@@ -100,2 +100,5 @@ const wrapBrowserContext = (browserContext, controller) => { | ||
}; | ||
case 'addScriptTag': | ||
case 'addStyleTag': | ||
return (0, proxyHandlers_1.proxiedGetFuncWithAnalyzeWrapped)(target, prop, controller); | ||
case 'waitForSelector': | ||
@@ -111,4 +114,2 @@ return async (...args) => { | ||
case '$eval': | ||
case 'addScriptTag': | ||
case 'addStyleTag': | ||
case 'bringToFront': | ||
@@ -149,3 +150,3 @@ case 'check': | ||
const handle = await target[prop](...args); | ||
return (0, exports.wrapJSHandle)(handle, controller); | ||
return (0, exports.wrapSmartHandle)(handle, controller); | ||
}; | ||
@@ -281,3 +282,3 @@ case 'frame': | ||
const el = await target.evaluateHandle(...args); | ||
return (0, exports.wrapJSHandle)(el, controller); | ||
return (0, exports.wrapSmartHandle)(el, controller); | ||
}; | ||
@@ -440,3 +441,3 @@ case 'childFrames': | ||
const handle = await target.evaluateHandle(...args); | ||
return (0, exports.wrapJSHandle)(handle, controller); | ||
return (0, exports.wrapSmartHandle)(handle, controller); | ||
}; | ||
@@ -499,3 +500,3 @@ case 'and': | ||
const handle = await target.evaluateHandle(...args); | ||
return (0, exports.wrapJSHandle)(handle, controller); | ||
return (0, exports.wrapSmartHandle)(handle, controller); | ||
}; | ||
@@ -511,2 +512,9 @@ default: | ||
exports.wrapJSHandle = wrapJSHandle; | ||
const wrapSmartHandle = (smartHandle, controller) => { | ||
if ('$' in smartHandle) { | ||
return (0, exports.wrapElementHandle)(smartHandle, controller); | ||
} | ||
return (0, exports.wrapJSHandle)(smartHandle, controller); | ||
}; | ||
exports.wrapSmartHandle = wrapSmartHandle; | ||
const wrapKeyboard = (keyboard, controller) => { | ||
@@ -513,0 +521,0 @@ if ((0, proxyHandlers_1.isWrapped)(keyboard)) { |
@@ -12,2 +12,3 @@ "use strict"; | ||
const writeVariables_1 = __importDefault(require("./utils/writeVariables")); | ||
const assertVariablesWereWritten_1 = require("./utils/assertVariablesWereWritten"); | ||
function headlessNotSupportedError(config) { | ||
@@ -38,2 +39,3 @@ if (!(config === null || config === void 0 ? void 0 : config.headless) || config.headless === 'new') { | ||
super({ debugLoggerName: 'PuppeteerController' }); | ||
(0, assertVariablesWereWritten_1.assertVariablesWereWritten)('Puppeteer', 'puppeteerConfig()'); | ||
this.driver = driver; | ||
@@ -40,0 +42,0 @@ } |
import type Controller from '../Controller'; | ||
import { type PlaywrightController } from '../playwright'; | ||
declare const kWrapped: unique symbol; | ||
@@ -11,3 +12,4 @@ export type PossiblyWrapped<T> = T & { | ||
export declare const proxiedGetFuncWithAnalyze: <T>(target: T, prop: keyof T, controller: Controller) => (...args: unknown[]) => Promise<unknown>; | ||
export declare const proxiedGetFuncWithAnalyzeWrapped: <T>(target: T, prop: keyof T, controller: PlaywrightController) => (...args: unknown[]) => Promise<unknown>; | ||
export declare const proxiedGetWithoutAnalyze: <T>(target: T, prop: keyof T) => unknown; | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.proxiedGetWithoutAnalyze = exports.proxiedGetFuncWithAnalyze = exports.markAsWrapped = exports.isWrapped = void 0; | ||
exports.proxiedGetWithoutAnalyze = exports.proxiedGetFuncWithAnalyzeWrapped = exports.proxiedGetFuncWithAnalyze = exports.markAsWrapped = exports.isWrapped = void 0; | ||
const playwrightWrapping_1 = require("../playwrightWrapping"); | ||
const kWrapped = Symbol('axe watcher wrapped'); | ||
@@ -29,2 +30,14 @@ const isWrapped = (o) => { | ||
exports.proxiedGetFuncWithAnalyze = proxiedGetFuncWithAnalyze; | ||
const proxiedGetFuncWithAnalyzeWrapped = (target, prop, controller) => async (...args) => { | ||
await controller.analyze({ | ||
__Method: prop, | ||
__UserRequestedAnalyze: false | ||
}); | ||
const result = await target[prop].call(target, ...args); | ||
if (!result) { | ||
return null; | ||
} | ||
return (0, playwrightWrapping_1.wrapElementHandle)(result, controller); | ||
}; | ||
exports.proxiedGetFuncWithAnalyzeWrapped = proxiedGetFuncWithAnalyzeWrapped; | ||
const proxiedGetWithoutAnalyze = (target, prop) => { | ||
@@ -31,0 +44,0 @@ const original = target[prop]; |
@@ -15,2 +15,3 @@ "use strict"; | ||
const mergeChromeArgs_1 = __importDefault(require("./utils/mergeChromeArgs")); | ||
const assertVariablesWereWritten_1 = require("./utils/assertVariablesWereWritten"); | ||
const noop = () => { | ||
@@ -87,2 +88,3 @@ }; | ||
super({ debugLoggerName: 'WdioController' }); | ||
(0, assertVariablesWereWritten_1.assertVariablesWereWritten)('WDIO', 'wdioConfig()'); | ||
this.driver = driver; | ||
@@ -89,0 +91,0 @@ } |
@@ -12,2 +12,3 @@ "use strict"; | ||
const mergeChromeArgs_1 = __importDefault(require("./utils/mergeChromeArgs")); | ||
const assertVariablesWereWritten_1 = require("./utils/assertVariablesWereWritten"); | ||
var webdriverWrapping_1 = require("./webdriverWrapping"); | ||
@@ -33,2 +34,3 @@ Object.defineProperty(exports, "wrapWebdriver", { enumerable: true, get: function () { return webdriverWrapping_1.wrapDriver; } }); | ||
super({ debugLoggerName: 'WebdriverController' }); | ||
(0, assertVariablesWereWritten_1.assertVariablesWereWritten)('WebDriver', 'webdriverConfig()'); | ||
this.driver = driver; | ||
@@ -35,0 +37,0 @@ } |
{ | ||
"name": "@axe-core/watcher", | ||
"version": "3.16.0-next.8dea0e82", | ||
"version": "3.16.0-next.acef2936", | ||
"description": "", | ||
@@ -28,3 +28,3 @@ "license": "UNLICENSED", | ||
"devDependencies": { | ||
"@deque/advanced-rule-recorder": "^1.24.0-next.5ee4d0d2", | ||
"@deque/advanced-rule-recorder": "^1.24.0-next.3be02ec6", | ||
"@playwright/test": "^1.45.0", | ||
@@ -31,0 +31,0 @@ "@types/body-parser": "^1.19.2", |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2264540
126
4330
11