RFR: 8255940: localStorage is null after window.close() [v3]
Jay Bhaskar
duke at openjdk.java.net
Sun Feb 27 05:28:51 UTC 2022
On Fri, 25 Feb 2022 23:09:00 GMT, Kevin Rushforth <kcr at openjdk.org> wrote:
>> Jay Bhaskar has updated the pull request incrementally with three additional commits since the last revision:
>>
>> - Change Dir Path and use local Dir and set data before clearing localstorage test
>> - Merge branch 'PRLocalstorage' of https://github.com/jaybhaskar/jfx into PRLocalstorage
>> - Merge branch 'master' into PRLocalstorage
>
> modules/javafx.web/src/main/native/Source/WebCore/page/DOMWindow.cpp line 861:
>
>> 859: // after calling window.close(). See <https://bugs.webkit.org/show_bug.cgi?id=135330>.
>> 860: if (m_localStorage)
>> 861: return m_localStorage.get();
>
> This is not needed here if you take my suggestion of doing it above.
Kindly look code
ExceptionOr<Storage*> DOMWindow::localStorage()
{
if (!isCurrentlyDisplayedInFrame())
return nullptr;
RefPtr document = this->document();
if (!document)
return nullptr;
if (!document->securityOrigin().canAccessLocalStorage(nullptr))
return Exception { SecurityError };
// FIXME: We should consider supporting access/modification to local storage
// after calling window.close(). See <https://bugs.webkit.org/show_bug.cgi?id=135330>.
if (m_localStorage)
return m_localStorage.get();
auto* page = document->page();
if (!page)
return nullptr;
// Check if localstorage setting is disabled, then return nullptr
if (!page->settings().localStorageEnabled())
return nullptr;
auto storageArea = page->storageNamespaceProvider().localStorageArea(*document);
m_localStorage = Storage::create(*this, WTFMove(storageArea));
return m_localStorage.get();
}
is it now ok?
> modules/javafx.web/src/test/java/test/javafx/scene/web/LocalStorageTest.java line 55:
>
>> 53:
>> 54: private static final File LOCAL_STORAGE_DIR = new File("LocalStorageDir");
>> 55: private static final File PRE_LOCKED = new File("zoo_local_storage");
>
> This looks like a copy / paste from `UserDataDirectoryTest`, and is unused (and not needed) in this test.
LOCAL_STORAGE_DIR is used by web engine , to store local data in this case
-------------
PR: https://git.openjdk.java.net/jfx/pull/703
More information about the openjfx-dev
mailing list