Skip to content

Commit 2fcecbf

Browse files
tbiethmanflotwigBlue F
authored
chore(webkit): driver updates for clicking/typing actions and related tests (#23522)
* detect playwright-webkit browser * fix: use stdio for CDP instead of TCP (#14348) * wip: begin launchin webkit * run mode works w webkit in 10.0 * reset previous cdp changes * run driver webkit tests * always detect webkit in non-prod * fix version detection * actually run new job * cleanup * fix run * try caching pw binary * npx install pw binary * install-deps * add experimentalSessionAndOrigin wk tests * wk experimentalSessionAndOrigin tests * browser icon * fix some tests * reset browsers.ts change * fix more tests * fix even more tests, skip driver CI for now * comma * fix server-unit-test * fix websockets_spec * refactor wkautomation to initialize self from static async method * fix(proxy/prerequests): fix duplicate key behavior, fallthrough * Apply suggestions from code review Co-authored-by: Blue F <blue@cypress.io> * simpler name for StackMap * fix proxy-logging spec, some xhr specs * fix last xhr test * update testConfigOverrides * skip webcam.cy.js * reenable driver tests * ci? * Suggestions from code review * skip remaining failures which won't be fixed here * fix/skip a couple tests * fix tests * skip crashy specs * skip hidden suites * Scoping down range of skipped type tests * Scoping down click test skips * Updating webkit contenteditable selection handling and associated test * Adding additional mouse event filtering when disabled. Validated by opening playwright-webkit outside of cypress and validating logged events when enabled/disabled. * Updating click 'mouseout coords' tests to account for default style changes * Updating a few more click 'mouse state' tests * Getting all click tests passing with no webkit skips. Fixing _most_ type tests, selection focus is troublesome. * Updating cross-origin type action test * Tweaking coords for CI rendering * Adding workaround for webkit default input selection. * Webkit -> WebKit * Adding logic and test for handling capture-phase focus event selections * Type errors tests now passing * Adding a couple more WebKit keyboard/mouse tweaks * Couple more tweaks for special_chars tests. * Updating contenteditable beforeinput event tests * Making WebKit checks more consistent * Don't expose webkit in public types * Adding comments and doing a little cleanup * PR updates * Simplifying workaround for webkit focus selection * Removing unnecessary test * Revert "Removing unnecessary test" This reverts commit 2c52293. * Revert "Simplifying workaround for webkit focus selection" This reverts commit 47d1155. * Removing comment that is no longer applicable * Simplifying selection logic that is now functional for all supported browsers Co-authored-by: Zach Bloomquist <git@chary.us> Co-authored-by: Zach Bloomquist <github@chary.us> Co-authored-by: Blue F <blue@cypress.io>
1 parent 7ddcc96 commit 2fcecbf

File tree

15 files changed

+315
-153
lines changed

15 files changed

+315
-153
lines changed

packages/app/src/runner/logger.ts

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export const logger = {
3232
this._logValues(consoleProps)
3333
this._logArgs(consoleProps)
3434
this._logGroups(consoleProps)
35-
this._logTable(consoleProps)
35+
this._logTables(consoleProps)
3636
},
3737

3838
_logValues (consoleProps: any) {
@@ -118,43 +118,46 @@ export const logger = {
118118
})
119119
},
120120

121-
_logTable (consoleProps: any) {
122-
if (isMultiEntryTable(consoleProps.table)) {
123-
_.each(
124-
_.sortBy(consoleProps.table, (val, key) => key),
125-
(table) => {
126-
return this._logTable({ table })
127-
},
128-
)
121+
_logTables (consoleProps: any) {
122+
const logTable = ({ name, data, columns }) => {
123+
let tableData = data
129124

130-
return
131-
}
125+
if (Cypress.isBrowser('webkit')) {
126+
// WebKit will hang when we attempt to log element references
127+
// within a table. We replace the element with a simplified display
128+
// string in this case.
129+
// https://bugs.webkit.org/show_bug.cgi?id=244100
132130

133-
const table = this._getTable(consoleProps)
131+
const getSimplifiedElementDisplay = (element: Element) => {
132+
let display = element.tagName.toLowerCase()
134133

135-
if (!table) return
134+
if (element.id) {
135+
display += `#${element.id}`
136+
}
136137

137-
if (_.isArray(table)) {
138-
console.table(table)
139-
} else {
140-
console.group(table.name)
141-
console.table(table.data, table.columns)
142-
console.groupEnd()
143-
}
144-
},
138+
element.classList.forEach((className) => {
139+
display += `.${className}`
140+
})
145141

146-
_getTable (consoleProps: any): Table | Table[] | undefined {
147-
const table = _.result<Table | Table[]>(consoleProps, 'table')
142+
return display
143+
}
148144

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

151-
return table
152-
},
153-
}
149+
return acc
150+
}, {})
151+
})
152+
}
153+
154+
console.group(name)
155+
console.table(tableData, columns)
156+
console.groupEnd()
157+
}
154158

155-
const isMultiEntryTable = (table: Table) => {
156-
return !_.isFunction(table) &&
157-
!_.some(_.keys(table)
158-
.map((x) => isNaN(parseInt(x, 10)))
159-
.filter(Boolean), true)
159+
_.each(_.sortBy(consoleProps.table, (val, key) => key), (getTableData: () => Table) => {
160+
return logTable(getTableData())
161+
})
162+
},
160163
}

packages/driver/cypress/e2e/commands/actions/click.cy.js

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ const getMidPoint = (el) => {
4545
}
4646

4747
const isFirefox = Cypress.isBrowser('firefox')
48+
const isWebKit = Cypress.isBrowser('webkit')
4849

49-
// TODO(webkit): fix+unskip for experimental webkit
50-
describe('src/cy/commands/actions/click', { browser: '!webkit' }, () => {
50+
describe('src/cy/commands/actions/click', () => {
5151
beforeEach(() => {
5252
cy.visit('/fixtures/dom.html')
5353
})
@@ -3596,7 +3596,8 @@ describe('src/cy/commands/actions/click', { browser: '!webkit' }, () => {
35963596

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

3599-
cy.getAll('el', 'pointerdown pointerup').each(isFirefox ? shouldNotBeCalled : shouldBeCalled)
3599+
// On disabled inputs, pointer events are still fired in chrome, not in firefox or webkit
3600+
cy.getAll('el', 'pointerdown pointerup').each(isFirefox || isWebKit ? shouldNotBeCalled : shouldBeCalled)
36003601
})
36013602

36023603
it('rightclick cancel contextmenu', () => {
@@ -3929,8 +3930,7 @@ describe('src/cy/commands/actions/click', { browser: '!webkit' }, () => {
39293930
})
39303931
})
39313932

3932-
// TODO(webkit): fix+unskip for experimental webkit
3933-
describe('shadow dom', { browser: '!webkit' }, () => {
3933+
describe('shadow dom', () => {
39343934
beforeEach(() => {
39353935
cy.visit('/fixtures/shadow-dom.html')
39363936
})
@@ -3993,8 +3993,7 @@ describe('shadow dom', { browser: '!webkit' }, () => {
39933993
})
39943994
})
39953995

3996-
// TODO(webkit): fix+unskip for experimental webkit
3997-
describe('mouse state', { browser: '!webkit' }, () => {
3996+
describe('mouse state', () => {
39983997
describe('mouse/pointer events', () => {
39993998
beforeEach(() => {
40003999
cy.visit('http://localhost:3500/fixtures/dom.html')
@@ -4064,12 +4063,28 @@ describe('mouse state', { browser: '!webkit' }, () => {
40644063
y: 10,
40654064
}
40664065

4066+
const coordsWebKit = {
4067+
clientX: 500,
4068+
clientY: 10,
4069+
layerX: 500,
4070+
layerY: 226,
4071+
pageX: 500,
4072+
pageY: 226,
4073+
screenX: 500,
4074+
screenY: 10,
4075+
x: 500,
4076+
y: 10,
4077+
}
4078+
40674079
let coords
40684080

40694081
switch (Cypress.browser.family) {
40704082
case 'firefox':
40714083
coords = coordsFirefox
40724084
break
4085+
case 'webkit':
4086+
coords = coordsWebKit
4087+
break
40734088
default:
40744089
coords = coordsChrome
40754090
break
@@ -4498,9 +4513,10 @@ describe('mouse state', { browser: '!webkit' }, () => {
44984513
// cy.wrap(onAction).should('calledOnce')
44994514

45004515
cy.getAll('btn', 'pointerover pointerenter').each(shouldBeCalledOnce)
4501-
cy.getAll('btn', 'pointerdown pointerup').each(isFirefox ? shouldNotBeCalled : shouldBeCalledOnce)
45024516

4503-
cy.getAll('btn', 'mouseover mouseenter').each(isFirefox ? shouldBeCalled : shouldNotBeCalled)
4517+
// On disabled inputs, pointer events are still fired in chrome, not in firefox or webkit
4518+
cy.getAll('btn', 'pointerdown pointerup').each(isFirefox || isWebKit ? shouldNotBeCalled : shouldBeCalledOnce)
4519+
cy.getAll('btn', 'mouseover mouseenter').each(isFirefox || isWebKit ? shouldBeCalled : shouldNotBeCalled)
45044520
cy.getAll('btn', 'mousedown mouseup click').each(shouldNotBeCalled)
45054521
})
45064522

@@ -4524,7 +4540,9 @@ describe('mouse state', { browser: '!webkit' }, () => {
45244540
cy.get('#btn').click()
45254541

45264542
cy.getAll('btn', 'pointerdown mousedown').each(shouldBeCalledOnce)
4527-
cy.getAll('btn', 'pointerup').each(isFirefox ? shouldNotBeCalled : shouldBeCalledOnce)
4543+
4544+
// On disabled inputs, pointer events are still fired in chrome, not in firefox or webkit
4545+
cy.getAll('btn', 'pointerup').each(isFirefox || isWebKit ? shouldNotBeCalled : shouldBeCalledOnce)
45284546

45294547
cy.getAll('btn', 'mouseup click').each(shouldNotBeCalled)
45304548
})
@@ -4599,8 +4617,8 @@ describe('mouse state', { browser: '!webkit' }, () => {
45994617

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

4602-
// on disabled inputs, pointer events are still fired in chrome, not in firefox
4603-
cy.getAll('btn', 'pointerdown pointerup').each(isFirefox ? shouldNotBeCalled : shouldBeCalled)
4620+
// On disabled inputs, pointer events are still fired in chrome, not in firefox or webkit
4621+
cy.getAll('btn', 'pointerdown pointerup').each(isFirefox || isWebKit ? shouldNotBeCalled : shouldBeCalled)
46044622
})
46054623

46064624
it('can target new element after mousedown sequence', () => {

0 commit comments

Comments
 (0)