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

Side by Side Diff: LayoutTests/fast/dom/XMLSerializer-attribute-entities.html

Issue 117103003: DOM serialization: fix quoting of < and > in HMTL attribute values. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: < and > are un-quoted in HTML, quoted in XML. Created 6 years, 11 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
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <script src="../../resources/js-test.js"></script>
3
4 <script>
5 description('Test that XMLSerializer quotes the attribute characters specified i n <a href="https://dvcs.w3.org/hg/innerhtml/raw-file/tip/index.html#dfn-concept- serialize-xml-attributes">the W3C spec</a>.');
6
7 var attrValue = '< > & " \' \xA0';
8
9 // HTML case.
10 // DOM parsing and serialization defers to the HTML specification: http://www.w3 .org/html/wg/drafts/html/master/syntax.html#attribute's-serialized-name
11 // Steps 1-3 under the "Escaping a string" heading are relevant to attributes.
12 window.htmlElement = document.createElement('div');
13 htmlElement.setAttribute('quoteme', attrValue);
14 shouldBe('htmlElement.outerHTML', '"<div quoteme=\\"< > &amp; &quot; \' &nbsp;\\ "><' + '/div>"');
15
16 // XML case.
17 // DOM parsing and serialization: https://dvcs.w3.org/hg/innerhtml/raw-file/tip/ index.html#dfn-concept-serialize-xml-attributes
18 // Step 2 substep 4 is relevant to attributes.
19 var xmlDocument = document.implementation.createDocument('http://www.w3.org/1999 /xhtml', 'html', null);
20 window.xmlElement = xmlDocument.createElement('div');
21 xmlElement.setAttribute('quoteme', attrValue);
22 shouldBe('(new XMLSerializer()).serializeToString(xmlElement)', '"<div xmlns=\\" http://www.w3.org/1999/xhtml\\" quoteme=\\"&lt; &gt; &amp; &quot; \' \\xA0\\"><' + '/div>"');
23 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698