Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Specify the URL, content type and encoding of DOMParser-created docum…

…ents.
  • Loading branch information...
commit ed7b611c2e37ca585fb577b8cd961fa8f2df6629 1 parent 2f6067b
@Ms2ger Ms2ger authored
Showing with 64 additions and 3 deletions.
  1. +14 −3 domparser
  2. +11 −0 source.html
  3. +39 −0 tests/DOMParser.html
View
17 domparser
@@ -19,7 +19,7 @@
<body class=draft>
<div class=head id=head>
<h1>DOM Parsing and Serialization</h1>
-<h2 class="no-num no-toc" id=work-in-progress-&mdash;-last-update-21-december-2011>Work in Progress &mdash; Last Update 21 December 2011</h2>
+<h2 class="no-num no-toc" id=work-in-progress-&mdash;-last-update-19-january-2012>Work in Progress &mdash; Last Update 19 January 2012</h2>
<dl>
<dt>Editor
<dd>Ms2ger &lt;ms2ger@gmail.com&gt;
@@ -27,7 +27,7 @@
<dt>Version history
<dd><a href=http://bitbucket.org/ms2ger/dom-parsing-and-serialization/>http://bitbucket.org/ms2ger/dom-parsing-and-serialization</a>
</dl>
-<p class=copyright>&copy; 2010&ndash;2011 The editors.
+<p class=copyright>&copy; 2010&ndash;2012 The editors.
<p class=copyright><a href=http://creativecommons.org/publicdomain/zero/1.0/>CC0 1.0 Universal</a>.
</div>
@@ -322,6 +322,17 @@ method must run these steps:
<li><p>Return <var title="">document</var>.
</ol>
+<p>In either case, the returned
+<a class=external data-anolis-spec=dom href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-document title=concept-document>document</a>'s
+<a class=external data-anolis-spec=dom href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-document-content-type title=concept-document-content-type>content type</a>
+must be the <var title="">type</var> argument, and its
+<a class=external data-anolis-spec=dom href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-document-url title=concept-document-url>URL</a> must be null.
+
+<p class=note>The returned
+<a class=external data-anolis-spec=dom href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-document title=concept-document>document</a>'s
+<a class=external data-anolis-spec=dom href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-document-encoding title=concept-document-encoding>encoding</a> is
+the default, UTF-8.
+
<h2 id=the-xmlserializer-interface><span class=secno>5 </span>The <a href=#xmlserializer><code>XMLSerializer</code></a> interface</h2>
@@ -826,7 +837,7 @@ method must run these steps:
<dd><cite><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html>DOM4</a></cite>, Anne van Kesteren, Aryeh Gregor and Ms2ger. W3C.
<dt id=refsHTML>[HTML]
-<dd><cite><a href=http://www.whatwg.org/html>HTML</a></cite>, Ian Hickson. WHATWG.
+<dd><cite><a href=http://www.whatwg.org/C>HTML</a></cite>, Ian Hickson. WHATWG.
<dt id=refsRFC2119>[RFC2119]
<dd><cite><a href=http://tools.ietf.org/html/rfc2119>Key words for use in RFCs to Indicate Requirement Levels</a></cite>, Scott Bradner. IETF.
View
11 source.html
@@ -301,6 +301,17 @@ <h2 class=no-num>Issues</h2>
<li><p>Return <var title>document</var>.
</ol>
+<p>In either case, the returned
+<span title=concept-document data-anolis-spec=dom>document</span>'s
+<span title=concept-document-content-type data-anolis-spec=dom>content type</span>
+must be the <var title>type</var> argument, and its
+<span title=concept-document-url data-anolis-spec=dom>URL</span> must be null.
+
+<p class=note>The returned
+<span title=concept-document data-anolis-spec=dom>document</span>'s
+<span title=concept-document-encoding data-anolis-spec=dom>encoding</span> is
+the default, UTF-8.
+
<h2>The <code>XMLSerializer</code> interface</h2>
View
39 tests/DOMParser.html
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<title>DOMParser</title>
+<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+function isErrorDocument(doc, contentType) {
+ assert_true(doc instanceof Document)
+ assert_true(doc instanceof XMLDocument)
+ assert_equals(doc.documentElement.namespaceURI, "http://www.mozilla.org/newlayout/xml/parsererror.xml");
+ assert_equals(doc.documentElement.localName, "parsererror");
+ assert_equals(doc.documentElement.tagName, "parsererror");
+ assert_equals(doc.URL, null)
+ assert_equals(doc.documentURI, null)
+ assert_equals(doc.characterSet, "UTF-8")
+ assert_equals(doc.contentType, contentType)
+}
+
+var allowedTypes = ["text/xml", "application/xml", "application/xhtml+xml", "image/svg+xml"]
+
+test(function() {
+ var p = new DOMParser();
+ var doc = p.parseFromString("<foo/>", "text/xml")
+ assert_true(doc instanceof Document)
+ assert_equals(doc.URL, null)
+ assert_equals(doc.documentURI, null)
+ assert_equals(doc.characterSet, "UTF-8")
+ assert_equals(doc.contentType, "text/xml")
+})
+
+allowedTypes.forEach(function(type) {
+ test(function() {
+ var p = new DOMParser();
+ var doc = p.parseFromString("<foo>", type)
+ isErrorDocument(doc, type);
+ }, "Should return an error document for XML wellformedness errors in type " + type)
+})
+</script>
Please sign in to comment.
Something went wrong with that request. Please try again.