[SessionStorageS13N] Disabling onion soup

TBR: jam@chromium.org
Bug: 897581
Change-Id: I22fa2e787a7628a8a6cb40bec9aea166150a9d9a
Reviewed-on: https://chromium-review.googlesource.com/c/1447119
Commit-Queue: Daniel Murphy <dmurph@chromium.org>
Auto-Submit: Daniel Murphy <dmurph@chromium.org>
Reviewed-by: Marijn Kruisselbrink <mek@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#627703}(cherry picked from commit b584e22552127d1edb167c83e047864f37808f5c)
Reviewed-on: https://chromium-review.googlesource.com/c/1448983
Reviewed-by: Daniel Murphy <dmurph@chromium.org>
Cr-Commit-Position: refs/branch-heads/3683@{#98}
Cr-Branched-From: e51029943e0a38dd794b73caaf6373d5496ae783-refs/heads/master@{#625896}
diff --git a/content/browser/dom_storage/dom_storage_context_wrapper_unittest.cc b/content/browser/dom_storage/dom_storage_context_wrapper_unittest.cc
index 6398811..71b1cc8 100644
--- a/content/browser/dom_storage/dom_storage_context_wrapper_unittest.cc
+++ b/content/browser/dom_storage/dom_storage_context_wrapper_unittest.cc
@@ -9,6 +9,7 @@
 #include "base/memory/ptr_util.h"
 #include "base/run_loop.h"
 #include "base/test/bind_test_util.h"
+#include "base/test/scoped_feature_list.h"
 #include "base/test/scoped_task_environment.h"
 #include "base/test/test_simple_task_runner.h"
 #include "base/threading/sequenced_task_runner_handle.h"
@@ -16,13 +17,16 @@
 #include "content/browser/dom_storage/session_storage_context_mojo.h"
 #include "storage/browser/test/mock_special_storage_policy.h"
 #include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/blink/public/common/features.h"
 #include "third_party/blink/public/mojom/dom_storage/storage_area.mojom.h"
 
 namespace content {
 
 class DOMStorageContextWrapperTest : public testing::Test {
  public:
-  DOMStorageContextWrapperTest() = default;
+  DOMStorageContextWrapperTest() {
+    feature_list_.InitAndEnableFeature(blink::features::kOnionSoupDOMStorage);
+  }
 
   void SetUp() override {
     storage_policy_ = new MockSpecialStoragePolicy();
@@ -46,6 +50,7 @@
   }
 
  protected:
+  base::test::ScopedFeatureList feature_list_;
   base::test::ScopedTaskEnvironment task_environment_;
   scoped_refptr<base::TestSimpleTaskRunner> fake_mojo_task_runner_;
   scoped_refptr<MockSpecialStoragePolicy> storage_policy_;
diff --git a/content/renderer/dom_storage/local_storage_cached_areas.cc b/content/renderer/dom_storage/local_storage_cached_areas.cc
index 5cd2f24..32dc5d9 100644
--- a/content/renderer/dom_storage/local_storage_cached_areas.cc
+++ b/content/renderer/dom_storage/local_storage_cached_areas.cc
@@ -134,7 +134,6 @@
     LOCAL_HISTOGRAM_ENUMERATION("SessionStorage.RendererAreaCacheHit", metric);
 
   if (!result) {
-    ClearAreasIfNeeded();
     if (!dom_namespace) {
       dom_namespace = &cached_namespaces_[namespace_id];
     }
@@ -155,6 +154,7 @@
           this, scheduler);
     }
     dom_namespace->cached_areas.emplace(origin, result);
+    ClearAreasIfNeeded();
   }
   return result;
 }
diff --git a/third_party/blink/common/features.cc b/third_party/blink/common/features.cc
index 1802700..0c0ea5a 100644
--- a/third_party/blink/common/features.cc
+++ b/third_party/blink/common/features.cc
@@ -71,7 +71,7 @@
 
 // Onion souping for all DOMStorage. https://crbug.com/781870
 const base::Feature kOnionSoupDOMStorage{"OnionSoupDOMStorage",
-                                         base::FEATURE_ENABLED_BY_DEFAULT};
+                                         base::FEATURE_DISABLED_BY_DEFAULT};
 
 // Enable browser-initiated dedicated worker script loading
 // (PlzDedicatedWorker). https://crbug.com/906991