Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Unified Diff: LayoutTests/fast/dom/dom-parse-parsererror.html

Issue 771493002: Insert the error message block when stopping parsing and an error occurred Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix svg/custom/missing-xlink.svg Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | LayoutTests/fast/dom/dom-parse-parsererror-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/fast/dom/dom-parse-parsererror.html
diff --git a/LayoutTests/fast/dom/dom-parse-parsererror.html b/LayoutTests/fast/dom/dom-parse-parsererror.html
new file mode 100644
index 0000000000000000000000000000000000000000..2463ddd8f6385a5c6b5db2eb2c9360d456ccfda8
--- /dev/null
+++ b/LayoutTests/fast/dom/dom-parse-parsererror.html
@@ -0,0 +1,75 @@
+<!DOCTYPE html>
+<html>
+<body onload="onPageLoad()">
+This tests parsing XHTML containing various syntax errors to make sure that a &lt;parsererror&gt; element is added.
+<p id="result">Running test...</p>
+<ol id="errors"></ol>
+<script type="text/javascript">
+function onPageLoad() {
+ var xhtmlStartString = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n' +
+ '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">\n' +
+ '<body id="body">\n',
+ xhtmlEndString = '</body>\n' +
+ '</html>\n';
+
+ var invalidXHTMLFragments = [
+ '<span x:test="testing">1</span>' // undeclared 'x' namespace prefix
+ ,'< span>2</span>' // bad start tag
+ ,'<span :test="testing">3</span>' // empty namespace prefix
+ ,'<span><em>4</span></em>' // staggered tags
+ ,'<span>5' // missing end </span> tag
+ ,'6</span>' // missing start <span> tag
+ ,'<span>7< /span>' // bad end tag
+ ,'<span>8</ span>' // bad end tag
+ ,'<span novalue>9</span>' // missing attribute value
+ ,'<span ="noattr">10</span>' // missing attribute name
+ ,'<span ::="test">11</span>' // bad namespace prefix
+ ,'<span xmlns:="urn:x-test:test">12</span>' // missing namespace prefix
+ ,'<span xmlns:xmlns="">13</span>' // invalid namespace prefix
+ ,'<span data-test=testing>14</span>' // unquoted attribute value
+ ,'15<span' // bad start tag
+ ,'<8:test xmlns:8="urn:x-test:test">16</8:test>' // invalid namespace prefix
+ ,'<span xmlns:p1 xmlns:p2="urn:x-test:test"/>17' // missing namespace URI
+ ];
+
+ var parser = new DOMParser,
+ serializer = new XMLSerializer,
+ result = document.getElementById("result"),
+ errors = document.getElementById("errors");
+ for (var i = 0; i < invalidXHTMLFragments.length; ++i) {
+ var xhtmlDoc = parser.parseFromString(xhtmlStartString + invalidXHTMLFragments[i] + xhtmlEndString, "application/xhtml+xml");
+
+ var parsererrorElems = xhtmlDoc.getElementsByTagName("parsererror");
+ if (parsererrorElems.length == 0) {
+ result.textContent = "FAIL - invalid XHTML fragment `" + invalidXHTMLFragments[i] + "' did not result in a <parsererror> element.";
+ return;
+ } else if (parsererrorElems.length >= 2) {
+ result.textContent = "FAIL - invalid XHTML fragment `" + invalidXHTMLFragments[i] + "' resulted in multiple <parsererror> elements.";
+ return;
+ } else {
+ var liElem = document.createElement("li");
+ var errorText = parsererrorElems[0].textContent;
+
+ // Remove boilerplate text.
+ var prefix = "This page contains the following errors:";
+ if (errorText.startsWith(prefix))
+ errorText = errorText.substring(prefix.length);
+ errorText = errorText.replace(/^\s*error on line \d at column \d+:/, "");
+ var suffix = "Below is a rendering of the page up to the first error.";
+ if (errorText.endsWith(suffix))
+ errorText = errorText.substring(0, errorText.length - suffix.length);
+
+ liElem.textContent = errorText.trim();
+ errors.appendChild(liElem);
+ }
+ }
+
+ if (result.textContent == "Running test...")
+ result.textContent = "";
+
+ if (window.testRunner)
+ testRunner.dumpAsText();
+}
+</script>
+</body>
+</html>
« no previous file with comments | « no previous file | LayoutTests/fast/dom/dom-parse-parsererror-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698