Index: test/filterStorage_readwrite.js
===================================================================
--- a/test/filterStorage_readwrite.js
+++ b/test/filterStorage_readwrite.js
@@ -19,26 +19,27 @@
 
 const {createSandbox, unexpectedError} = require("./_common");
 
 let Filter = null;
 let FilterStorage = null;
 let IO = null;
 let Prefs = null;
 let ExternalSubscription = null;
+let SpecialSubscription = null;
 
 exports.setUp = function(callback)
 {
   let sandboxedRequire = createSandbox();
   (
     {Filter} = sandboxedRequire("../lib/filterClasses"),
     {FilterStorage} = sandboxedRequire("../lib/filterStorage"),
     {IO} = sandboxedRequire("./stub-modules/io"),
     {Prefs} = sandboxedRequire("./stub-modules/prefs"),
-    {ExternalSubscription} = sandboxedRequire("../lib/subscriptionClasses")
+    {ExternalSubscription, SpecialSubscription} = sandboxedRequire("../lib/subscriptionClasses")
   );
 
   FilterStorage.addFilter(Filter.fromText("foobar"));
   callback();
 };
 
 let testData = new Promise((resolve, reject) =>
 {
@@ -85,17 +86,17 @@
       return -1;
     else if (a.key > b.key)
       return 1;
     return 0;
   });
   return sections;
 }
 
-function testReadWrite(test, withExternal)
+function testReadWrite(test, withExternal, withEmptySpecial)
 {
   test.ok(!FilterStorage.initialized, "Uninitialized before the first load");
 
   return testData.then(data =>
   {
     IO._setFileContents(FilterStorage.sourceFile, data);
     return FilterStorage.loadFromDisk();
   }).then(() =>
@@ -113,16 +114,30 @@
 
       let externalSubscriptions = [...FilterStorage.subscriptions()].filter(subscription => subscription instanceof ExternalSubscription);
       test.equal(externalSubscriptions.length, 1, "Number of external subscriptions after updateExternalSubscription");
 
       test.equal(externalSubscriptions[0].url, "~external~external subscription ID", "ID of external subscription");
       test.equal(externalSubscriptions[0].filters.length, 2, "Number of filters in external subscription");
     }
 
+    if (withEmptySpecial)
+    {
+      let specialSubscription =
+        SpecialSubscription.createForFilter(Filter.fromText("!foo"));
+      FilterStorage.addSubscription(specialSubscription);
+
+      FilterStorage.removeFilter(Filter.fromText("!foo"), specialSubscription);
+
+      test.equal(specialSubscription.filters.length, 0,
+                 "No filters in special subscription");
+      test.ok(new Set(FilterStorage.subscriptions()).has(specialSubscription),
+              "Empty special subscription still in storage");
+    }
+
     return FilterStorage.saveToDisk();
   }).then(() => testData).then(expected =>
   {
     test.deepEqual(canonize(IO._getFileContents(FilterStorage.sourceFile)),
                canonize(expected), "Read/write result");
   }).catch(unexpectedError.bind(test)).then(() => test.done());
 }
 
@@ -131,16 +146,21 @@
   testReadWrite(test, false);
 };
 
 exports.testReadAndSaveToFileWithExternalSubscription = function(test)
 {
   testReadWrite(test, true);
 };
 
+exports.testReadAndSaveToFileWithEmptySpecial = function(test)
+{
+  testReadWrite(test, false, true);
+};
+
 exports.testImportExport = function(test)
 {
   testData.then(lines =>
   {
     if (lines.length && lines[lines.length - 1] == "")
       lines.pop();
 
     let importer = FilterStorage.importData();
