Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(webkit): driver updates for clicking/typing actions and related tests #23522

Merged
merged 75 commits into from
Aug 25, 2022
Merged
Show file tree
Hide file tree
Changes from 64 commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
de8e6c3
detect playwright-webkit browser
flotwig Mar 16, 2021
d0d1736
fix: use stdio for CDP instead of TCP (#14348)
flotwig Jan 19, 2021
818c7de
wip: begin launchin webkit
flotwig Mar 16, 2021
a7279e5
Merge remote-tracking branch 'origin/develop' into cy-webkit
flotwig Aug 2, 2022
45b5286
run mode works w webkit in 10.0
flotwig Aug 4, 2022
ecd6f0f
reset previous cdp changes
flotwig Aug 4, 2022
505c0dd
run driver webkit tests
flotwig Aug 4, 2022
35b4039
always detect webkit in non-prod
flotwig Aug 5, 2022
ceba06f
fix version detection
flotwig Aug 5, 2022
68ebaca
actually run new job
flotwig Aug 4, 2022
a5a0fc6
Merge remote-tracking branch 'origin/develop' into cy-webkit
flotwig Aug 5, 2022
f974e99
cleanup
flotwig Aug 5, 2022
25b8fc9
fix run
flotwig Aug 5, 2022
411a2f1
try caching pw binary
flotwig Aug 5, 2022
83c58d5
npx install pw binary
flotwig Aug 5, 2022
def14cc
install-deps
flotwig Aug 5, 2022
e85025c
add experimentalSessionAndOrigin wk tests
flotwig Aug 5, 2022
53db500
wk experimentalSessionAndOrigin tests
flotwig Aug 5, 2022
12b3cab
browser icon
flotwig Aug 8, 2022
37de56a
fix some tests
flotwig Aug 8, 2022
32ed232
reset browsers.ts change
flotwig Aug 8, 2022
3acc19b
fix more tests
flotwig Aug 8, 2022
0681f0a
fix even more tests, skip driver CI for now
flotwig Aug 8, 2022
67fdd2d
comma
flotwig Aug 8, 2022
58b2d39
fix server-unit-test
flotwig Aug 8, 2022
406d8ec
fix websockets_spec
flotwig Aug 8, 2022
8fb785a
refactor wkautomation to initialize self from static async method
flotwig Aug 9, 2022
b997ff0
fix(proxy/prerequests): fix duplicate key behavior, fallthrough
flotwig Aug 9, 2022
14270e1
Apply suggestions from code review
flotwig Aug 9, 2022
43b2f0a
simpler name for StackMap
flotwig Aug 9, 2022
ad863e2
fix proxy-logging spec, some xhr specs
flotwig Aug 9, 2022
ebc6335
fix last xhr test
flotwig Aug 9, 2022
6620008
update testConfigOverrides
flotwig Aug 9, 2022
c8c7ac7
skip webcam.cy.js
flotwig Aug 9, 2022
fb66f8f
reenable driver tests
flotwig Aug 9, 2022
71639e2
ci?
flotwig Aug 9, 2022
9ac53fd
Suggestions from code review
flotwig Aug 15, 2022
b7117fe
skip remaining failures which won't be fixed here
flotwig Aug 15, 2022
f6f2513
Merge branch 'cy-webkit' into webkit-prerequests
flotwig Aug 15, 2022
f4a432b
Merge remote-tracking branch 'origin/develop' into webkit-prerequests
flotwig Aug 15, 2022
8ca3edc
fix/skip a couple tests
flotwig Aug 15, 2022
82950c5
fix tests
flotwig Aug 17, 2022
cb3821c
skip crashy specs
flotwig Aug 17, 2022
50c5ae6
skip hidden suites
flotwig Aug 17, 2022
bd3606c
Merge branch 'develop' into webkit-prerequests
flotwig Aug 17, 2022
4cbf03f
Scoping down range of skipped type tests
tbiethman Aug 17, 2022
ab0afae
Scoping down click test skips
tbiethman Aug 17, 2022
f403085
Updating webkit contenteditable selection handling and associated test
tbiethman Aug 18, 2022
af4bc78
Adding additional mouse event filtering when disabled. Validated by o…
tbiethman Aug 18, 2022
c6bd5c3
Updating click 'mouseout coords' tests to account for default style c…
tbiethman Aug 18, 2022
2c5f3a3
Updating a few more click 'mouse state' tests
tbiethman Aug 18, 2022
1b1e010
Getting all click tests passing with no webkit skips. Fixing _most_ t…
tbiethman Aug 19, 2022
6bb9bcc
Updating cross-origin type action test
tbiethman Aug 19, 2022
cf7af74
Merge branch 'develop' of https://github.com/cypress-io/cypress into …
tbiethman Aug 19, 2022
8f97a38
Tweaking coords for CI rendering
tbiethman Aug 19, 2022
5e71864
Adding workaround for webkit default input selection.
tbiethman Aug 19, 2022
d585ee2
Webkit -> WebKit
tbiethman Aug 19, 2022
1814b02
Adding logic and test for handling capture-phase focus event selections
tbiethman Aug 20, 2022
9c35a0e
Type errors tests now passing
tbiethman Aug 20, 2022
b57d8f8
Adding a couple more WebKit keyboard/mouse tweaks
tbiethman Aug 22, 2022
4e5d0ac
Couple more tweaks for special_chars tests.
tbiethman Aug 22, 2022
521cb77
Updating contenteditable beforeinput event tests
tbiethman Aug 23, 2022
33cc866
Making WebKit checks more consistent
tbiethman Aug 23, 2022
ef49430
Don't expose webkit in public types
tbiethman Aug 23, 2022
5bc01fd
Adding comments and doing a little cleanup
tbiethman Aug 23, 2022
48d2010
Merge branch 'develop' of https://github.com/cypress-io/cypress into …
tbiethman Aug 23, 2022
f082b2d
PR updates
tbiethman Aug 23, 2022
47d1155
Simplifying workaround for webkit focus selection
tbiethman Aug 24, 2022
2c52293
Removing unnecessary test
tbiethman Aug 24, 2022
455ea3f
Revert "Removing unnecessary test"
tbiethman Aug 24, 2022
822f4c0
Revert "Simplifying workaround for webkit focus selection"
tbiethman Aug 24, 2022
3468805
Merge branch 'develop' into tbiethman/webkit-tests
tbiethman Aug 24, 2022
b986f8e
Removing comment that is no longer applicable
tbiethman Aug 24, 2022
a694163
Simplifying selection logic that is now functional for all supported …
tbiethman Aug 24, 2022
31cb6fd
Merge branch 'develop' into tbiethman/webkit-tests
tbiethman Aug 25, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 35 additions & 32 deletions packages/app/src/runner/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const logger = {
this._logValues(consoleProps)
this._logArgs(consoleProps)
this._logGroups(consoleProps)
this._logTable(consoleProps)
this._logTables(consoleProps)
},

_logValues (consoleProps: any) {
Expand Down Expand Up @@ -118,43 +118,46 @@ export const logger = {
})
},

_logTable (consoleProps: any) {
if (isMultiEntryTable(consoleProps.table)) {
_.each(
_.sortBy(consoleProps.table, (val, key) => key),
(table) => {
return this._logTable({ table })
},
)
_logTables (consoleProps: any) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We currently log tables for keyboard and mouse events, and we were creating slightly different data structures within the consoleProps for each. These differences made the existing logic complicated (and made parsing out the elements to avoid the WebKit hang difficult).

So I normalized the inputs and simplified the parsing here a bit, while ensuring that the elements don't make it into the table for WebKit. I'm sure we could simplify this further.

const logTable = ({ name, data, columns }) => {
let tableData = data

return
}
if (Cypress.isBrowser('webkit')) {
// WebKit will hang when we attempt to log element references
Copy link
Contributor

Choose a reason for hiding this comment

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

Woah, major bug in webkit.

// within a table. We replace the element with a simplified display
// string in this case.
// https://bugs.webkit.org/show_bug.cgi?id=244100

const table = this._getTable(consoleProps)
const getSimplifiedElementDisplay = (element: Element) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems similar to https://github.com/cypress-io/cypress/blob/develop/packages/driver/src/dom/elements/utils.ts#L45 - or are they different enough not to warrant reuse?

Copy link
Contributor Author

@tbiethman tbiethman Aug 24, 2022

Choose a reason for hiding this comment

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

They are pretty close. I wrote the current version to match what Chrome renders in its tables, the util would produce slightly different results. But we could reuse if there are strong feelings either way, it's exposed in app through Cypress.dom.stringify()

Copy link
Contributor

Choose a reason for hiding this comment

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

Up to you, I do not have strong feelings about this 💯

let display = element.tagName.toLowerCase()

if (!table) return
if (element.id) {
display += `#${element.id}`
}

if (_.isArray(table)) {
console.table(table)
} else {
console.group(table.name)
console.table(table.data, table.columns)
console.groupEnd()
}
},
element.classList.forEach((className) => {
display += `.${className}`
})

_getTable (consoleProps: any): Table | Table[] | undefined {
const table = _.result<Table | Table[]>(consoleProps, 'table')
return display
}

if (!table) return
tableData = data.map((rowObj) => {
return Object.entries(rowObj).reduce((acc: any, value) => {
acc[value[0]] = _.isElement(value[1]) ? getSimplifiedElementDisplay(value[1] as Element) : value[1]

return table
},
}
return acc
}, {})
})
}

console.group(name)
console.table(tableData, columns)
console.groupEnd()
}

const isMultiEntryTable = (table: Table) => {
return !_.isFunction(table) &&
!_.some(_.keys(table)
.map((x) => isNaN(parseInt(x, 10)))
.filter(Boolean), true)
_.each(_.sortBy(consoleProps.table, (val, key) => key), (getTableData: () => Table) => {
return logTable(getTableData())
})
},
}
38 changes: 26 additions & 12 deletions packages/driver/cypress/e2e/commands/actions/click.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ const getMidPoint = (el) => {
}

const isFirefox = Cypress.isBrowser('firefox')
const isWebKit = Cypress.isBrowser('webkit')

// TODO(webkit): fix+unskip for experimental webkit
describe('src/cy/commands/actions/click', { browser: '!webkit' }, () => {
describe('src/cy/commands/actions/click', () => {
beforeEach(() => {
cy.visit('/fixtures/dom.html')
})
Expand Down Expand Up @@ -3596,7 +3596,7 @@ describe('src/cy/commands/actions/click', { browser: '!webkit' }, () => {

cy.getAll('el', 'mousedown contextmenu mouseup').each(shouldNotBeCalled)

cy.getAll('el', 'pointerdown pointerup').each(isFirefox ? shouldNotBeCalled : shouldBeCalled)
cy.getAll('el', 'pointerdown pointerup').each(isFirefox || isWebKit ? shouldNotBeCalled : shouldBeCalled)
})

it('rightclick cancel contextmenu', () => {
Expand Down Expand Up @@ -3929,8 +3929,7 @@ describe('src/cy/commands/actions/click', { browser: '!webkit' }, () => {
})
})

// TODO(webkit): fix+unskip for experimental webkit
describe('shadow dom', { browser: '!webkit' }, () => {
describe('shadow dom', () => {
beforeEach(() => {
cy.visit('/fixtures/shadow-dom.html')
})
Expand Down Expand Up @@ -3993,8 +3992,7 @@ describe('shadow dom', { browser: '!webkit' }, () => {
})
})

// TODO(webkit): fix+unskip for experimental webkit
describe('mouse state', { browser: '!webkit' }, () => {
describe('mouse state', () => {
describe('mouse/pointer events', () => {
beforeEach(() => {
cy.visit('http://localhost:3500/fixtures/dom.html')
Expand Down Expand Up @@ -4064,12 +4062,28 @@ describe('mouse state', { browser: '!webkit' }, () => {
y: 10,
}

const coordsWebKit = {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The coordinates vary per-browser due to differences in the default stylesheet.

clientX: 500,
clientY: 10,
layerX: 500,
layerY: 226,
pageX: 500,
pageY: 226,
screenX: 500,
screenY: 10,
x: 500,
y: 10,
}

let coords

switch (Cypress.browser.family) {
case 'firefox':
coords = coordsFirefox
break
case 'webkit':
coords = coordsWebKit
break
default:
coords = coordsChrome
break
Expand Down Expand Up @@ -4498,9 +4512,9 @@ describe('mouse state', { browser: '!webkit' }, () => {
// cy.wrap(onAction).should('calledOnce')

cy.getAll('btn', 'pointerover pointerenter').each(shouldBeCalledOnce)
cy.getAll('btn', 'pointerdown pointerup').each(isFirefox ? shouldNotBeCalled : shouldBeCalledOnce)
cy.getAll('btn', 'pointerdown pointerup').each(isFirefox || isWebKit ? shouldNotBeCalled : shouldBeCalledOnce)

cy.getAll('btn', 'mouseover mouseenter').each(isFirefox ? shouldBeCalled : shouldNotBeCalled)
cy.getAll('btn', 'mouseover mouseenter').each(isFirefox || isWebKit ? shouldBeCalled : shouldNotBeCalled)
cy.getAll('btn', 'mousedown mouseup click').each(shouldNotBeCalled)
})

Expand All @@ -4524,7 +4538,7 @@ describe('mouse state', { browser: '!webkit' }, () => {
cy.get('#btn').click()

cy.getAll('btn', 'pointerdown mousedown').each(shouldBeCalledOnce)
cy.getAll('btn', 'pointerup').each(isFirefox ? shouldNotBeCalled : shouldBeCalledOnce)
cy.getAll('btn', 'pointerup').each(isFirefox || isWebKit ? shouldNotBeCalled : shouldBeCalledOnce)

cy.getAll('btn', 'mouseup click').each(shouldNotBeCalled)
})
Expand Down Expand Up @@ -4599,8 +4613,8 @@ describe('mouse state', { browser: '!webkit' }, () => {

cy.getAll('btn', 'mousedown mouseup click').each(shouldNotBeCalled)

// on disabled inputs, pointer events are still fired in chrome, not in firefox
cy.getAll('btn', 'pointerdown pointerup').each(isFirefox ? shouldNotBeCalled : shouldBeCalled)
// on disabled inputs, pointer events are still fired in chrome, not in firefox or webkit
cy.getAll('btn', 'pointerdown pointerup').each(isFirefox || isWebKit ? shouldNotBeCalled : shouldBeCalled)
})

it('can target new element after mousedown sequence', () => {
Expand Down
Loading