On Thu, 14 Oct 2021 12:32:24 GMT, Kevin Rushforth <k...@openjdk.org> wrote:
> The failure was caused by a change that was done in connection with the > WebKit 610.2 update, > [JDK-8259635](https://bugs.openjdk.java.net/browse/JDK-8259635). The > `FrameLoaderClient::userAgent` function was changed in WebKit itself to be a > const method in WebKit 610.2. We override that method in > `FrameLoaderClientJava` to return the user agent string, which is done by > reading the user agent from an instance of the `Page` class. > `FrameLoaderClientJava` has a `m_page` field that is lazily initialized > whenever it is needed. This lazy initialization can no longer be done from > the `userAgent` method, since it is `const`, as can be seen from this change > that was done as part of WebKit 610.2: > > > --- > a/modules/javafx.web/src/main/native/Source/WebKitLegacy/java/WebCoreSupport/FrameLoaderClientJava.cpp > +++ > b/modules/javafx.web/src/main/native/Source/WebKitLegacy/java/WebCoreSupport/FrameLoaderClientJava.cpp > -String FrameLoaderClientJava::userAgent(const URL&) > +String FrameLoaderClientJava::userAgent(const URL&) const > { > - return page()->settings().userAgent(); > + if (!m_page) > + return emptyString(); > + return m_page->settings().userAgent(); > } > > > Formerly, if the `m_page` field was uninitialized, > FrameLoaderClient::userAgent would have initialized it by the call to the > `page()` function, but since it is now `const` we can't do that. This means > that the user agent string will be empty until some other method is called > that initializes the `m_page` field. > > The fix is to initialize that field when the `WebPage` is created. We can't > do it in the constructor, since the needed reference to the `Page` class > isn't yet available, so I added an `init` method that is called from > `WebPage::twkInit`. > > I added a new unit test that fails without the fix and passes with the fix. Marked as reviewed by aghaisas (Reviewer). The fix looks fine. I built and tested on mac. The new test fails without the fix and passes with it. ------------- PR: https://git.openjdk.java.net/jfx/pull/643