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

Reliably generate mutations while the snapshot is iterating #61

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

eoghanmurray
Copy link
Contributor

Reliably generate mutations while the snapshot is iterating in order to test rarely occurring problems. Have added what I believe should be the correct parsing, on the assumption that the DOM changes will subsequently be correctly picked up by mutation events.

  • The difference between test cases a & b demonstrate different outcomes because of the freezing of childNodes in for (const childN of Array.from(n.childNodes)) — I'm not sure if there's a better way to iterate over child nodes (I imagine this freezing was intentional)
  • Test case d takes this further to show that it should not be possible to iterate to the #d3 element
  • The final e test case is the important one as it demonstrates that the snapshot can produce duplicate nodes, in this case #a1 appears twice in the output

I authored #60 assuming there was something similar to the e test case going on.
But maybe a better solution would be to ensure all __sn attributes are wiped before the start of a snapshot, and ignore any nodes that already have a __sn assigned if we encounter them in the DOM walk, as presumably they have a lower id from earlier in the walk.

Node: The code modifications in snapshot.ts to get these tests to work would need to be removed or somehow only targetted to a special test build.

I'd like to get further input into this before proceeding on fixes for the test case failures I've created in this pull request!

…to test rare occurrences. Have added what I believe should be the correct parsing
@eoghanmurray
Copy link
Contributor Author

@Yuyz0112 Just to note that it is intentional that the tests are failing for this pull request (in case you are avoiding it for that reason).

I also need some good ideas as to how to target the bit of code which does the eval in d6b57fc#diff-75923536d00ea7b9bdbd2a5196a698720893adb4993f502c3d777ca9b51a4df2 so that it only executes in testing?

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.

1 participant