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

Side by Side Diff: LayoutTests/fast/forms/resources/common-setrangetext.js

Issue 373043004: IDL: Treat undefined as missing for optional arguments with defaults (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebased Created 6 years, 5 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
1 function runTestsShouldPass(tagName, attributes) 1 function runTestsShouldPass(tagName, attributes)
2 { 2 {
3 attributes = attributes || {}; 3 attributes = attributes || {};
4 window.element = document.createElement(tagName); 4 window.element = document.createElement(tagName);
5 for (var key in attributes) 5 for (var key in attributes)
6 element.setAttribute(key, attributes[key]); 6 element.setAttribute(key, attributes[key]);
7 document.body.appendChild(element); 7 document.body.appendChild(element);
8 debug("<hr>"); 8 debug("<hr>");
9 debug("Running tests on " + tagName + " with attributes: " + JSON.stringify( attributes) + "\n"); 9 debug("Running tests on " + tagName + " with attributes: " + JSON.stringify( attributes) + "\n");
10 debug("setRangeText() with only one parameter."); 10 debug("setRangeText() with only one parameter.");
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 83
84 evalAndLog("element.value = '0123456789'"); 84 evalAndLog("element.value = '0123456789'");
85 evalAndLog("element.setSelectionRange(6, 9)"); 85 evalAndLog("element.setSelectionRange(6, 9)");
86 evalAndLog("element.setRangeText('AB', 1, 1, 'invalid')"); // Invalid select Mode values default to preserve. 86 evalAndLog("element.setRangeText('AB', 1, 1, 'invalid')"); // Invalid select Mode values default to preserve.
87 shouldBeEqualToString("element.value", "0AB123456789"); 87 shouldBeEqualToString("element.value", "0AB123456789");
88 shouldBe("element.selectionStart", "8"); 88 shouldBe("element.selectionStart", "8");
89 shouldBe("element.selectionEnd", "11"); 89 shouldBe("element.selectionEnd", "11");
90 90
91 evalAndLog("element.value = '0123456789'"); 91 evalAndLog("element.value = '0123456789'");
92 evalAndLog("element.setSelectionRange(6, 9)"); 92 evalAndLog("element.setSelectionRange(6, 9)");
93 evalAndLog("element.setRangeText('AB', 1, 1, undefined)"); // Undefined sele ctMode also default to preserve.
94 shouldBeEqualToString("element.value", "0AB123456789");
95 shouldBe("element.selectionStart", "8");
96 shouldBe("element.selectionEnd", "11");
97
98 evalAndLog("element.value = '0123456789'");
99 evalAndLog("element.setSelectionRange(6, 9)");
93 evalAndLog("element.setRangeText('A', 1, 3, 'preserve')"); 100 evalAndLog("element.setRangeText('A', 1, 3, 'preserve')");
94 shouldBeEqualToString("element.value", "0A3456789"); 101 shouldBeEqualToString("element.value", "0A3456789");
95 shouldBe("element.selectionStart", "5"); 102 shouldBe("element.selectionStart", "5");
96 shouldBe("element.selectionEnd", "8"); 103 shouldBe("element.selectionEnd", "8");
97 104
98 evalAndLog("element.value = '0123456789'"); 105 evalAndLog("element.value = '0123456789'");
99 evalAndLog("element.setSelectionRange(2, 6)"); 106 evalAndLog("element.setSelectionRange(2, 6)");
100 evalAndLog("element.setRangeText('A', 1, 4, 'preserve')"); 107 evalAndLog("element.setRangeText('A', 1, 4, 'preserve')");
101 shouldBeEqualToString("element.value", "0A456789"); 108 shouldBeEqualToString("element.value", "0A456789");
102 shouldBe("element.selectionStart", "1"); 109 shouldBe("element.selectionStart", "1");
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 shouldThrow("element.value = '0123456789XYZ'"); 156 shouldThrow("element.value = '0123456789XYZ'");
150 else 157 else
151 evalAndLog("element.value = '0123456789XYZ'"); 158 evalAndLog("element.value = '0123456789XYZ'");
152 var initialValue = element.value; 159 var initialValue = element.value;
153 shouldThrow("element.setRangeText('ABC', 0, 0)"); 160 shouldThrow("element.setRangeText('ABC', 0, 0)");
154 // setRangeText() shouldn't do anything on non-text form controls. 161 // setRangeText() shouldn't do anything on non-text form controls.
155 shouldBeEqualToString("element.value", initialValue); 162 shouldBeEqualToString("element.value", initialValue);
156 } 163 }
157 164
158 165
OLDNEW
« no previous file with comments | « LayoutTests/fast/encoding/api/basics.html ('k') | LayoutTests/fast/forms/search/search-setrangetext-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698