mirror of
https://github.com/cypress-io/cypress.git
synced 2026-01-25 16:39:04 -06:00
* Initial async changes * Small fixes and test updates. * updating tests * Fixes for cookie login tests * remove the onlys * Most tests passing * Fix driver tests? * fix firefox test? * fix unit tests * fix tests?? * a better check * fix integration tests * minor cleanup * Comment out tyler fix for 10.0 origin issue * also fix integration tests * remove fixmes * Adding Retries for cookie actions. May break other error tests. * Address (some) PR comments * update to warn about cross origin command AUT in assertions * Fix type errors * Move document.cookie patch to injection * Adding iframe patching. * forward errors prior to attaching * Add error message when using visit to visit a cross origin site with the onLoad or onBeforeLoad options. * Attempt to fix test errors. * more fixes, but not all * use the origin policy * Fix types * more fixes * consider chromeWebSecurity when checking if you can communicate with the AUT * firefox * prevent hangs if before unload happens after on load. * Fix some ToDos * code cleanup * remove quotes * Code review changes * more cr changes * fix tests possibly * for realz this time * roll back change * Fix some flake * Fix flakey xhr test hopefully. * oops, forgot communicator changes. need those. * modify error message to not lose the original error * read config right derp * simpler check * no unused vars * don't put config on window * Make isRunnerAbleToCommunicateWithTheAUT a util function instead of attaching it to cypress. * fix a race condition maybe * clear document when window is cross origin... we'll see if this breaks anything. * Retry if querying against the wrong AUT * use timeout * Don't print the retrying string unless you're retrying due to command aut origin mismatch * try handling undefined document * Code review updates. What could go wrong?? * Apply suggestions from code review Co-authored-by: Bill Glesias <bglesias@gmail.com> * minor fixes * try aut location and move the async state collection. * fix flake around the loading message, probably * Fix system tests and some flake around redirect counts. * Improve error handler prior to attaching. * Code review suggestions * use a generated ID when promisifying post message * clean up promise helper * skip xhr test until issue is resolved. * Apply suggestions from code review Co-authored-by: Chris Breiding <chrisbreiding@users.noreply.github.com> * use state directly * Apply suggestions from code review Co-authored-by: Bill Glesias <bglesias@gmail.com> * Update packages/driver/src/cypress/error_messages.ts Co-authored-by: Chris Breiding <chrisbreiding@users.noreply.github.com> Co-authored-by: Bill Glesias <bglesias@gmail.com> Co-authored-by: Chris Breiding <chrisbreiding@users.noreply.github.com>
126 lines
3.1 KiB
JavaScript
126 lines
3.1 KiB
JavaScript
const systemTests = require('../lib/system-tests').default
|
|
|
|
const onServer = function (app) {
|
|
app.get('/link', (req, res) => {
|
|
res.send('<html><h1>link</h1><a href=\'https://www.foo.com:44665/cross_origin\'>second</a></html>')
|
|
})
|
|
|
|
app.get('/cross_origin', (req, res) => {
|
|
res.send('<html><h1>cross origin</h1></html>')
|
|
})
|
|
|
|
app.get('/form', (req, res) => {
|
|
res.send(`\
|
|
<html>
|
|
<h1>form</h1>
|
|
<form method='POST' action='https://www.foo.com:44665/submit'>
|
|
<input type='submit' name='foo' value='bar' />
|
|
</form>
|
|
</html>\
|
|
`)
|
|
})
|
|
|
|
app.post('/submit', (req, res) => {
|
|
res.redirect('https://www.foo.com:44665/cross_origin')
|
|
})
|
|
|
|
app.get('/javascript', (req, res) => {
|
|
res.send(`\
|
|
<html>
|
|
<script type='text/javascript'>
|
|
window.redirect = function(){
|
|
window.location.href = 'https://www.foo.com:44665/cross_origin'
|
|
}
|
|
</script>
|
|
<h1>javascript</h1>
|
|
<button onclick='redirect()'>click me</button>
|
|
</html>\
|
|
`)
|
|
})
|
|
|
|
app.get('/cors', (req, res) => {
|
|
res.send(`<script>
|
|
fetch('https://www.foo.com:44665/cross_origin')
|
|
.then((res) => res.text())
|
|
.then(text => {
|
|
if (text.includes('cross origin')) document.write('success!')
|
|
})
|
|
.catch(err => document.write(err.message))
|
|
</script>`)
|
|
})
|
|
}
|
|
|
|
describe('e2e web security', () => {
|
|
systemTests.setup({
|
|
servers: [{
|
|
port: 4466,
|
|
onServer,
|
|
}, {
|
|
port: 44665,
|
|
https: true,
|
|
onServer,
|
|
}],
|
|
settings: {
|
|
hosts: {
|
|
'*.foo.com': '127.0.0.1',
|
|
'*.bar.com': '127.0.0.1',
|
|
'*.foobar.com': '127.0.0.1',
|
|
},
|
|
e2e: {},
|
|
},
|
|
})
|
|
|
|
context('when enabled', () => {
|
|
systemTests.it('fails', {
|
|
browser: '!webkit', // TODO(webkit): fix+unskip
|
|
spec: 'web_security.cy.js',
|
|
config: {
|
|
experimentalSessionAndOrigin: false,
|
|
pageLoadTimeout: 5000,
|
|
},
|
|
snapshot: true,
|
|
expectedExitCode: 4,
|
|
})
|
|
})
|
|
|
|
context('when disabled', () => {
|
|
systemTests.it('passes', {
|
|
spec: 'web_security.cy.js',
|
|
config: {
|
|
chromeWebSecurity: false,
|
|
experimentalSessionAndOrigin: false,
|
|
},
|
|
snapshot: true,
|
|
browser: ['chrome', 'electron'],
|
|
})
|
|
})
|
|
|
|
context('firefox', () => {
|
|
systemTests.it('displays warning when firefox and chromeWebSecurity:false', {
|
|
spec: 'simple_passing.cy.js',
|
|
snapshot: true,
|
|
// TODO(webkit): run this test in webkit
|
|
browser: 'firefox',
|
|
config: {
|
|
chromeWebSecurity: false,
|
|
},
|
|
onStdout (stdout) {
|
|
expect(stdout).include('Your project has set the configuration option: `chromeWebSecurity` to `false`.\n\nThis option will not have an effect in Firefox.')
|
|
},
|
|
})
|
|
})
|
|
|
|
context('when experimentalSessionAndOrigin is enabled', () => {
|
|
systemTests.it('fails', {
|
|
browser: '!webkit', // TODO(webkit): fix+unskip Fixed by: https://github.com/cypress-io/cypress/issues/23532
|
|
spec: 'web_security.cy.js',
|
|
config: {
|
|
experimentalSessionAndOrigin: true,
|
|
defaultCommandTimeout: 50,
|
|
},
|
|
snapshot: true,
|
|
expectedExitCode: 4,
|
|
})
|
|
})
|
|
})
|