-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
chore(webkit): add before:browser:launch and download support #23662
Conversation
~60 tests skipped out of ~99: * ~6 skipped due to needing multidomain support * ~8 skipped due to missing before:browser:launch support * ~22 skipped due to broken stack traces
Thanks for taking the time to open a PR!
|
Test summaryRun details
View run in Cypress Dashboard ➡️ Flakiness
This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard |
* However, the Electron binary does not support an entrypoint, leading Cypress to think it's being opened in global mode (no args) when this fn is called. | ||
* Solution is to filter out the problematic function. | ||
* TODO(webkit): do we want to run this cleanup script another way? | ||
* @see https://github.com/microsoft/playwright/blob/7e2aec7454f596af452b51a2866e86370291ac8b/packages/playwright-core/src/utils/processLauncher.ts#L191-L203 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh this must have been tricky to debug. Nice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super tricky. The stdout/stderr isn't inherited and it doesn't pass --inspect-brk
so it was like a ghost process. I eventually figured out what was going on by adding logging using fs.createWriteStream
and tail
'ing the file.
I tried video recording. It worked! I first tested a basic site using a JS based download. It works great (including video). describe('empty spec', () => {
it('passes', () => {
cy.visit('http://localhost:8080')
cy.get('input#btn').click()
cy.readFile(`${Cypress.config('downloadsFolder')}/output.txt`)
})
}) Website: <!DOCTYPE html>
<html>
<head>
<title>
How to Download files Using JavaScript
</title>
</head>
<body>
<textarea id="text">DelftStack</textarea>
<br />
<input type="button" id="btn" value="Download" />
<script>
function download(filename, textInput) {
var element = document.createElement('a');
element.setAttribute('href','data:text/plain;charset=utf-8, ' + encodeURIComponent(textInput));
element.setAttribute('download', filename);
document.body.appendChild(element);
element.click();
//document.body.removeChild(element);
}
document.getElementById("btn")
.addEventListener("click", function () {
var text = document.getElementById("text").value;
var filename = "output.txt";
download(filename, text);
}, false);
</script>
</body>
</html> I also tried using a spammy test download site for my testing - it's more "real world". Edit: this website exhibits the same weird problems in Cypress + Chrome - I think the problems are not WK specific. describe('empty spec', () => {
it('passes', () => {
cy.visit('https://file-examples.com/index.php/sample-documents-download/sample-rtf-download/')
cy.get('a').contains('Download sample rtf file').click()
})
}) It did work in open mode - kind of - the file was downloaded. Due to the websites's jankiness, it somehow injected a Google Ad into the command log (wtf?). Also it shows an error: It failed in run mode:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code seems fine, I did some testing - see my comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can confirm Cypress no longer relaunches after exiting in run mode.
User facing changelog
n/a
Additional details
before:browser:launch
support.launchOptions.extensions
isn't supported since WK doesn't take extensions.config.downloadsFolder
and download events.cypress run
ended, since it was making local system-tests fail.Steps to test
Refer to #23579 testing steps for instructions on installing WebKit.
before:browser:launch
using WebKit, observe that the event is hit and that the launchOptions can be edited.downloadsFolder
when using WebKit.open
mode.How has the user experience changed?
PR Tasks
cypress-documentation
?type definitions
?