RFR: 8255940: localStorage is null after window.close() [v7]

Ambarish Rapte arapte at openjdk.java.net
Tue Mar 1 16:58:12 UTC 2022


On Tue, 1 Mar 2022 02:42:54 GMT, Jay Bhaskar <duke at openjdk.java.net> wrote:

>> Issue: The current implementation of DOMWindow ::localStorage(..) returns null pointer in case of page is being closed. 
>> Fix: It should not return nullptr , as per the [w3c web storage spec](https://www.w3.org/TR/2016/REC-webstorage-20160419/) 
>> "User agents should expire data from the local storage areas only for security reasons or when requested to do so by the user. User agents should always avoid deleting data while a script that could access that data is running."
>
> Jay Bhaskar has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Clean up test and fix

The fix looks good, suggesting a minor change in test and a change in `DOMWindow.cpp`
The JavaFX specific changes in the shared code should be enclosed inside `#if PLATFORM(JAVA)` macro.

modules/javafx.web/src/main/native/Source/WebCore/page/DOMWindow.cpp line 850:

> 848:         return Exception { SecurityError };
> 849: 
> 850:     if (m_localStorage)

Let's enclose this change in `#if PLATFORM(JAVA)` macro. It makes easy to identify Java platform specific changes and handle merging when updating WebKit.

modules/javafx.web/src/test/java/test/javafx/scene/web/LocalStorageTest.java line 49:

> 47: import javafx.concurrent.Worker;
> 48: import javafx.scene.web.WebView;
> 49: import javafx.scene.web.WebEngine;

Several import statements can be removed. Only below imports are sufficient to run the test, others can be removed.

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertNotNull;
import org.junit.AfterClass;
import org.junit.Test;

import java.io.File;
import java.io.IOException;

import javafx.scene.web.WebView;
import javafx.scene.web.WebEngine;

-------------

Changes requested by arapte (Reviewer).

PR: https://git.openjdk.java.net/jfx/pull/703


More information about the openjfx-dev mailing list