diff --git a/components/script/textinput.rs b/components/script/textinput.rs index c4d8b3747b6..310e0566453 100644 --- a/components/script/textinput.rs +++ b/components/script/textinput.rs @@ -770,7 +770,11 @@ impl TextInput { /// any \n encountered will be stripped and force a new logical line. pub fn set_content(&mut self, content: DOMString) { self.lines = if self.multiline { - content.split('\n').map(DOMString::from).collect() + // https://html.spec.whatwg.org/multipage/#textarea-line-break-normalisation-transformation + content.replace("\r\n", "\n") + .split(|c| c == '\n' || c == '\r') + .map(DOMString::from) + .collect() } else { vec!(content) }; diff --git a/tests/wpt/metadata/html/semantics/forms/the-textarea-element/value-defaultValue-textContent.html.ini b/tests/wpt/metadata/html/semantics/forms/the-textarea-element/value-defaultValue-textContent.html.ini index 9377d122a79..70748406931 100644 --- a/tests/wpt/metadata/html/semantics/forms/the-textarea-element/value-defaultValue-textContent.html.ini +++ b/tests/wpt/metadata/html/semantics/forms/the-textarea-element/value-defaultValue-textContent.html.ini @@ -1,17 +1,8 @@ [value-defaultValue-textContent.html] type: testharness - [defaultValue and value treat CRLF differently] - expected: FAIL - - [tests for the value setter] - expected: FAIL - [defaultValue and value are affected by textContent in combination with appending a DocumentFragment] expected: FAIL [defaultValue and value reflect child text content, not textContent] expected: FAIL - [value normalizes CRLF even spread over multiple text nodes] - expected: FAIL -