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

chore: Remove hardcoded domain for multi-domain #19323

Merged
merged 57 commits into from
Jan 12, 2022

Conversation

chrisbreiding
Copy link
Contributor

User facing changelog

N/A - internal work for multi-domain

Additional details

Removes hard-coded domain in multi-domain implementation, so any secondary domain can be visited.

PR Tasks

  • Have tests been added/updated?
  • N/A Has the original issue (or this PR, if no issue exists) been tagged with a release in ZenHub? (user-facing changes only)
  • N/A Has a PR for user-facing changes been opened in cypress-documentation?
  • N/A Have API changes been updated in the type definitions?
  • N/A Have new configuration options been added to the cypress.schema.json?

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Dec 9, 2021

Thanks for taking the time to open a PR!

@chrisbreiding chrisbreiding changed the title Multi-domain: Remove hardcoded domain chore: Remove hardcoded domain for multi-domain Dec 9, 2021
@cypress
Copy link

cypress bot commented Dec 9, 2021



Test summary

19005 0 238 4Flakiness 3


Run details

Project cypress
Status Passed
Commit c9c4abf
Started Jan 11, 2022 9:36 PM
Ended Jan 11, 2022 9:47 PM
Duration 11:21 💡
OS Linux Debian - 10.10
Browser Multiple

View run in Cypress Dashboard ➡️


Flakiness

commands/net_stubbing_spec.ts Flakiness
1 network stubbing > intercepting response > can 'delay' a proxy response using Promise.delay
2 network stubbing > waiting and aliasing > can timeout waiting on a single request using "alias.request"
e2e/multi_domain_spec.ts Flakiness
1 multi-domain > errors > propagates secondary domain errors to the primary that occur within the test

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

Copy link
Contributor

@flotwig flotwig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice work on the isAUTiframe code, looks solid

packages/driver/src/cy/multidomain/index.ts Outdated Show resolved Hide resolved
packages/driver/src/cypress/command_queue.ts Outdated Show resolved Hide resolved
packages/extension/app/background.js Show resolved Hide resolved
packages/proxy/lib/http/response-middleware.ts Outdated Show resolved Hide resolved
packages/server/lib/browsers/cdp_automation.ts Outdated Show resolved Hide resolved
packages/server/lib/browsers/cdp_automation.ts Outdated Show resolved Hide resolved
packages/server/lib/browsers/chrome.ts Show resolved Hide resolved
@chrisbreiding chrisbreiding requested a review from flotwig January 11, 2022 16:25
chrisbreiding and others added 4 commits January 11, 2022 11:37
…9601)

* WIP: multi domain refactor event bus

* refactor multidomain setup so cy/cypress are created once and not on every page load

* use unique ids per origin for logs instead of trying to sync the counter

* refactor postMessage/eventBus methods into the multidomain communicator to consolidate messaging logic. Add basic JSDocs to classes and methods within the communicator.

* fix issue where event data being fed into the message listener is undefined

* remove forgot about commented out code

* use debug to log unexpected post messages

* refactor and update types

* move internal:window:load to internal types

* accept data argument in switchToDomain and validate arguments

* add experimentalMultiDomain flag and fail switchToDomain if not enabled

* add types for switchToDomain

* fix types

* add experimental flag

* remove comment

* update config suite titles and snapshots

* use message in error, update test for browser family

* remove unnecessary return

* convert src/multidomain/index.js to typescript

* use consistent naming for multi-domain

* remove some data

* Multidomain -> MultiDomain

* address PR feedback

Co-authored-by: Bill Glesias <bglesias@gmail.com>
Co-authored-by: Chris Breiding <chrisbreiding@gmail.com>
@chrisbreiding
Copy link
Contributor Author

i'm a little worried that debouncing this could cause flake since it will cause the frameTree to be out of date. it seems like debouncing, or even having the Promise be a singleton, could cause flake here

Good call. Looks like this was causing the rerun spec to fail, so it was already causing issues.

a bunch in a row = two frameAttached and two frameNavigated events when the tests start, then a frameDetached/frameAttached/frameNavigated for each cy.visit?

Two frameAttached and then four frameNavigated. Each frame navigates to about:blank first and then navigates to the src we set on it.

Then they detach when the spec is re-run and it starts over with the frameAttached/frameNavigated events.

After digging into how the events work a bit more, I decided it's unnecessary to listen to the frameNavigated event. We already have enough info about the tree once the frames are attached and nothing significant changes witht the frameNavigated event, so there's no need to update the tree for it.

So the solution is to not debounce and only listen for frameAttached and frameDetached. This makes more calls to Page.getFrameTree than strictly necessary, but it's not going to be an exorbitant number of times (especially for a common test with no frames nested in the AUT, there will only be 2 calls).

I verified that it being a singleton shouldn't be a problem because the Page.getFrameTree calls come back in order and, since any requests made before the AUT frame is attached can't be for the AUT frame itself, there's no risk of the frameTree we save being stale.

@chrisbreiding chrisbreiding merged commit 2ee9893 into feature-multidomain Jan 12, 2022
@chrisbreiding chrisbreiding deleted the issue-17253-remove-hardcoded-domain branch January 12, 2022 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants