You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
spike: cut over cy.url(), cy.hash(), cy.location(), cy.reload(), cy.go(), and cy.title() all to use the automation client to subvert the cross-origin boundary
expect(err.message).to.include(`The command was expected to run against origin \`http://localhost:3500\` but the application is at origin \`http://www.foobar.com:3500\`.`)
196
-
expect(err.message).to.include(`This commonly happens when you have either not navigated to the expected origin or have navigated away unexpectedly.`)
197
-
expect(err.message).to.include(`Using \`cy.origin()\` to wrap the commands run on \`http://www.foobar.com:3500\` will likely fix this issue.`)
198
-
expect(err.message).to.include(`cy.origin('http://www.foobar.com:3500', () => {\`\n\` <commands targeting http://www.foobar.com:3500 go here>\`\n\`})`)
199
-
200
-
// make sure that the secondary origin failures do NOT show up as spec failures or AUT failures
201
-
expect(err.message).not.to.include(`The following error originated from your test code, not from Cypress`)
202
-
expect(err.message).not.to.include(`The following error originated from your application code, not from Cypress`)
203
-
done()
204
-
}
205
-
206
-
it('.get()',{defaultCommandTimeout: 50},(done)=>{
207
-
cy.on('fail',(err)=>{
208
-
expect(err.message).to.include(`Timed out retrying after 50ms:`)
209
-
assertOriginFailure(err,done)
210
-
})
211
-
212
-
cy.get('a[data-cy="dom-link"]').click()
213
-
cy.get('#button')
214
-
})
215
-
191
+
// With Cypress 15, window() will work always without cy.origin().
192
+
// However, users may not have access to the AUT window object, so cy.window() yielded window objects
193
+
// may return cross-origin errors.
194
+
context('cross-origin AUT commands working with cy.origin()',()=>{
216
195
it('.window()',(done)=>{
217
-
cy.on('fail',(err)=>{
218
-
assertOriginFailure(err,done)
219
-
})
220
-
221
196
cy.get('a[data-cy="dom-link"]').click()
222
-
cy.window()
223
-
})
224
-
225
-
it('.document()',(done)=>{
226
-
cy.on('fail',(err)=>{
227
-
assertOriginFailure(err,done)
197
+
cy.window().then((win)=>{
198
+
// The window is in a cross-origin state, but users are able to yield the command
199
+
// as well as basic accessible properties
200
+
expect(win.length).to.equal(2)
201
+
try{
202
+
// but cannot access cross-origin properties
203
+
win[0].location.href
204
+
}catch(e){
205
+
expect(e.name).to.equal('SecurityError')
206
+
if(Cypress.isBrowser('firefox')){
207
+
expect(e.message).to.include('Permission denied to get property "href" on cross-origin object')
208
+
}else{
209
+
expect(e.message).to.include('Blocked a frame with origin "http://localhost:3500" from accessing a cross-origin frame.')
expect(err.message).to.include(`The command was expected to run against origin \`http://localhost:3500\` but the application is at origin \`http://www.foobar.com:3500\`.`)
261
+
expect(err.message).to.include(`This commonly happens when you have either not navigated to the expected origin or have navigated away unexpectedly.`)
262
+
expect(err.message).to.include(`Using \`cy.origin()\` to wrap the commands run on \`http://www.foobar.com:3500\` will likely fix this issue.`)
263
+
expect(err.message).to.include(`cy.origin('http://www.foobar.com:3500', () => {\`\n\` <commands targeting http://www.foobar.com:3500 go here>\`\n\`})`)
265
264
266
-
cy.get('a[data-cy="dom-link"]').click()
267
-
cy.location()
268
-
})
265
+
// make sure that the secondary origin failures do NOT show up as spec failures or AUT failures
266
+
expect(err.message).not.to.include(`The following error originated from your test code, not from Cypress`)
267
+
expect(err.message).not.to.include(`The following error originated from your application code, not from Cypress`)
268
+
done()
269
+
}
269
270
270
-
it('.go()',(done)=>{
271
+
it('.get()',{defaultCommandTimeout: 50},(done)=>{
271
272
cy.on('fail',(err)=>{
273
+
expect(err.message).to.include(`Timed out retrying after 50ms:`)
0 commit comments