Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: issue with 'other' targets not fully loading #28229

Merged
merged 9 commits into from
Nov 3, 2023
1 change: 1 addition & 0 deletions cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ _Released 11/7/2023 (PENDING)_
**Bugfixes:**

- Fixed an issue determining visibility when an element is hidden by an ancestor with a shared edge. Fixes [#27514](https://github.com/cypress-io/cypress/issues/27514).
- Fixed an issue with 'other' targets (e.g. pdf documents embedded in an object tag) not fully loading. Fixes [#28228](https://github.com/cypress-io/cypress/issues/28228)

## 13.4.0

Expand Down
3 changes: 2 additions & 1 deletion packages/server/lib/browsers/browser-cri-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,8 @@ export class BrowserCriClient {
debug('Target.attachedToTarget %o', event.targetInfo)

try {
if (event.targetInfo.type !== 'page') {
// We don't track child tabs/page network traffic. 'other' targets can't have network enabled
if (event.targetInfo.type !== 'page' && event.targetInfo.type !== 'other') {
await browserClient.send('Network.enable', protocolManager?.networkEnableOptions ?? DEFAULT_NETWORK_ENABLE_OPTIONS, event.sessionId)
}

Expand Down
3 changes: 2 additions & 1 deletion packages/server/lib/browsers/cri-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,8 @@ export const create = async ({
cri.on('Target.attachedToTarget', async (event) => {
try {
// Service workers get attached at the page and browser level. We only want to handle them at the browser level
if (event.targetInfo.type !== 'service_worker' && event.targetInfo.type !== 'page') {
// We don't track child tabs/page network traffic. 'other' targets can't have network enabled
if (event.targetInfo.type !== 'service_worker' && event.targetInfo.type !== 'page' && event.targetInfo.type !== 'other') {
await cri.send('Network.enable', protocolManager?.networkEnableOptions ?? DEFAULT_NETWORK_ENABLE_OPTIONS, event.sessionId)
}

Expand Down
5 changes: 5 additions & 0 deletions system-tests/projects/e2e/cypress/e2e/other_target.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
context('Test', () => {
it('visit site with unsupported content', () => {
cy.visit('http://localhost:1515/other_target.html')
})
})
Binary file added system-tests/projects/e2e/other-target.pdf
Binary file not shown.
18 changes: 18 additions & 0 deletions system-tests/projects/e2e/other_target.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<title>mask-unsupported-content</title>
</head>
<body>
<!-- Video Player -->
<h2>Video Player</h2>
<video width="640" height="360" controls>
<source src="https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.webm" type="video/mp4" />
Your browser does not support the video tag.
</video>

<!-- Objects -->
<h2>Objects</h2>
<object type="application/pdf" data="/other-target.pdf" width="250" height="200"></object>
</body>
</html>
26 changes: 26 additions & 0 deletions system-tests/test/other_target_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const express = require('express')
const Fixtures = require('../lib/fixtures')
const systemTests = require('../lib/system-tests').default

const e2ePath = Fixtures.projectPath('e2e')

const onServer = function (app) {
app.use(express.static(e2ePath, {
// force caching to happen
maxAge: 3600000,
}))
}

describe('e2e other target', () => {
systemTests.setup({
servers: [{
port: 1515,
onServer,
}],
})

systemTests.it.only(`executes a page with a target type of 'other'`, {
project: 'e2e',
spec: 'other_target.cy.js',
})
})