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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/parser/inselect-tokenization.html

Issue 2625103002: Teach the background parser to ignore certain elements inside '<select>'. (Closed)
Patch Set: Test. Created 3 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/testharness.js"></script>
3 <script src="../../resources/testharnessreport.js"></script>
4 <body>
5 <script>
6 /************************************************************************
7 * Helper functions!
8 */
9 function createFrame(markup) {
10 var i = document.createElement('iframe');
11 i.srcdoc = markup;
12 return i;
13 }
14
15 function appendAndWaitForLoad(test, frame) {
16 return new Promise((resolve, reject) => {
17 frame.onload = test.step_func(_ => {
18 frame.onload = null;
19 resolve();
20 });
21 document.body.appendChild(frame);
22 });
23 }
24
25 function assert_select(test, frame, value) {
26 var select = frame.contentDocument.querySelector('select');
27 assert_equals(select.value, value, 'select');
28 }
29
30 function assert_element_innerText(test, frame, name, value) {
31 var el = frame.contentDocument.querySelector(name);
32 if (value === null || value === undefined)
33 assert_equals(el, null, name);
34 else
35 assert_equals(el.innerText, value, name);
36 }
37
38 /************************************************************************
39 * The actual tests!
40 */
41 var tests = [
42 // <input>, <keygen>, and <textarea> close <select>, so <plaintext> works.
43 ];
44
45 var elementsToIgnore = [
46 "iframe",
47 "noembed",
48 "noframes",
49 "noscript",
50 "plaintext",
51 "style",
52 "xmp",
53 ];
54
55 elementsToIgnore.forEach(el => {
56 tests.push(
57 {
58 markup: `<form><select><option><${el}>1<element></element>`,
59 select: "1",
60 innerText: null,
61 name: el
62 }, {
63 markup: `<form><select><option>1<${el}>2<element></element>`,
64 select: "12",
65 innerText: null,
66 name: el
67 }, {
68 markup: `<form><select><option>1<${el}>2<element></element>3`,
69 select: "123",
70 innerText: null,
71 name: el
72 });
73 if (el != "iframe") {
74 tests.push(
75 {
76 markup: `<form><select><option>1<input><${el}>2<element></element>`,
77 select: "1",
78 innerText: "2<element></element>",
79 name: el
80 }, {
81 markup: `<form><select><option>1<keygen><${el}>2<element></element>`,
82 select: "1",
83 innerText: "2<element></element>",
84 name: el
85 }, {
86 markup: `<form><select><option>1<textarea></textarea><${el}>2<element> </element>`,
87 select: "1",
88 innerText: "2<element></element>",
89 name: el
90 });
91 }
92 });
93
94
95 tests.forEach(test => {
96 async_test(t => {
97 var i = createFrame(test.markup);
98
99 appendAndWaitForLoad(t, i)
100 .then(t.step_func_done(_ => {
101 assert_select(t, i, test.select);
102 assert_element_innerText(t, i, test.name, test.innerText);
103 }));
104 }, test.markup);
105 });
106 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698