ComposerPageStateTest: Don't use NBSP directly

In some WebKitGTK versions, we were getting the following error from
within WebKit when running the `replace_non_breaking_space` test:

> SyntaxError Invalid character: '\0'

Doing some further investigation, it seems like webkit was choking on
the raw non-breaking space character (NBSP) that we were using in the
test's string literals, specifically the first byte of its raw value
`U+00A0`.

Work around this for now by generating the NBSP in Javascript itself,
rather than passing on the raw value.
This commit is contained in:
Niels De Graef 2025-12-15 01:30:59 +01:00
parent 619bf5b4e0
commit c5630d0567

View file

@ -388,18 +388,20 @@ I can send email through smtp.gmail.com:587 or through <a href="https://www.gmai
public void replace_non_breaking_space() throws Error { public void replace_non_breaking_space() throws Error {
load_body_fixture(); load_body_fixture();
string single_nbsp = "a b";
string multiple_nbsp = "a b c"; string nbsp = "String.fromCharCode(160)";
string single_nbsp = @"'a' + $(nbsp) + 'b'";
string multiple_nbsp = @"'a' + $(nbsp) + 'b' + $(nbsp) + 'c'";
try { try {
assert( assert(
Util.JS.to_string( Util.JS.to_string(
run_javascript(@"ComposerPageState.replaceNonBreakingSpace('$(single_nbsp)');") run_javascript(@"ComposerPageState.replaceNonBreakingSpace($(single_nbsp));")
) == "a b"); ) == "a b");
assert( assert(
Util.JS.to_string( Util.JS.to_string(
run_javascript(@"ComposerPageState.replaceNonBreakingSpace('$(multiple_nbsp)');") run_javascript(@"ComposerPageState.replaceNonBreakingSpace($(multiple_nbsp));")
) == "a b c"); ) == "a b c");
} catch (Util.JS.Error err) { } catch (Util.JS.Error err) {
print("Util.JS.Error: %s\n", err.message); print("Util.JS.Error: %s\n", err.message);