Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 0a0601825925359bd980aa5c47a43839ce085ea7
      
https://github.com/WebKit/WebKit/commit/0a0601825925359bd980aa5c47a43839ce085ea7
  Author: Razvan Caliman <[email protected]>
  Date:   2025-10-08 (Wed, 08 Oct 2025)

  Changed paths:
    M 
LayoutTests/inspector/formatting/resources/javascript-tests/for-statements-expected.js
    M 
LayoutTests/inspector/formatting/resources/javascript-tests/for-statements.js
    M Source/WebInspectorUI/UserInterface/Workers/Formatter/JSFormatter.js

  Log Message:
  -----------
  Web Inspector: Can't view js file on reddit.com
https://bugs.webkit.org/show_bug.cgi?id=298821
rdar://160617913

Reviewed by BJ Burg and Devin Rousso.

The current checkout of esprima-next used by Web Inspector does not immediately 
identify
a statement like `for(;x?.y;){}` as a ForStatement. This leads to an unhandled 
exception
when attempting to accesss the `range` member of its test condition.

This occurs when the `for` statement 1) does not have an initializer and
2) its test condition is an optional chaining expression.

According to the Esprima documentation, the `range` member is an optional 
member:
https://docs.esprima.org/en/stable/syntax-tree-format.html?highlight=ForStatement#for-statement

This patch guards for this, checking that `range` exists before using it.

* 
LayoutTests/inspector/formatting/resources/javascript-tests/for-statements-expected.js:
(c.d.1):
* LayoutTests/inspector/formatting/resources/javascript-tests/for-statements.js:
(c.d.1):

Add tests for `for` with optional chaining expressions.

* Source/WebInspectorUI/UserInterface/Workers/Formatter/JSFormatter.js:
(JSFormatter.prototype._handleTokenAtNode):

When the test condition of a ForStatement is an optional chaining expression,
its `test` member doesn't have a `range`. Instead, it has an `expression` which 
itself has a `range`.

Canonical link: https://commits.webkit.org/301197@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to