[10743] Add content type to XmlDocument constructor based on namespace

[10743] Fix namespace in createDocument test

[10743] Remove test ini file, match returns static strings instead of DOMString.

[10743] Fix arguments to XMLDocument::new

Update failing test

[10743] Add content type to XmlDocument constructor based on namespace

[10743] Fix namespace in createDocument test

[10743] Remove test ini file, match returns static strings instead of DOMString.

[10743] Fix arguments to XMLDocument::new

Update failing test
This commit is contained in:
cjkenned 2016-04-24 10:12:15 -06:00
parent f932db34c8
commit d9128fba07
4 changed files with 14 additions and 16 deletions

View file

@ -12,7 +12,7 @@ use dom::bindings::global::GlobalRef;
use dom::bindings::inheritance::Castable; use dom::bindings::inheritance::Castable;
use dom::bindings::js::{JS, Root}; use dom::bindings::js::{JS, Root};
use dom::bindings::reflector::{Reflector, reflect_dom_object}; use dom::bindings::reflector::{Reflector, reflect_dom_object};
use dom::bindings::xmlname::validate_qualified_name; use dom::bindings::xmlname::{validate_qualified_name, namespace_from_domstring};
use dom::document::DocumentSource; use dom::document::DocumentSource;
use dom::document::{Document, IsHTMLDocument}; use dom::document::{Document, IsHTMLDocument};
use dom::documenttype::DocumentType; use dom::documenttype::DocumentType;
@ -62,19 +62,26 @@ impl DOMImplementationMethods for DOMImplementation {
// https://dom.spec.whatwg.org/#dom-domimplementation-createdocument // https://dom.spec.whatwg.org/#dom-domimplementation-createdocument
fn CreateDocument(&self, fn CreateDocument(&self,
namespace: Option<DOMString>, maybe_namespace: Option<DOMString>,
qname: DOMString, qname: DOMString,
maybe_doctype: Option<&DocumentType>) maybe_doctype: Option<&DocumentType>)
-> Fallible<Root<XMLDocument>> { -> Fallible<Root<XMLDocument>> {
let win = self.document.window(); let win = self.document.window();
let loader = DocumentLoader::new(&self.document.loader()); let loader = DocumentLoader::new(&self.document.loader());
let namespace = namespace_from_domstring(maybe_namespace.to_owned());
let content_type = match namespace {
ns!(html) => "application/xhtml+xml",
ns!(svg) => "image/svg+xml",
_ => "application/xml"
};
// Step 1. // Step 1.
let doc = XMLDocument::new(win, let doc = XMLDocument::new(win,
None, None,
None, None,
IsHTMLDocument::NonHTMLDocument, IsHTMLDocument::NonHTMLDocument,
None, Some(DOMString::from(content_type)),
None, None,
DocumentSource::NotFromParser, DocumentSource::NotFromParser,
loader); loader);
@ -82,7 +89,7 @@ impl DOMImplementationMethods for DOMImplementation {
let maybe_elem = if qname.is_empty() { let maybe_elem = if qname.is_empty() {
None None
} else { } else {
match doc.upcast::<Document>().CreateElementNS(namespace, qname) { match doc.upcast::<Document>().CreateElementNS(maybe_namespace, qname) {
Err(error) => return Err(error), Err(error) => return Err(error),
Ok(elem) => Some(elem), Ok(elem) => Some(elem),
} }

View file

@ -1,9 +0,0 @@
[DOMImplementation-createDocument.html]
type: testharness
bug: https://github.com/servo/servo/issues/10743
[createDocument test 179: metadata for "http://www.w3.org/1999/xhtml","",null]
expected: FAIL
[createDocument test 180: metadata for "http://www.w3.org/2000/svg","",null]
expected: FAIL

View file

@ -123,7 +123,7 @@ test(function() {
var doc = document.implementation.createDocument(namespace, qualifiedName, doctype) var doc = document.implementation.createDocument(namespace, qualifiedName, doctype)
assert_equals(doc.compatMode, "CSS1Compat") assert_equals(doc.compatMode, "CSS1Compat")
assert_equals(doc.characterSet, "UTF-8") assert_equals(doc.characterSet, "UTF-8")
assert_equals(doc.contentType, namespace == htmlNamespace ? "text/html" assert_equals(doc.contentType, namespace == htmlNamespace ? "application/xhtml+xml"
: namespace == svgNamespace ? "image/svg+xml" : namespace == svgNamespace ? "image/svg+xml"
: "application/xml") : "application/xml")
assert_equals(doc.URL, "about:blank") assert_equals(doc.URL, "about:blank")

View file

@ -1,11 +1,11 @@
<!DOCTYPE html> <!DOCTYPE html>
<title>document.implementation.createDocument: document.contentType === 'application/xml'</title> <title>document.implementation.createDocument: document.contentType === 'application/xhtml+xml'</title>
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<div id=log></div> <div id=log></div>
<script> <script>
test(function() { test(function() {
var doc = document.implementation.createDocument("http://www.w3.org/1999/xhtml", "html", null); var doc = document.implementation.createDocument("http://www.w3.org/1999/xhtml", "html", null);
assert_equals(doc.contentType, "application/xml"); assert_equals(doc.contentType, "application/xhtml+xml");
}); });
</script> </script>