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

[WIP] Fix namespaces of elements created in XML documents #14401

Closed
wants to merge 2 commits into from

Conversation

@linclark
Copy link
Contributor

linclark commented Nov 29, 2016

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"

  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #14095 (github issue number if applicable).
  • There are tests for these changes OR
  • These changes do not require tests because there are already tests which were being ignored.

This change is Reviewable

@linclark linclark force-pushed the linclark:14095-ns-xml-docs branch from 851d1bc to b0285e9 Nov 29, 2016
@emilio
Copy link
Member

emilio commented Nov 30, 2016

r? @nox

@nox
Copy link
Member

nox commented Nov 30, 2016

This should probably wait for #14423 to land.

@KiChjang
Copy link
Member

KiChjang commented Dec 11, 2016

#14423 landed.

@jdm
Copy link
Member

jdm commented Dec 15, 2016

@nox Review ping.

@nox
Copy link
Member

nox commented Dec 16, 2016

@linclark Why not just follow current step 4 correctly in 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.

I'm wary of changing how is_html_document is computed.

// Before, the call to XMLDocument::new was hardcoded to pass in NonHTMLDocument as the doc type. That means
// that document.is_html_document is false for documents that are actually HTML. That makes the tests fail
// because I use that property in document.createElement to decide whether to use the HTML namespace or not.
let doc_type = match maybe_doctype {

This comment has been minimized.

Copy link
@Ms2ger

Ms2ger Dec 16, 2016

Contributor

This does look problematic; for example, consider the case

var doctype = document.implementation.createDocumentType("html", "", "");
var doc = document.implementation.createDocument("http://www.w3.org/1999/xhtml", "html", doctype);
assert_equals(doc.documentElement.tagName, "html")

I believe this should pass per spec, and it does in Chrome, though not in Gecko. We should add this test somewhere.

@Ms2ger
Copy link
Contributor

Ms2ger commented Dec 16, 2016

Let's see if this fails anything else
@bors-servo try

@bors-servo
Copy link
Contributor

bors-servo commented Dec 16, 2016

Trying commit b0285e9 with merge f7fa149...

bors-servo added a commit that referenced this pull request Dec 16, 2016
[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 -->
@bors-servo
Copy link
Contributor

bors-servo commented Dec 16, 2016

💔 Test failed - linux-rel-wpt

@KiChjang
Copy link
Member

KiChjang commented Dec 16, 2016

@bors-servo retry

  • Looks like infrastructure issues
@bors-servo
Copy link
Contributor

bors-servo commented Dec 16, 2016

Trying commit b0285e9 with merge fae4fe0...

bors-servo added a commit that referenced this pull request Dec 16, 2016
[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 -->
@jdm
Copy link
Member

jdm commented Dec 16, 2016

I strongly suspect those are actual failures caused by these changes.

@bors-servo
Copy link
Contributor

bors-servo commented Dec 16, 2016

💔 Test failed - mac-rel-wpt1

@bors-servo
Copy link
Contributor

bors-servo commented Dec 29, 2016

The latest upstream changes (presumably #14647) made this pull request unmergeable. Please resolve the merge conflicts.

@jdm
Copy link
Member

jdm commented Jan 27, 2017

@linclark Are you planning to address the review feedback, or should we close this PR?

@linclark
Copy link
Contributor Author

linclark commented Jan 27, 2017

Unfortunately I'm heads down on an assignment over the next few weeks, so won't get a chance to tackle this. Feel free to close it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

8 participants
You can’t perform that action at this time.