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

Side by Side 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, 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | LayoutTests/fast/dom/dom-parse-parsererror-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <body onload="onPageLoad()">
4 This tests parsing XHTML containing various syntax errors to make sure that a &l t;parsererror&gt; element is added.
5 <p id="result">Running test...</p>
6 <ol id="errors"></ol>
7 <script type="text/javascript">
8 function onPageLoad() {
9 var xhtmlStartString = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict/ /EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n' +
10 '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang= "en" lang="en">\n' +
11 '<body id="body">\n',
12 xhtmlEndString = '</body>\n' +
13 '</html>\n';
14
15 var invalidXHTMLFragments = [
16 '<span x:test="testing">1</span>' // undeclared 'x' names pace prefix
17 ,'< span>2</span>' // bad start tag
18 ,'<span :test="testing">3</span>' // empty namespace pref ix
19 ,'<span><em>4</span></em>' // staggered tags
20 ,'<span>5' // missing end </span> tag
21 ,'6</span>' // missing start <span> tag
22 ,'<span>7< /span>' // bad end tag
23 ,'<span>8</ span>' // bad end tag
24 ,'<span novalue>9</span>' // missing attribute va lue
25 ,'<span ="noattr">10</span>' // missing attribute na me
26 ,'<span ::="test">11</span>' // bad namespace prefix
27 ,'<span xmlns:="urn:x-test:test">12</span>' // missing namespace pr efix
28 ,'<span xmlns:xmlns="">13</span>' // invalid namespace pr efix
29 ,'<span data-test=testing>14</span>' // unquoted attribute v alue
30 ,'15<span' // bad start tag
31 ,'<8:test xmlns:8="urn:x-test:test">16</8:test>' // invalid namespace pr efix
32 ,'<span xmlns:p1 xmlns:p2="urn:x-test:test"/>17' // missing namespace UR I
33 ];
34
35 var parser = new DOMParser,
36 serializer = new XMLSerializer,
37 result = document.getElementById("result"),
38 errors = document.getElementById("errors");
39 for (var i = 0; i < invalidXHTMLFragments.length; ++i) {
40 var xhtmlDoc = parser.parseFromString(xhtmlStartString + invalidXHTMLFra gments[i] + xhtmlEndString, "application/xhtml+xml");
41
42 var parsererrorElems = xhtmlDoc.getElementsByTagName("parsererror");
43 if (parsererrorElems.length == 0) {
44 result.textContent = "FAIL - invalid XHTML fragment `" + invalidXHTM LFragments[i] + "' did not result in a <parsererror> element.";
45 return;
46 } else if (parsererrorElems.length >= 2) {
47 result.textContent = "FAIL - invalid XHTML fragment `" + invalidXHTM LFragments[i] + "' resulted in multiple <parsererror> elements.";
48 return;
49 } else {
50 var liElem = document.createElement("li");
51 var errorText = parsererrorElems[0].textContent;
52
53 // Remove boilerplate text.
54 var prefix = "This page contains the following errors:";
55 if (errorText.startsWith(prefix))
56 errorText = errorText.substring(prefix.length);
57 errorText = errorText.replace(/^\s*error on line \d at column \d+:/, "");
58 var suffix = "Below is a rendering of the page up to the first error .";
59 if (errorText.endsWith(suffix))
60 errorText = errorText.substring(0, errorText.length - suffix.len gth);
61
62 liElem.textContent = errorText.trim();
63 errors.appendChild(liElem);
64 }
65 }
66
67 if (result.textContent == "Running test...")
68 result.textContent = "";
69
70 if (window.testRunner)
71 testRunner.dumpAsText();
72 }
73 </script>
74 </body>
75 </html>
OLDNEW
« 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