@wdio/image-comparison-core 1.2.3 → 1.2.4

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,15 @@
1
1
  # @wdio/image-comparison-core
2
2
 
3
+ ## 1.2.4
4
+
5
+ ### Patch Changes
6
+
7
+ - 60997df: fix: prevent false emulation detection when checkElement is called inside an iframe after switchFrame
8
+
9
+ ### Committers: 1
10
+
11
+ - Taro.Nonoyama([@n2-freevas](https://github.com/n2-freevas))
12
+
3
13
  ## 1.2.3
4
14
 
5
15
  ### 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,CAwG/E"}
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.2.3",
3
+ "version": "1.2.4",
4
4
  "author": "Wim Selles - wswebcreation",
5
5
  "description": "Image comparison core module for @wdio/visual-service - WebdriverIO visual testing framework",
6
6
  "keywords": [