Bug 1425146 - P2 - Add a test reproducing the reported issue to verify that a Cache directory without a padding file and with an old version of the database doesn't break the storage initialization; r=janv a=jcristau
authorTom Tung <shes050117@gmail.com>
Thu, 25 Oct 2018 16:34:56 +0200
changeset 501105 7a1bcf3d6977e2944c6fd0c80b713e0add581848
parent 501104 b82e4143ecdbf2d35811fc952738c2d7ab772f7f
child 501106 8034ed187c948ad0cfea0bca8d840f5fa3c3a980
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjanv, jcristau
bugs1425146
milestone64.0
Bug 1425146 - P2 - Add a test reproducing the reported issue to verify that a Cache directory without a padding file and with an old version of the database doesn't break the storage initialization; r=janv a=jcristau An issue for missing the "response_padding_size" column in cache.sqlite was reported in bug 1425146 comment 39. This test reproduces it and is mainly to ensure that a Cache directory which lacks a directory padding file and contains an old version of cache.sqlite can still be initialized successfully.
dom/cache/test/xpcshell/bug1425146_profile.zip
dom/cache/test/xpcshell/test_bug1425146.js
dom/cache/test/xpcshell/xpcshell.ini
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..fc57bc1043d7a786246e3dd37c233d5a489cd3d9
GIT binary patch
literal 2834
zc$^FHW@h1H0D+|Da9;)_z`-EEP+XE<l$f5X9~!~Kz;Aj!db|Gl=&y_-3;}RmI&G-B
z1dw#4q^2d7=9Iv7e=$Mm76IE}RU7VG`}e+p0Z1zo0|OsIw_b5!PG(6eNN=Cf`Dl4n
zh+b~KFDG?8Lp@IGpYqiSG)PNGN=Qj52na|3f|jH^4V?`(9{cB=aE|M^6==Z0h~(1t
z;z$&iYB0!PxHO}rq@Y+^Tf4lxTrW4jDl;c1Q7^wJT|YF0lY#l}wu{jqTw1}+z{v8I
zk%0m13*0v7kzhk|Vsb_*L3<#f2D0az{;EH*EFfDL8LUaR2TT^jf*6mbZ||JVd+fq+
z;A7$K-pO^|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is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+// This test is mainly to verify that we are able to recover from a situation
+// in which the padding file and the padding column are missing during origin
+// initialization. This was originally reported in bug 1425146 comment 39.
+// The situation can be described as follows:
+// 1. A profile is used in FF57. The storage version is 2.1. There's no cache
+//    storage for http://www.mozilla.org
+// 2. The same profile is used in FF56. The storage version is still 2.1 which
+//    doesn't prevent storage system from working since minor upgrades are
+//    backwards-compatible. The cache storage for http://www.mozilla.org is
+//    created with schema version 25 (without any padding stuff).
+// 3. The profile is used in FF57 again. Zero padding files for existing cache
+//    storages are not created because storage is already at version 2.1.
+//    Storage is being initialized and a missing padding file triggers padding
+//    size computation from the cache database with schema version 25. Since
+//    the computation happens before any real DOM cache operation, the database
+//    is not upgraded to schema version 26, so the padding column is missing.
+
+async function run_test() {
+  do_test_pending();
+
+  // The profile contains one cache storage, a script for cache creation and
+  // the storage database:
+  // - storage/default/http+++www.mozilla.org/cache
+  // - create_cache.js
+  // - storage.sqlite
+  // The file create_cache.js in the package was run locally, specifically it
+  // was temporarily added to xpcshell.ini and then executed:
+  //   mach xpcshell-test --interactive dom/cache/test/xpcshell/create_cache.js
+  // Note: it must be executed in FF56 and it only creates the directory
+  // "storage/default/chrome/cache" and the file "storage.sqlite". To make it
+  // become the profile in the test, additional manual steps are needed.
+  // 1. Create "http+++www.mozilla.org" folder under the ""storage/default".
+  // 2. Copy the "cache" folder under the "storage/default/chrome" to
+  //    "storage/default/http+++www.mozilla.org".
+  // 3. Remove the folder "storage/default/chrome"
+  // 4. Remove the folder "storage/temporary".
+  // 5. Add "create_cache.js".
+  // 6. Replace the "storage.sqlite" created by FF56 (storage v2.0) with the
+  //    "storage.sqlite" created by FF57 (storage v2.1)
+  create_test_profile('bug1425146_profile.zip');
+
+  try {
+    await caches.open("test");
+    ok(true, "Should not have thrown");
+  } catch(ex) {
+    ok(false, "Should not have thrown");
+  }
+
+  do_test_finished();
+}
--- a/dom/cache/test/xpcshell/xpcshell.ini
+++ b/dom/cache/test/xpcshell/xpcshell.ini
@@ -1,17 +1,19 @@
 # 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/.
 
 [DEFAULT]
 head = head.js
 support-files =
+  bug1425146_profile.zip
   schema_15_profile.zip
   schema_25_profile.zip
 
 # dummy test entry to generate profile zip files
 [make_profile.js]
   skip-if = true
 
+[test_bug1425146.js]
 [test_migration.js]
 [test_padding_error_handle.js]
 [test_schema_26_upgrade.js]