Bug 1423917 - P2 - Have a test to verify a set of hidden files don't block QuotaManager's initialization and getting usauge; r=asuth a=lizzard
authorTom Tung <shes050117@gmail.com>
Fri, 19 Oct 2018 15:40:07 +0200
changeset 515943 d6e47c340828f443a824ec136d52d6d21d6e1d99
parent 515942 4b73d443d7716a561aaca29838cf41385add16ef
child 515944 99fa26897e4189c491946dfb2d667c8bda522b89
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth, lizzard
bugs1423917
milestone66.0
Bug 1423917 - P2 - Have a test to verify a set of hidden files don't block QuotaManager's initialization and getting usauge; r=asuth a=lizzard
dom/quota/test/unit/test_whiteListFiles.js
dom/quota/test/unit/xpcshell.ini
new file mode 100644
--- /dev/null
+++ b/dom/quota/test/unit/test_whiteListFiles.js
@@ -0,0 +1,55 @@
+/**
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+/**
+ * This test is mainly to verify thoes unexpected files are in the white list of
+ * QuotaManager. They aren't expected in the repository but if there are,
+ * QuotaManager shouldn't fail to initialize an origin and getting usage, though
+ * those files aren't managed by QuotaManager.
+ */
+
+async function testSteps()
+{
+  const whiteListFiles = [
+    ".dot-file",
+    "desktop.ini",
+    "Desktop.ini",
+    "Thumbs.db"
+  ];
+
+  for (let whiteListFile of whiteListFiles) {
+    info("Testing " + whiteListFile + " in the repository");
+
+    info("Creating unknown file");
+
+    for (let dir of ["persistenceType dir", "origin dir"]) {
+      let dirPath =
+        dir == "persistenceType dir" ? "storage/default/"
+                                     : "storage/default/http+++example.com/";
+        let file = getRelativeFile(dirPath + whiteListFile);
+        file.create(Ci.nsIFile.NORMAL_FILE_TYPE, parseInt("0644", 8));
+    }
+
+    info("Initializing an origin");
+
+    let request = initOrigin(getPrincipal("http://example.com"), "default");
+    await requestFinished(request);
+
+    info("Resetting");
+
+    request = reset();
+    await requestFinished(request);
+
+    info("Getting usage");
+
+    request = getCurrentUsage(continueToNextStepSync);
+    await requestFinished(request);
+
+    info("Clearing");
+
+    request = clear();
+    await requestFinished(request);
+  }
+}
--- a/dom/quota/test/unit/xpcshell.ini
+++ b/dom/quota/test/unit/xpcshell.ini
@@ -39,8 +39,9 @@ support-files =
 [test_removeLocalStorage.js]
 [test_simpledb.js]
 [test_specialOrigins.js]
 [test_storagePersistentUpgrade.js]
 [test_storagePressure.js]
 [test_tempMetadataCleanup.js]
 [test_unknownFiles.js]
 [test_version2_1upgrade.js]
+[test_whiteListFiles.js]