Bug 1404486 - Do not flush necko cache to avoid keeping the CacheIOThread alive. r=valentin
authorNicolas B. Pierron <nicolas.b.pierron@mozilla.com>
Tue, 03 Oct 2017 10:07:00 -0400
changeset 1311821 52a87a609fcb45416dfd14a0879a32f6702a3ead
parent 1311820 8012e6b0d4814abe6816a274fc6eedabaccd6d2f
child 1311822 c5af9e7f8e360b76a8b11bafe16fad858a5317a3
push id225897
push useropettay@mozilla.com
push dateWed, 04 Oct 2017 19:25:01 +0000
treeherdertry@2f2f41234c44 [default view] [failures only]
reviewersvalentin
bugs1404486
milestone58.0a1
Bug 1404486 - Do not flush necko cache to avoid keeping the CacheIOThread alive. r=valentin
dom/base/test/test_script_loader_js_cache.html
--- a/dom/base/test/test_script_loader_js_cache.html
+++ b/dom/base/test/test_script_loader_js_cache.html
@@ -39,27 +39,16 @@
               "scriptloader_no_encode": "fallback_source_exec"
             }
           }
         },
         "scriptloader_execute": "bytecode_exec"
       }
     };
 
-    function flushNeckoCache() {
-      return new Promise (resolve => {
-        // We need to do a GC pass to ensure the cache entry has been freed.
-        SpecialPowers.gc();
-        var nsICacheTesting = SpecialPowers.Ci.nsICacheTesting;
-        var cacheTesting = SpecialPowers.Services.cache2;
-        cacheTesting = cacheTesting.QueryInterface(nsICacheTesting);
-        cacheTesting.flush(() => { resolve(); });
-      });
-    };
-
     function WaitForScriptTagEvent(url) {
       var iframe = document.createElement("iframe");
       document.body.appendChild(iframe);
 
       var stateMachine = scriptLoaderStateMachine;
       var stateHistory = [];
       var stateMachineResolve, stateMachineReject;
       var statePromise = new Promise((resolve, reject) => {
@@ -133,36 +122,30 @@
 
       // Load the test page, and verify that the code path taken by the
       // nsScriptLoadRequest corresponds to the code path which is loading a
       // source and saving it as bytecode.
       var stateMachineResult = WaitForScriptTagEvent("file_js_cache.html");
       assert_equals(await stateMachineResult, "bytecode_saved",
                     "[1] ScriptLoadRequest status after the first visit");
 
-      // When the bytecode is saved, we have to flush the cache to read it.
-      await flushNeckoCache();
-
       // Reload the same test page, and verify that the code path taken by
       // the nsScriptLoadRequest corresponds to the code path which is
       // loading bytecode and executing it.
       stateMachineResult = WaitForScriptTagEvent("file_js_cache.html");
       assert_equals(await stateMachineResult, "bytecode_exec",
                     "[2] ScriptLoadRequest status after the second visit");
 
       // Load another page which loads the same script with an SRI, while
       // the cached bytecode does not have any. This should fallback to
       // loading the source before saving the bytecode once more.
       stateMachineResult = WaitForScriptTagEvent("file_js_cache_with_sri.html");
       assert_equals(await stateMachineResult, "fallback_bytecode_saved",
                     "[3] ScriptLoadRequest status after the SRI hash");
 
-      // When the bytecode is saved, we have to flush the cache to read it.
-      await flushNeckoCache();
-
       // Loading a page, which has the same SRI should verify the SRI and
       // continue by executing the bytecode.
       var stateMachineResult1 = WaitForScriptTagEvent("file_js_cache_with_sri.html");
 
       // Loading a page which does not have a SRI while we have one in the
       // cache should not change anything. We should also be able to load
       // the cache simultanesouly.
       var stateMachineResult2 = WaitForScriptTagEvent("file_js_cache.html");