Skip to content

Commit 2e5cf0a

Browse files
committed
Add some tests for CSS and scrolling; fix scroll handling so errors clearer
1 parent a142a7b commit 2e5cf0a

File tree

3 files changed

+38
-10
lines changed

3 files changed

+38
-10
lines changed

code-input.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ code-input .code-input_dialog-container .code-input_keyboard-navigation-instruct
190190
padding-left: 10px;
191191
margin: 0;
192192
text-wrap: balance;
193-
overflow: hidden;
193+
overflow: auto;
194194
text-overflow: ellipsis;
195195
width: calc(100% - 12px);
196196
box-sizing: content-box; /* Make height, width work consistently no matter the box-sizing of ancestors. */

code-input.js

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,17 +1066,26 @@ var codeInput = {
10661066
set scrollHeight(val) { this.textareaElement.scrollHeight = val; };
10671067
get scrollWidth() { return this.textareaElement.scrollWidth; };
10681068
set scrollWidth(val) { this.textareaElement.scrollWidth = val; };
1069-
scroll(firstArg, secondArg=undefined) {
1070-
if(secondArg === undefined) this.textareaElement.scroll(firstArg);
1071-
else this.textareaElement.scroll(firstArg, secondArg);
1069+
scroll(options) {
1070+
this.textareaElement.scroll(options);
1071+
this.textareaElement.scroll(x, y);
10721072
};
1073-
scrollTo(firstArg, secondArg=undefined) {
1074-
if(secondArg === undefined) this.textareaElement.scrollTo(firstArg);
1075-
else this.textareaElement.scrollTo(firstArg, secondArg);
1073+
scroll(x, y) {
1074+
this.textareaElement.scroll(x, y);
10761075
};
1077-
scrollBy(firstArg, secondArg=undefined) {
1078-
if(secondArg === undefined) this.textareaElement.scrollBy(firstArg);
1079-
else this.textareaElement.scrollBy(firstArg, secondArg);
1076+
scrollTo(options) {
1077+
this.textareaElement.scroll(options);
1078+
this.textareaElement.scroll(x, y);
1079+
};
1080+
scrollTo(x, y) {
1081+
this.textareaElement.scroll(x, y);
1082+
};
1083+
scrollBy(options) {
1084+
this.textareaElement.scroll(options);
1085+
this.textareaElement.scroll(x, y);
1086+
};
1087+
scrollBy(x, y) {
1088+
this.textareaElement.scroll(x, y);
10801089
};
10811090
},
10821091

tests/tester.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,25 @@ console.log("I've got another line!", 2 < 3, "should be true.");`);
323323
// A second line
324324
// A third line with <html> tags`);
325325

326+
codeInputElement.setAttribute("style", "width: 10em; height: 30em; white-space: pre-wrap; word-break: normal;");
327+
textarea.selectionStart -= 1;
328+
await waitAsync(50); // Wait for CSS to visibly change
329+
testAssertion("Core", "CSS pre-wrap normal", confirm("Is the code wrapped, and the selected character aligned? (OK=Yes)"), "user-judged");
330+
codeInputElement.setAttribute("style", "width: 10em; height: 30em; white-space: pre-wrap; word-break: break-word;");
331+
await waitAsync(50); // Wait for CSS to visibly change
332+
testAssertion("Core", "CSS pre-wrap break-word", confirm("Is the code wrapped, and the selected character aligned? (OK=Yes)"), "user-judged");
333+
codeInputElement.setAttribute("style", "width: 10em; height: 30em; white-space: pre-wrap; word-break: break-all;");
334+
await waitAsync(50); // Wait for CSS to visibly change
335+
testAssertion("Core", "CSS pre-wrap break-all", confirm("Is the code wrapped, and the selected character aligned? (OK=Yes)"), "user-judged");
336+
codeInputElement.setAttribute("style", "font-size: 50px; height: 10em;");
337+
await waitAsync(50); // Wait for CSS to visibly change
338+
testAssertion("Core", "CSS font-size", confirm("Is the selected character aligned? (OK=Yes)"), "user-judged");
339+
codeInputElement.setAttribute("style", "width: 10em; height: 10em; white-space: pre-wrap; word-break: break-all;");
340+
codeInputElement.scrollTo(0, (codeInputElement.offsetHeight - codeInputElement.clientHeight) + codeInputElement.scrollHeight); // Scroll to bottom - offset-client is margin+border+padding
341+
await waitAsync(50); // Wait for CSS to visibly change
342+
testAssertion("Core", "Scroll aligned", confirm("Is the selected character aligned? (OK=Yes)"), "user-judged");
343+
codeInputElement.removeAttribute("style");
344+
326345
/*--- Tests for plugins ---*/
327346
// AutoCloseBrackets
328347
testAddingText("AutoCloseBrackets", textarea, function(textarea) {

0 commit comments

Comments
 (0)