Bug 258254 - document.execCommand('insertOrderedList'); can hang browser on removing list
Summary: document.execCommand('insertOrderedList'); can hang browser on removing list
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: HTML Editing (show other bugs)
Version: Safari Technology Preview
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL: https://jsfiddle.net/qLnwv728/show
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2023-06-17 17:36 PDT by Ahmad Saleem
Modified: 2024-06-24 04:03 PDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ahmad Saleem 2023-06-17 17:36:34 PDT
Hi Team,

This seems to another test case, which hangs tab (only tab) and make it non-interactive, if we follow the instructions as per test case.

It is from crbug.com/653732

^ I came across this bug while looking into: crbug.com/571420, which has following commit:

Blink Commit: https://chromium.googlesource.com/chromium/src.git/+/f15d4cc339737df653274e39726ae0d14d409b18

^ Test Case from above in JSFiddle: https://jsfiddle.net/5y09um8b/

^^ Safari Technology Preview 172 and Firefox Nightly 116 both fail above.

I think we should fix hanging issue and ensure that Safari remain interactive, so raising it for tracking and fixing purposes.

Thanks!
Comment 1 Ahmad Saleem 2023-06-17 17:37:03 PDT
Hanging test case is in URL field. Forgot to add.
Comment 2 Radar WebKit Bug Importer 2023-06-24 17:37:14 PDT
<rdar://problem/111272008>
Comment 3 Ahmad Saleem 2023-06-26 13:48:14 PDT
Change in 'Source/WebCore/editing/Editing.cpp' and following function 'firstEditablePositionAfterPositionInRoot':

From Line 271 onward:

Node* nonEditableNode = nullptr;
    while (candidate.deprecatedNode() && !isEditablePosition(candidate) && candidate.deprecatedNode()->isDescendantOf(*highestRoot)) {
        nonEditableNode = candidate.deprecatedNode();
        candidate = isAtomicNode(candidate.deprecatedNode()) ? positionInParentAfterNode(candidate.deprecatedNode()) : nextVisuallyDistinctCandidate(candidate);
    }
    if (candidate.deprecatedNode() && candidate.deprecatedNode() != highestRoot && !candidate.deprecatedNode()->isDescendantOf(*highestRoot))
        return { };
    if (nonEditableNode && nonEditableNode->isDescendantOf(candidate.deprecatedNode()))
        candidate = nextVisuallyDistinctCandidate(candidate);
    return candidate;
}
Comment 4 Ahmad Saleem 2023-06-26 13:50:07 PDT
(In reply to Ahmad Saleem from comment #3)
> Change in 'Source/WebCore/editing/Editing.cpp' and following function
> 'firstEditablePositionAfterPositionInRoot':
> 
> From Line 271 onward:
> 
> Node* nonEditableNode = nullptr;
>     while (candidate.deprecatedNode() && !isEditablePosition(candidate) &&
> candidate.deprecatedNode()->isDescendantOf(*highestRoot)) {
>         nonEditableNode = candidate.deprecatedNode();
>         candidate = isAtomicNode(candidate.deprecatedNode()) ?
> positionInParentAfterNode(candidate.deprecatedNode()) :
> nextVisuallyDistinctCandidate(candidate);
>     }
>     if (candidate.deprecatedNode() && candidate.deprecatedNode() !=
> highestRoot && !candidate.deprecatedNode()->isDescendantOf(*highestRoot))
>         return { };
>     if (nonEditableNode &&
> nonEditableNode->isDescendantOf(candidate.deprecatedNode()))
>         candidate = nextVisuallyDistinctCandidate(candidate);
>     return candidate;
> }

This fixes hanging test case but the problem is that the test case uses 'assert_selection.js' and does not produce 'passing' test output. :-(

Something is wrong with 'assert_selection.js' while using in WebKit.
Comment 5 Ahmad Saleem 2024-06-15 22:26:04 PDT
Draft PR - https://github.com/WebKit/WebKit/pull/29422

It is leading to legit WPT failure - which we are passing earlier. :-(
Comment 6 Ahmad Saleem 2024-06-15 22:27:12 PDT
Failing - imported/w3c/web-platform-tests/editing/run/forwarddelete.html?6001-last

> PASS [["forwarddelete",""]] "foo<span>bar[]<span contenteditable=false>baz</span></span>qux" compare innerHTML
> FAIL [["forwarddelete",""]] "foo<span>bar[]<span contenteditable=false>baz</span></span>qux" compare innerHTML assert_equals: Unexpected innerHTML (after normalizing inline style) expected "foo<span>bar</span>qux" but got "foo<span>bar</span>ux"
Comment 7 Ahmad Saleem 2024-06-24 04:03:36 PDT
PR attempt - https://github.com/WebKit/WebKit/pull/29422

It leads to legit failure in following WPT:

imported/w3c/web-platform-tests/editing/run/forwarddelete.html?6001-7000

and following fails:

> [["forwarddelete",""]] "foo<span>bar[]<span contenteditable=false>baz</span></span>qux" compare innerHTML

> FAIL [["forwarddelete",""]] "foo<span>bar[]<span contenteditable=false>baz</span></span>qux" compare innerHTML assert_equals: Unexpected innerHTML (after normalizing inline style) expected "foo<span>bar</span>qux" but got "foo<span>bar</span>ux"