-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into renovate/npm-underscore-vulnerability
- Loading branch information
Showing
29 changed files
with
449 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<script> | ||
let setCounter = 0 | ||
let getCounter = 0 | ||
const { getAttribute, setAttribute } = HTMLElement.prototype | ||
HTMLElement.prototype.getAttribute = function() { | ||
if (this.tagName === 'FORM' || this.tagName === 'A') { | ||
getCounter++ | ||
} | ||
return getAttribute.apply(this, arguments) | ||
} | ||
HTMLElement.prototype.setAttribute = function(name) { | ||
if (this.tagName === 'FORM' || this.tagName === 'A' && !name.startsWith('data-cypress')) { | ||
setCounter++ | ||
} | ||
return setAttribute.apply(this, arguments) | ||
} | ||
function handleEventTarget(e) { | ||
if (e.target.target !== '_top') { | ||
e.target.target = '_top' | ||
} | ||
if (e.target.target !== '_top') { | ||
throw new Error('target property must be top') | ||
} | ||
} | ||
function handleEventAttribute(e) { | ||
if (e.target.getAttribute('target') !== '_top') { | ||
e.target.setAttribute('target', '_top') | ||
} | ||
if (e.target.getAttribute('target') !== '_top') { | ||
throw new Error('Get Attribute must have top') | ||
} | ||
} | ||
window.getCounters = () => { | ||
return { | ||
getCounter, | ||
setCounter | ||
} | ||
} | ||
</script> | ||
<div> | ||
<form method="GET" action="/fixtures/dom.html" onsubmit="handleEventTarget(event)"> | ||
<button class="setTarget" type="submit">Submit setTarget</button> | ||
</form> | ||
<form method="GET" action="/fixtures/dom.html" onsubmit="handleEventAttribute(event)"> | ||
<button class="setAttr" type="submit">Submit setAttribute</button> | ||
</form> | ||
<form target="_top" method="GET" action="/fixtures/dom.html"> | ||
<button class="inline_top" type="submit">Submit inline top</button> | ||
</form> | ||
<form target="_parent" method="GET" action="/fixtures/dom.html"> | ||
<button class="inline_parent" type="submit">Submit inline parent</button> | ||
</form> | ||
<form target="_self" method="GET" action="/fixtures/dom.html"> | ||
<button class="inline_self" type="submit">Submit inline self</button> | ||
</form> | ||
<form target="_blank" method="GET" action="/fixtures/dom.html"> | ||
<button class="inline_blank" type="submit">Submit blank</button> | ||
</form> | ||
<form target="invalid" method="GET" action="/fixtures/dom.html"> | ||
<button class="inline_invalid" type="submit">Submit invalid</button> | ||
</form> | ||
<div> | ||
<a class="setTarget" href="/fixtures/dom.html" onclick="handleEventTarget(event)">Link setTarget</a> | ||
<a class="setAttr" href="/fixtures/dom.html" onclick="handleEventAttribute(event)">Link setAttribute</a> | ||
<a class="inline_top" href="/fixtures/dom.html" target="_top">Link top</a> | ||
<a class="inline_parent" href="/fixtures/dom.html" target="_parent">Link parent</a> | ||
<a class="inline_self" href="/fixtures/dom.html" target="_self">Link self</a> | ||
<a class="inline_blank" href="/fixtures/dom.html" target="_blank">Link _blank</a> | ||
<a class="inline_invalid" href="/fixtures/dom.html" target="invalid">Link invalid</a> | ||
</div> | ||
<iframe src="issue-1244.html"> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
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 | ||
describe(`<${target}> ${action}`, () => { | ||
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') | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.