@wdio/image-comparison-core 1.2.3 → 1.3.0
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,25 @@
|
|
|
1
1
|
# @wdio/image-comparison-core
|
|
2
2
|
|
|
3
|
+
## 1.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 10d34d6: chore: refresh @wdio/\* deps for the v9 maintenance line
|
|
8
|
+
|
|
9
|
+
### Committers: 1
|
|
10
|
+
|
|
11
|
+
- Wim Selles ([@wswebcreation](https://github.com/wswebcreation))
|
|
12
|
+
|
|
13
|
+
## 1.2.4
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- 60997df: fix: prevent false emulation detection when checkElement is called inside an iframe after switchFrame
|
|
18
|
+
|
|
19
|
+
### Committers: 1
|
|
20
|
+
|
|
21
|
+
- Taro.Nonoyama([@n2-freevas](https://github.com/n2-freevas))
|
|
22
|
+
|
|
3
23
|
## 1.2.3
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getScreenDimensions.d.ts","sourceRoot":"","sources":["../../src/clientSideScripts/getScreenDimensions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAA;AAExE;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,QAAQ,EAAE,OAAO,GAAG,gBAAgB,
|
|
1
|
+
{"version":3,"file":"getScreenDimensions.d.ts","sourceRoot":"","sources":["../../src/clientSideScripts/getScreenDimensions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAA;AAExE;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,QAAQ,EAAE,OAAO,GAAG,gBAAgB,CA0G/E"}
|
|
@@ -8,7 +8,9 @@ export default function getScreenDimensions(isMobile) {
|
|
|
8
8
|
const dpr = window.devicePixelRatio || 1;
|
|
9
9
|
const minEdge = Math.min(width, height);
|
|
10
10
|
const maxEdge = Math.max(width, height);
|
|
11
|
+
const isInIframe = window.self !== window.top;
|
|
11
12
|
const isLikelyEmulated = !isMobile && // Only check for emulated on desktop
|
|
13
|
+
!isInIframe && // Skip emulation detection inside iframes
|
|
12
14
|
dpr >= 2 && // High-DPI signal
|
|
13
15
|
minEdge <= 800 && // Catch phones/tablets in portrait/landscape
|
|
14
16
|
maxEdge <= 1280 && // Conservative max for emulated tablet sizes
|
|
@@ -145,6 +145,28 @@ describe('getScreenDimensions', () => {
|
|
|
145
145
|
expect(dimensions.dimensions.window.screenWidth).toBe(2880);
|
|
146
146
|
expect(dimensions.dimensions.window.screenHeight).toBe(1800);
|
|
147
147
|
});
|
|
148
|
+
it('should not detect emulation when running inside an iframe', () => {
|
|
149
|
+
const originalSelf = window.self;
|
|
150
|
+
Object.defineProperty(window, 'self', {
|
|
151
|
+
value: {},
|
|
152
|
+
configurable: true,
|
|
153
|
+
writable: true,
|
|
154
|
+
});
|
|
155
|
+
Object.defineProperty(window, 'devicePixelRatio', { value: 3, configurable: true });
|
|
156
|
+
Object.defineProperty(window, 'innerWidth', { value: 50, configurable: true });
|
|
157
|
+
Object.defineProperty(window, 'innerHeight', { value: 100, configurable: true });
|
|
158
|
+
Object.defineProperty(window, 'matchMedia', {
|
|
159
|
+
value: vi.fn().mockImplementation(() => ({ matches: false })),
|
|
160
|
+
...CONFIGURABLE,
|
|
161
|
+
});
|
|
162
|
+
const dimensions = getScreenDimensions(false);
|
|
163
|
+
Object.defineProperty(window, 'self', {
|
|
164
|
+
value: originalSelf,
|
|
165
|
+
configurable: true,
|
|
166
|
+
writable: true,
|
|
167
|
+
});
|
|
168
|
+
expect(dimensions.dimensions.window.isEmulated).toBe(false);
|
|
169
|
+
});
|
|
148
170
|
it('should handle zero devicePixelRatio', () => {
|
|
149
171
|
Object.defineProperty(window, 'devicePixelRatio', { value: 0, configurable: true });
|
|
150
172
|
Object.defineProperty(window, 'innerWidth', { value: 1920, configurable: true });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wdio/image-comparison-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"author": "Wim Selles - wswebcreation",
|
|
5
5
|
"description": "Image comparison core module for @wdio/visual-service - WebdriverIO visual testing framework",
|
|
6
6
|
"keywords": [
|
|
@@ -27,11 +27,11 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"jimp": "^1.6.1",
|
|
30
|
-
"@wdio/logger": "^9.
|
|
31
|
-
"@wdio/types": "^9.
|
|
30
|
+
"@wdio/logger": "^9.29.1",
|
|
31
|
+
"@wdio/types": "^9.29.1"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"webdriverio": "^9.
|
|
34
|
+
"webdriverio": "^9.29.1"
|
|
35
35
|
},
|
|
36
36
|
"publishConfig": {
|
|
37
37
|
"access": "public"
|