Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: b21fb0d39d87fb3a040f2b9e962fb7c43e575fe2
https://github.com/WebKit/WebKit/commit/b21fb0d39d87fb3a040f2b9e962fb7c43e575fe2
Author: Razvan Caliman <[email protected]>
Date: 2025-12-01 (Mon, 01 Dec 2025)
Changed paths:
A LayoutTests/inspector/formatting/resources/html-source-map-tests/3.html
A LayoutTests/inspector/formatting/resources/html-source-map-tests/4.html
M
LayoutTests/inspector/formatting/resources/html-tests/inline-script-expected.html
M LayoutTests/inspector/formatting/resources/html-tests/inline-script.html
A
LayoutTests/inspector/formatting/resources/javascript-source-map-tests/3.js
M
LayoutTests/inspector/formatting/resources/javascript-tests/template-strings-expected.js
M
LayoutTests/inspector/formatting/resources/javascript-tests/template-strings.js
A LayoutTests/inspector/formatting/source-map-html-3-expected.txt
A LayoutTests/inspector/formatting/source-map-html-3.html
A LayoutTests/inspector/formatting/source-map-html-4-expected.txt
A LayoutTests/inspector/formatting/source-map-html-4.html
A LayoutTests/inspector/formatting/source-map-javascript-3-expected.txt
A LayoutTests/inspector/formatting/source-map-javascript-3.html
M Source/WebInspectorUI/UserInterface/Workers/Formatter/JSFormatter.js
Log Message:
-----------
Web Inspector: Wrong breakpoint and search result positions after
pretty-printing inline script with multi-line template literal
https://bugs.webkit.org/show_bug.cgi?id=291140
rdar://29417859
Reviewed by Devin Rousso.
`JSFormatter.prototype._handleTokenAtNode()` appended multi-line template
literals
as a single token to the formatted content. This assumes the token is on a
single line.
This actually triggered the assertion in
`FormatterContentBuilder.prototype.appendToken()`.
This is benign in the context of formatting a standalone script file because
`JSFormatter`
uses the original line endings only from the script text. But when formatting a
HTML file with an inline
script, the formatter switches modes
(`HTMLFormatter.prototype._formatWithNestedFormatter()`)
and the `JSFormatter` instance uses the original line endings from the HTML
text.
This causes an offset for formatted positions of anything following
the multi-line template literal where its newlines aren't accounted for.
This patch updates handling of multi-line template literals the same way as a
block comments,
inserting their contents line-by-line to map formatted to original line endings
accordingly.
Tests: inspector/formatting/source-map-html-3.html
inspector/formatting/source-map-html-4.html
inspector/formatting/source-map-javascript-3.html
* LayoutTests/inspector/formatting/resources/html-source-map-tests/3.html:
Added.
* LayoutTests/inspector/formatting/resources/html-source-map-tests/4.html:
Added.
*
LayoutTests/inspector/formatting/resources/html-tests/inline-script-expected.html:
* LayoutTests/inspector/formatting/resources/html-tests/inline-script.html:
* LayoutTests/inspector/formatting/resources/javascript-source-map-tests/3.js:
Added.
*
LayoutTests/inspector/formatting/resources/javascript-tests/template-strings-expected.js:
*
LayoutTests/inspector/formatting/resources/javascript-tests/template-strings.js:
* LayoutTests/inspector/formatting/source-map-html-3-expected.txt: Added.
* LayoutTests/inspector/formatting/source-map-html-3.html: Added.
* LayoutTests/inspector/formatting/source-map-html-4-expected.txt: Added.
* LayoutTests/inspector/formatting/source-map-html-4.html: Added.
* LayoutTests/inspector/formatting/source-map-javascript-3-expected.txt: Added.
* LayoutTests/inspector/formatting/source-map-javascript-3.html: Added.
* Source/WebInspectorUI/UserInterface/Workers/Formatter/JSFormatter.js:
(JSFormatter.prototype._insertCommentsAndNewlines):
(JSFormatter.prototype._advanceLineEndingsIndexToEndOfToken):
Drive-by fix for a bug where multiple newlines are added before the token
following a multi-line template literal,
one for each unaccounted newline in the template literal.
(JSFormatter.prototype._handleTokenAtNode):
Canonical link: https://commits.webkit.org/303680@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications