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

new XMLSerializer().serializeToString(document); panics #23130

Closed
mateon1 opened this issue Mar 29, 2019 · 11 comments · Fixed by #23153
Closed

new XMLSerializer().serializeToString(document); panics #23130

mateon1 opened this issue Mar 29, 2019 · 11 comments · Fixed by #23153
Labels
A-content/dom Interacting with the DOM from web content C-assigned There is someone working on resolving the issue C-has-manual-testcase C-has-open-pr There is a PR open that resolves the issue E-less-complex Straightforward. Recommended for a new contributor. I-panic Servo encounters a panic.

Comments

@mateon1
Copy link
Contributor

mateon1 commented Mar 29, 2019

<script>new XMLSerializer.serializeToString(document)</script>

This causes a ScriptThread panic, Can't serialize Document node itself

NodeTypeId::Document(_) => panic!("Can't serialize Document node itself"),

Both Chrome and Firefox properly serialize the entire page when serializeToString is called on the document.

@CYBAI
Copy link
Member

CYBAI commented Mar 29, 2019

As @jdm mentioned in #23044 (comment) , I think this will be fixed when servo/html5ever#368 is fixed.

@CYBAI CYBAI added the A-content/dom Interacting with the DOM from web content label Mar 29, 2019
@jdm
Copy link
Member

jdm commented Mar 29, 2019

Specifically, this would be handled by https://w3c.github.io/DOM-Parsing/#dfn-xml-serialization-algorithm.

@jdm jdm added C-has-manual-testcase I-panic Servo encounters a panic. E-less-complex Straightforward. Recommended for a new contributor. labels Mar 29, 2019
@highfive
Copy link

Hi! If you have any questions regarding this issue, feel free to make a comment here, or ask it in the #servo channel in IRC.

If you intend to work on this issue, then add @highfive: assign me to your comment, and I'll assign this to you. 😄

@jdm
Copy link
Member

jdm commented Mar 29, 2019

That being said, fixing the panic here is separate from implementing the full algorithm in the html5ever repository. We should implement the document serialization algorithm by checking for a document in the SerializationIterator constructor and pushing all of the immediate child nodes of the document.

@jdm
Copy link
Member

jdm commented Mar 29, 2019

If this case is not already tested by tests/wpt/web-platform-tests/domparsing/XMLSerializer-serializeToString.html, then a new testcase should be added.

@5h1rU
Copy link
Contributor

5h1rU commented Apr 1, 2019

Hello!

would like to contribute here but probably I'll need some assistance since I'm a newbie on the codebase.
@jdm what do you think?

@jdm
Copy link
Member

jdm commented Apr 1, 2019

@5h1rU I think you should give it a try and ask questions about anything that is unclear :)

@5h1rU
Copy link
Contributor

5h1rU commented Apr 1, 2019

@highfive assign me

@highfive highfive added the C-assigned There is someone working on resolving the issue label Apr 1, 2019
@highfive
Copy link

highfive commented Apr 1, 2019

Hey @5h1rU! Thanks for your interest in working on this issue. It's now assigned to you!

@5h1rU
Copy link
Contributor

5h1rU commented Apr 1, 2019

After some hours trying to figure out what's going on I have some blockers

  • html5ever serializer doesn't have the document serialization algorithm.

Then I change the Document match to:

NodeTypeId::Document(DocumentTypeId::Document) => {
    let doc = n.downcast::<Node>().unwrap();
    // What else?
},

I'm confused about the document serialization algorithm implementation. Not sure where is the best place to put the logic. I tried using the push_node from the SerializationIterator but no luck.

iter.push_node(doc);

@jdm Do you think is possible to use one of the current existent serializer methods?

In conclusion: I don't know what's the next step in order to return the document serialized.

@jdm
Copy link
Member

jdm commented Apr 1, 2019

@5h1rU This comment means that we should not modify the match with the panic. However, we should modify the SerializationIterator new method to check for a document node, iterate over its children and push each one of them without pushing the actual document node.

bors-servo pushed a commit that referenced this issue Apr 1, 2019
…r=<try>

Add new XMLSerializer().serializeToString functionality

<!-- Please describe your changes on the following line: -->
This is the fix for ScriptThread panic when `new XMLSerializer().serializeToString(document);` is called.

r?@jdm

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #23130

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because ___

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23153)
<!-- Reviewable:end -->
@jdm jdm added the C-has-open-pr There is a PR open that resolves the issue label Apr 5, 2019
bors-servo pushed a commit that referenced this issue Apr 15, 2019
…r=jdm

Make serializeToString serialize document nodes correctly

<!-- Please describe your changes on the following line: -->
This is the fix for ScriptThread panic when `new XMLSerializer().serializeToString(document);` is called.

r?@jdm

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #23130

<!-- Either: -->
- [x] There are tests for these changes OR
- [ ] These changes do not require tests because ___

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23153)
<!-- Reviewable:end -->
bors-servo pushed a commit that referenced this issue Apr 16, 2019
…r=jdm

Make serializeToString serialize document nodes correctly

<!-- Please describe your changes on the following line: -->
This is the fix for ScriptThread panic when `new XMLSerializer().serializeToString(document);` is called.

r?@jdm

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #23130

<!-- Either: -->
- [x] There are tests for these changes OR
- [ ] These changes do not require tests because ___

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23153)
<!-- Reviewable:end -->
bors-servo pushed a commit that referenced this issue Apr 16, 2019
…r=jdm

Make serializeToString serialize document nodes correctly

<!-- Please describe your changes on the following line: -->
This is the fix for ScriptThread panic when `new XMLSerializer().serializeToString(document);` is called.

r?@jdm

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #23130

<!-- Either: -->
- [x] There are tests for these changes OR
- [ ] These changes do not require tests because ___

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23153)
<!-- Reviewable:end -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-content/dom Interacting with the DOM from web content C-assigned There is someone working on resolving the issue C-has-manual-testcase C-has-open-pr There is a PR open that resolves the issue E-less-complex Straightforward. Recommended for a new contributor. I-panic Servo encounters a panic.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants