Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.
This repository was archived by the owner on Feb 2, 2023. It is now read-only.

WebTextTest.testGenerateOutputBRElements should have spec complaint test expectaion #10

Closed
@yosinch

Description

@yosinch

Hi, I'm a Chrome developer working to make Element#innerText to the spec compliant[1
and this causes a test failure in WebTextTest.testGenerateOutputBRElements().

The root cause is this test case depends on current Chrome's spec violated behavior:
emitting newline for <br> in Node#textContent[2]. The spec says Node#innerText
returns simple concatenation of descendants Text nodes[3].

Note: Element#innerText returns Node#textContent for disconnected element and this test attempt to call Element#innerText for disconnected element.

Thus, I proposed to change testGenerateOutputBRElements() as below:

CURRENT got = text.generateOutput(true);
PROPOSED got = text.generateOutput(true).replace("\n", "");
Removing newline from got allows us this test works both broken innerText and spec compliant innerText
CURRENT want = "Words\nsplit\nwith\nlines";
PROPOSED want = "Wordssplitwithlines";
assertEquals(want, got);

Above assert is essentially:
<p>Words<br>split<br>with<br>lines</p>.textContent = Wordssplitwithlines

[1] https://html.spec.whatwg.org/multipage/dom.html#the-innertext-idl-attribute
[2] http://crbug.com/859410 Element#innerText for not being rendered element should not have newline for BR
[3] https://dom.spec.whatwg.org/#dom-node-textcontent

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions