-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Fix namespaces of elements created in XML documents #14095
Comments
Please make a comment here if you intend to work on this issue. Thank you! |
Blocks #2185. |
I would like to take this one! |
Sure! |
I saw this listed as potentially open on https://starters.servo.org/. If it is available, I'd like to give it a shot. |
That sounds fine to me. @OldManMike, if you'd like to work on something else let us know and we'll find another issue for you. |
Sure, I'd be willing to pass this one off to @linclark! |
Thanks! I posted my work-in-progress. I ran into two issues, which I explain in the PR. |
[WIP] Fix namespaces of elements created in XML documents This is a work in progress. Without this PR, all elements are created using the HTML namespace, even when createElement is called in an XML document. To fix this, I check `self.is_html_document` and assign the namespace based on that. However, there were two problems with this approach: 1. It seems some documents that I would think are HTML documents aren't currently handled as such. See the condition I added in the second commit. 2. The last test in `Document-constructor.html` fails. I'm not sure whether the test is correct, though. I tried running something similar in Firefox DevEdition (replacing `assert_equals` with `console.log`) and it looks to me like that test would fail in Firefox as well. ``` var doc = new Document(); var a = doc.createElement("a"); a.href = "http://example.org/?\u00E4"; console.log(a.href, "http://example.org/?%C3%A4"); ``` Result: ``` "http://example.org/?ä" "http://example.org/?%C3%A4" ``` --- <!-- 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 #14095 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [X] These changes do not require tests because there are already tests which were being ignored. <!-- 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/14401) <!-- Reviewable:end -->
[WIP] Fix namespaces of elements created in XML documents This is a work in progress. Without this PR, all elements are created using the HTML namespace, even when createElement is called in an XML document. To fix this, I check `self.is_html_document` and assign the namespace based on that. However, there were two problems with this approach: 1. It seems some documents that I would think are HTML documents aren't currently handled as such. See the condition I added in the second commit. 2. The last test in `Document-constructor.html` fails. I'm not sure whether the test is correct, though. I tried running something similar in Firefox DevEdition (replacing `assert_equals` with `console.log`) and it looks to me like that test would fail in Firefox as well. ``` var doc = new Document(); var a = doc.createElement("a"); a.href = "http://example.org/?\u00E4"; console.log(a.href, "http://example.org/?%C3%A4"); ``` Result: ``` "http://example.org/?ä" "http://example.org/?%C3%A4" ``` --- <!-- 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 #14095 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [X] These changes do not require tests because there are already tests which were being ignored. <!-- 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/14401) <!-- Reviewable:end -->
#14401 has a WIP solution, and there are some review comments that need to be addressed. |
I would like to work on this issue! |
Please do! Ask questions if anything is unclear. |
I used @linclark's changes to understand the unpassed tests and her thoughts about modifying the doctype when XML documents are created. The tests are failing on
I think that these tests are supposed to pass, and the Another question : Steps 3 and 6 of the spec (about the is attribute) aren't implemented. Is there a reason for this? Is it the matter of another issue? |
Yes, the contents of the ini files reflect the status of the test on the master branch of Servo. PASS expected FAIL means that the test now passes correctly. Deleting the ini file is the correct thing to do. |
The |
@enizor Have you made any progress with this? |
I have a lot of trouble understanding the origin of the failed test pointed out in the PR. I looked for other failed tests and found Document-createElement.html. I changed the test as only HTML documents have the HTML namespace now.
All the tests results from Document-createElement.html are then expected. I will take another look in the Document-constructor.html fail this week-end |
@Ms2ger You're more familiar with the namespace stuff than me; could you answer the previous comment? |
Nevermind my previous comment, I realised that I misunderstood the HTML namespace usage. No changes for Document-createElement are needed. |
@enizor How is it going? Still working on this? |
I still don't understand the test fail. I had some trouble running the tests ( |
Yeah, |
Hi everyone! I'm new to both rust and servo, but would like to try working on this issue as it is currently not assigned to anyone. |
Go ahead! Please ask questions if anything is unclear! |
A bit unsure how to proceed here. As mentioned above and in @linclark's pull request, required changes result in
I'm not very familiar with the specs, but after giving them some look I tend to think that it is test at fault here. Created document will have |
Fix namespaces of elements created in XML documents Correctly implement following step of [Dom Document Spec](https://dom.spec.whatwg.org/#dom-document-createelement): > Let namespace be the HTML namespace, if the context object is an HTML document or context object’s content type is "application/xhtml+xml", and null otherwise. Note, this will make following test in `tests/wpt/web-platform-tests/dom/nodes/Document-constructor.html` to fail, so related .ini file added to mark it as such: ``` test(function() { var doc = new Document(); var a = doc.createElement("a"); // In UTF-8: 0xC3 0xA4 a.href = "http://example.org/?\u00E4"; assert_equals(a.href, "http://example.org/?%C3%A4"); }, "new Document(): URL parsing") ``` I'm not very familiar with specs, but from quick look at it, I'm doubtfull that it is valid in the first place. This is an "application/xml" document, so I don't see why it should encode a.href. Firefox also fails that. --- <!-- 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 #14095 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [X] These changes do not require tests because because there are already tests which were being ignored <!-- 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/16472) <!-- Reviewable:end -->
Fix namespaces of elements created in XML documents Correctly implement following step of [Dom Document Spec](https://dom.spec.whatwg.org/#dom-document-createelement): > Let namespace be the HTML namespace, if the context object is an HTML document or context object’s content type is "application/xhtml+xml", and null otherwise. Note, this will make following test in `tests/wpt/web-platform-tests/dom/nodes/Document-constructor.html` to fail, so related .ini file added to mark it as such: ``` test(function() { var doc = new Document(); var a = doc.createElement("a"); // In UTF-8: 0xC3 0xA4 a.href = "http://example.org/?\u00E4"; assert_equals(a.href, "http://example.org/?%C3%A4"); }, "new Document(): URL parsing") ``` I'm not very familiar with specs, but from quick look at it, I'm doubtfull that it is valid in the first place. This is an "application/xml" document, so I don't see why it should encode a.href. Firefox also fails that. --- <!-- 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 #14095 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [X] These changes do not require tests because because there are already tests which were being ignored <!-- 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/16472) <!-- Reviewable:end -->
Fix namespaces of elements created in XML documents Correctly implement following step of [Dom Document Spec](https://dom.spec.whatwg.org/#dom-document-createelement): > Let namespace be the HTML namespace, if the context object is an HTML document or context object’s content type is "application/xhtml+xml", and null otherwise. Note, this will make following test in `tests/wpt/web-platform-tests/dom/nodes/Document-constructor.html` to fail, so related .ini file added to mark it as such: ``` test(function() { var doc = new Document(); var a = doc.createElement("a"); // In UTF-8: 0xC3 0xA4 a.href = "http://example.org/?\u00E4"; assert_equals(a.href, "http://example.org/?%C3%A4"); }, "new Document(): URL parsing") ``` I'm not very familiar with specs, but from quick look at it, I'm doubtfull that it is valid in the first place. This is an "application/xml" document, so I don't see why it should encode a.href. Firefox also fails that. --- <!-- 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 #14095 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [X] These changes do not require tests because because there are already tests which were being ignored <!-- 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/16472) <!-- Reviewable:end -->
Step 6 of the spec is not correctly implemented, and elements created in XML documents also get the HTML namespace where they shouldn't.
Files:
The text was updated successfully, but these errors were encountered: