-
Notifications
You must be signed in to change notification settings - Fork 3.1k
/
1244.cy.js
83 lines (68 loc) · 2.68 KB
/
1244.cy.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
describe('issue 1244', () => {
beforeEach(() => {
cy.visit('/fixtures/issue-1244.html').then(() => {
cy.on('window:before:unload', (e) => {
const win = cy.state('window')
expect(win.getCounters()).to.deep.equal({ getCounter: 0, setCounter: 0 })
})
})
})
for (const [el, target, action] of [['button', 'form', 'submit'], ['a', 'a', 'click']]) {
// <form> submit, <a> click
// TODO(webkit): fix+unskip for webkit release, or make skip more specific (only 4 of these generated tests fail in webkit)
describe(`<${target}> ${action}`, { browser: '!webkit' }, () => {
it('correctly redirects when target=_top with target.target =', () => {
cy.get(`${el}.setTarget`).click()
cy.get('#dom').should('contain', 'DOM')
cy.url().should('include', 'dom.html')
})
it('correctly redirects when target=_top with setAttribute', () => {
cy.get(`${el}.setAttr`).click()
cy.get('#dom').should('contain', 'DOM')
cy.url().should('include', 'dom.html')
})
it('correctly redirects when target=_top inline in dom', () => {
cy.get(`${el}.inline_top`).click()
cy.get('#dom').should('contain', 'DOM')
cy.url().should('include', 'dom.html')
})
it('correctly redirects when target=_parent inline in dom', () => {
cy.get(`${el}.inline_parent`).click()
cy.get('#dom').should('contain', 'DOM')
cy.url().should('include', 'dom.html')
})
it('maintains behavior when target=_self', () => {
cy.get(`${el}.inline_self`).click()
cy.get('#dom').should('contain', 'DOM')
cy.url().should('include', 'dom.html')
})
it('maintains behavior when target=_blank,invalid', () => {
cy.get(`${el}.inline_blank`).click().then(() => {
cy.url().should('not.include', 'dom.html')
})
cy.get(`${el}.inline_invalid`).click().then(() => {
cy.url().should('not.include', 'dom.html')
})
})
})
}
describe('nested frame', () => {
it('does not strip form _parent', () => {
cy.get('iframe').then(($iframe) => {
const $el = $iframe.contents().find('button.inline_parent')
expect($el.closest('form')).to.have.attr('target', '_parent')
$el.trigger('click')
})
cy.get('#dom').should('contain', 'DOM')
cy.url().should('include', 'dom.html')
})
it('does not strip link _parent', () => {
cy.get('iframe').then(($iframe) => {
const $el = $iframe.contents().find('a.inline_parent')
$el[0].click()
})
cy.get('#dom').should('contain', 'DOM')
cy.url().should('include', 'dom.html')
})
})
})