-
Notifications
You must be signed in to change notification settings - Fork 3.2k
/
inject.js
32 lines (26 loc) · 903 Bytes
/
inject.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
const { oneLine } = require('common-tags')
module.exports = {
partial (domain) {
return oneLine`
<script type='text/javascript'>
window.Cypress = {
// so window.top, etc. still work when browsing outside of Cypress
resolveWindowReference: (w, o, v) => o[v];
}
document.domain = '${domain}';
</script>
`
},
full (domain) {
return oneLine`
<script type='text/javascript'>
document.domain = '${domain}';
var Cypress = window.Cypress = parent.Cypress;
if (!Cypress) {
throw new Error('Something went terribly wrong and we cannot proceed. We expected to find the global Cypress in the parent window but it is missing!. This should never happen and likely is a bug. Please open an issue!');
};
Cypress.action('app:window:before:load', window);
</script>
`
},
}