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

Side by Side Diff: LayoutTests/fast/innerHTML/javascript-url.html

Issue 1031783002: Escape '&' in javascript URLs for innerHTML/outerHTML (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Patch for landing Created 5 years, 9 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/innerHTML/javascript-url-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
1 <head> 1 <!DOCTYPE html>
2 <script> 2 <script src="../../resources/js-test.js"></script>
3 if (window.testRunner)
4 testRunner.dumpAsText();
5
6 function print(message, color)
7 {
8 var paragraph = document.createElement("div");
9 paragraph.appendChild(document.createTextNode(message));
10 paragraph.style.fontFamily = "monospace";
11 if (color)
12 paragraph.style.color = color;
13 document.getElementById("console").appendChild(paragraph);
14 }
15
16 function run(a)
17 {
18 print(a);
19 try {
20 eval(a);
21 } catch(e) {
22 print(e);
23 }
24 }
25
26 function shouldBe(a, b)
27 {
28 var evalA;
29 try {
30 evalA = eval(a);
31 } catch(e) {
32 evalA = e;
33 }
34
35 if (evalA == b)
36 print("PASS: " + a + " should be " + b + " and is.", "green");
37 else
38 print("FAIL: " + a + " should be " + b + " but instead is " + evalA + ". ", "red");
39 }
40 </script>
41 </head>
42 <body> 3 <body>
43 Test that innerHTML does not mangle javascript: urls. 4 Test that innerHTML/outerHTML does not mangle javascript: urls.
44 <div id=console></div> 5 <div id=console></div>
45 <div id=jsurltest><a href=' 6 <div id=jsurltest><a href='javascript:test(&37;3C!--D--&37;3E)'>link</a></div>
46 javascript:test(&37;3C!--D--&37;3E)'>link</a></div>
47 <script> 7 <script>
48 var r = document.getElementById('jsurltest'); 8 var r = document.getElementById('jsurltest');
49 run("r.innerHTML = r.innerHTML.replace(/&37;3C!--D--&37;3E/g, 123)"); 9
50 shouldBe("r.innerHTML.indexOf('javascript:test(123)') > -1", true); 10 r.innerHTML = r.innerHTML.replace('&amp;37;3C!--D--&amp;37;3E', 123);
51 run("r.firstChild.setAttribute('href', 'javascript:test(\"text<\")')"); 11 shouldBeEqualToString('r.innerHTML', '<a href="javascript:test(123)">link</a>');
52 shouldBe("r.innerHTML.indexOf('javascript:test(\"text<\")') > -1", true); 12
53 run('r.firstChild.setAttribute("href", "javascript:test(\'text>\')")'); 13 r.firstChild.setAttribute('href', 'javascript:test(\"text<\")');
54 shouldBe('r.innerHTML.indexOf("javascript:test(\'text>\')") > -1', true); 14 shouldBeEqualToString('r.innerHTML', '<a href=\'javascript:test("text<")\'>link< /a>');
15
16 r.firstChild.setAttribute('href', 'javascript:test(\'text>\')');
17 shouldBeEqualToString("r.innerHTML", '<a href="javascript:test(\'text>\')">link< /a>');
18
55 testString = 'javascript:test(\'text&\',"test2&")'; 19 testString = 'javascript:test(\'text&\',"test2&")';
56 print("testString = " + testString); 20 r.firstChild.setAttribute('href', testString);
57 run('r.firstChild.setAttribute("href", testString)'); 21 shouldBeEqualToString('r.innerHTML', '<a href="javascript:test(\'text&amp;\',&qu ot;test2&amp;&quot;)">link</a>');
58 shouldBe('r.innerHTML.indexOf("javascript:test(\'text&\',&quot;test2&&quot;)") > 1', true);
59 22
60 run("r.firstChild.setAttribute('href', 'http://www.google.fi/search?q=scarlett j ohansson&meta=&btnG=Google-haku')"); 23 r.firstChild.href = 'javascript:window.location=\'?x&y\'';
61 print(r.innerHTML); 24 shouldBeEqualToString("r.firstChild.outerHTML", '<a href="javascript:window.loca tion=\'?x&amp;y\'">link</a>');
25
26 // Behavior is same as FF
27 r.firstChild.href = 'javascript:window.location=\'?x&amp;y\'';
28 shouldBeEqualToString('r.firstChild.outerHTML', '<a href="javascript:window.loca tion=\'?x&amp;amp;y\'">link</a>');
29 r.innerHTML = '<a href="javascript:window.location=\'?x&amp;y\'">link</a>';
30 shouldBeEqualToString('r.firstChild.outerHTML', '<a href="javascript:window.loca tion=\'?x&amp;y\'">link</a>');
62 </script> 31 </script>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/fast/innerHTML/javascript-url-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698