forked from cypress-io/cypress
-
Notifications
You must be signed in to change notification settings - Fork 0
/
2_iframe_spec.js
89 lines (75 loc) · 2.03 KB
/
2_iframe_spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
const path = require('path')
const bodyParser = require('body-parser')
const Fixtures = require('../support/helpers/fixtures')
const e2e = require('../support/helpers/e2e').default
const e2ePath = Fixtures.projectPath('e2e')
const onServer = function (app) {
app.use(bodyParser.json())
app.get('/', (req, res) => {
return res.send('<html>outer content<iframe src=\'/iframe\'></iframe></html>')
})
app.get('/500', (req, res) => {
return res.send('<html>outer content<iframe src=\'/iframe_500\'></iframe></html>')
})
app.get('/sync_iframe', (req, res) => {
return res.send(`\
<html>
outer contents
<iframe src='/timeout'></iframe>
</html>\
`)
})
app.get('/insert_iframe', (req, res) => {
return res.send(`\
<html>
<script type='text/javascript'>
window.insert = function(){
var i = document.createElement("iframe")
i.src = "/timeout"
document.body.appendChild(i)
}
</script>
<button onclick='insert()'>insert iframe</button>
</html>\
`)
})
app.get('/origin', (req, res) => {
return res.send('<html>outer content<iframe src=\'http://www.bar.com/simple\'></iframe></html>')
})
app.get('/cross', (req, res) => {
return res.send('<html>outer content<iframe src=\'http://www.bar.com:1616/simple\'></iframe></html>')
})
app.get('/simple', (req, res) => {
return res.send('<html>simple</html>')
})
app.get('/iframe', (req, res) => {
return res.sendFile(path.join(e2ePath, 'static', 'iframe', 'index.html'))
})
app.get('/iframe_500', (req, res) => {
return res.status(500).sendFile(path.join(e2ePath, 'static', 'iframe', 'index.html'))
})
return app.get('/timeout', (req, res) => {
return setTimeout(() => {
return res.send('<html>timeout</html>')
}
, 2000)
})
}
describe('e2e iframes', () => {
e2e.setup({
servers: {
port: 1616,
onServer,
},
})
e2e.it('passes', {
spec: 'iframe_spec.js',
snapshot: true,
config: {
hosts: {
'*.foo.com': '127.0.0.1',
'*.bar.com': '127.0.0.1',
},
},
})
})