Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/issue-1096-firefox-support' into…
Browse files Browse the repository at this point in the history
… issue-1096-firefox-support
  • Loading branch information
brian-mann committed Jan 7, 2020
2 parents e0f0ecc + cc17935 commit 3ae42a4
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 44 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,6 @@
"editor.codeActionsOnSave": {
"source.fixAll.eslint": false
}
}
},
"typescript.tsdk": "node_modules/typescript/lib"
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@
"@types/react-dom": "16.9.4",
"@types/request-promise": "4.1.45",
"@types/sinon-chai": "3.2.3",
"@typescript-eslint/eslint-plugin": "1.13.0",
"@typescript-eslint/parser": "1.13.0",
"@typescript-eslint/eslint-plugin": "2.14.0",
"@typescript-eslint/parser": "2.14.0",
"ansi-styles": "3.2.1",
"arg": "4.1.2",
"ascii-table": "0.0.9",
Expand Down Expand Up @@ -167,7 +167,7 @@
"terminal-banner": "1.1.0",
"through": "2.3.8",
"ts-node": "8.3.0",
"typescript": "3.5.3",
"typescript": "3.7.4",
"vinyl-paths": "2.1.0"
},
"engines": {
Expand Down
33 changes: 16 additions & 17 deletions packages/driver/src/cy/keyboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ interface KeyDetailsPartial extends Partial<KeyDetails> {
type SimulatedDefault = (
el: HTMLElement,
key: KeyDetails,
options: any
options: typeOptions
) => void

interface KeyDetails {
Expand Down Expand Up @@ -236,7 +236,7 @@ const shouldIgnoreEvent = <
return options[eventName] === false
}

const shouldUpdateValue = (el: HTMLElement, key: KeyDetails, options) => {
const shouldUpdateValue = (el: HTMLElement, key: KeyDetails, options: typeOptions) => {
if (!key.text) return false

const bounds = $selection.getSelectionBounds(el)
Expand All @@ -250,7 +250,7 @@ const shouldUpdateValue = (el: HTMLElement, key: KeyDetails, options) => {
const isNumberInputType = $elements.isInput(el) && $elements.isInputType(el, 'number')

if (isNumberInputType) {
const needsValue = options.prevVal || ''
const needsValue = options.prevValue || ''
const needsValueLength = (needsValue && needsValue.length) || 0
const curVal = $elements.getNativeProp(el, 'value')
const bounds = $selection.getSelectionBounds(el)
Expand All @@ -263,18 +263,18 @@ const shouldUpdateValue = (el: HTMLElement, key: KeyDetails, options) => {
debug('skipping inserting value since number input would be invalid', key.text, potentialValue)
// when typing in a number input, only certain whitelisted chars will insert text
if (!key.text.match(isValidNumberInputChar)) {
options.prevVal = ''
options.prevValue = ''

return
}

options.prevVal = needsValue + key.text
options.prevValue = needsValue + key.text

return
}

key.text = (options.prevVal || '') + key.text
options.prevVal = null
key.text = (options.prevValue || '') + key.text
options.prevValue = undefined
}

if (noneSelected) {
Expand Down Expand Up @@ -490,7 +490,7 @@ const simulatedDefaultKeyMap: { [key: string]: SimulatedDefault } = {
$selection.replaceSelectionContents(el, '\n')
}

options.onEnterPressed()
options.onEnterPressed && options.onEnterPressed()
},
Delete: (el, key) => {
key.events.input = $selection.deleteRightOfCursor(el)
Expand Down Expand Up @@ -599,11 +599,14 @@ export interface typeOptions {
onEnterPressed?: Function
onNoMatchingSpecialChars?: Function
onBeforeSpecialCharAction?: Function
prevValue?: string
id?: string
}

export class Keyboard {
constructor (private state: State) {
null
private state
constructor (state: State) {
this.state = state
}

type (opts: typeOptions) {
Expand Down Expand Up @@ -775,11 +778,7 @@ export class Keyboard {
el: HTMLElement,
eventType: KeyEventType,
keyDetails: KeyDetails,
opts: {
id: string
onEvent?: (...args) => boolean
onBeforeEvent?: (...args) => boolean
}
opts: typeOptions
) {
debug('fireSimulatedEvent', eventType, keyDetails)

Expand Down Expand Up @@ -963,7 +962,7 @@ export class Keyboard {
return true
}

simulatedKeydown (el: HTMLElement, _key: KeyDetails, options: any) {
simulatedKeydown (el: HTMLElement, _key: KeyDetails, options: typeOptions) {
if (isModifier(_key)) {
const didFlag = this.flagModifier(_key)

Expand Down Expand Up @@ -1048,7 +1047,7 @@ export class Keyboard {
this.simulatedKeyup(elToKeyup, key, options)
}

simulatedKeyup (el: HTMLElement, _key: KeyDetails, options: any) {
simulatedKeyup (el: HTMLElement, _key: KeyDetails, options: typeOptions) {
if (shouldIgnoreEvent('keyup', _key.events)) {
debug('simulatedKeyup: ignoring event')
delete _key.events.keyup
Expand Down
2 changes: 1 addition & 1 deletion packages/driver/src/cy/mouse.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ const create = (state, keyboard, focused, Cypress) => {

const mouse = {
_getDefaultMouseOptions (x, y, win) {
const _activeModifiers = keyboard.getActiveModifiers(state)
const _activeModifiers = keyboard.getActiveModifiers()
const modifiersEventOptions = $Keyboard.toModifiersEventOptions(_activeModifiers)
const coordsEventOptions = toCoordsEventOptions(x, y, win)

Expand Down
11 changes: 11 additions & 0 deletions packages/driver/src/dom/elements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import * as $jquery from './jquery'
import * as $selection from './selection'
import { parentHasDisplayNone } from './visibility'
import * as $window from './window'
import Debug from 'debug'

const debug = Debug('cypress:driver:elements')

const { wrap } = $jquery

Expand Down Expand Up @@ -730,11 +733,15 @@ const isScrollable = ($el) => {
const checkDocumentElement = (win, documentElement) => {
// Check if body height is higher than window height
if (win.innerHeight < documentElement.scrollHeight) {
debug('isScrollable: window scrollable on Y')

return true
}

// Check if body width is higher than window width
if (win.innerWidth < documentElement.scrollWidth) {
debug('isScrollable: window scrollable on X')

return true
}

Expand Down Expand Up @@ -762,13 +769,17 @@ const isScrollable = ($el) => {
if (el.clientHeight < el.scrollHeight) {
// and our element has scroll or auto overflow or overflowX
if (isScrollOrAuto(overflow) || isScrollOrAuto(overflowY)) {
debug('isScrollable: clientHeight < scrollHeight and scroll/auto overflow')

return true
}
}

// x axis
if (el.clientWidth < el.scrollWidth) {
if (isScrollOrAuto(overflow) || isScrollOrAuto(overflowX)) {
debug('isScrollable: clientWidth < scrollWidth and scroll/auto overflow')

return true
}
}
Expand Down
24 changes: 7 additions & 17 deletions packages/driver/src/dom/selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,15 +347,7 @@ const moveCursorRight = function (el) {
}
}

const moveCursorUp = (el) => {
return _moveCursorUpOrDown(el, true)
}

const moveCursorDown = (el) => {
return _moveCursorUpOrDown(el, false)
}

const _moveCursorUpOrDown = function (el, up) {
const _moveCursorUpOrDown = function (up: boolean, el: HTMLElement) {
if ($elements.isInput(el)) {
// on an input, instead of moving the cursor
// we want to perform the native browser action
Expand Down Expand Up @@ -422,15 +414,10 @@ const _moveCursorUpOrDown = function (el, up) {
}
}

const moveCursorToLineStart = (el) => {
return _moveCursorToLineStartOrEnd(el, true)
}

const moveCursorToLineEnd = (el) => {
return _moveCursorToLineStartOrEnd(el, false)
}
const moveCursorUp = _.curry(_moveCursorUpOrDown)(true)
const moveCursorDown = _.curry(_moveCursorUpOrDown)(false)

const _moveCursorToLineStartOrEnd = function (el: HTMLElement, toStart) {
const _moveCursorToLineStartOrEnd = function (toStart: boolean, el: HTMLElement) {
const isInput = $elements.isInput(el)
const isTextarea = $elements.isTextarea(el)
const isInputOrTextArea = isInput || isTextarea
Expand Down Expand Up @@ -484,6 +471,9 @@ const _moveCursorToLineStartOrEnd = function (el: HTMLElement, toStart) {
}
}

const moveCursorToLineStart = _.curry(_moveCursorToLineStartOrEnd)(true)
const moveCursorToLineEnd = _.curry(_moveCursorToLineStartOrEnd)(false)

const isCollapsed = function (el) {
if ($elements.isTextarea(el) || $elements.isInput(el)) {
const { start, end } = getSelectionBounds(el)
Expand Down
7 changes: 2 additions & 5 deletions packages/runner/src/errors/errors.scss
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,14 @@

.script-error {
background-color: #f8f8f8;
bottom: 0;
border: none;
border-radius: 0;
color: #ec6573;
left: 0;
overflow: auto;
margin: 0;
padding: 2em;
position: absolute;
right: 0;
top: 0;
width: 100%;
height: 100%;

&:empty {
display: none;
Expand Down
5 changes: 5 additions & 0 deletions packages/runner/src/iframe/iframe.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
.runner {
.iframes-container {
position: fixed;

&.has-error {
width: 100%;
height: 100%;
}
}

.size-container {
Expand Down

1 comment on commit 3ae42a4

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 3ae42a4 Jan 7, 2020

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.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/3.8.2/linux-x64/circle-issue-1096-firefox-support-3ae42a4de81ce92f562d14a4476fcb01077d862a-227580/cypress.zip
npm install https://cdn.cypress.io/beta/npm/3.8.2/circle-issue-1096-firefox-support-3ae42a4de81ce92f562d14a4476fcb01077d862a-227568/cypress.tgz

Please sign in to comment.