@wdio/image-comparison-core 1.2.0 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# @wdio/image-comparison-core
|
|
2
2
|
|
|
3
|
+
## 1.2.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- db33fa7: #### `@wdio/image-comparison-core` and `@wdio/ocr-service` Security: update jimp (CVE in `file-type` transitive dep)
|
|
8
|
+
|
|
9
|
+
Bumped `jimp` to the latest version to resolve a reported vulnerability in its `file-type` transitive dependency (see [#1130](https://github.com/webdriverio/visual-testing/issues/1130), raised by [@denis-sokolov](https://github.com/denis-sokolov), thank you!).
|
|
10
|
+
|
|
11
|
+
**Actual impact on these packages**
|
|
12
|
+
`file-type` is used by `@jimp/core` solely to detect image MIME types when reading a buffer. In both `@wdio/image-comparison-core` and `@wdio/ocr-service`, every image passed to jimp originates from either WebDriver screenshots (browser-controlled base64 data) or local files written by the framework itself. There is no code path where untrusted external input is fed directly into jimp, which removes the exploitability that the CVE describes.
|
|
13
|
+
|
|
14
|
+
That said, the reputational and compliance risk was real, security scanners flag the package as vulnerable, enterprise users hit audit failures, and some organisations block installation of packages with known CVEs. The update addresses all of that.
|
|
15
|
+
|
|
16
|
+
#### `@wdio/visual-reporter` and `@wdio/visual-service`
|
|
17
|
+
|
|
18
|
+
Updated internal dependencies to pick up the jimp bump in `@wdio/image-comparison-core`.
|
|
19
|
+
|
|
20
|
+
### Committers: 1
|
|
21
|
+
|
|
22
|
+
- Wim Selles ([@wswebcreation](https://github.com/wswebcreation))
|
|
23
|
+
|
|
24
|
+
## 1.2.1
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- d5afb54: ## #1129 Fix `TypeError: element.getBoundingClientRect is not a function` when a `ChainablePromiseElement` is passed to `checkElement`
|
|
29
|
+
|
|
30
|
+
When `checkElement` (or `saveElement`) was called with a `ChainablePromiseElement`, the lazy promise-based element reference that WebdriverIO's `$()` returns, the element was passed directly as an argument to `browser.execute()` without being awaited first. `browser.execute()` serializes its arguments for transfer to the browser context and cannot handle a pending Promise, so it arrived in the browser as a plain empty object `{}` instead of a WebElement reference. This caused `element.getBoundingClientRect is not a function` because the browser-side `scrollElementIntoView` script received `{}` rather than a DOM element.
|
|
31
|
+
|
|
32
|
+
# Committers: 1
|
|
33
|
+
|
|
34
|
+
- Wim Selles ([@wswebcreation](https://github.com/wswebcreation))
|
|
35
|
+
|
|
3
36
|
## 1.2.0
|
|
4
37
|
|
|
5
38
|
### Minor Changes
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ChainablePromiseElement } from 'webdriverio';
|
|
1
2
|
import type { DeviceRectangles, RectanglesOutput } from './rectangles.interfaces.js';
|
|
2
3
|
/**
|
|
3
4
|
* Universal screenshot information that applies to ALL screenshot scenarios.
|
|
@@ -192,7 +193,7 @@ export interface ElementScreenshotDataOptions extends ScreenshotInfo, MobileDevi
|
|
|
192
193
|
/** Whether to automatically scroll the element into view. */
|
|
193
194
|
autoElementScroll: boolean;
|
|
194
195
|
/** The element to take a screenshot of. */
|
|
195
|
-
element:
|
|
196
|
+
element: HTMLElement | WebdriverIO.Element | ChainablePromiseElement;
|
|
196
197
|
/** The inner height. */
|
|
197
198
|
innerHeight?: number;
|
|
198
199
|
/** Resize dimensions for the screenshot. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"screenshots.interfaces.d.ts","sourceRoot":"","sources":["../../src/methods/screenshots.interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAIpF;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC3B,8BAA8B;IAC9B,gBAAgB,EAAE,MAAM,CAAC;IACzB,sCAAsC;IACtC,uBAAuB,CAA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B,EACrB,aAAa;IACb,2BAA2B;IAC3B,WAAW,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,yBAA0B,SACvC,cAAc,EACd,YAAY,EACZ,aAAa;CAEhB;AAED;;GAEG;AACH,MAAM,WAAW,wBAAyB,SACtC,cAAc,EACd,UAAU,EACV,wBAAwB,EACxB,qBAAqB;IACrB,4BAA4B;IAC5B,eAAe,EAAE,WAAW,CAAC,OAAO,CAAC;IACrC,2CAA2C;IAC3C,OAAO,EAAE,GAAG,CAAC;IACb,wCAAwC;IACxC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,sCAAsC;IACtC,UAAU,EAAE,OAAO,CAAC;IACpB,wBAAwB;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,wBAAyB,SACtC,cAAc,EACd,gBAAgB,EAChB,wBAAwB,EACxB,oBAAoB;IACpB,kDAAkD;IAClD,4BAA4B,EAAE,OAAO,CAAC;IACtC,wBAAwB;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,uBAAuB;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,4BAA6B,SAC1C,cAAc,EACd,gBAAgB,EAChB,wBAAwB,EACxB,qBAAqB;IACrB,6DAA6D;IAC7D,iBAAiB,EAAE,OAAO,CAAC;IAC3B,2CAA2C;IAC3C,OAAO,EAAE,GAAG,CAAC;
|
|
1
|
+
{"version":3,"file":"screenshots.interfaces.d.ts","sourceRoot":"","sources":["../../src/methods/screenshots.interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAIpF;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC3B,8BAA8B;IAC9B,gBAAgB,EAAE,MAAM,C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Ac,EACd,UAAU,EACV,YAAY,EACZ,qBAAqB,EACrB,aAAa;IACb,2BAA2B;IAC3B,WAAW,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,yBAA0B,SACvC,cAAc,EACd,YAAY,EACZ,aAAa;CAEhB;AAED;;GAEG;AACH,MAAM,WAAW,wBAAyB,SACtC,cAAc,EACd,UAAU,EACV,wBAAwB,EACxB,qBAAqB;IACrB,4BAA4B;IAC5B,eAAe,EAAE,WAAW,CAAC,OAAO,CAAC;IACrC,2CAA2C;IAC3C,OAAO,EAAE,GAAG,CAAC;IACb,wCAAwC;IACxC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,sCAAsC;IACtC,UAAU,EAAE,OAAO,CAAC;IACpB,wBAAwB;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,wBAAyB,SACtC,cAAc,EACd,gBAAgB,EAChB,wBAAwB,EACxB,oBAAoB;IACpB,kDAAkD;IAClD,4BAA4B,EAAE,OAAO,CAAC;IACtC,wBAAwB;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,uBAAuB;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,4BAA6B,SAC1C,cAAc,EACd,gBAAgB,EAChB,wBAAwB,EACxB,qBAAqB;IACrB,6DAA6D;IAC7D,iBAAiB,EAAE,OAAO,CAAC;IAC3B,2CAA2C;IAC3C,OAAO,EAAE,WAAW,GAAG,WAAW,CAAC,OAAO,GAAG,uBAAuB,CAAC;IACrE,wBAAwB;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4CAA4C;IAC5C,gBAAgB,EAAE,GAAG,CAAC;CACzB"}
|
|
@@ -13,18 +13,22 @@ export async function takeElementScreenshot(browserInstance, options, shouldUseB
|
|
|
13
13
|
}
|
|
14
14
|
async function takeBiDiElementScreenshot(browserInstance, options) {
|
|
15
15
|
const isWebDriverElementScreenshot = false;
|
|
16
|
+
// Fix #1129: scrollElementIntoView receives a promise
|
|
17
|
+
// The element might be a promise, so we need to resolve it before using it as a browser.execute() argument
|
|
18
|
+
// if we need to use it in browser.execute()
|
|
19
|
+
const element = await options.element;
|
|
16
20
|
// Scroll the element into the viewport so any lazy‑load / intersection
|
|
17
21
|
// observers are triggered. We always capture from the *document* origin,
|
|
18
22
|
// so the clip coordinates are document‑relative and independent of scroll.
|
|
19
23
|
let currentPosition;
|
|
20
24
|
if (options.autoElementScroll) {
|
|
21
|
-
currentPosition = await browserInstance.execute(scrollElementIntoView,
|
|
25
|
+
currentPosition = await browserInstance.execute(scrollElementIntoView, element, options.addressBarShadowPadding);
|
|
22
26
|
await waitFor(100);
|
|
23
27
|
}
|
|
24
28
|
// Get the element rect and clip the screenshot. WebDriver getElementRect
|
|
25
29
|
// returns coordinates relative to the document origin, which matches the
|
|
26
30
|
// BiDi `origin: 'document'` coordinate system.
|
|
27
|
-
const rect = await browserInstance.getElementRect(
|
|
31
|
+
const rect = await browserInstance.getElementRect(element.elementId);
|
|
28
32
|
const clip = { x: Math.floor(rect.x), y: Math.floor(rect.y), width: Math.floor(rect.width), height: Math.floor(rect.height) };
|
|
29
33
|
const base64Image = await takeBase64BiDiScreenshot({
|
|
30
34
|
browserInstance,
|
|
@@ -43,10 +47,14 @@ async function takeBiDiElementScreenshot(browserInstance, options) {
|
|
|
43
47
|
async function takeWebDriverElementScreenshot(browserInstance, options) {
|
|
44
48
|
let base64Image;
|
|
45
49
|
let isWebDriverElementScreenshot = false;
|
|
50
|
+
// Fix #1129: scrollElementIntoView receives a promise
|
|
51
|
+
// The element might be a promise, so we need to resolve it before using it as a browser.execute() argument
|
|
52
|
+
// if we need to use it in browser.execute()
|
|
53
|
+
const element = await options.element;
|
|
46
54
|
// Scroll the element into top of the viewport and return the current scroll position
|
|
47
55
|
let currentPosition;
|
|
48
56
|
if (options.autoElementScroll) {
|
|
49
|
-
currentPosition = await browserInstance.execute(scrollElementIntoView,
|
|
57
|
+
currentPosition = await browserInstance.execute(scrollElementIntoView, element, options.addressBarShadowPadding);
|
|
50
58
|
// We need to wait for the scroll to finish before taking the screenshot
|
|
51
59
|
await waitFor(100);
|
|
52
60
|
}
|
|
@@ -56,7 +64,7 @@ async function takeWebDriverElementScreenshot(browserInstance, options) {
|
|
|
56
64
|
browserInstance,
|
|
57
65
|
devicePixelRatio: options.devicePixelRatio,
|
|
58
66
|
deviceRectangles: options.deviceRectangles,
|
|
59
|
-
element
|
|
67
|
+
element,
|
|
60
68
|
initialDevicePixelRatio: options.initialDevicePixelRatio,
|
|
61
69
|
isEmulated: options.isEmulated,
|
|
62
70
|
innerHeight: options.innerHeight,
|
|
@@ -115,6 +115,19 @@ describe('takeElementScreenshot', () => {
|
|
|
115
115
|
expect(executeMock).toHaveBeenCalledTimes(1);
|
|
116
116
|
expect(waitForSpy).toHaveBeenCalledWith(100);
|
|
117
117
|
});
|
|
118
|
+
it('should resolve a Promise-wrapped element (ChainablePromiseElement) before passing to browser.execute()', async () => {
|
|
119
|
+
const resolvedElement = { elementId: 'promise-element' };
|
|
120
|
+
const optionsWithPromiseElement = {
|
|
121
|
+
...baseOptions,
|
|
122
|
+
autoElementScroll: true,
|
|
123
|
+
element: Promise.resolve(resolvedElement),
|
|
124
|
+
};
|
|
125
|
+
executeMock.mockResolvedValueOnce(100);
|
|
126
|
+
await takeElementScreenshot(browserInstance, optionsWithPromiseElement, true);
|
|
127
|
+
expect(getElementRectMock).toHaveBeenCalledWith('promise-element');
|
|
128
|
+
// The resolved element (not the Promise) must be passed to browser.execute()
|
|
129
|
+
expect(executeMock.mock.calls[0][1]).toEqual(resolvedElement);
|
|
130
|
+
});
|
|
118
131
|
});
|
|
119
132
|
describe('Legacy screenshots', () => {
|
|
120
133
|
let logErrorSpy;
|
|
@@ -184,6 +197,20 @@ describe('takeElementScreenshot', () => {
|
|
|
184
197
|
expect(executeMock).toHaveBeenCalledTimes(1); // Only the scroll into view call
|
|
185
198
|
expect(waitForSpy).toHaveBeenCalledWith(100);
|
|
186
199
|
});
|
|
200
|
+
it('should resolve a Promise-wrapped element (ChainablePromiseElement) before passing to browser.execute()', async () => {
|
|
201
|
+
const resolvedElement = { elementId: 'promise-element' };
|
|
202
|
+
const optionsWithPromiseElement = {
|
|
203
|
+
...baseOptions,
|
|
204
|
+
autoElementScroll: true,
|
|
205
|
+
element: Promise.resolve(resolvedElement),
|
|
206
|
+
};
|
|
207
|
+
executeMock.mockResolvedValueOnce(100);
|
|
208
|
+
await takeElementScreenshot(browserInstance, optionsWithPromiseElement, false);
|
|
209
|
+
// The resolved element (not the Promise) must be passed to browser.execute()
|
|
210
|
+
expect(executeMock.mock.calls[0][1]).toEqual(resolvedElement);
|
|
211
|
+
// And also passed to takeWebElementScreenshot
|
|
212
|
+
expect(takeWebElementScreenshotSpy).toHaveBeenCalledWith(expect.objectContaining({ element: resolvedElement }));
|
|
213
|
+
});
|
|
187
214
|
it('should enable fallback when resizeDimensions is provided', async () => {
|
|
188
215
|
const optionsWithResize = {
|
|
189
216
|
...baseOptions,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wdio/image-comparison-core",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"author": "Wim Selles - wswebcreation",
|
|
5
5
|
"description": "Image comparison core module for @wdio/visual-service - WebdriverIO visual testing framework",
|
|
6
6
|
"keywords": [
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
"url": "https://github.com/webdriverio/visual-testing/issues"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"jimp": "^1.6.
|
|
29
|
+
"jimp": "^1.6.1",
|
|
30
30
|
"@wdio/logger": "^9.18.0",
|
|
31
|
-
"@wdio/types": "^9.
|
|
31
|
+
"@wdio/types": "^9.27.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"webdriverio": "^9.
|
|
34
|
+
"webdriverio": "^9.27.0"
|
|
35
35
|
},
|
|
36
36
|
"publishConfig": {
|
|
37
37
|
"access": "public"
|