Skip to content

Commit

Permalink
call setTimeout with the right global scope to prevent 'this' f… (#5709)
Browse files Browse the repository at this point in the history
  • Loading branch information
brian-mann authored and jennifer-shehane committed Nov 15, 2019
1 parent 5d2825c commit ff6bdcd
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/driver/src/cy/timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const create = () => {

const invoke = (contentWindow, fnOrCode, params = []) => {
if (_.isFunction(fnOrCode)) {
return fnOrCode(...params)
return fnOrCode.apply(contentWindow, params)
}

return contentWindow.eval(fnOrCode)
Expand Down
11 changes: 11 additions & 0 deletions packages/driver/test/cypress/fixtures/issue-5707.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!doctype html>
<html lang="en">
<body>
<script>
'use strict';
window.setTimeout(function () {
this.foo = 'bar'
}, 50)
</script>
</body>
</html>
7 changes: 7 additions & 0 deletions packages/driver/test/cypress/integration/issues/5707_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// https://github.com/cypress-io/cypress/issues/5707
describe('issue 5707', () => {
it('calls setTimeout with the correct context', () => {
cy.visit('/fixtures/issue-5707.html')
cy.window().its('foo').should('eq', 'bar')
})
})

3 comments on commit ff6bdcd

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on ff6bdcd Nov 15, 2019

Choose a reason for hiding this comment

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

AppVeyor has built the win32 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.

set CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/3.6.2/win32-x64/appveyor-develop-ff6bdcdfeeda17c77446dde098f62d71044210fa-28886776/cypress.zip
npm install https://cdn.cypress.io/beta/binary/3.6.2/win32-x64/appveyor-develop-ff6bdcdfeeda17c77446dde098f62d71044210fa-28886776/cypress.zip

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on ff6bdcd Nov 15, 2019

Choose a reason for hiding this comment

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

AppVeyor has built the win32 ia32 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.

set CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/3.6.2/win32-ia32/appveyor-develop-ff6bdcdfeeda17c77446dde098f62d71044210fa-28886776/cypress.zip
npm install https://cdn.cypress.io/beta/binary/3.6.2/win32-ia32/appveyor-develop-ff6bdcdfeeda17c77446dde098f62d71044210fa-28886776/cypress.zip

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on ff6bdcd Nov 15, 2019

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.

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.6.2/darwin-x64/circle-develop-ff6bdcdfeeda17c77446dde098f62d71044210fa-192170/cypress.zip
npm install https://cdn.cypress.io/beta/npm/3.6.2/circle-develop-ff6bdcdfeeda17c77446dde098f62d71044210fa-192136/cypress.tgz

Please sign in to comment.