Skip to content

Compare the JavaScript Builder's Promise value as text, so a browser with promises gets the promise form - #194

Merged
ben51degrees merged 3 commits into
rcfrom
fix/promise-full-equals
Nov 19, 2026
Merged

ben51degrees merged 3 commits into
rcfrom
fix/promise-full-equals

Conversation

@jwrosewell

@jwrosewell jwrosewell commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Problem

JavaScriptBuilderElement.getSupportsPromises read the Promise Property and compared supportsPromisesValue.getValue() == "Full". In Java == compares two strings by reference, not by their text. A value read from the Device Detection data file is a String made at run time, so the comparison was false even when the value was "Full", and every browser was given the script's form for a browser without promises. Only the literal "Full", as a unit test gives it, matched, which is why no existing test saw it.

What the specification says

javascript-builder.md line 98 at d79bbe3b gives the template's _supportsPromises value as

False. Unless Device Detection is in the Pipeline and the ‘Promise’ Property returns ‘Full’ | If true, the script will use Promises

so _supportsPromises is true when the Property's value is the text "Full", whoever made the String that holds it.

What changed

JavaScriptBuilderElement.getSupportsPromises compares with "Full".equals(supportsPromisesValue.getValue()) at line 440. One line of package code. No public name is removed or renamed. The catch below it is unchanged, so every exit of the method still sets the flag.

Before you upgrade

A browser whose Promise value is "Full" now gets the script's promise form, where it got the form for a browser without promises. Anything that compared the script byte for byte for such a browser sees a different script.

Released tests

The draft changes no released test. The released JavaScript Builder test classes on main are CookieTests, JavaScriptBuilderElementBuilderTests, JavaScriptBuilderTests, JavaScriptObjectNameTests, JavaScriptUrlTests, SessionIdAndSequenceTests and the flowelements tests, and all of them passed in the build of the head below.

Tests

JavaScriptBuilderPromiseTests.PromiseFull_MadeAtRunTime_GivesThePromiseForm, new, renders the script for a request whose Promise is "Full" made at run time (new StringBuilder("Fu").append("ll")), for the literal "Full" and for "None". It checks the literal gives a different script from "None", so the test can see the promise form, and that "Full" made at run time gives the same script as the literal. It mocks the Flow Data and needs no browser, because the existing JavaScriptBuilderTests class is skipped where there is no Chrome driver.

Red and green, run 43911806420 on tmp/red-promise. At the test commit 4c75843 the test failed with "Full made at run time did not give the promise form.", the first assertion having passed. At the fix 7fd9ea0 it passed, 1 of 1.

Build of the head

Run 43952784482 on tmp/pr-matrix-194y (workflow commit ac6d36e on rc 820a544) built the head b6c613f, as the Setting 'PullRequestSha' line of its Windows Java 21 job names, on nine configurations, Ubuntu x64 with Java 8, 11, 17 and 21, Ubuntu arm64 with Java 17, and Windows with Java 8, 11, 17 and 21. macOS was left out, and the rc head is built with macOS before it merges into main.

  • Configure and eight of the nine Build and Test jobs passed.
  • Windows Java 21 (job 133610513220) failed in device-detection.hash.engine.on-premise, a module this draft does not touch. There DataRefreshTests.Refresh_FromSeveralThreads_EngineStillWorks reported "java.lang.RuntimeException: Insufficient memory allocated for the operation" and the forked Java process then stopped ("The forked VM terminated without properly saying goodbye"). That test came in with rc, and rc has changed its file since 820a544.
  • In that same job "51Degrees :: Pipeline :: Java Script Builder" ended SUCCESS, with JavaScriptBuilderPromiseTests 1 run and 0 failures, and every other JavaScript Builder test class passing (JavaScriptBuilderTests 15 run, none skipped, JavaScriptMinifyTests 22 run).

The tests of what this draft touches are green on the head.

Base branch

Branched from rc 81e3d4a, with rc 820a544 merged in at b6c613f. That merge brought in #178, which minifies the script by default, so the build above shows the promise form is chosen with minification on.

Changes at this head

One commit follows the fix, 7fd9ea0.

  • b6c613f9 merges rc 820a544 in, which brings #178 and its default minification of the script. The build of the head above shows JavaScriptBuilderPromiseTests passing with minification on, so the promise form is still chosen for "Full" made at run time once the script is minified.

What remains

Nothing in this draft. The Windows Java 21 failure is in the data refresh test from several threads that rc already holds, not in anything this draft changes.

@ben51degrees
ben51degrees marked this pull request as ready for review November 19, 2026 17:18
@ben51degrees
ben51degrees merged commit dd4c53f into rc Nov 19, 2026
3 checks passed
@ben51degrees
ben51degrees deleted the fix/promise-full-equals branch November 19, 2026 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants