Bug 1260247. In chaos mode randomly decide to start a new image load even if the image is in the image cache when allowed by spec. r=seth
authorTimothy Nikkel <tnikkel@gmail.com>
Sat, 02 Apr 2016 13:53:12 -0500
changeset 291488 9adc763aae7608252bb3e9df1ef7888da4f9f2ba
parent 291486 f5842faffb354576520aec05920c67dd01933a1b
child 291489 873bdc9379fda4887e4a19bfc82998276e1a65d4
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersseth
bugs1260247
milestone48.0a1
Bug 1260247. In chaos mode randomly decide to start a new image load even if the image is in the image cache when allowed by spec. r=seth If the image load is from the same document that cached the image we are required to use the cached version. Otherwise we should be free to ignore the cached version.
image/imgLoader.cpp
mfbt/ChaosMode.h
--- a/image/imgLoader.cpp
+++ b/image/imgLoader.cpp
@@ -3,16 +3,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/Attributes.h"
 #include "mozilla/ClearOnShutdown.h"
 #include "mozilla/Move.h"
 #include "mozilla/Preferences.h"
+ #include "mozilla/ChaosMode.h"
 
 #include "ImageLogging.h"
 #include "nsPrintfCString.h"
 #include "imgLoader.h"
 #include "imgRequestProxy.h"
 
 #include "nsCOMPtr.h"
 
@@ -1767,16 +1768,22 @@ imgLoader::ValidateEntry(imgCacheEntry* 
   void *key = (void*) aCX;
   if (request->LoadId() != key) {
     // If we would need to revalidate this entry, but we're being told to
     // bypass the cache, we don't allow this entry to be used.
     if (aLoadFlags & nsIRequest::LOAD_BYPASS_CACHE) {
       return false;
     }
 
+    if (MOZ_UNLIKELY(ChaosMode::isActive(ChaosFeature::ImageCache))) {
+      if (ChaosMode::randomUint32LessThan(4) < 1) {
+        return false;
+      }
+    }
+
     // Determine whether the cache aEntry must be revalidated...
     validateRequest = ShouldRevalidateEntry(aEntry, aLoadFlags, hasExpired);
 
     MOZ_LOG(gImgLog, LogLevel::Debug,
            ("imgLoader::ValidateEntry validating cache entry. "
             "validateRequest = %d", validateRequest));
   } else if (!key && MOZ_LOG_TEST(gImgLog, LogLevel::Debug)) {
     nsAutoCString spec;
--- a/mfbt/ChaosMode.h
+++ b/mfbt/ChaosMode.h
@@ -22,16 +22,18 @@ enum ChaosFeature {
   // Altering network request scheduling.
   NetworkScheduling = 0x2,
   // Altering timer scheduling.
   TimerScheduling = 0x4,
   // Read and write less-than-requested amounts.
   IOAmounts = 0x8,
   // Iterate over hash tables in random order.
   HashTableIteration = 0x10,
+  // Randomly refuse to use cached version of image (when allowed by spec).
+  ImageCache = 0x20,
   Any = 0xffffffff,
 };
 
 namespace detail {
 extern MFBT_DATA Atomic<uint32_t> gChaosModeCounter;
 extern MFBT_DATA ChaosFeature gChaosFeatures;
 } // namespace detail