From ed0ed36fa921d76b0a64bef49ff9eee873448ca7 Mon Sep 17 00:00:00 2001 From: BlueWinds Date: Mon, 7 Feb 2022 14:11:21 -0800 Subject: [PATCH] Attempt to fix failures with chrome-beta --- packages/driver/src/cy/chai/inspect.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/driver/src/cy/chai/inspect.ts b/packages/driver/src/cy/chai/inspect.ts index 512336709ff4..ba17a831755a 100644 --- a/packages/driver/src/cy/chai/inspect.ts +++ b/packages/driver/src/cy/chai/inspect.ts @@ -54,6 +54,12 @@ export function create (chai) { typeof object.nodeName === 'string' } + // We can't just check if object instanceof Document, because it might be the document of an iframe, + // which in Chrome 99+ is a separate class, and instanceof Document returns false. + let isDocument = function (object) { + return object.defaultView && object.defaultView === object.defaultView.window + } + let formatValueHook const setFormatValueHook = (fn) => formatValueHook = fn @@ -124,6 +130,10 @@ export function create (chai) { } } + if (isDocument(value)) { + return value.documentElement.outerHTML + } + // Look up the keys of the object. let visibleKeys = getEnumerableProperties(value) let keys = ctx.showHidden ? getProperties(value) : visibleKeys