Skip to content

Commit

Permalink
fix: Fix issues with stack traces and command log in Chrome 99 (#20049)
Browse files Browse the repository at this point in the history
Co-authored-by: cypress-bot[bot] <2f0651858c6e38e0+cypress-bot[bot]@users.noreply.github.com>
Co-authored-by: Emily Rohrbough <emilyrohrbough@users.noreply.github.com>
Co-authored-by: Blue F <blue@cypress.io>
Co-authored-by: Zach Bloomquist <git@chary.us>
  • Loading branch information
5 people committed Feb 10, 2022
1 parent 5d77abc commit 1db8992
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion browser-versions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"chrome:beta": "98.0.4758.80",
"chrome:beta": "99.0.4844.27",
"chrome:stable": "98.0.4758.80"
}
20 changes: 20 additions & 0 deletions packages/driver/src/cy/chai/inspect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@ export function create (chai) {
typeof object.nodeName === 'string'
}

// We can't just check if object instanceof ShadowRoot, because it might be the document of an iframe,
// which in Chrome 99+ is a separate class, and instanceof ShadowRoot returns false.
const isShadowRoot = function (object) {
return isDOMElement(object.host) && object.host.shadowRoot === object
}

// 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.
const isDocument = function (object) {
return object.defaultView && object.defaultView === object.defaultView.window
}

let formatValueHook

const setFormatValueHook = (fn) => formatValueHook = fn
Expand Down Expand Up @@ -124,6 +136,14 @@ export function create (chai) {
}
}

if (isShadowRoot(value)) {
return value.innerHTML
}

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
Expand Down
10 changes: 9 additions & 1 deletion packages/driver/src/cypress/stack_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,21 @@ const captureUserInvocationStack = (ErrorConstructor, userInvocationStack?) => {
if (!userInvocationStack) {
const newErr = new ErrorConstructor('userInvocationStack')

userInvocationStack = newErr.stack

// if browser natively supports Error.captureStackTrace, use it (chrome) (must be bound)
// otherwise use our polyfill on top.Error
const captureStackTrace = ErrorConstructor.captureStackTrace ? ErrorConstructor.captureStackTrace.bind(ErrorConstructor) : Error.captureStackTrace

captureStackTrace(newErr, captureUserInvocationStack)

userInvocationStack = newErr.stack
// On Chrome 99+, captureStackTrace strips away the whole stack,
// leaving nothing beyond the error message. If we get back a single line
// (just the error message with no stack trace), then use the original value
// instead of the trimmed one.
if (newErr.stack.match('\n')) {
userInvocationStack = newErr.stack
}
}

userInvocationStack = normalizedUserInvocationStack(userInvocationStack)
Expand Down

3 comments on commit 1db8992

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 1db8992 Feb 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/9.4.2/linux-x64/circle-develop-1db89922e5559855ad0e71b422eb02aa681057c8/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 1db8992 Feb 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the win32 x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/9.4.2/win32-x64/circle-develop-1db89922e5559855ad0e71b422eb02aa681057c8/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 1db8992 Feb 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/9.4.2/darwin-x64/circle-develop-1db89922e5559855ad0e71b422eb02aa681057c8/cypress.tgz

Please sign in to comment.