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

Pdf does not preview in iframe in electron #2835

Closed
rbokel opened this issue Nov 26, 2018 · 20 comments
Closed

Pdf does not preview in iframe in electron #2835

rbokel opened this issue Nov 26, 2018 · 20 comments
Labels
browser: electron stage: ready for work The issue is reproducible and in scope stale no activity on this issue for a long period type: bug

Comments

@rbokel
Copy link

rbokel commented Nov 26, 2018

Current behavior:

A Pdf url is offered for download in Electron.

Desired behavior:

The Pdf should open in the pdf viewer in Electron
This works fine in Chrome.
The content-disposition header is set to inline

I think, this was working fine before 3.1.2

cypress 3.1.2
ubuntu 18.4
chrome 70
electron 59

@rbokel rbokel changed the title Pdf is offered for download in electron Pdf is offered for download in electron (was working before 3.1.2) Nov 26, 2018
@rbokel rbokel changed the title Pdf is offered for download in electron (was working before 3.1.2) Pdf is offered for download in electron Nov 26, 2018
@jennifer-shehane
Copy link
Member

Could you provide a way to reproduce this?

@Juholei
Copy link

Juholei commented Jan 4, 2019

We just hit this one and now I'm really confused. What should happen when there is an embedded pdf on a page and Cypress test is run on the page? Should it be displayed, should there be a placeholder (I've seen this on some runs, that there is an iframe placeholder on the page) or should this happen?

We seemingly changed nothing on our system but suddenly our test runs in CI started to hang and I found out it was because of the save dialog popping up when navigating to a page with an embedded pdf. We've had the tests run ok for a few months now and now I'm in doubt that what happened now and how they have passed before.

Tried with Cypress versions of 3.1.0 and 3.1.4.

@jennifer-shehane
Copy link
Member

Are you running the tests on CI with the --browser flag?

We'll need an example of the behavior, including test code and app code, to really look at the issue though.

@Juholei
Copy link

Juholei commented Jan 4, 2019

https://github.com/Juholei/cypress-pdf-problem here's an isolated example app with the simplest test.

The app is a Reagent (React) ClojureScript app. Contains pdf embedded with an iframe. The test navigates to the page and looks for "Hello world!", but it gets stuck during the test run as the pdf prompts a save dialog.

Works fine with Chrome, the problem occurs when running in Electron. There's also a couple screenshots of the prompt occurring, one when running headless and one when running with the GUI


The web page itself can also be found at https://juholei.github.io/cypress-pdf-problem/.

This example does not contain setting content-disposition header to inline which is mentioned on the original issue. Our real project does have that though set. Tests are ran in the real project in CI with cypress run command and using Electron.

As per my original comment, I would like to know what should happen when the page under testing contains an embedded pdf and the tests are ran using Electron?

@jennifer-shehane
Copy link
Member

jennifer-shehane commented Jan 15, 2019

@Juholei Thanks so much for providing a reproducible example! 💯

I've simplified this repo so that ClojureScript is no longer required. You can find my fork https://github.com/jennifer-shehane/cypress-pdf-problem

@olaf89
Copy link

olaf89 commented Mar 27, 2019

I have the same issue, is they any workaround for this?

@Juholei
Copy link

Juholei commented Mar 27, 2019

@olaf89 the workaround is to run the tests in Chrome. This is less than ideal though, as then it is not possible to get video of the test run.

Still hoping this will get fixed soon.

@MSchusterDcb
Copy link

Any updates on this issue?

@flotwig
Copy link
Contributor

flotwig commented Jun 5, 2019

I wonder if it's because Electron doesn't package Chromium's built-in PDF viewer: electron/electron#12337

Maybe a fix could be to add this plugin to the BrowserWindow launched for the AUT: https://github.com/gerhardberger/electron-pdf-window

@laurencehoess
Copy link

I've discovered this problem as well, but not until I was trying to run our tests in CI using the headless option. Locally I was using Chrome so it took a while to figure out what was happening on the CI server.

@Sharondio
Copy link

Running into this one as well. PDFs shown inline are a big part of our app. We can run tests with Chrome in CI, but we lose the ability to generate artifacts without Electron.

@asafbenm
Copy link

I have the same issue, waiting for news...
I must to run with Electron to create video.
and not found workaround for this except run in chrome.

@jennifer-shehane
Copy link
Member

jennifer-shehane commented Feb 5, 2020

A simple example inline of way to reproduce. Requires testing.pdf file in project root.

index.html

<html>
<body>
  <iframe src="testing.pdf"></iframe>
</body>
</html>

spec.js

it('Visiting iframe with pdf src', function () {
  cy.visit('index.html')
})

@jennifer-shehane
Copy link
Member

jennifer-shehane commented Feb 5, 2020

@flotwig Electron removed support for the Chromium PDF viewer in 3.0.0. If this were due to the Electron not packaging the Chromium viewer electron/electron#12337, then this test case should work in Cypress 3.4.1 and fail in 3.5.0 (since that is when we upgraded from 2.0.18 to 5.0.10, but that is not the case. Right?

Although this seems to describe this issue completely, they even mention iframes and nested iframes in Electron not working for PDF viewer: https://github.com/electron/electron/projects/7

I tested this all the way back to Cypress 2.0.0 and it breaks in that version too, so the original assertion that this may have been working in 3.1.2 by @rbokel doesn't appear to be the case.

These issue sound completely relevant, but they are all tagged as duplicates of electron/electron#12337:

Workaround

I was unable to find a current workaround to have this work when running in Electron.

The only way around this is to run your tests in Chrome using the --browser chrome flag, which will launch Cypress on a Chrome browser installed on the machine.

@jennifer-shehane
Copy link
Member

This will be partially addressed in the Electron 9 upgrade #7791

The browser will no longer prompt to 'download', which will prevent some locking up if running via cypress run, however the pdf still does not appear to load in the iframe correctly.

Running this example after the PR shows the results below: https://github.com/jennifer-shehane/cypress-pdf-problem

Screen Shot 2020-06-29 at 1 05 12 PM

@86SUSHIL
Copy link

@jennifer-shehane Not able to understand what is the solution provided.... do I need to create index.html in cypress test suite...

@jennifer-shehane
Copy link
Member

@86SUSHIL There is no workaround. You can run your test in Chrome using the --browser flag to avoid running Cypress in electron.

@86SUSHIL
Copy link

@jennifer-shehane I have some restriction in using Chrome

@jennifer-shehane jennifer-shehane changed the title Pdf is offered for download in electron Pdf does not preview in iframe in electron Dec 30, 2020
@cypress-app-bot
Copy link
Collaborator

This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.

@cypress-app-bot cypress-app-bot added the stale no activity on this issue for a long period label May 18, 2023
@cypress-app-bot
Copy link
Collaborator

This issue has been closed due to inactivity.

@cypress-app-bot cypress-app-bot closed this as not planned Won't fix, can't repro, duplicate, stale Jun 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
browser: electron stage: ready for work The issue is reproducible and in scope stale no activity on this issue for a long period type: bug
Projects
None yet
Development

No branches or pull requests