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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/forms/add-and-remove-option.html

Issue 1509853008: Move select/option/optgroup-related tests in fast/forms to fast/forms/select. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 <p>Test for <a href="https://bugs.webkit.org/show_bug.cgi?id=13287">bug 13287</a >:
2 Cannot change SELECT to a dynamically created option.</p>
3 <p>Test that DOM is updated before DOMNodeInserted is dispatched.</p>
4 <form>
5 <select ><option selected>1</option><option >2</option></select>
6 <select multiple><option selected>1</option><option >2</option></select>
7 <select size=5><option selected>1</option><option selected>2</option></select>
8 </form>
9 <div id=res></div>
10 <script>
11 if (window.testRunner)
12 testRunner.dumpAsText();
13
14 function log(msg)
15 {
16 var r = document.getElementById('res');
17 r.innerHTML = r.innerHTML + "<br>" + msg;
18 }
19
20 var theSelect;
21
22 function testResults(expectedArr)
23 {
24 var resultsArr = new Array(theSelect.options.length);
25
26 var i;
27 for (i=0; i < theSelect.options.length; i++) {
28 resultsArr[i] = theSelect.options[i].selected;
29 }
30 var successString = "Failed";
31 var success = false;
32 if (expectedArr.join() == resultsArr.join()) {
33 success = true;
34 successString = "Passed";
35 }
36
37 log(successString);
38 if (!success) {
39 log("<pre> Expected: " + expectedArr.join() + "<br>" + " Act ual: " + resultsArr.join() + "</pre>");
40 }
41 }
42
43 function nodeInserted()
44 {
45 if (theSelect.options.length != 3)
46 log("Incorrect options length: " + theSelect.options.length);
47 theSelect.removeChild(theSelect.firstChild);
48 if (theSelect.options.length != 2)
49 log("Incorrect options length: " + theSelect.options.length);
50 }
51
52 try {
53 theSelect = document.forms[0].elements[0];
54 theSelect.addEventListener("DOMNodeInserted", nodeInserted, true);
55 theSelect.options.add(new Option("3", "3", false, true), 0);
56 testResults([true, false], theSelect);
57
58 theSelect = document.forms[0].elements[1];
59 theSelect.addEventListener("DOMNodeInserted", nodeInserted, true);
60 theSelect.options.add(new Option("3", "3", false, true), 0);
61 testResults([true, false], theSelect);
62
63 theSelect = document.forms[0].elements[2];
64 theSelect.addEventListener("DOMNodeInserted", nodeInserted, true);
65 theSelect.insertBefore(new Option("3", "3", false, true), theSelect.firs tChild);
66 testResults([false, false], theSelect);
67
68 } catch (ex) {
69 alert(ex);
70 }
71 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698