<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[245891] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/245891">245891</a></dd>
<dt>Author</dt> <dd>tsavell@apple.com</dd>
<dt>Date</dt> <dd>2019-05-30 09:58:54 -0700 (Thu, 30 May 2019)</dd>
</dl>

<h3>Log Message</h3>
<pre>Unreviewed, rolling out <a href="http://trac.webkit.org/projects/webkit/changeset/245881">r245881</a>.

Broke 13 Layout tests on WK2

Reverted changeset:

"WKWebsiteDataStore API fails to fetch web storage data for
non-persistent data store"
https://bugs.webkit.org/show_bug.cgi?id=198317
https://trac.webkit.org/changeset/245881</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitNetworkProcessWebStorageStorageManagercpp">trunk/Source/WebKit/NetworkProcess/WebStorage/StorageManager.cpp</a></li>
<li><a href="#trunkSourceWebKitNetworkProcessWebStorageStorageManagerh">trunk/Source/WebKit/NetworkProcess/WebStorage/StorageManager.h</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebStorageStorageAreaMapcpp">trunk/Source/WebKit/WebProcess/WebStorage/StorageAreaMap.cpp</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebStorageStorageNamespaceImplcpp">trunk/Source/WebKit/WebProcess/WebStorage/StorageNamespaceImpl.cpp</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebStorageStorageNamespaceImplh">trunk/Source/WebKit/WebProcess/WebStorage/StorageNamespaceImpl.h</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebStorageWebStorageNamespaceProvidercpp">trunk/Source/WebKit/WebProcess/WebStorage/WebStorageNamespaceProvider.cpp</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitCocoaWKWebsiteDatastoremm">trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebsiteDatastore.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (245890 => 245891)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog    2019-05-30 16:55:22 UTC (rev 245890)
+++ trunk/Source/WebKit/ChangeLog       2019-05-30 16:58:54 UTC (rev 245891)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2019-05-30  Truitt Savell  <tsavell@apple.com>
+
+        Unreviewed, rolling out r245881.
+
+        Broke 13 Layout tests on WK2
+
+        Reverted changeset:
+
+        "WKWebsiteDataStore API fails to fetch web storage data for
+        non-persistent data store"
+        https://bugs.webkit.org/show_bug.cgi?id=198317
+        https://trac.webkit.org/changeset/245881
+
</ins><span class="cx"> 2019-05-30  Philippe Normand  <pnormand@igalia.com>
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, WPE without a11y support build fix.
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcessWebStorageStorageManagercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/WebStorage/StorageManager.cpp (245890 => 245891)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/WebStorage/StorageManager.cpp 2019-05-30 16:55:22 UTC (rev 245890)
+++ trunk/Source/WebKit/NetworkProcess/WebStorage/StorageManager.cpp    2019-05-30 16:58:54 UTC (rev 245891)
</span><span class="lines">@@ -63,7 +63,7 @@
</span><span class="cx">     const HashMap<String, String>& items() const;
</span><span class="cx">     void clear();
</span><span class="cx"> 
</span><del>-    bool isEphemeral() const { return !m_localStorageNamespace; }
</del><ins>+    bool isSessionStorage() const { return !m_localStorageNamespace; }
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     explicit StorageArea(LocalStorageNamespace*, const SecurityOriginData&, unsigned quotaInBytes);
</span><span class="lines">@@ -72,7 +72,7 @@
</span><span class="cx"> 
</span><span class="cx">     void dispatchEvents(IPC::Connection::UniqueID sourceConnection, uint64_t sourceStorageAreaID, const String& key, const String& oldValue, const String& newValue, const String& urlString) const;
</span><span class="cx"> 
</span><del>-    // Will be null if the storage area belongs to a session storage namespace or the storage area is in an ephemeral session.
</del><ins>+    // Will be null if the storage area belongs to a session storage namespace.
</ins><span class="cx">     LocalStorageNamespace* m_localStorageNamespace;
</span><span class="cx">     mutable RefPtr<LocalStorageDatabase> m_localStorageDatabase;
</span><span class="cx">     mutable bool m_didImportItemsFromDatabase { false };
</span><span class="lines">@@ -91,16 +91,12 @@
</span><span class="cx"> 
</span><span class="cx">     StorageManager* storageManager() const { return &m_storageManager; }
</span><span class="cx"> 
</span><del>-    enum class IsEphemeral : bool { No, Yes };
-    Ref<StorageArea> getOrCreateStorageArea(SecurityOriginData&&, IsEphemeral);
</del><ins>+    Ref<StorageArea> getOrCreateStorageArea(SecurityOriginData&&);
</ins><span class="cx">     void didDestroyStorageArea(StorageArea*);
</span><span class="cx"> 
</span><span class="cx">     void clearStorageAreasMatchingOrigin(const SecurityOriginData&);
</span><span class="cx">     void clearAllStorageAreas();
</span><span class="cx"> 
</span><del>-    Vector<SecurityOriginData> ephemeralOrigins() const;
-    void cloneTo(LocalStorageNamespace& newLocalStorageNamespace);
-
</del><span class="cx"> private:
</span><span class="cx">     LocalStorageNamespace(StorageManager&, uint64_t storageManagerID);
</span><span class="cx"> 
</span><span class="lines">@@ -108,7 +104,8 @@
</span><span class="cx">     uint64_t m_storageNamespaceID;
</span><span class="cx">     unsigned m_quotaInBytes;
</span><span class="cx"> 
</span><del>-    HashMap<SecurityOriginData, RefPtr<StorageArea>> m_storageAreaMap;
</del><ins>+    // We don't hold an explicit reference to the StorageAreas; they are kept alive by the m_storageAreasByConnection map in StorageManager.
+    HashMap<SecurityOriginData, StorageArea*> m_storageAreaMap;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> // Suggested by https://www.w3.org/TR/webstorage/#disk-space
</span><span class="lines">@@ -199,7 +196,7 @@
</span><span class="cx"> 
</span><span class="cx"> void StorageManager::StorageArea::removeListener(IPC::Connection::UniqueID connectionID, uint64_t storageMapID)
</span><span class="cx"> {
</span><del>-    ASSERT(isEphemeral() || m_eventListeners.contains(std::make_pair(connectionID, storageMapID)));
</del><ins>+    ASSERT(isSessionStorage() || m_eventListeners.contains(std::make_pair(connectionID, storageMapID)));
</ins><span class="cx">     m_eventListeners.remove(std::make_pair(connectionID, storageMapID));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -239,10 +236,7 @@
</span><span class="cx"> 
</span><span class="cx"> void StorageManager::StorageArea::setItems(const HashMap<String, String>& items)
</span><span class="cx"> {
</span><del>-    // Import items from web process if items are not stored on disk.
-    if (!isEphemeral())
-        return;
-
</del><ins>+    ASSERT(!m_localStorageDatabase);
</ins><span class="cx">     for (auto& item : items) {
</span><span class="cx">         String oldValue;
</span><span class="cx">         bool quotaException;
</span><span class="lines">@@ -317,10 +311,9 @@
</span><span class="cx">     if (!m_localStorageNamespace)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    ASSERT(m_localStorageNamespace->storageManager()->m_localStorageDatabaseTracker);
</del><span class="cx">     // We open the database here even if we've already imported our items to ensure that the database is open if we need to write to it.
</span><span class="cx">     if (!m_localStorageDatabase)
</span><del>-        m_localStorageDatabase = LocalStorageDatabase::create(m_localStorageNamespace->storageManager()->m_queue.copyRef(), *m_localStorageNamespace->storageManager()->m_localStorageDatabaseTracker, m_securityOrigin);
</del><ins>+        m_localStorageDatabase = LocalStorageDatabase::create(m_localStorageNamespace->storageManager()->m_queue.copyRef(), m_localStorageNamespace->storageManager()->m_localStorageDatabaseTracker.copyRef(), m_securityOrigin);
</ins><span class="cx"> 
</span><span class="cx">     if (m_didImportItemsFromDatabase)
</span><span class="cx">         return;
</span><span class="lines">@@ -357,13 +350,14 @@
</span><span class="cx"> 
</span><span class="cx"> StorageManager::LocalStorageNamespace::~LocalStorageNamespace()
</span><span class="cx"> {
</span><ins>+    ASSERT(m_storageAreaMap.isEmpty());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-auto StorageManager::LocalStorageNamespace::getOrCreateStorageArea(SecurityOriginData&& securityOrigin, IsEphemeral isEphemeral) -> Ref<StorageArea>
</del><ins>+auto StorageManager::LocalStorageNamespace::getOrCreateStorageArea(SecurityOriginData&& securityOrigin) -> Ref<StorageArea>
</ins><span class="cx"> {
</span><span class="cx">     RefPtr<StorageArea> protectedStorageArea;
</span><span class="cx">     return *m_storageAreaMap.ensure(securityOrigin, [&]() mutable {
</span><del>-        protectedStorageArea = StorageArea::create(isEphemeral == IsEphemeral::Yes ? nullptr : this, WTFMove(securityOrigin), m_quotaInBytes);
</del><ins>+        protectedStorageArea = StorageArea::create(this, WTFMove(securityOrigin), m_quotaInBytes);
</ins><span class="cx">         return protectedStorageArea.get();
</span><span class="cx">     }).iterator->value;
</span><span class="cx"> }
</span><span class="lines">@@ -389,26 +383,10 @@
</span><span class="cx"> 
</span><span class="cx"> void StorageManager::LocalStorageNamespace::clearAllStorageAreas()
</span><span class="cx"> {
</span><del>-    for (auto storageArea : m_storageAreaMap.values())
</del><ins>+    for (auto* storageArea : m_storageAreaMap.values())
</ins><span class="cx">         storageArea->clear();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-Vector<SecurityOriginData> StorageManager::LocalStorageNamespace::ephemeralOrigins() const
-{
-    Vector<SecurityOriginData> origins;
-    for (const auto& storageArea : m_storageAreaMap.values()) {
-        if (!storageArea->items().isEmpty())
-            origins.append(storageArea->securityOrigin());
-    }
-    return origins;
-}
-
-void StorageManager::LocalStorageNamespace::cloneTo(LocalStorageNamespace& newLocalStorageNamespace)
-{
-    for (auto& pair : m_storageAreaMap)
-        newLocalStorageNamespace.m_storageAreaMap.add(pair.key, pair.value->clone());
-}
-
</del><span class="cx"> class StorageManager::SessionStorageNamespace : public ThreadSafeRefCounted<SessionStorageNamespace> {
</span><span class="cx"> public:
</span><span class="cx">     static Ref<SessionStorageNamespace> create(unsigned quotaInBytes);
</span><span class="lines">@@ -505,11 +483,11 @@
</span><span class="cx"> 
</span><span class="cx"> StorageManager::StorageManager(const String& localStorageDirectory)
</span><span class="cx">     : m_queue(WorkQueue::create("com.apple.WebKit.StorageManager"))
</span><ins>+    , m_localStorageDatabaseTracker(LocalStorageDatabaseTracker::create(m_queue.copyRef(), localStorageDirectory))
+    , m_isEphemeral(localStorageDirectory.isNull())
</ins><span class="cx"> {
</span><span class="cx">     // Make sure the encoding is initialized before we start dispatching things to the queue.
</span><span class="cx">     UTF8Encoding();
</span><del>-    if (!localStorageDirectory.isNull())
-        m_localStorageDatabaseTracker = LocalStorageDatabaseTracker::create(m_queue.copyRef(), localStorageDirectory);
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> StorageManager::~StorageManager()
</span><span class="lines">@@ -570,13 +548,6 @@
</span><span class="cx">         ASSERT(newSessionStorageNamespace);
</span><span class="cx"> 
</span><span class="cx">         sessionStorageNamespace->cloneTo(*newSessionStorageNamespace);
</span><del>-
-        if (!m_localStorageDatabaseTracker) {
-            if (auto* localStorageNamespace = m_localStorageNamespaces.get(storageNamespaceID)) {
-                LocalStorageNamespace* newlocalStorageNamespace = getOrCreateLocalStorageNamespace(newStorageNamespaceID);
-                localStorageNamespace->cloneTo(*newlocalStorageNamespace);
-            }
-        }
</del><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -658,15 +629,8 @@
</span><span class="cx">     m_queue->dispatch([this, protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)]() mutable {
</span><span class="cx">         HashSet<SecurityOriginData> origins;
</span><span class="cx"> 
</span><del>-        if (m_localStorageDatabaseTracker) {
-            for (auto& origin : m_localStorageDatabaseTracker->origins())
-                origins.add(origin);
-        } else {
-            for (const auto& localStorageNameSpace : m_localStorageNamespaces.values()) {
-                for (auto& origin : localStorageNameSpace->ephemeralOrigins())
-                    origins.add(origin);
-            }
-        }
</del><ins>+        for (auto& origin : m_localStorageDatabaseTracker->origins())
+            origins.add(origin);
</ins><span class="cx"> 
</span><span class="cx">         for (auto& transientLocalStorageNamespace : m_transientLocalStorageNamespaces.values()) {
</span><span class="cx">             for (auto& origin : transientLocalStorageNamespace->origins())
</span><span class="lines">@@ -682,9 +646,7 @@
</span><span class="cx"> void StorageManager::getLocalStorageOriginDetails(Function<void(Vector<LocalStorageDatabaseTracker::OriginDetails>&&)>&& completionHandler)
</span><span class="cx"> {
</span><span class="cx">     m_queue->dispatch([this, protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)]() mutable {
</span><del>-        Vector<LocalStorageDatabaseTracker::OriginDetails> originDetails;
-        if (m_localStorageDatabaseTracker)
-            originDetails = m_localStorageDatabaseTracker->originDetails();
</del><ins>+        auto originDetails = m_localStorageDatabaseTracker->originDetails();
</ins><span class="cx"> 
</span><span class="cx">         RunLoop::main().dispatch([originDetails = WTFMove(originDetails), completionHandler = WTFMove(completionHandler)]() mutable {
</span><span class="cx">             completionHandler(WTFMove(originDetails));
</span><span class="lines">@@ -701,8 +663,7 @@
</span><span class="cx">         for (auto& transientLocalStorageNamespace : m_transientLocalStorageNamespaces.values())
</span><span class="cx">             transientLocalStorageNamespace->clearStorageAreasMatchingOrigin(copiedOrigin);
</span><span class="cx"> 
</span><del>-        if (m_localStorageDatabaseTracker)
-            m_localStorageDatabaseTracker->deleteDatabaseWithOrigin(copiedOrigin);
</del><ins>+        m_localStorageDatabaseTracker->deleteDatabaseWithOrigin(copiedOrigin);
</ins><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -709,21 +670,16 @@
</span><span class="cx"> void StorageManager::deleteLocalStorageOriginsModifiedSince(WallTime time, Function<void()>&& completionHandler)
</span><span class="cx"> {
</span><span class="cx">     m_queue->dispatch([this, protectedThis = makeRef(*this), time, completionHandler = WTFMove(completionHandler)]() mutable {
</span><del>-        if (m_localStorageDatabaseTracker) {
-            auto originsToDelete = m_localStorageDatabaseTracker->databasesModifiedSince(time);
-            
-            for (auto& transientLocalStorageNamespace : m_transientLocalStorageNamespaces.values())
-                transientLocalStorageNamespace->clearAllStorageAreas();
</del><ins>+        auto originsToDelete = m_localStorageDatabaseTracker->databasesModifiedSince(time);
+        
+        for (auto& transientLocalStorageNamespace : m_transientLocalStorageNamespaces.values())
+            transientLocalStorageNamespace->clearAllStorageAreas();
</ins><span class="cx"> 
</span><del>-            for (const auto& origin : originsToDelete) {
-                for (auto& localStorageNamespace : m_localStorageNamespaces.values())
-                    localStorageNamespace->clearStorageAreasMatchingOrigin(origin);
-                
-                m_localStorageDatabaseTracker->deleteDatabaseWithOrigin(origin);
-            }
-        } else {
</del><ins>+        for (const auto& origin : originsToDelete) {
</ins><span class="cx">             for (auto& localStorageNamespace : m_localStorageNamespaces.values())
</span><del>-                localStorageNamespace->clearAllStorageAreas();
</del><ins>+                localStorageNamespace->clearStorageAreasMatchingOrigin(origin);
+            
+            m_localStorageDatabaseTracker->deleteDatabaseWithOrigin(origin);
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         RunLoop::main().dispatch(WTFMove(completionHandler));
</span><span class="lines">@@ -746,8 +702,7 @@
</span><span class="cx">             for (auto& transientLocalStorageNamespace : m_transientLocalStorageNamespaces.values())
</span><span class="cx">                 transientLocalStorageNamespace->clearStorageAreasMatchingOrigin(origin);
</span><span class="cx"> 
</span><del>-            if (m_localStorageDatabaseTracker)
-                m_localStorageDatabaseTracker->deleteDatabaseWithOrigin(origin);
</del><ins>+            m_localStorageDatabaseTracker->deleteDatabaseWithOrigin(origin);
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         RunLoop::main().dispatch(WTFMove(completionHandler));
</span><span class="lines">@@ -757,6 +712,7 @@
</span><span class="cx"> void StorageManager::createLocalStorageMap(IPC::Connection& connection, uint64_t storageMapID, uint64_t storageNamespaceID, SecurityOriginData&& securityOriginData)
</span><span class="cx"> {
</span><span class="cx">     m_queue->dispatch([this, protectedThis = makeRef(*this), connectionID = connection.uniqueID(), storageMapID, storageNamespaceID, securityOriginData = securityOriginData.isolatedCopy()]() mutable {
</span><ins>+        ASSERT(!m_isEphemeral);
</ins><span class="cx">         std::pair<IPC::Connection::UniqueID, uint64_t> connectionAndStorageMapIDPair(connectionID, storageMapID);
</span><span class="cx"> 
</span><span class="cx">         // FIXME: This should be a message check.
</span><span class="lines">@@ -773,7 +729,7 @@
</span><span class="cx">         // FIXME: This should be a message check.
</span><span class="cx">         ASSERT(localStorageNamespace);
</span><span class="cx"> 
</span><del>-        auto storageArea = localStorageNamespace->getOrCreateStorageArea(WTFMove(securityOriginData), m_localStorageDatabaseTracker ? StorageManager::LocalStorageNamespace::IsEphemeral::No : StorageManager::LocalStorageNamespace::IsEphemeral::Yes);
</del><ins>+        auto storageArea = localStorageNamespace->getOrCreateStorageArea(WTFMove(securityOriginData));
</ins><span class="cx">         storageArea->addListener(connectionID, storageMapID);
</span><span class="cx"> 
</span><span class="cx">         result.iterator->value = WTFMove(storageArea);
</span><span class="lines">@@ -792,7 +748,7 @@
</span><span class="cx">             if (it->key.first != connectionID)
</span><span class="cx">                 continue;
</span><span class="cx">             Ref<StorageArea> area = *it->value;
</span><del>-            if (!area->isEphemeral())
</del><ins>+            if (!area->isSessionStorage())
</ins><span class="cx">                 continue;
</span><span class="cx">             if (!origin.securityOrigin()->isSameSchemeHostPort(area->securityOrigin().securityOrigin().get()))
</span><span class="cx">                 continue;
</span><span class="lines">@@ -824,6 +780,10 @@
</span><span class="cx"> void StorageManager::createSessionStorageMap(IPC::Connection& connection, uint64_t storageMapID, uint64_t storageNamespaceID, SecurityOriginData&& securityOriginData)
</span><span class="cx"> {
</span><span class="cx">     m_queue->dispatch([this, protectedThis = makeRef(*this), connectionID = connection.uniqueID(), storageMapID, storageNamespaceID, securityOriginData = securityOriginData.isolatedCopy()]() mutable {
</span><ins>+        if (m_isEphemeral) {
+            m_ephemeralStorage.add(securityOriginData, WebCore::StorageMap::create(localStorageDatabaseQuotaInBytes));
+            return;
+        }
</ins><span class="cx">         // FIXME: This should be a message check.
</span><span class="cx">         ASSERT(m_sessionStorageNamespaces.isValidKey(storageNamespaceID));
</span><span class="cx"> 
</span><span class="lines">@@ -869,7 +829,7 @@
</span><span class="cx">         it->value->removeListener(connectionID, storageMapID);
</span><span class="cx"> 
</span><span class="cx">         // Don't remove session storage maps. The web process may reconnect and expect the data to still be around.
</span><del>-        if (it->value->isEphemeral())
</del><ins>+        if (it->value->isSessionStorage())
</ins><span class="cx">             return;
</span><span class="cx"> 
</span><span class="cx">         m_storageAreasByConnection.remove(connectionAndStorageMapIDPair);
</span><span class="lines">@@ -887,11 +847,14 @@
</span><span class="cx"> {
</span><span class="cx">     m_queue->dispatch([this, protectedThis = makeRef(*this), connection = makeRef(connection), securityOriginData = securityOriginData.isolatedCopy(), storageMapID, storageMapSeed, completionHandler = WTFMove(completionHandler)]() mutable {
</span><span class="cx">         auto* storageArea = findStorageArea(connection.get(), storageMapID);
</span><del>-
-        // This is a session storage area for a page that has already been closed. Ignore it.
-        if (!storageArea)
</del><ins>+        if (!storageArea) {
+            if (m_isEphemeral) {
+                if (auto storageMap = m_ephemeralStorage.get(securityOriginData))
+                    return didGetValues(connection.get(), storageMapID, storageMap->items(), WTFMove(completionHandler));
+            }
+            // This is a session storage area for a page that has already been closed. Ignore it.
</ins><span class="cx">             return didGetValues(connection.get(), storageMapID, { }, WTFMove(completionHandler));
</span><del>-
</del><ins>+        }
</ins><span class="cx">         didGetValues(connection.get(), storageMapID, storageArea->items(), WTFMove(completionHandler));
</span><span class="cx">         connection->send(Messages::StorageAreaMap::DidGetValues(storageMapSeed), storageMapID);
</span><span class="cx">     });
</span><span class="lines">@@ -901,10 +864,17 @@
</span><span class="cx"> {
</span><span class="cx">     m_queue->dispatch([this, protectedThis = makeRef(*this), connection = makeRef(connection), securityOriginData = securityOriginData.isolatedCopy(), storageMapID, sourceStorageAreaID, storageMapSeed, key = key.isolatedCopy(), value = value.isolatedCopy(), urlString = urlString.isolatedCopy()]() mutable {
</span><span class="cx">         auto* storageArea = findStorageArea(connection.get(), storageMapID);
</span><del>-
-        // This is a session storage area for a page that has already been closed. Ignore it.
-        if (!storageArea)
</del><ins>+        if (!storageArea) {
+            if (m_isEphemeral) {
+                if (auto storageMap = m_ephemeralStorage.get(securityOriginData)) {
+                    String oldValue;
+                    bool quotaException;
+                    storageMap->setItem(key, value, oldValue, quotaException);
+                }
+            }
+            // This is a session storage area for a page that has already been closed. Ignore it.
</ins><span class="cx">             return;
</span><ins>+        }
</ins><span class="cx"> 
</span><span class="cx">         bool quotaError;
</span><span class="cx">         storageArea->setItem(connection->uniqueID(), sourceStorageAreaID, key, value, urlString, quotaError);
</span><span class="lines">@@ -924,10 +894,16 @@
</span><span class="cx"> {
</span><span class="cx">     m_queue->dispatch([this, protectedThis = makeRef(*this), connection = makeRef(connection), securityOriginData = securityOriginData.isolatedCopy(), storageMapID, sourceStorageAreaID, storageMapSeed, key = key.isolatedCopy(), urlString = urlString.isolatedCopy()]() mutable {
</span><span class="cx">         auto* storageArea = findStorageArea(connection.get(), storageMapID);
</span><del>-
-        // This is a session storage area for a page that has already been closed. Ignore it.
-        if (!storageArea)
</del><ins>+        if (!storageArea) {
+            if (m_isEphemeral) {
+                if (auto storageMap = m_ephemeralStorage.get(securityOriginData)) {
+                    String oldValue;
+                    storageMap->removeItem(key, oldValue);
+                }
+            }
+            // This is a session storage area for a page that has already been closed. Ignore it.
</ins><span class="cx">             return;
</span><ins>+        }
</ins><span class="cx"> 
</span><span class="cx">         storageArea->removeItem(connection->uniqueID(), sourceStorageAreaID, key, urlString);
</span><span class="cx">         connection->send(Messages::StorageAreaMap::DidRemoveItem(storageMapSeed, key), storageMapID);
</span><span class="lines">@@ -938,10 +914,12 @@
</span><span class="cx"> {
</span><span class="cx">     m_queue->dispatch([this, protectedThis = makeRef(*this), connection = makeRef(connection), securityOriginData = securityOriginData.isolatedCopy(), storageMapID, sourceStorageAreaID, storageMapSeed, urlString = urlString.isolatedCopy()]() mutable {
</span><span class="cx">         auto* storageArea = findStorageArea(connection.get(), storageMapID);
</span><del>-
-        // This is a session storage area for a page that has already been closed. Ignore it.
-        if (!storageArea)
</del><ins>+        if (!storageArea) {
+            if (m_isEphemeral)
+                m_ephemeralStorage.remove(securityOriginData);
+            // This is a session storage area for a page that has already been closed. Ignore it.
</ins><span class="cx">             return;
</span><ins>+        }
</ins><span class="cx"> 
</span><span class="cx">         storageArea->clear(connection->uniqueID(), sourceStorageAreaID, urlString);
</span><span class="cx">         connection->send(Messages::StorageAreaMap::DidClear(storageMapSeed), storageMapID);
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcessWebStorageStorageManagerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/WebStorage/StorageManager.h (245890 => 245891)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/WebStorage/StorageManager.h   2019-05-30 16:55:22 UTC (rev 245890)
+++ trunk/Source/WebKit/NetworkProcess/WebStorage/StorageManager.h      2019-05-30 16:58:54 UTC (rev 245891)
</span><span class="lines">@@ -101,7 +101,7 @@
</span><span class="cx"> 
</span><span class="cx">     Ref<WorkQueue> m_queue;
</span><span class="cx"> 
</span><del>-    RefPtr<LocalStorageDatabaseTracker> m_localStorageDatabaseTracker;
</del><ins>+    Ref<LocalStorageDatabaseTracker> m_localStorageDatabaseTracker;
</ins><span class="cx">     HashMap<uint64_t, RefPtr<LocalStorageNamespace>> m_localStorageNamespaces;
</span><span class="cx"> 
</span><span class="cx">     HashMap<std::pair<uint64_t, WebCore::SecurityOriginData>, RefPtr<TransientLocalStorageNamespace>> m_transientLocalStorageNamespaces;
</span><span class="lines">@@ -110,6 +110,9 @@
</span><span class="cx">     HashMap<uint64_t, RefPtr<SessionStorageNamespace>> m_sessionStorageNamespaces;
</span><span class="cx"> 
</span><span class="cx">     HashMap<std::pair<IPC::Connection::UniqueID, uint64_t>, RefPtr<StorageArea>> m_storageAreasByConnection;
</span><ins>+
+    HashMap<WebCore::SecurityOriginData, Ref<WebCore::StorageMap>> m_ephemeralStorage;
+    bool m_isEphemeral { false };
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebStorageStorageAreaMapcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebStorage/StorageAreaMap.cpp (245890 => 245891)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebStorage/StorageAreaMap.cpp     2019-05-30 16:55:22 UTC (rev 245890)
+++ trunk/Source/WebKit/WebProcess/WebStorage/StorageAreaMap.cpp        2019-05-30 16:58:54 UTC (rev 245891)
</span><span class="lines">@@ -294,7 +294,7 @@
</span><span class="cx">         applyChange(key, newValue);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (storageType() == StorageType::Session || storageType() == StorageType::EphemeralLocal)
</del><ins>+    if (storageType() == StorageType::Session)
</ins><span class="cx">         dispatchSessionStorageEvent(sourceStorageAreaID, key, oldValue, newValue, urlString);
</span><span class="cx">     else
</span><span class="cx">         dispatchLocalStorageEvent(sourceStorageAreaID, key, oldValue, newValue, urlString);
</span><span class="lines">@@ -307,7 +307,9 @@
</span><span class="cx"> 
</span><span class="cx"> void StorageAreaMap::dispatchSessionStorageEvent(uint64_t sourceStorageAreaID, const String& key, const String& oldValue, const String& newValue, const String& urlString)
</span><span class="cx"> {
</span><del>-    // Namespace IDs for session storage namespaces and ephemeral local storage namespaces are equivalent to web page IDs
</del><ins>+    ASSERT(storageType() == StorageType::Session);
+
+    // Namespace IDs for session storage namespaces are equivalent to web page IDs
</ins><span class="cx">     // so we can get the right page here.
</span><span class="cx">     WebPage* webPage = WebProcess::singleton().webPage(makeObjectIdentifier<PageIdentifierType>(m_storageNamespaceID));
</span><span class="cx">     if (!webPage)
</span><span class="lines">@@ -375,7 +377,6 @@
</span><span class="cx"> 
</span><span class="cx">     switch (m_storageType) {
</span><span class="cx">     case StorageType::Local:
</span><del>-    case StorageType::EphemeralLocal:
</del><span class="cx">     case StorageType::TransientLocal:
</span><span class="cx">         if (SecurityOrigin* topLevelOrigin = m_storageNamespace->topLevelOrigin())
</span><span class="cx">             WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::StorageManager::CreateTransientLocalStorageMap(m_storageMapID, m_storageNamespace->storageNamespaceID(), topLevelOrigin->data(), m_securityOrigin->data()), 0);
</span><span class="lines">@@ -384,10 +385,14 @@
</span><span class="cx">         break;
</span><span class="cx">     case StorageType::Session:
</span><span class="cx">         WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::StorageManager::CreateSessionStorageMap(m_storageMapID, m_storageNamespace->storageNamespaceID(), m_securityOrigin->data()), 0);
</span><ins>+        if (m_storageMap)
+            WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::StorageManager::SetItems(m_storageMapID, m_storageMap->items()), 0);
+        break;
+    case StorageType::EphemeralLocal:
+        ASSERT_NOT_REACHED();
+        return;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (m_storageMap)
-        WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::StorageManager::SetItems(m_storageMapID, m_storageMap->items()), 0);
</del><span class="cx">     m_isDisconnected = false;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebStorageStorageNamespaceImplcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebStorage/StorageNamespaceImpl.cpp (245890 => 245891)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebStorage/StorageNamespaceImpl.cpp       2019-05-30 16:55:22 UTC (rev 245890)
+++ trunk/Source/WebKit/WebProcess/WebStorage/StorageNamespaceImpl.cpp  2019-05-30 16:58:54 UTC (rev 245891)
</span><span class="lines">@@ -47,12 +47,12 @@
</span><span class="cx"> 
</span><span class="cx"> Ref<StorageNamespaceImpl> StorageNamespaceImpl::createEphemeralLocalStorageNamespace(uint64_t identifier, unsigned quotaInBytes)
</span><span class="cx"> {
</span><del>-    return createLocalStorageNamespace(identifier, quotaInBytes, IsEphemeral::Yes);
</del><ins>+    return createSessionStorageNamespace(identifier, quotaInBytes);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-Ref<StorageNamespaceImpl> StorageNamespaceImpl::createLocalStorageNamespace(uint64_t identifier, unsigned quotaInBytes, IsEphemeral isEphemeral)
</del><ins>+Ref<StorageNamespaceImpl> StorageNamespaceImpl::createLocalStorageNamespace(uint64_t identifier, unsigned quotaInBytes)
</ins><span class="cx"> {
</span><del>-    return adoptRef(*new StorageNamespaceImpl(isEphemeral == IsEphemeral::Yes ? StorageType::EphemeralLocal : StorageType::Local, identifier, nullptr, quotaInBytes));
</del><ins>+    return adoptRef(*new StorageNamespaceImpl(StorageType::Local, identifier, nullptr, quotaInBytes));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Ref<StorageNamespaceImpl> StorageNamespaceImpl::createTransientLocalStorageNamespace(uint64_t identifier, WebCore::SecurityOrigin& topLevelOrigin, uint64_t quotaInBytes)
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebStorageStorageNamespaceImplh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebStorage/StorageNamespaceImpl.h (245890 => 245891)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebStorage/StorageNamespaceImpl.h 2019-05-30 16:55:22 UTC (rev 245890)
+++ trunk/Source/WebKit/WebProcess/WebStorage/StorageNamespaceImpl.h    2019-05-30 16:58:54 UTC (rev 245891)
</span><span class="lines">@@ -41,9 +41,7 @@
</span><span class="cx"> public:
</span><span class="cx">     static Ref<StorageNamespaceImpl> createSessionStorageNamespace(uint64_t identifier, unsigned quotaInBytes);
</span><span class="cx">     static Ref<StorageNamespaceImpl> createEphemeralLocalStorageNamespace(uint64_t identifier, unsigned quotaInBytes);
</span><del>-
-    enum class IsEphemeral : bool { No, Yes };
-    static Ref<StorageNamespaceImpl> createLocalStorageNamespace(uint64_t identifier, unsigned quotaInBytes, IsEphemeral isEphemeral);
</del><ins>+    static Ref<StorageNamespaceImpl> createLocalStorageNamespace(uint64_t identifier, unsigned quotaInBytes);
</ins><span class="cx">     static Ref<StorageNamespaceImpl> createTransientLocalStorageNamespace(uint64_t identifier, WebCore::SecurityOrigin& topLevelOrigin, uint64_t quotaInBytes);
</span><span class="cx"> 
</span><span class="cx">     virtual ~StorageNamespaceImpl();
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebStorageWebStorageNamespaceProvidercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebStorage/WebStorageNamespaceProvider.cpp (245890 => 245891)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebStorage/WebStorageNamespaceProvider.cpp        2019-05-30 16:55:22 UTC (rev 245890)
+++ trunk/Source/WebKit/WebProcess/WebStorage/WebStorageNamespaceProvider.cpp   2019-05-30 16:58:54 UTC (rev 245891)
</span><span class="lines">@@ -77,7 +77,7 @@
</span><span class="cx"> 
</span><span class="cx"> Ref<WebCore::StorageNamespace> WebStorageNamespaceProvider::createLocalStorageNamespace(unsigned quota)
</span><span class="cx"> {
</span><del>-    return StorageNamespaceImpl::createLocalStorageNamespace(m_identifier, quota, StorageNamespaceImpl::IsEphemeral::Yes);
</del><ins>+    return StorageNamespaceImpl::createLocalStorageNamespace(m_identifier, quota);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Ref<WebCore::StorageNamespace> WebStorageNamespaceProvider::createTransientLocalStorageNamespace(WebCore::SecurityOrigin& topLevelOrigin, unsigned quota)
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (245890 => 245891)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog    2019-05-30 16:55:22 UTC (rev 245890)
+++ trunk/Tools/ChangeLog       2019-05-30 16:58:54 UTC (rev 245891)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2019-05-30  Truitt Savell  <tsavell@apple.com>
+
+        Unreviewed, rolling out r245881.
+
+        Broke 13 Layout tests on WK2
+
+        Reverted changeset:
+
+        "WKWebsiteDataStore API fails to fetch web storage data for
+        non-persistent data store"
+        https://bugs.webkit.org/show_bug.cgi?id=198317
+        https://trac.webkit.org/changeset/245881
+
</ins><span class="cx"> 2019-05-30  Aakash Jain  <aakash_jain@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [ews-build] Update configuration to share bots across queues
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKitCocoaWKWebsiteDatastoremm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebsiteDatastore.mm (245890 => 245891)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebsiteDatastore.mm        2019-05-30 16:55:22 UTC (rev 245890)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebsiteDatastore.mm   2019-05-30 16:58:54 UTC (rev 245891)
</span><span class="lines">@@ -304,46 +304,4 @@
</span><span class="cx">     TestWebKitAPI::Util::run(&done);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-TEST(WKWebsiteDataStore, FetchNonPersistentWebStorage)
-{
-    auto nonPersistentDataStore = [WKWebsiteDataStore nonPersistentDataStore];
-    auto configuration = adoptNS([WKWebViewConfiguration new]);
-    [configuration setWebsiteDataStore:nonPersistentDataStore];
-    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
-    auto navigationDelegate = adoptNS([[NavigationTestDelegate alloc] init]);
-    [webView setNavigationDelegate:navigationDelegate.get()];
-    [webView loadHTMLString:@"<script>sessionStorage.setItem('session', 'storage');localStorage.setItem('local', 'storage');</script>" baseURL:[NSURL URLWithString:@"http://localhost"]];
-    [navigationDelegate waitForDidFinishNavigation];
-
-    readyToContinue = false;
-    [webView evaluateJavaScript:@"window.sessionStorage.getItem('session')" completionHandler:^(id result, NSError *) {
-        EXPECT_TRUE([@"storage" isEqualToString:result]);
-        readyToContinue = true;
-    }];
-    TestWebKitAPI::Util::run(&readyToContinue);
-
-    readyToContinue = false;
-    [webView evaluateJavaScript:@"window.localStorage.getItem('local')" completionHandler:^(id result, NSError *) {
-        EXPECT_TRUE([@"storage" isEqualToString:result]);
-        readyToContinue = true;
-    }];
-    TestWebKitAPI::Util::run(&readyToContinue);
-
-    readyToContinue = false;
-    [nonPersistentDataStore fetchDataRecordsOfTypes:[NSSet setWithObject:WKWebsiteDataTypeSessionStorage] completionHandler:^(NSArray<WKWebsiteDataRecord *> *dataRecords) {
-        EXPECT_EQ((int)dataRecords.count, 1);
-        EXPECT_TRUE([[[dataRecords objectAtIndex:0] displayName] isEqualToString:@"localhost"]);
-        readyToContinue = true;
-    }];
-    TestWebKitAPI::Util::run(&readyToContinue);
-
-    readyToContinue = false;
-    [nonPersistentDataStore fetchDataRecordsOfTypes:[NSSet setWithObject:WKWebsiteDataTypeLocalStorage] completionHandler:^(NSArray<WKWebsiteDataRecord *> *dataRecords) {
-        EXPECT_EQ((int)dataRecords.count, 1);
-        EXPECT_TRUE([[[dataRecords objectAtIndex:0] displayName] isEqualToString:@"localhost"]);
-        readyToContinue = true;
-    }];
-    TestWebKitAPI::Util::run(&readyToContinue);
</del><span class="cx"> }
</span><del>-
-}
</del></span></pre>
</div>
</div>

</body>
</html>