Commit 55fa369e authored by rniwa@webkit.org's avatar rniwa@webkit.org

XML fragment parsing algorithm doesn't use the context element's default namespace URI

https://bugs.webkit.org/show_bug.cgi?id=125132

Reviewed by Darin Adler.

Source/WebCore:

Always use the context element's namespace as the default namespace URI when one is not specified by xmlns.

The new behavior matches that of Internet Explorer and the specified behavior in HTML5:
http://www.w3.org/TR/2013/CR-html5-20130806/the-xhtml-syntax.html#parsing-xhtml-fragments

"The default namespace is the namespace for which the DOM isDefaultNamespace() method on the element would
return true."

Test: fast/parser/fragment-parsing-in-document-without-xmlns.html

* xml/parser/XMLDocumentParserLibxml2.cpp:
(WebCore::XMLDocumentParser::XMLDocumentParser):

LayoutTests:

Added a test for parsing a markup fragment inside a XHTML document without xmlns.
The parsed fragment should use the context element's namespace as the default namespace.

* fast/parser/fragment-parsing-in-document-without-xmlns-expected.txt: Added.
* fast/parser/fragment-parsing-in-document-without-xmlns.html: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@160024 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent e2986bb9
2013-12-03 Ryosuke Niwa <rniwa@webkit.org>
XML fragment parsing algorithm doesn't use the context element's default namespace URI
https://bugs.webkit.org/show_bug.cgi?id=125132
Reviewed by Darin Adler.
Added a test for parsing a markup fragment inside a XHTML document without xmlns.
The parsed fragment should use the context element's namespace as the default namespace.
* fast/parser/fragment-parsing-in-document-without-xmlns-expected.txt: Added.
* fast/parser/fragment-parsing-in-document-without-xmlns.html: Added.
2013-12-03 Radu Stavila <stavila@adobe.com>
The overflow border of a relatively positioned element inside a region is not painted
......
This tests the fragment parsing algorithm inside a XHTML document without xmlns set on the document element via innerHTML. The element without prefix or xmlns attribute should use the default namespace of the context element (that of body element in this case).
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
xmlDocumentWithoutXmlns.body = xmlDocumentWithoutXmlns.createElement('body');
contextElement = xmlDocumentWithoutXmlns.body;
FAIL contextElement.innerHTML = '<a href=""></a>'; contextElement.body.firstChild.namespaceURI should be http://www.w3.org/1999/xhtml. Threw exception TypeError: undefined is not an object (evaluating 'contextElement.body.firstChild')
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<html>
<body>
<script src="../../resources/js-test-pre.js"></script>
<script>
description("This tests the fragment parsing algorithm inside a XHTML document without xmlns set on the document element via innerHTML.\n"
+ "The element without prefix or xmlns attribute should use the default namespace of the context element (that of body element in this case).");
var xhtmlDoctype = document.implementation.createDocumentType('html',
'-//W3C//DTD XHTML 1.0 Strict//EN', 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd');
var xmlDocumentWithoutXmlns = document.implementation.createDocument('http://www.w3.org/1999/xhtml', 'html', xhtmlDoctype);
evalAndLog("xmlDocumentWithoutXmlns.body = xmlDocumentWithoutXmlns.createElement('body');");
evalAndLog("contextElement = xmlDocumentWithoutXmlns.body;");
shouldBe("contextElement.innerHTML = '<a href=\"\"></a>'; contextElement.body.firstChild.namespaceURI", "'http://www.w3.org/1999/xhtml'");
var successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>
2013-12-03 Ryosuke Niwa <rniwa@webkit.org>
XML fragment parsing algorithm doesn't use the context element's default namespace URI
https://bugs.webkit.org/show_bug.cgi?id=125132
Reviewed by Darin Adler.
Always use the context element's namespace as the default namespace URI when one is not specified by xmlns.
The new behavior matches that of Internet Explorer and the specified behavior in HTML5:
http://www.w3.org/TR/2013/CR-html5-20130806/the-xhtml-syntax.html#parsing-xhtml-fragments
"The default namespace is the namespace for which the DOM isDefaultNamespace() method on the element would
return true."
Test: fast/parser/fragment-parsing-in-document-without-xmlns.html
* xml/parser/XMLDocumentParserLibxml2.cpp:
(WebCore::XMLDocumentParser::XMLDocumentParser):
2013-12-03 Nick Diego Yamane <nick.yamane@openbossa.org>
Remove some CSS Variables leftovers
......@@ -627,6 +627,7 @@ XMLDocumentParser::XMLDocumentParser(DocumentFragment& fragment, Element* parent
if (elemStack.isEmpty())
return;
// FIXME: Share code with isDefaultNamespace() per http://www.whatwg.org/specs/web-apps/current-work/multipage/the-xhtml-syntax.html#parsing-xhtml-fragments
for (; !elemStack.isEmpty(); elemStack.removeLast()) {
Element* element = elemStack.last();
if (element->hasAttributes()) {
......@@ -640,8 +641,7 @@ XMLDocumentParser::XMLDocumentParser(DocumentFragment& fragment, Element* parent
}
}
// If the parent element is not in document tree, there may be no xmlns attribute; just default to the parent's namespace.
if (m_defaultNamespaceURI.isNull() && !parentElement->inDocument())
if (m_defaultNamespaceURI.isNull())
m_defaultNamespaceURI = parentElement->namespaceURI();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment