aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2019-04-15 23:30:56 -0400
committerGitHub <noreply@github.com>2019-04-15 23:30:56 -0400
commit456ea6a388f2d67959ece38ecb7742ff9b74d699 (patch)
tree1578c37e8c6791afddd727c66bd1dd61ccf7fb31
parent0ba7da443101f2c12e2b50473fe2165c35d52e99 (diff)
parent1ffe8f059ad25d37adf8ec2ed6b385b461e63229 (diff)
downloadservo-456ea6a388f2d67959ece38ecb7742ff9b74d699.tar.gz
servo-456ea6a388f2d67959ece38ecb7742ff9b74d699.zip
Auto merge of #23153 - 5h1rU:xmlserializer-serializetostring-panics, 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 -->
-rw-r--r--components/script/dom/servoparser/html.rs2
-rw-r--r--tests/wpt/metadata/MANIFEST.json2
-rw-r--r--tests/wpt/metadata/domparsing/XMLSerializer-serializeToString.html.ini3
-rw-r--r--tests/wpt/web-platform-tests/domparsing/XMLSerializer-serializeToString.html5
4 files changed, 10 insertions, 2 deletions
diff --git a/components/script/dom/servoparser/html.rs b/components/script/dom/servoparser/html.rs
index 106c6dc7261..965982d8b51 100644
--- a/components/script/dom/servoparser/html.rs
+++ b/components/script/dom/servoparser/html.rs
@@ -167,7 +167,7 @@ fn rev_children_iter(n: &Node) -> impl Iterator<Item = DomRoot<Node>> {
impl SerializationIterator {
fn new(node: &Node, skip_first: bool) -> SerializationIterator {
let mut ret = SerializationIterator { stack: vec![] };
- if skip_first || node.is::<DocumentFragment>() {
+ if skip_first || node.is::<DocumentFragment>() || node.is::<Document>() {
for c in rev_children_iter(node) {
ret.push_node(&*c);
}
diff --git a/tests/wpt/metadata/MANIFEST.json b/tests/wpt/metadata/MANIFEST.json
index ec13744c29e..3ca5aafc9c4 100644
--- a/tests/wpt/metadata/MANIFEST.json
+++ b/tests/wpt/metadata/MANIFEST.json
@@ -642407,7 +642407,7 @@
"support"
],
"domparsing/XMLSerializer-serializeToString.html": [
- "23b9ce841f5046f180ce78d92d7ac1132712f999",
+ "1ee9b8014c5d0983a02722a0db8caa83df958439",
"testharness"
],
"domparsing/createContextualFragment.html": [
diff --git a/tests/wpt/metadata/domparsing/XMLSerializer-serializeToString.html.ini b/tests/wpt/metadata/domparsing/XMLSerializer-serializeToString.html.ini
index eb1f8013236..fea191de1ee 100644
--- a/tests/wpt/metadata/domparsing/XMLSerializer-serializeToString.html.ini
+++ b/tests/wpt/metadata/domparsing/XMLSerializer-serializeToString.html.ini
@@ -1,5 +1,8 @@
[XMLSerializer-serializeToString.html]
type: testharness
+ [check XMLSerializer.serializeToString method could parsing document to string]
+ expected: FAIL
+
[Check if the default namespace is correctly reset.]
expected: FAIL
diff --git a/tests/wpt/web-platform-tests/domparsing/XMLSerializer-serializeToString.html b/tests/wpt/web-platform-tests/domparsing/XMLSerializer-serializeToString.html
index 23b9ce841f5..1ee9b8014c5 100644
--- a/tests/wpt/web-platform-tests/domparsing/XMLSerializer-serializeToString.html
+++ b/tests/wpt/web-platform-tests/domparsing/XMLSerializer-serializeToString.html
@@ -32,6 +32,11 @@ test(function() {
}, 'check XMLSerializer.serializeToString method could parsing xmldoc to string');
test(function() {
+ var root = parse('<html><head></head><body><div></div><span></span></body></html>');
+ assert_equals(serialize(root.ownerDocument), '<html><head/><body><div/><span/></body></html>');
+}, 'check XMLSerializer.serializeToString method could parsing document to string');
+
+test(function() {
var root = createXmlDoc().documentElement;
var element = root.ownerDocument.createElementNS('urn:foo', 'another');
var child1 = root.firstChild;