Skip to content

Commit 8c4a106

Browse files
fix: issue with 'other' targets not fully loading (#28229)
1 parent 6620eb3 commit 8c4a106

File tree

8 files changed

+66
-2
lines changed

8 files changed

+66
-2
lines changed

cli/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ _Released 11/7/2023 (PENDING)_
66
**Bugfixes:**
77

88
- 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).
9+
- 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)
910
- Fixed an issue where network requests made from tabs/windows other than the main Cypress tab would be delayed. Fixes [#28113](https://github.com/cypress-io/cypress/issues/28113).
1011
- Stopped processing CDP events at the end of a spec when Test Isolation is off and Test Replay is enabled. Addressed in [#28213](https://github.com/cypress-io/cypress/pull/28213).
1112

packages/server/lib/browsers/browser-cri-client.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,8 @@ export class BrowserCriClient {
277277
try {
278278
// The basic approach here is we attach to targets and enable network traffic
279279
// We must attach in a paused state so that we can enable network traffic before the target starts running.
280-
if (targetInfo.type !== 'page') {
280+
// We don't track child tabs/page network traffic. 'other' targets can't have network enabled
281+
if (event.targetInfo.type !== 'page' && event.targetInfo.type !== 'other') {
281282
await browserClient.send('Network.enable', protocolManager?.networkEnableOptions ?? DEFAULT_NETWORK_ENABLE_OPTIONS, event.sessionId)
282283
}
283284
} catch (error) {

packages/server/lib/browsers/cri-client.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,8 @@ export const create = async ({
287287
cri.on('Target.attachedToTarget', async (event) => {
288288
try {
289289
// Service workers get attached at the page and browser level. We only want to handle them at the browser level
290-
if (event.targetInfo.type !== 'service_worker' && event.targetInfo.type !== 'page') {
290+
// We don't track child tabs/page network traffic. 'other' targets can't have network enabled
291+
if (event.targetInfo.type !== 'service_worker' && event.targetInfo.type !== 'page' && event.targetInfo.type !== 'other') {
291292
await cri.send('Network.enable', protocolManager?.networkEnableOptions ?? DEFAULT_NETWORK_ENABLE_OPTIONS, event.sessionId)
292293
}
293294

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// The goal of this test is to load a page containing a target type of 'other' (e.g. embedded pdfs)
2+
// This is to ensure that we don't hang on the cy.visit (https://github.com/cypress-io/cypress/issues/28228)
3+
context('Test', () => {
4+
it('visit site with unsupported content', () => {
5+
cy.visit('http://localhost:1515/other_target.html')
6+
})
7+
})
13 KB
Binary file not shown.
541 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>mask-unsupported-content</title>
5+
</head>
6+
<body>
7+
<!-- Video Player -->
8+
<h2>Video Player</h2>
9+
10+
<object
11+
type="video/mp4"
12+
data="https://localhost:1516/other-target.webm"
13+
width="320"
14+
height="180">
15+
</object>
16+
17+
<!-- Objects -->
18+
<h2>Objects</h2>
19+
<embed src="http://localhost:1515/other-target.pdf" width="500" height="375" type="application/pdf">
20+
<object type="text/html" data="http://localhost:1515/other-target.pdf" width="250" height="200"></object>
21+
</body>
22+
</html>
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
const express = require('express')
2+
const Fixtures = require('../lib/fixtures')
3+
const systemTests = require('../lib/system-tests').default
4+
5+
const e2ePath = Fixtures.projectPath('e2e')
6+
7+
const onServer = function (app) {
8+
app.use(express.static(e2ePath, {
9+
// force caching to happen
10+
maxAge: 3600000,
11+
}))
12+
}
13+
14+
describe('e2e other target', () => {
15+
systemTests.setup({
16+
servers: [{
17+
port: 1515,
18+
onServer,
19+
}, {
20+
https: true,
21+
port: 1516,
22+
onServer,
23+
}],
24+
})
25+
26+
// The goal of this test is to load a page containing a target type of 'other' (e.g. embedded pdfs)
27+
// This is to ensure that we don't hang on the cy.visit (https://github.com/cypress-io/cypress/issues/28228)
28+
systemTests.it(`executes a page containing a target type of 'other'`, {
29+
project: 'e2e',
30+
spec: 'other_target.cy.js',
31+
})
32+
})

0 commit comments

Comments
 (0)