[Pkg-mozext-commits] [requestpolicy] 51/100: [refactoring] rename Policy to Ruleset almost everywhere

David Prévot taffit at moszumanska.debian.org
Fri Dec 12 22:56:57 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository requestpolicy.

commit c69744e10571d0fec37fe8e3db0285827d7d6f8b
Author: myrdd <myrdd at users.noreply.github.com>
Date:   Sat Oct 4 03:52:24 2014 +0200

    [refactoring] rename Policy to Ruleset almost everywhere
---
 src/components/requestpolicyService.js             |  28 +--
 src/content/classicmenu.js                         |   2 +-
 src/content/menu.js                                |  26 +--
 src/content/settings/oldrules.js                   |   8 +-
 src/content/settings/setup.js                      |   2 +-
 src/content/settings/yourpolicy.js                 |  34 +--
 src/modules/PolicyManager.jsm                      | 193 ++++++++--------
 src/modules/RequestProcessor.jsm                   |  12 +-
 src/modules/{Policy.jsm => Ruleset.jsm}            | 103 +++++----
 .../{PolicyStorage.jsm => RulesetStorage.jsm}      |  16 +-
 src/modules/Subscription.jsm                       |  16 +-
 tests/modules/Policy/do_test.sh                    |   2 +-
 tests/modules/Policy/rawpolicy_1.js                |   4 +-
 tests/modules/Policy/test1.js                      |   2 +-
 tests/modules/Policy/test2.js                      |   2 +-
 tests/modules/Policy/test3.js                      |   2 +-
 tests/modules/Policy/test4.js                      |   2 +-
 tests/modules/Policy/test5.js                      |   2 +-
 tests/xpcshell/head_utils.js                       |  18 +-
 tests/xpcshell/test_policymanager.js               | 252 ++++++++++-----------
 tests/xpcshell/test_policystorage.js               | 128 +++++------
 21 files changed, 428 insertions(+), 426 deletions(-)

diff --git a/src/components/requestpolicyService.js b/src/components/requestpolicyService.js
index 19cb2ed..294ad9e 100644
--- a/src/components/requestpolicyService.js
+++ b/src/components/requestpolicyService.js
@@ -421,19 +421,19 @@ RequestPolicyService.prototype = {
     this._prefService.savePrefFile(null);
   },
 
-  _loadConfigAndPolicies : function() {
+  _loadConfigAndRules : function() {
     this._subscriptions = new rp.mod.UserSubscriptions();
     this._policyMgr = new rp.mod.PolicyManager();
-    this._policyMgr.loadUserPolicies();
+    this._policyMgr.loadUserRules();
 
     var defaultPolicy = this._defaultAllow ? 'allow' : 'deny';
 
-    var failures = this._policyMgr.loadSubscriptionPolicies(
+    var failures = this._policyMgr.loadSubscriptionRules(
           this._subscriptions.getSubscriptionInfo(defaultPolicy));
     // TODO: check a preference that indicates the last time we checked for
     // updates. Don't do it if we've done it too recently.
     // TODO: Maybe we should probably ship snapshot versions of the official
-    // policies so that they can be available immediately after installation.
+    // rulesets so that they can be available immediately after installation.
     var serials = {};
     for (var listName in failures) {
       serials[listName] = {};
@@ -441,14 +441,14 @@ RequestPolicyService.prototype = {
         serials[listName][subName] = -1;
       }
     }
-    var loadedSubs = this._policyMgr._subscriptionPolicies;
+    var loadedSubs = this._policyMgr._subscriptionRulesets;
     for (var listName in loadedSubs) {
       for (var subName in loadedSubs[listName]) {
         if (!serials[listName]) {
           serials[listName] = {};
         }
-        var rawPolicy = loadedSubs[listName][subName].rawPolicy;
-        serials[listName][subName] = rawPolicy._metadata['serial'];
+        var rawRuleset = loadedSubs[listName][subName].rawRuleset;
+        serials[listName][subName] = rawRuleset._metadata['serial'];
       }
     }
     function updateCompleted(result) {
@@ -645,7 +645,7 @@ RequestPolicyService.prototype = {
     var modules = [
       "Logger.jsm",
       "DomainUtil.jsm",
-      "Policy.jsm",
+      "Ruleset.jsm",
       "PolicyManager.jsm",
       "Request.jsm",
       "RequestProcessor.jsm",
@@ -848,7 +848,7 @@ RequestPolicyService.prototype = {
   },
 
   revokeTemporaryPermissions : function() {
-    this._policyMgr.resetTemporaryPolicy();
+    this._policyMgr.revokeTemporaryRules();
   },
 
   isAllowedRedirect : function(originUri, destinationUri) {
@@ -863,7 +863,7 @@ RequestPolicyService.prototype = {
    *         false otherwise.
    */
   areTemporaryPermissionsGranted : function() {
-    return this._policyMgr.temporaryPoliciesExist();
+    return this._policyMgr.temporaryRulesExist();
   },
 
   getConflictingExtensions : function() {
@@ -967,14 +967,14 @@ RequestPolicyService.prototype = {
         // disabled it between the time the update started and when it
         // completed.
         var subInfo = JSON.parse(data);
-        var failures = this._policyMgr.loadSubscriptionPolicies(subInfo);
+        var failures = this._policyMgr.loadSubscriptionRules(subInfo);
         break;
 
       case rp.mod.SUBSCRIPTION_ADDED_TOPIC:
         rp.mod.Logger.debug(
           rp.mod.Logger.TYPE_INTERNAL, 'XXX added: ' + data);
         var subInfo = JSON.parse(data);
-        var failures = this._policyMgr.loadSubscriptionPolicies(subInfo);
+        var failures = this._policyMgr.loadSubscriptionRules(subInfo);
         var failed = false;
         for (var listName in failures) {
           failed = true;
@@ -1002,7 +1002,7 @@ RequestPolicyService.prototype = {
         rp.mod.Logger.debug(
           rp.mod.Logger.TYPE_INTERNAL, 'YYY: ' + data);
         var subInfo = JSON.parse(data);
-        var failures = this._policyMgr.unloadSubscriptionPolicies(subInfo);
+        var failures = this._policyMgr.unloadSubscriptionRules(subInfo);
         break;
 
       case HTTPS_EVERYWHERE_REWRITE_TOPIC :
@@ -1025,7 +1025,7 @@ RequestPolicyService.prototype = {
         // accessible. If we tried to load preferences before this, we would get
         // default preferences rather than user preferences.
         this._syncFromPrefs();
-        this._loadConfigAndPolicies();
+        this._loadConfigAndRules();
         this._initVersionInfo();
         // Detect other installed extensions and the current application and do
         // what is needed to allow their requests.
diff --git a/src/content/classicmenu.js b/src/content/classicmenu.js
index 35837a8..a9a43a2 100644
--- a/src/content/classicmenu.js
+++ b/src/content/classicmenu.js
@@ -26,7 +26,7 @@
 //
 // Components.utils.import("resource://requestpolicy/DomainUtil.jsm", rp.mod);
 // Components.utils.import("resource://requestpolicy/Logger.jsm", rp.mod);
-// Components.utils.import("resource://requestpolicy/Policy.jsm", rp.mod);
+// Components.utils.import("resource://requestpolicy/Ruleset.jsm", rp.mod);
 // Components.utils.import("resource://requestpolicy/RequestUtil.jsm", rp.mod);
 // Components.utils.import("resource://requestpolicy/PolicyManager.jsm",
 //     rp.mod);
diff --git a/src/content/menu.js b/src/content/menu.js
index 094f349..2fcb3bf 100644
--- a/src/content/menu.js
+++ b/src/content/menu.js
@@ -26,7 +26,7 @@ if (!rp) {
 
 Components.utils.import("resource://requestpolicy/DomainUtil.jsm", rp.mod);
 Components.utils.import("resource://requestpolicy/Logger.jsm", rp.mod);
-Components.utils.import("resource://requestpolicy/Policy.jsm", rp.mod);
+Components.utils.import("resource://requestpolicy/Ruleset.jsm", rp.mod);
 Components.utils.import("resource://requestpolicy/RequestUtil.jsm", rp.mod);
 Components.utils.import("resource://requestpolicy/PolicyManager.jsm", rp.mod);
 
@@ -530,7 +530,7 @@ requestpolicy.menu = {
       return;
     }
 
-    var canonicalRule = rp.mod.Policy.rawRuleToCanonicalString(ruleData);
+    var canonicalRule = rp.mod.Ruleset.rawRuleToCanonicalString(ruleData);
     rp.mod.Logger.dump("ruleData: " + canonicalRule);
     rp.mod.Logger.dump("ruleAction: " + ruleAction);
     rp.mod.Logger.dump("undo: " + undo);
@@ -872,7 +872,7 @@ requestpolicy.menu = {
     item.requestpolicyRuleAction = ruleAction;
     //var statustext = ''; // TODO
     item.setAttribute('class', 'rp-od-item ' + cssClass);
-    var canonicalRule = rp.mod.Policy.rawRuleToCanonicalString(ruleData);
+    var canonicalRule = rp.mod.Ruleset.rawRuleToCanonicalString(ruleData);
     if (this._ruleChangeQueues[ruleAction]) {
       if (this._ruleChangeQueues[ruleAction][canonicalRule]) {
         item.setAttribute('selected-rule', 'true');
@@ -980,9 +980,9 @@ requestpolicy.menu = {
 
           for (var i in results.matchedAllowRules) {
 
-            var policy, match;
-            [policy, match] = results.matchedAllowRules[i];
-            var rawRule = rp.mod.Policy.matchToRawRule(match);
+            var ruleset, match;
+            [ruleset, match] = results.matchedAllowRules[i];
+            var rawRule = rp.mod.Ruleset.matchToRawRule(match);
 
             if (!this._currentlySelectedDest) {
               if (rawRule['d'] && rawRule['d']['h']) {
@@ -990,12 +990,12 @@ requestpolicy.menu = {
               }
             }
 
-            var rawRuleStr = rp.mod.Policy.rawRuleToCanonicalString(rawRule);
+            var rawRuleStr = rp.mod.Ruleset.rawRuleToCanonicalString(rawRule);
             //rp.mod.Logger.info(rp.mod.Logger.TYPE_POLICY,
             //       "matched allow rule: " + rawRuleStr);
             // This is how we remove duplicates: if two rules have the same
             // canonical string, they'll have in the same key.
-            if (policy.userPolicy) {
+            if (ruleset.userRuleset) {
               userRules[rawRuleStr] = rawRule;
             } else {
               subscriptionRules[rawRuleStr] = rawRule;
@@ -1062,9 +1062,9 @@ requestpolicy.menu = {
 
           for (var i in results.matchedDenyRules) {
 
-            var policy, match;
-            [policy, match] = results.matchedDenyRules[i];
-            var rawRule = rp.mod.Policy.matchToRawRule(match);
+            var ruleset, match;
+            [ruleset, match] = results.matchedDenyRules[i];
+            var rawRule = rp.mod.Ruleset.matchToRawRule(match);
 
             if (!this._currentlySelectedDest) {
               if (rawRule['d'] && rawRule['d']['h']) {
@@ -1072,12 +1072,12 @@ requestpolicy.menu = {
               }
             }
 
-            var rawRuleStr = rp.mod.Policy.rawRuleToCanonicalString(rawRule);
+            var rawRuleStr = rp.mod.Ruleset.rawRuleToCanonicalString(rawRule);
             //rp.mod.Logger.info(rp.mod.Logger.TYPE_POLICY,
             //       "matched allow rule: " + rawRuleStr);
             // This is how we remove duplicates: if two rules have the same
             // canonical string, they'll have in the same key.
-            if (policy.userPolicy) {
+            if (ruleset.userRuleset) {
               userRules[rawRuleStr] = rawRule;
             } else {
               subscriptionRules[rawRuleStr] = rawRule;
diff --git a/src/content/settings/oldrules.js b/src/content/settings/oldrules.js
index 6c71323..0221773 100644
--- a/src/content/settings/oldrules.js
+++ b/src/content/settings/oldrules.js
@@ -17,7 +17,7 @@ var rules = null;
 var addHostWildcard = true;
 
 
-function clearPolicyTable() {
+function clearRulesTable() {
   var table = document.getElementById('rules');
   var children = table.getElementsByTagName('tr');
   while (children.length) {
@@ -35,11 +35,11 @@ function populateRuleTable() {
     var entry = rules[i];
     var origin = entry['o'] ? ruleDataPartToDisplayString(entry['o']) : '';
     var dest = entry['d'] ? ruleDataPartToDisplayString(entry['d']) : '';
-    addPolicyTableRow(table, 'allow', origin, dest, entry);
+    addRulesTableRow(table, 'allow', origin, dest, entry);
   }
 }
 
-function addPolicyTableRow(table, type, origin, dest, ruleData) {
+function addRulesTableRow(table, type, origin, dest, ruleData) {
   var typeClass = type == 'allow' ? 'allow' : 'block';
   var ruleType = type == 'allow' ? _('allow') : _('block');
 
@@ -94,7 +94,7 @@ function importOldRules() {
 
 function handleAddHostWildcardsChange(event) {
   addHostWildcard = event.target.checked;
-  clearPolicyTable();
+  clearRulesTable();
   populateRuleTable();
 }
 
diff --git a/src/content/settings/setup.js b/src/content/settings/setup.js
index b2ba71c..a24e91e 100644
--- a/src/content/settings/setup.js
+++ b/src/content/settings/setup.js
@@ -98,7 +98,7 @@ function onload() {
     // of the old rules. We check for new-style rules just in case the user has
     // opened the setup window again after initial upgrade.
     try {
-      var ruleCount = rpService._policyMgr.getUserPolicyRuleCount();
+      var ruleCount = rpService._policyMgr.getUserRuleCount();
     } catch (e) {
       Logger.warning(Logger.TYPE_INTERNAL, 'Unable to get new rule count: ' + e);
       ruleCount = -1;
diff --git a/src/content/settings/yourpolicy.js b/src/content/settings/yourpolicy.js
index ed27136..6a11131 100644
--- a/src/content/settings/yourpolicy.js
+++ b/src/content/settings/yourpolicy.js
@@ -41,30 +41,30 @@ function populateRuleTable(filter) {
 
   var table = document.getElementById('rules');
 
-  clearPolicyTable(table);
+  clearRulesTable(table);
 
-  // Get and display user policies
-  var user = policyMgr._userPolicies['user'];
-  var entries = user.rawPolicy.toJSON()['entries'];
-  addPolicies(entries, 'User', filter, false);
+  // Get and display user rules
+  var user = policyMgr._userRulesets['user'];
+  var entries = user.rawRuleset.toJSON()['entries'];
+  addRules(entries, 'User', filter, false);
 
-  // Get and display temorary policies
-  var temp = policyMgr._userPolicies['temp'];
-  var entries = temp.rawPolicy.toJSON()['entries'];
-  addPolicies(entries, 'Temporary', filter, false);
+  // Get and display temorary rules
+  var temp = policyMgr._userRulesets['temp'];
+  var entries = temp.rawRuleset.toJSON()['entries'];
+  addRules(entries, 'Temporary', filter, false);
 
-  // Get and display subscription policies
-  var subscriptionLists = policyMgr._subscriptionPolicies;
+  // Get and display subscription rules
+  var subscriptionLists = policyMgr._subscriptionRulesets;
   for (subscriptionList in subscriptionLists) {
     for (subscription in subscriptionLists[subscriptionList]) {
-      entries = subscriptionLists[subscriptionList][subscription].rawPolicy.toJSON()['entries'];
-      addPolicies(entries, subscription, filter, true);
+      entries = subscriptionLists[subscriptionList][subscription].rawRuleset.toJSON()['entries'];
+      addRules(entries, subscription, filter, true);
     }
   }
 
 }
 
-function addPolicies(entries, source, filter, readOnly) {
+function addRules(entries, source, filter, readOnly) {
   var table = $('#rules');
   for (var entryType in entries) {
     for (var i = 0; i < entries[entryType].length; i++) {
@@ -76,7 +76,7 @@ function addPolicies(entries, source, filter, readOnly) {
           continue;
         }
       }
-      addPolicyTableRow(table, entryType, origin, dest, entry, source, readOnly);
+      addRulesTableRow(table, entryType, origin, dest, entry, source, readOnly);
     }
   }
 }
@@ -93,7 +93,7 @@ function deleteRule(event) {
   anchor.closest('tr').remove();
 }
 
-function clearPolicyTable(table) {
+function clearRulesTable(table) {
   var children = table.getElementsByTagName('tr');
   while (children.length) {
     var child = children.item(0);
@@ -101,7 +101,7 @@ function clearPolicyTable(table) {
   }
 }
 
-function addPolicyTableRow(table, type, origin, dest, ruleData, source, readOnly) {
+function addRulesTableRow(table, type, origin, dest, ruleData, source, readOnly) {
 
   var typeClass = type == 'allow' ? 'allow' : 'block';
   var ruleType = type == 'allow' ? _('allow') : _('block');
diff --git a/src/modules/PolicyManager.jsm b/src/modules/PolicyManager.jsm
index 533bbb4..e675955 100644
--- a/src/modules/PolicyManager.jsm
+++ b/src/modules/PolicyManager.jsm
@@ -36,8 +36,8 @@ if (!rp) {
 }
 
 Components.utils.import("resource://requestpolicy/Logger.jsm", rp.mod);
-Components.utils.import("resource://requestpolicy/Policy.jsm", rp.mod);
-Components.utils.import("resource://requestpolicy/PolicyStorage.jsm", rp.mod);
+Components.utils.import("resource://requestpolicy/Ruleset.jsm", rp.mod);
+Components.utils.import("resource://requestpolicy/RulesetStorage.jsm", rp.mod);
 Components.utils.import("resource://requestpolicy/RequestResult.jsm", rp.mod);
 
 
@@ -197,76 +197,75 @@ Destination.compareFunction = function (a, b, sortType) {
 
 /**
  * Provides a simplified interface to handling multiple
- * policies, checking requests against multiple policies, etc.
+ * rulesets, checking requests against multiple rulesets, etc.
  */
 function PolicyManager() {
-  this._userPolicies = {};
-  this._subscriptionPolicies = {};
+  this._userRulesets = {};
+  this._subscriptionRulesets = {};
 }
 PolicyManager.prototype = {
 
-  //_policies : null,
+  //_rulesets : null,
 
-  getUserPolicyRuleCount : function() {
-    return this._userPolicies["user"]["rawPolicy"].getAllowRuleCount() +
-        this._userPolicies["user"]["rawPolicy"].getDenyRuleCount();
+  getUserRuleCount : function() {
+    return this._userRulesets["user"]["rawRuleset"].getAllowRuleCount() +
+        this._userRulesets["user"]["rawRuleset"].getDenyRuleCount();
   },
 
-  loadUserPolicies : function() {
-    // Read the user policy from a file.
+  loadUserRules : function() {
+    // Read the user rules from a file.
     try {
-      dprint("PolicyManager::loadPolicies loading user policy");
-      rawPolicy = rp.mod.PolicyStorage
-        .loadRawPolicyFromFile("user.json");
+      dprint("PolicyManager::loadUserRules loading user rules");
+      rawRuleset = rp.mod.RulesetStorage.loadRawRulesetFromFile("user.json");
     } catch (e) {
-      // TODO: log a message about missing user.json policy file.
-      // There's no user policy. This is either because RP has just been
+      // TODO: log a message about missing user.json ruleset file.
+      // There's no user ruleset. This is either because RP has just been
       // installed, the file has been deleted, or something is wrong. For now,
       // we'll assume this is a new install.
-      rawPolicy = new rp.mod.RawPolicy();
+      rawRuleset = new rp.mod.RawRuleset();
     }
-    this._userPolicies["user"] = {
-      "rawPolicy" : rawPolicy,
-      "policy" : rawPolicy.toPolicy("user")
+    this._userRulesets["user"] = {
+      "rawRuleset" : rawRuleset,
+      "ruleset" : rawRuleset.toRuleset("user")
     };
-    this._userPolicies["user"]["policy"].userPolicy = true;
-    this._userPolicies["user"].policy.print();
+    this._userRulesets["user"]["ruleset"].userRuleset = true;
+    this._userRulesets["user"].ruleset.print();
     // Temporary rules. These are never stored.
-    this.resetTemporaryPolicy();
+    this.revokeTemporaryRules();
 
     notifyRulesChanged();
   },
 
-  loadSubscriptionPolicies : function(subscriptionInfo) {
+  loadSubscriptionRules : function(subscriptionInfo) {
     var failures = {};
 
     // Read each subscription from a file.
-    var rawPolicy;
+    var rawRuleset;
     for (var listName in subscriptionInfo) {
       for (var subName in subscriptionInfo[listName]) {
         try {
-          dprint("PolicyManager::loadSubscriptionPolicies: " +
+          dprint("PolicyManager::loadSubscriptionRules: " +
                  listName + ' / ' + subName);
-          rawPolicy = rp.mod.PolicyStorage
-                .loadRawPolicyFromFile(subName + ".json", listName);
+          rawRuleset = rp.mod.RulesetStorage
+              .loadRawRulesetFromFile(subName + ".json", listName);
         } catch (e) {
-          warn("Unable to load policy from file: " + e);
+          warn("Unable to load ruleset from file: " + e);
           if (!failures[listName]) {
             failures[listName] = {};
           }
           failures[listName][subName] = null;
           continue;
         }
-        if (!this._subscriptionPolicies[listName]) {
-          this._subscriptionPolicies[listName] = {};
+        if (!this._subscriptionRulesets[listName]) {
+          this._subscriptionRulesets[listName] = {};
         }
-        var list = this._subscriptionPolicies[listName];
+        var list = this._subscriptionRulesets[listName];
         list[subName] = {
-          "rawPolicy" : rawPolicy,
-          "policy" : rawPolicy.toPolicy(subName)
+          "rawRuleset" : rawRuleset,
+          "ruleset" : rawRuleset.toRuleset(subName)
         };
-        list[subName]["policy"].userPolicy = false;
-        list[subName].policy.print();
+        list[subName]["ruleset"].userRuleset = false;
+        list[subName].ruleset.print();
       }
     }
 
@@ -275,22 +274,22 @@ PolicyManager.prototype = {
     return failures;
   },
 
-  unloadSubscriptionPolicies : function(subscriptionInfo) {
+  unloadSubscriptionRules : function(subscriptionInfo) {
     var failures = {};
 
     for (var listName in subscriptionInfo) {
       for (var subName in subscriptionInfo[listName]) {
-        dprint("PolicyManager::unloadSubscriptionPolicies: " +
+        dprint("PolicyManager::unloadSubscriptionRules: " +
                  listName + ' / ' + subName);
-        if (!this._subscriptionPolicies[listName] ||
-            !this._subscriptionPolicies[listName][subName]) {
+        if (!this._subscriptionRulesets[listName] ||
+            !this._subscriptionRulesets[listName][subName]) {
           if (!failures[listName]) {
             failures[listName] = {};
           }
           failures[listName][subName] = null;
           continue;
         }
-        var list = this._subscriptionPolicies[listName];
+        var list = this._subscriptionRulesets[listName];
         delete list[subName];
       }
     }
@@ -309,15 +308,15 @@ PolicyManager.prototype = {
 
   ruleExists : function(ruleType, ruleData) {
     this._assertRuleType(ruleType);
-    for (var name in this._userPolicies) {
-      if (this._userPolicies[name].rawPolicy.ruleExists(ruleType, ruleData)) {
+    for (var name in this._userRulesets) {
+      if (this._userRulesets[name].rawRuleset.ruleExists(ruleType, ruleData)) {
         return true;
       }
     }
-    for (var listName in this._subscriptionPolicies) {
-      var policies = this._subscriptionPolicies[listName];
-      for (var name in policies) {
-        if (policies[name].rawPolicy.ruleExists(ruleType, ruleData)) {
+    for (var listName in this._subscriptionRulesets) {
+      var rulesets = this._subscriptionRulesets[listName];
+      for (var name in rulesets) {
+        if (rulesets[name].rawRuleset.ruleExists(ruleType, ruleData)) {
           return true;
         }
       }
@@ -327,109 +326,109 @@ PolicyManager.prototype = {
 
   addRule : function(ruleType, ruleData, noStore) {
     dprint("PolicyManager::addRule " + ruleType + " "
-           + rp.mod.Policy.rawRuleToCanonicalString(ruleData));
-    //this._userPolicies["user"].policy.print();
+           + rp.mod.Ruleset.rawRuleToCanonicalString(ruleData));
+    //this._userRulesets["user"].ruleset.print();
 
     this._assertRuleType(ruleType);
     // TODO: check rule format validity
-    this._userPolicies["user"].rawPolicy.addRule(ruleType, ruleData,
-          this._userPolicies["user"].policy);
+    this._userRulesets["user"].rawRuleset.addRule(ruleType, ruleData,
+          this._userRulesets["user"].ruleset);
 
     // TODO: only save if we actually added a rule. This will require
-    // modifying |RawPolicy.addRule()| to indicate whether a rule
+    // modifying |RawRuleset.addRule()| to indicate whether a rule
     // was added.
     // TODO: can we do this in the background and add some locking? It will
     // become annoying when there is a large file to write.
     if (!noStore) {
-        rp.mod.PolicyStorage.saveRawPolicyToFile(
-              this._userPolicies["user"].rawPolicy, "user.json");
+        rp.mod.RulesetStorage.saveRawRulesetToFile(
+            this._userRulesets["user"].rawRuleset, "user.json");
     }
 
-    //this._userPolicies["user"].policy.print();
+    //this._userRulesets["user"].ruleset.print();
 
     notifyRulesChanged();
   },
 
   storeRules : function() {
-    rp.mod.PolicyStorage.saveRawPolicyToFile(
-        this._userPolicies["user"].rawPolicy, "user.json");
+    rp.mod.RulesetStorage.saveRawRulesetToFile(
+        this._userRulesets["user"].rawRuleset, "user.json");
   },
 
   addTemporaryRule : function(ruleType, ruleData) {
     dprint("PolicyManager::addTemporaryRule " + ruleType + " "
-           + rp.mod.Policy.rawRuleToCanonicalString(ruleData));
-    //this._userPolicies["temp"].policy.print();
+           + rp.mod.Ruleset.rawRuleToCanonicalString(ruleData));
+    //this._userRulesets["temp"].ruleset.print();
 
     this._assertRuleType(ruleType);
     // TODO: check rule format validity
-    this._userPolicies["temp"].rawPolicy.addRule(ruleType, ruleData,
-          this._userPolicies["temp"].policy);
+    this._userRulesets["temp"].rawRuleset.addRule(ruleType, ruleData,
+          this._userRulesets["temp"].ruleset);
 
-    //this._userPolicies["temp"].policy.print();
+    //this._userRulesets["temp"].ruleset.print();
 
     notifyRulesChanged();
   },
 
   removeRule : function(ruleType, ruleData, noStore) {
     dprint("PolicyManager::removeRule " + ruleType + " "
-           + rp.mod.Policy.rawRuleToCanonicalString(ruleData));
-    //this._userPolicies["user"].policy.print();
-    //this._userPolicies["temp"].policy.print();
+           + rp.mod.Ruleset.rawRuleToCanonicalString(ruleData));
+    //this._userRulesets["user"].ruleset.print();
+    //this._userRulesets["temp"].ruleset.print();
 
     this._assertRuleType(ruleType);
     // TODO: check rule format validity
     // TODO: use noStore
-    this._userPolicies["user"].rawPolicy.removeRule(ruleType, ruleData,
-          this._userPolicies["user"].policy);
-    this._userPolicies["temp"].rawPolicy.removeRule(ruleType, ruleData,
-          this._userPolicies["temp"].policy);
+    this._userRulesets["user"].rawRuleset.removeRule(ruleType, ruleData,
+          this._userRulesets["user"].ruleset);
+    this._userRulesets["temp"].rawRuleset.removeRule(ruleType, ruleData,
+          this._userRulesets["temp"].ruleset);
 
     // TODO: only save if we actually removed a rule. This will require
-    // modifying |RawPolicy.removeRule()| to indicate whether a rule
+    // modifying |RawRuleset.removeRule()| to indicate whether a rule
     // was removed.
     // TODO: can we do this in the background and add some locking? It will
     // become annoying when there is a large file to write.
     if (!noStore) {
-        rp.mod.PolicyStorage.saveRawPolicyToFile(
-              this._userPolicies["user"].rawPolicy, "user.json");
+        rp.mod.RulesetStorage.saveRawRulesetToFile(
+              this._userRulesets["user"].rawRuleset, "user.json");
     }
 
-    //this._userPolicies["user"].policy.print();
-    //this._userPolicies["temp"].policy.print();
+    //this._userRulesets["user"].ruleset.print();
+    //this._userRulesets["temp"].ruleset.print();
 
     notifyRulesChanged();
   },
 
   temporaryRulesExist : function() {
-    return this._userPolicies["temp"].rawPolicy.getAllowRuleCount() ||
-           this._userPolicies["temp"].rawPolicy.getDenyRuleCount();
+    return this._userRulesets["temp"].rawRuleset.getAllowRuleCount() ||
+           this._userRulesets["temp"].rawRuleset.getDenyRuleCount();
   },
 
-  resetTemporaryPolicy : function() {
-    var rawPolicy = new rp.mod.RawPolicy();
-    this._userPolicies["temp"] = {
-      "rawPolicy" : rawPolicy,
-      "policy" : rawPolicy.toPolicy("temp")
+  revokeTemporaryRules : function() {
+    var rawRuleset = new rp.mod.RawRuleset();
+    this._userRulesets["temp"] = {
+      "rawRuleset" : rawRuleset,
+      "ruleset" : rawRuleset.toRuleset("temp")
     };
-    this._userPolicies["temp"]["policy"].userPolicy = true;
+    this._userRulesets["temp"]["ruleset"].userRuleset = true;
 
     notifyRulesChanged();
   },
 
-  checkRequestAgainstUserPolicies : function(origin, dest) {
-    return this._checkRequest(origin, dest, this._userPolicies);
+  checkRequestAgainstUserRules : function(origin, dest) {
+    return this._checkRequest(origin, dest, this._userRulesets);
   },
 
-  checkRequestAgainstSubscriptionPolicies : function(origin, dest) {
+  checkRequestAgainstSubscriptionRules : function(origin, dest) {
     var result = new rp.mod.RequestResult();
-    for (var listName in this._subscriptionPolicies) {
-      var policies = this._subscriptionPolicies[listName];
-      this._checkRequest(origin, dest, policies, result);
+    for (var listName in this._subscriptionRulesets) {
+      var ruleset = this._subscriptionRulesets[listName];
+      this._checkRequest(origin, dest, ruleset, result);
     }
     return result;
   },
 
-  _checkRequest : function(origin, dest, policies, result) {
+  _checkRequest : function(origin, dest, aRuleset, result) {
     if (!(origin instanceof CI.nsIURI)) {
       throw "Origin must be an nsIURI.";
     }
@@ -439,20 +438,20 @@ PolicyManager.prototype = {
     if (!result) {
       result = new rp.mod.RequestResult();
     }
-    for (var i in policies) {
-      var policy = policies[i].policy;
-      //policy.setPrintFunction(print);
-      //policy.print();
+    for (var i in aRuleset) {
+      var ruleset = aRuleset[i].ruleset;
+      //ruleset.setPrintFunction(print);
+      //ruleset.print();
       var tempAllow, tempDeny;
       // TODO wrap this in a try/catch.
-      [tempAllow, tempDeny] = policy.check(origin, dest);
-      // I'm not convinced I like appending these [policy, matchedRule] arrays,
+      [tempAllow, tempDeny] = ruleset.check(origin, dest);
+      // I'm not convinced I like appending these [ruleset, matchedRule] arrays,
       // but it works for now.
       for (var i in tempAllow) {
-        result.matchedAllowRules.push([policy, tempAllow[i]]);
+        result.matchedAllowRules.push([ruleset, tempAllow[i]]);
       }
       for (var i in tempDeny) {
-        result.matchedDenyRules.push([policy, tempDeny[i]]);
+        result.matchedDenyRules.push([ruleset, tempDeny[i]]);
       }
     }
     return result;
diff --git a/src/modules/RequestProcessor.jsm b/src/modules/RequestProcessor.jsm
index 8fff234..61272d8 100644
--- a/src/modules/RequestProcessor.jsm
+++ b/src/modules/RequestProcessor.jsm
@@ -342,7 +342,7 @@ RequestProcessor.prototype.process = function(request) {
     }
 
     request.requestResult = this._rpService._policyMgr.
-        checkRequestAgainstUserPolicies(request.aRequestOrigin,
+        checkRequestAgainstUserRules(request.aRequestOrigin,
             request.aContentLocation);
     for (var i = 0; i < request.requestResult.matchedDenyRules.length; i++) {
       rp.mod.Logger.dump('Matched deny rules');
@@ -386,7 +386,7 @@ RequestProcessor.prototype.process = function(request) {
     }
 
     request.requestResult = this._rpService._policyMgr.
-        checkRequestAgainstSubscriptionPolicies(request.aRequestOrigin,
+        checkRequestAgainstSubscriptionRules(request.aRequestOrigin,
             request.aContentLocation);
     for (var i = 0; i < request.requestResult.matchedDenyRules.length; i++) {
       rp.mod.Logger.dump('Matched deny rules');
@@ -405,12 +405,12 @@ RequestProcessor.prototype.process = function(request) {
       if (this._rpService._defaultAllow) {
         request.requestResult.isAllowed = true;
         return this.accept(
-            "Subscription policies indicate both allow and block. " +
+            "Subscription rules indicate both allow and block. " +
             "Using default allow policy", request);
       } else {
         request.requestResult.isAllowed = false;
         return this.reject(
-            "Subscription policies indicate both allow and block. " +
+            "Subscription rules indicate both allow and block. " +
             "Using default block policy", request);
       }
     }
@@ -956,7 +956,7 @@ RequestProcessor.prototype.checkRedirect = function(request) {
   var originURIObj = rp.mod.DomainUtil.getUriObject(originURI);
   var destURIObj = rp.mod.DomainUtil.getUriObject(destURI);
 
-  var result = this._rpService._policyMgr.checkRequestAgainstUserPolicies(
+  var result = this._rpService._policyMgr.checkRequestAgainstUserRules(
       originURIObj, destURIObj);
   // For now, we always give priority to deny rules.
   if (result.denyRulesExist()) {
@@ -969,7 +969,7 @@ RequestProcessor.prototype.checkRedirect = function(request) {
   }
 
   var result = this._rpService._policyMgr.
-      checkRequestAgainstSubscriptionPolicies(originURIObj, destURIObj);
+      checkRequestAgainstSubscriptionRules(originURIObj, destURIObj);
   // For now, we always give priority to deny rules.
   if (result.denyRulesExist()) {
     result.isAllowed = false;
diff --git a/src/modules/Policy.jsm b/src/modules/Ruleset.jsm
similarity index 90%
rename from src/modules/Policy.jsm
rename to src/modules/Ruleset.jsm
index b3a989a..c566a3c 100644
--- a/src/modules/Policy.jsm
+++ b/src/modules/Ruleset.jsm
@@ -21,8 +21,8 @@
  */
 
 var EXPORTED_SYMBOLS = [
-  "Policy",
-  "RawPolicy",
+  "Ruleset",
+  "RawRuleset",
   "RULE_TYPE_ALLOW",
   "RULE_TYPE_DENY"
 ];
@@ -103,7 +103,7 @@ function dump(arr,level) {
   return dumped_text;
 }
 
-function RawPolicy(jsonData) {
+function RawRuleset(jsonData) {
   this._metadata = {"version" : 1};
   this._entries = {};
   if (jsonData) {
@@ -117,12 +117,12 @@ function RawPolicy(jsonData) {
   }
 }
 
-RawPolicy.prototype = {
+RawRuleset.prototype = {
   _metadata : null,
   _entries : null,
 
   toString : function() {
-    return "[RawPolicy " + this._metadata + " " + this._entries + "]";
+    return "[RawRuleset " + this._metadata + " " + this._entries + "]";
   },
 
   getAllowRuleCount : function() {
@@ -148,14 +148,14 @@ RawPolicy.prototype = {
     return [rules, r];
   },
 
-  _addEntryToPolicy : function(entry, ruleType, policy) {
+  _addEntryToRuleset : function(entry, ruleType, policy) {
     // TODO: add an "entryPart" format verifier/normalizer.
     //    notes: 'pathPre' => path prefix (must start with "/")
     var o = entry["o"];
     var d = entry["d"];
     var rules, r;
 
-    //dprint("_addEntryToPolicy: " + o + " " + d + " " + ruleType);
+    //dprint("_addEntryToRuleset: " + o + " " + d + " " + ruleType);
 
     if (o && d) {
       [rules, r] = this._addEntryHelper(o, policy);
@@ -193,15 +193,16 @@ RawPolicy.prototype = {
   },
 
   ruleExists : function(ruleType, ruleData) {
-    var typeStr = {RULE_TYPE_ALLOW:"allow", RULE_TYPE_DENY:"deny"}[ruleType];
+    var typeStr = ruleType == RULE_TYPE_ALLOW ? "allow" :
+        ruleType == RULE_TYPE_DENY ? "deny" : "";
     if (!typeStr) {
       throw "Invalid ruleType: " + ruleType;
     }
 
-    var ruleStr = Policy.rawRuleToCanonicalString(ruleData);
+    var ruleStr = Ruleset.rawRuleToCanonicalString(ruleData);
     var entries = this._entries[typeStr];
     for (var i in entries) {
-      var curRuleStr = Policy.rawRuleToCanonicalString(entries[i]);
+      var curRuleStr = Ruleset.rawRuleToCanonicalString(entries[i]);
       if (ruleStr == curRuleStr) {
         return true;
       }
@@ -210,8 +211,8 @@ RawPolicy.prototype = {
   },
 
   /**
-   * Adds the rule to the entries of this |RawPolicy| instance as well as the
-   * |Policy| optionally provided as the policy argument.
+   * Adds the rule to the entries of this |RawRuleset| instance as well as the
+   * |Ruleset| optionally provided as the policy argument.
    *
    * @param ruleType RULE_TYPE_ALLOW|RULE_TYPE_DENY
    * @param ruleData
@@ -219,7 +220,8 @@ RawPolicy.prototype = {
   addRule : function(ruleType, ruleData, policy) {
     // XXX: remove loggings
     //dprint("addRule: adding entry");
-    var typeStr = {RULE_TYPE_ALLOW:"allow", RULE_TYPE_DENY:"deny"}[ruleType];
+    var typeStr = ruleType == RULE_TYPE_ALLOW ? "allow" :
+        ruleType == RULE_TYPE_DENY ? "deny" : "";
     if (!typeStr) {
       throw "Invalid ruleType: " + ruleType;
     }
@@ -230,7 +232,7 @@ RawPolicy.prototype = {
     }
 
     if (policy) {
-      this._addEntryToPolicy(ruleData, ruleType, policy);
+      this._addEntryToRuleset(ruleData, ruleType, policy);
     }
   },
 
@@ -247,14 +249,14 @@ RawPolicy.prototype = {
   //     return rules.get(entryPart["s"], entryPart["port"]);
   // },
 
-  _removeEntryFromPolicy : function(entry, ruleType, policy) {
+  _removeEntryFromRuleset : function(entry, ruleType, policy) {
     // TODO: add an "entryPart" format verifier/normalizer.
     //    notes: 'pathPre' => path prefix (must start with "/")
     var o = entry["o"];
     var d = entry["d"];
     var rules, r;
 
-    // TODO: refactor like done with _addEntryToPolicy
+    // TODO: refactor like done with _addEntryToRuleset
 
     if (o && d) {
       if (o["h"]) {
@@ -288,7 +290,7 @@ RawPolicy.prototype = {
       // if (r.destinationRuleType == ruleType) {
       //   r.destinationRuleType = null;
       // }
-      //dprint("_removeEntryFromPolicy: got rule to alter: " + r.toString());
+      //dprint("_removeEntryFromRuleset: got rule to alter: " + r.toString());
       if (ruleType == RULE_TYPE_ALLOW) {
         r.allowDestination = null;
       } else if (ruleType == RULE_TYPE_DENY) {
@@ -356,8 +358,8 @@ RawPolicy.prototype = {
   },
 
   /**
-   * Removes the rule from the entries of this |RawPolicy| instance as well as the
-   * |Policy| optionally provided as the policy argument.
+   * Removes the rule from the entries of this |RawRuleset| instance as well as the
+   * |Ruleset| optionally provided as the policy argument.
    *
    * @param ruleType RULE_TYPE_ALLOW|RULE_TYPE_DENY
    * @param ruleData
@@ -365,15 +367,16 @@ RawPolicy.prototype = {
   removeRule : function(ruleType, ruleData, policy) {
     // XXX: remove loggings
     //dprint("removeRule: removing entry");
-    var typeStr = {RULE_TYPE_ALLOW:"allow", RULE_TYPE_DENY:"deny"}[ruleType];
+    var typeStr = ruleType == RULE_TYPE_ALLOW ? "allow" :
+        ruleType == RULE_TYPE_DENY ? "deny" : "";
     if (!typeStr) {
       throw "Invalid ruleType: " + ruleType;
     }
-    var ruleStr = Policy.rawRuleToCanonicalString(ruleData);
+    var ruleStr = Ruleset.rawRuleToCanonicalString(ruleData);
     var entries = this._entries[typeStr];
     var removeIndex = false;
     for (var i in entries) {
-      var curRuleStr = Policy.rawRuleToCanonicalString(entries[i]);
+      var curRuleStr = Ruleset.rawRuleToCanonicalString(entries[i]);
       if (ruleStr == curRuleStr) {
         // |i| is a string which will cause bugs when we use it in arithmetic
         // expressions below. Why does this form of iterator give us string
@@ -392,16 +395,16 @@ RawPolicy.prototype = {
     }
 
     if (policy) {
-      this._removeEntryFromPolicy(ruleData, ruleType, policy);
+      this._removeEntryFromRuleset(ruleData, ruleType, policy);
     }
   },
 
   /**
-   * Returns a |Policy| object initialized to reflect the contents of this
-   * |RawPolicy|.
+   * Returns a |Ruleset| object initialized to reflect the contents of this
+   * |RawRuleset|.
    */
-  toPolicy : function(name) {
-    var policy = new Policy(name);
+  toRuleset : function(name) {
+    var policy = new Ruleset(name);
 
     for (var typeStr in this._entries) {
       //dprint("typeStr: " + typeStr);
@@ -412,8 +415,8 @@ RawPolicy.prototype = {
       var ruleType = typeStr == "allow" ? RULE_TYPE_ALLOW : RULE_TYPE_DENY;
       var entryArray = this._entries[typeStr];
       for (var i in entryArray) {
-        //dprint("toPolicy: adding entry");
-        this._addEntryToPolicy(entryArray[i], ruleType, policy);
+        //dprint("toRuleset: adding entry");
+        this._addEntryToRuleset(entryArray[i], ruleType, policy);
       }
     }
 
@@ -437,7 +440,7 @@ RawPolicy.prototype = {
   },
 
   /**
-   * Initializes this |RawPolicy| from JSON data.
+   * Initializes this |RawRuleset| from JSON data.
    */
   _fromJSON : function(data) {
     // TODO: sanity check imported data, decide whether to ignore unrecognized
@@ -453,8 +456,8 @@ RawPolicy.prototype = {
   },
 
   /**
-   * Returns a simple object representing this |RawPolicy|. This function
-   * is automatically invoked when |JSON.stringify(rawPolicyObj)| is called and
+   * Returns a simple object representing this |RawRuleset|. This function
+   * is automatically invoked when |JSON.stringify(rawRulesetObj)| is called and
    * the result is passed through stringify before being returned.
    */
   toJSON : function() {
@@ -593,7 +596,7 @@ Rule.prototype = {
     if (this.destinations) {
       return;
     }
-    this.destinations = new Policy();
+    this.destinations = new Ruleset();
   },
 
   isMatch : function(uriObj) {
@@ -714,7 +717,7 @@ IPAddressEntry.prototype = {
 };
 
 
-function Policy(name) {
+function Ruleset(name) {
   this._name = name ? name : null;
   // Start off with an "empty" top-level domain entry. This will never have
   // its own rules. Non-host-specific rules go in |this.rules|.
@@ -728,14 +731,14 @@ function Policy(name) {
 //  var print;
 //}
 
-Policy.prototype = {
+Ruleset.prototype = {
   _name : null,
   _domain : null,
   _ipAddr : null,
   rules : null,
 
   toString : function() {
-    return "[Policy " + this._name + "]";
+    return "[Ruleset " + this._name + "]";
   },
 
   print : function(depth) {
@@ -1007,7 +1010,7 @@ Policy.prototype = {
 /**
  * @static
  */
-Policy._matchToRawRuleHelper = function(rawRule, originOrDest, entry, rule) {
+Ruleset._matchToRawRuleHelper = function(rawRule, originOrDest, entry, rule) {
   rawRule[originOrDest] = {};
   if (entry instanceof DomainEntry && entry.fullName) {
     rawRule[originOrDest]["h"] = entry.fullName;
@@ -1026,26 +1029,26 @@ Policy._matchToRawRuleHelper = function(rawRule, originOrDest, entry, rule) {
 /**
  * @static
  */
-Policy.matchToRawRule = function(match) {
+Ruleset.matchToRawRule = function(match) {
   // The matches are in the format
   //     [typeStr, entry, rule]
   // or
   //     [typeStr, originEntry, originRule, destEntry, destRule]
-  // as returned by calls to |Policy.check()|.
+  // as returned by calls to |Ruleset.check()|.
   var rawRule = {};
   var entry, rule, destEntry, destRule;
   var typeStr = match[0];
 
   if (typeStr == "origin") {
     [typeStr, entry, rule] = match;
-    Policy._matchToRawRuleHelper(rawRule, "o", entry, rule);
+    Ruleset._matchToRawRuleHelper(rawRule, "o", entry, rule);
   } else if (typeStr == "dest") {
     [typeStr, entry, rule] = match;
-    Policy._matchToRawRuleHelper(rawRule, "d", entry, rule);
+    Ruleset._matchToRawRuleHelper(rawRule, "d", entry, rule);
   } else if (typeStr == "origin-to-dest") {
     [typeStr, entry, rule, destEntry, destRule] = match;
-    Policy._matchToRawRuleHelper(rawRule, "o", entry, rule);
-    Policy._matchToRawRuleHelper(rawRule, "d", destEntry, destRule);
+    Ruleset._matchToRawRuleHelper(rawRule, "o", entry, rule);
+    Ruleset._matchToRawRuleHelper(rawRule, "d", destEntry, destRule);
   } else {
     throw "[matchToRawRule] Invalid match type: " + typeStr
           + " from match: " + match;
@@ -1057,7 +1060,7 @@ Policy.matchToRawRule = function(match) {
 /**
  * @static
  */
-Policy._rawRuleToCanonicalStringHelper = function(rawRule, originOrDest, parts) {
+Ruleset._rawRuleToCanonicalStringHelper = function(rawRule, originOrDest, parts) {
   if (rawRule[originOrDest]) {
     parts.push('"' + originOrDest + '":{');
     var needComma = false;
@@ -1084,16 +1087,16 @@ Policy._rawRuleToCanonicalStringHelper = function(rawRule, originOrDest, parts)
   return parts.join("");
 }
 
-Policy.rawRuleToCanonicalString = function(rawRule) {
+Ruleset.rawRuleToCanonicalString = function(rawRule) {
   var parts = ['{'];
   if (rawRule["d"]) {
-    Policy._rawRuleToCanonicalStringHelper(rawRule, "d", parts);
+    Ruleset._rawRuleToCanonicalStringHelper(rawRule, "d", parts);
   }
   if (rawRule["d"] && rawRule["o"]) {
     parts.push(',');
   }
   if (rawRule["o"]) {
-    Policy._rawRuleToCanonicalStringHelper(rawRule, "o", parts);
+    Ruleset._rawRuleToCanonicalStringHelper(rawRule, "o", parts);
   }
   parts.push('}');
   return parts.join("");
@@ -1102,8 +1105,8 @@ Policy.rawRuleToCanonicalString = function(rawRule) {
 /**
  * @static
  */
-// Policy.rawRulesAreEqual = function(first, second) {
-//   var firstStr = Policy.rawRuleToCanonicalString(first);
-//   var secondStr = Policy.rawRuleToCanonicalString(second);
+// Ruleset.rawRulesAreEqual = function(first, second) {
+//   var firstStr = Ruleset.rawRuleToCanonicalString(first);
+//   var secondStr = Ruleset.rawRuleToCanonicalString(second);
 //   return firstStr == secondStr;
 // }
diff --git a/src/modules/PolicyStorage.jsm b/src/modules/RulesetStorage.jsm
similarity index 85%
rename from src/modules/PolicyStorage.jsm
rename to src/modules/RulesetStorage.jsm
index e5e0a0a..bb5b0c9 100644
--- a/src/modules/PolicyStorage.jsm
+++ b/src/modules/RulesetStorage.jsm
@@ -20,7 +20,7 @@
  * ***** END LICENSE BLOCK *****
  */
 
-var EXPORTED_SYMBOLS = ["PolicyStorage"];
+var EXPORTED_SYMBOLS = ["RulesetStorage"];
 
 
 if (!rp) {
@@ -28,14 +28,14 @@ if (!rp) {
 }
 
 Components.utils.import("resource://requestpolicy/FileUtil.jsm", rp.mod);
-Components.utils.import("resource://requestpolicy/Policy.jsm", rp.mod);
+Components.utils.import("resource://requestpolicy/Ruleset.jsm", rp.mod);
 
-var PolicyStorage = {
+var RulesetStorage = {
 
   /**
-   * @return {RawPolicy}
+   * @return {RawRuleset}
    */
-  loadRawPolicyFromFile : function(/**string*/ filename,
+  loadRawRulesetFromFile : function(/**string*/ filename,
         /**string*/ subscriptionListName) {
     // TODO: change filename argument to policyname and we'll append the '.json'
     // TODO: get a stream and use the mozilla json interface to decode from stream.
@@ -48,11 +48,11 @@ var PolicyStorage = {
     }
     policyFile.appendRelativePath(filename);
     var str = rp.mod.FileUtil.fileToString(policyFile);
-    var rawPolicy = new rp.mod.RawPolicy(str);
-    return rawPolicy;
+    var rawRuleset = new rp.mod.RawRuleset(str);
+    return rawRuleset;
   },
 
-  saveRawPolicyToFile : function(/**RawPolicy*/ policy, /**string*/ filename,
+  saveRawRulesetToFile : function(/**RawRuleset*/ policy, /**string*/ filename,
         /**string*/ subscriptionListName) {
     // TODO: change filename argument to policyname and we'll append the '.json'
     // TODO: get a stream and use the mozilla json interface to encode to stream.
diff --git a/src/modules/Subscription.jsm b/src/modules/Subscription.jsm
index f030ba9..437cd35 100644
--- a/src/modules/Subscription.jsm
+++ b/src/modules/Subscription.jsm
@@ -31,8 +31,8 @@ var EXPORTED_SYMBOLS = [
 
 Components.utils.import("resource://requestpolicy/FileUtil.jsm");
 Components.utils.import("resource://requestpolicy/Logger.jsm");
-Components.utils.import("resource://requestpolicy/Policy.jsm");
-Components.utils.import("resource://requestpolicy/PolicyStorage.jsm");
+Components.utils.import("resource://requestpolicy/Ruleset.jsm");
+Components.utils.import("resource://requestpolicy/RulesetStorage.jsm");
 
 
 const SUBSCRIPTION_UPDATED_TOPIC = 'requestpolicy-subscription-policy-updated';
@@ -398,23 +398,23 @@ Subscription.prototype = {
         self._data = JSON.parse(req.responseText);
         // Make sure there's a ['metadata']['serial'] key as a way of sanity
         // checking the parsed JSON as well as enforcing the use of serial
-        // numbers in subscription policies.
+        // numbers in subscription rulesets.
         try {
           var serial = self._data['metadata']['serial'];
         } catch (e) {
-          var error = 'Policy has no serial number';
+          var error = 'Ruleset has no serial number';
           setTimeout(function () { errorCallback(self, error); }, 0);
           return;
         }
         if (typeof serial != 'number' || serial % 1 != 0) {
-          var error = 'Policy has invalid serial number: ' + serial;
+          var error = 'Ruleset has invalid serial number: ' + serial;
           setTimeout(function () { errorCallback(self, error); }, 0);
           return;
         }
-        // The rest of the sanity checking is done by RawPolicy().
+        // The rest of the sanity checking is done by RawRuleset().
         try {
-          var rawPolicy = new RawPolicy(self._rawData);
-          PolicyStorage.saveRawPolicyToFile(rawPolicy, self._name + '.json',
+          var rawRuleset = new RawRuleset(self._rawData);
+          RulesetStorage.saveRawRulesetToFile(rawRuleset, self._name + '.json',
                 self._list);
         } catch (e) {
           setTimeout(function () { errorCallback(self, e.toString()); }, 0);
diff --git a/tests/modules/Policy/do_test.sh b/tests/modules/Policy/do_test.sh
index 0983203..225f801 100755
--- a/tests/modules/Policy/do_test.sh
+++ b/tests/modules/Policy/do_test.sh
@@ -8,4 +8,4 @@ if [ ! -f "$1" ]; then
   exit 1
 fi
 
-../../run-xpcshell.sh -f helper.js -f $SRC_DIR/modules/Policy.jsm $1
+../../run-xpcshell.sh -f helper.js -f $SRC_DIR/modules/Ruleset.jsm $1
diff --git a/tests/modules/Policy/rawpolicy_1.js b/tests/modules/Policy/rawpolicy_1.js
index 838b1e9..248a450 100644
--- a/tests/modules/Policy/rawpolicy_1.js
+++ b/tests/modules/Policy/rawpolicy_1.js
@@ -30,7 +30,7 @@ var jsonData = JSON.stringify(exampleRawDataObj);
 tprint("typeof jsonData: " + typeof jsonData);
 tprint(jsonData);
 
-var raw1 = new RawPolicy(jsonData);
+var raw1 = new RawRuleset(jsonData);
 tprint(raw1);
 
 tprint("");
@@ -39,5 +39,5 @@ var jsonData2 = JSON.stringify(raw1);
 tprint("typeof jsonData2: " + typeof jsonData2);
 tprint(jsonData2);
 
-var raw2 = new RawPolicy(jsonData2);
+var raw2 = new RawRuleset(jsonData2);
 tprint(raw2);
diff --git a/tests/modules/Policy/test1.js b/tests/modules/Policy/test1.js
index 918d5b0..944d072 100644
--- a/tests/modules/Policy/test1.js
+++ b/tests/modules/Policy/test1.js
@@ -1,5 +1,5 @@
 
-var policy = new Policy();
+var policy = new Ruleset();
 
 dprint("== Allow all requests from origin www.foo.com ==");
 var host = policy.addHost("www.foo.com");
diff --git a/tests/modules/Policy/test2.js b/tests/modules/Policy/test2.js
index f08c993..b538f1e 100644
--- a/tests/modules/Policy/test2.js
+++ b/tests/modules/Policy/test2.js
@@ -1,5 +1,5 @@
 
-var policy = new Policy();
+var policy = new Ruleset();
 
 dprint("== Allow all requests to https://localhost:8888/baz ==");
 var host = policy.addHost("localhost");
diff --git a/tests/modules/Policy/test3.js b/tests/modules/Policy/test3.js
index 4a9e157..b339773 100644
--- a/tests/modules/Policy/test3.js
+++ b/tests/modules/Policy/test3.js
@@ -1,5 +1,5 @@
 
-var policy = new Policy();
+var policy = new Ruleset();
 
 dprint("== Allow all requests from https://localhost:8888/baz ==");
 var host = policy.addHost("localhost");
diff --git a/tests/modules/Policy/test4.js b/tests/modules/Policy/test4.js
index ad4d97a..735f3b1 100644
--- a/tests/modules/Policy/test4.js
+++ b/tests/modules/Policy/test4.js
@@ -1,5 +1,5 @@
 
-var policy = new Policy();
+var policy = new Ruleset();
 
 dprint("== Allow all requests from *.foo.com to *.bar.com ==");
 var host = policy.addHost("*.foo.com");
diff --git a/tests/modules/Policy/test5.js b/tests/modules/Policy/test5.js
index eb14895..0a74c89 100644
--- a/tests/modules/Policy/test5.js
+++ b/tests/modules/Policy/test5.js
@@ -1,5 +1,5 @@
 
-var policy = new Policy();
+var policy = new Ruleset();
 
 dprint("== Allow all requests to https://127.0.0.1:8888/baz ==");
 var host = policy.addHost("127.0.0.1");
diff --git a/tests/xpcshell/head_utils.js b/tests/xpcshell/head_utils.js
index e63c6bd..eea16b0 100644
--- a/tests/xpcshell/head_utils.js
+++ b/tests/xpcshell/head_utils.js
@@ -1,6 +1,6 @@
 Components.utils.import("resource://requestpolicy/FileUtil.jsm");
 
-function copyPolicyFileToProfile(filename, destFilename) {
+function copyRulesetFileToProfile(filename, destFilename) {
   if (!destFilename) {
     destFilename = "";
   }
@@ -16,7 +16,7 @@ function copyPolicyFileToProfile(filename, destFilename) {
 }
 
 /*
- * @throws If the file to delete doesn't exist. 
+ * @throws If the file to delete doesn't exist.
  */
 function deleteFileFromProfile(filename) {
   var profilePolicyDir = FileUtil.getRPUserDir("policies");
@@ -27,7 +27,7 @@ function deleteFileFromProfile(filename) {
 
 /**
  * Compares to objects recursively to see if they have the same keys
- * and values. 
+ * and values.
  */
 function objectsAreEqual(objA, objB) {
   print("%%%%%%%%%%%%%%%%%%%%%%%%%%");
@@ -42,7 +42,7 @@ function objectsAreEqual(objA, objB) {
   // different than our Object, and thus objects created in modules and
   // passed back to the test didn't have the equals method. I'm sure a
   // JavaScript master could have sorted it out, but for our purposes
-  // comparing "canonical" string representations works fine. 
+  // comparing "canonical" string representations works fine.
   var result = objToStr(objA) == objToStr(objB);
   return result;
 }
@@ -65,8 +65,8 @@ function objToStr(object, depth, max){
   var output = "{";
 
   var keys = Object.keys(object);
-  keys.sort(); 
-  
+  keys.sort();
+
   for (var i in keys) {
     var key = keys[i];
     output += "\n" + indent + '"' + key + '" : ';
@@ -77,18 +77,18 @@ function objToStr(object, depth, max){
       case "function": output += "function";
         break;
       default: output += object[key];
-        break;        
+        break;
     }
     if (i < keys.length - 1) {
       output += ",";
     }
   }
-  
+
   var indent = "";
   for (var i = 0; i < depth - 1; i++) {
     indent += "  ";
   }
-  
+
   output +="\n" + indent + "}";
   return output;
 }
diff --git a/tests/xpcshell/test_policymanager.js b/tests/xpcshell/test_policymanager.js
index c650df6..e9000db 100644
--- a/tests/xpcshell/test_policymanager.js
+++ b/tests/xpcshell/test_policymanager.js
@@ -1,5 +1,5 @@
 Components.utils.import("resource://requestpolicy/DomainUtil.jsm");
-Components.utils.import("resource://requestpolicy/Policy.jsm");
+Components.utils.import("resource://requestpolicy/Ruleset.jsm");
 Components.utils.import("resource://requestpolicy/PolicyManager.jsm");
 
 
@@ -26,21 +26,21 @@ function run_test() {
 
 
 function test_0() {
-  copyPolicyFileToProfile("user_0.json", "user.json");
-  copyPolicyFileToProfile("foo.json");
-  
+  copyRulesetFileToProfile("user_0.json", "user.json");
+  copyRulesetFileToProfile("foo.json");
+
   var manager = new PolicyManager();
   manager.loadPolicies(config);
-  
-  for (var i in manager._policies) {
-    print("print policy: " + i);
-    manager._policies[i].policy.print(0, print);
-    print(JSON.stringify(manager._policies[i].rawPolicy));
+
+  for (var i in manager._rulesets) {
+    print("print ruleset: " + i);
+    manager._rulesets[i].ruleset.print(0, print);
+    print(JSON.stringify(manager._rulesets[i].rawRuleset));
   }
-  
+
   // "user", "temp", and "foo".
-  do_check_eq(Object.keys(manager._policies).length, 3);
-  
+  do_check_eq(Object.keys(manager._rulesets).length, 3);
+
   var result;
 
   // This is allowed because of https to http.
@@ -51,7 +51,7 @@ function test_0() {
   do_check_false(result.isDenied());
   do_check_true(result.isAllowed());
   // for (var i in detailedResults) {
-  //   print("policy: " + i);
+  //   print("ruleset: " + i);
   //   print("  allow: " + detailedResults[i]["allowMatches"]);
   //   print(detailedResults[i]["allowMatches"].length);
   //   for (var rule in detailedResults[i]["allowMatches"]) {
@@ -70,7 +70,7 @@ function test_0() {
   result = manager.checkRequest(origin, dest);
   do_check_false(result.isDenied());
   do_check_false(result.isAllowed());
- 
+
   deleteFileFromProfile("user.json");
   deleteFileFromProfile("foo.json");
 }
@@ -79,7 +79,7 @@ function test_0() {
   // addRule
   // addTemporaryRule
   // removeRule
-  
+
 /*
  * Test only persistent (non-temporary) rules.
  */
@@ -95,17 +95,17 @@ function test_1() {
                "dest"           : {"d" : {"h" : "www.example.com"}},
                "origin-to-dest" : {"o" : {"h" : "*.foo.com"},
                                    "d" : {"h" : "www.example.com"}}};
-  
+
   for (var i in rules) {
     // Resetting the policy manager is useful for debugging failures.
     // var manager = new PolicyManager();
     // manager.loadPolicies();
-    
+
     print("Starting: " + i);
     var rawRule = rules[i];
     // Add a rule we just added.
     manager.addRule(RULE_TYPE_ALLOW, rawRule, noStore);
-  
+
     result = manager.checkRequest(origin, dest);
     do_check_false(result.isDenied());
     do_check_true(result.isAllowed());
@@ -113,76 +113,76 @@ function test_1() {
 
     // Remove the rule we just added.
     manager.removeRule(RULE_TYPE_ALLOW, rawRule, noStore);
-    
-    for (var i in manager._policies) {
-      print("print policy: " + i);
-      manager._policies[i].policy.print(0, print);
+
+    for (var i in manager._rulesets) {
+      print("print ruleset: " + i);
+      manager._rulesets[i].ruleset.print(0, print);
     }
-    
+
     result = manager.checkRequest(origin, dest);
     do_check_false(result.isDenied());
     do_check_false(result.isAllowed());
-    
+
     // Remove the same rule twice in a row.
     manager.removeRule(RULE_TYPE_ALLOW, rawRule, noStore);
-    
+
     result = manager.checkRequest(origin, dest);
     do_check_false(result.isDenied());
     do_check_false(result.isAllowed());
-    
-    for (var i in manager._policies) {
-      print("print policy: " + i);
-      manager._policies[i].policy.print(0, print);
+
+    for (var i in manager._rulesets) {
+      print("print ruleset: " + i);
+      manager._rulesets[i].ruleset.print(0, print);
     }
-    
+
     // Add the original allow rule back.
     manager.addRule(RULE_TYPE_ALLOW, rawRule, noStore);
-    
-    for (var i in manager._policies) {
-      print("print policy: " + i);
-      manager._policies[i].policy.print(0, print);
+
+    for (var i in manager._rulesets) {
+      print("print ruleset: " + i);
+      manager._rulesets[i].ruleset.print(0, print);
     }
-  
+
     result = manager.checkRequest(origin, dest);
     do_check_false(result.isDenied());
     do_check_true(result.isAllowed());
-  
+
     // Add the same rule details but as a deny rule.
     manager.addRule(RULE_TYPE_DENY, rawRule, noStore);
-  
-    for (var i in manager._policies) {
-      print("print policy: " + i);
-      manager._policies[i].policy.print(0, print);
+
+    for (var i in manager._rulesets) {
+      print("print ruleset: " + i);
+      manager._rulesets[i].ruleset.print(0, print);
     }
-  
+
     result = manager.checkRequest(origin, dest);
     do_check_true(result.isDenied());
     do_check_true(result.isAllowed());
-    
+
     // Add the same rule again.
     manager.addRule(RULE_TYPE_DENY, rawRule, noStore);
-  
+
     result = manager.checkRequest(origin, dest);
     do_check_true(result.isDenied());
     do_check_true(result.isAllowed());
     do_check_eq(result.matchedDenyRules.length, 1);
-    
+
     // Add same rule as an allow rule.
     manager.addRule(RULE_TYPE_ALLOW, rawRule, noStore);
-  
-    for (var i in manager._policies) {
-      print("print policy: " + i);
-      manager._policies[i].policy.print(0, print);
+
+    for (var i in manager._rulesets) {
+      print("print ruleset: " + i);
+      manager._rulesets[i].ruleset.print(0, print);
     }
-  
+
     result = manager.checkRequest(origin, dest);
     do_check_true(result.isDenied());
     do_check_true(result.isAllowed());
-    
+
     // Remove both rules.
     manager.removeRule(RULE_TYPE_ALLOW, rawRule, noStore);
     manager.removeRule(RULE_TYPE_DENY, rawRule, noStore);
-    
+
     result = manager.checkRequest(origin, dest);
     do_check_false(result.isDenied());
     do_check_false(result.isAllowed());
@@ -194,7 +194,7 @@ function test_1() {
   // addRule
   // addTemporaryRule
   // removeRule
-  
+
 /*
  * Test only temporary rules.
  */
@@ -210,94 +210,94 @@ function test_2() {
                "dest"           : {"d" : {"h" : "www.example.com"}},
                "origin-to-dest" : {"o" : {"h" : "*.foo.com"},
                                    "d" : {"h" : "www.example.com"}}};
-  
+
   for (var i in rules) {
     // Resetting the policy manager is useful for debugging failures.
     // var manager = new PolicyManager();
     // manager.loadPolicies();
-    
+
     print("Starting: " + i);
     var rawRule = rules[i];
     // Add a rule we just added.
     manager.addTemporaryRule(RULE_TYPE_ALLOW, rawRule, noStore);
-  
+
     result = manager.checkRequest(origin, dest);
     do_check_false(result.isDenied());
     do_check_true(result.isAllowed());
     do_check_eq(result.matchedAllowRules.length, 1);
-    
+
     // Remove the rule we just added.
     manager.removeRule(RULE_TYPE_ALLOW, rawRule, noStore);
-    
-    for (var i in manager._policies) {
-      print("print policy: " + i);
-      manager._policies[i].policy.print(0, print);
+
+    for (var i in manager._rulesets) {
+      print("print ruleset: " + i);
+      manager._rulesets[i].ruleset.print(0, print);
     }
-    
+
     result = manager.checkRequest(origin, dest);
     do_check_false(result.isDenied());
     do_check_false(result.isAllowed());
-    
+
     // Remove the same rule twice in a row.
     manager.removeRule(RULE_TYPE_ALLOW, rawRule, noStore);
-    
+
     result = manager.checkRequest(origin, dest);
     do_check_false(result.isDenied());
     do_check_false(result.isAllowed());
-    
-    for (var i in manager._policies) {
-      print("print policy: " + i);
-      manager._policies[i].policy.print(0, print);
+
+    for (var i in manager._rulesets) {
+      print("print ruleset: " + i);
+      manager._rulesets[i].ruleset.print(0, print);
     }
-    
+
     // Add the original allow rule back.
     manager.addTemporaryRule(RULE_TYPE_ALLOW, rawRule, noStore);
-    
-    for (var i in manager._policies) {
-      print("print policy: " + i);
-      manager._policies[i].policy.print(0, print);
+
+    for (var i in manager._rulesets) {
+      print("print ruleset: " + i);
+      manager._rulesets[i].ruleset.print(0, print);
     }
-  
+
     result = manager.checkRequest(origin, dest);
     do_check_false(result.isDenied());
     do_check_true(result.isAllowed());
-  
+
     // Add the same rule details but as a deny rule.
     manager.addTemporaryRule(RULE_TYPE_DENY, rawRule, noStore);
-  
-    for (var i in manager._policies) {
-      print("print policy: " + i);
-      manager._policies[i].policy.print(0, print);
+
+    for (var i in manager._rulesets) {
+      print("print ruleset: " + i);
+      manager._rulesets[i].ruleset.print(0, print);
     }
-  
+
     result = manager.checkRequest(origin, dest);
     do_check_true(result.isDenied());
     do_check_true(result.isAllowed());
-    
+
     // Add the same rule again.
     manager.addTemporaryRule(RULE_TYPE_DENY, rawRule, noStore);
-  
+
     result = manager.checkRequest(origin, dest);
     do_check_true(result.isDenied());
     do_check_true(result.isAllowed());
     do_check_eq(result.matchedDenyRules.length, 1);
-    
+
     // Add same rule as an allow rule.
     manager.addTemporaryRule(RULE_TYPE_ALLOW, rawRule, noStore);
-  
-    for (var i in manager._policies) {
-      print("print policy: " + i);
-      manager._policies[i].policy.print(0, print);
+
+    for (var i in manager._rulesets) {
+      print("print ruleset: " + i);
+      manager._rulesets[i].ruleset.print(0, print);
     }
-  
+
     result = manager.checkRequest(origin, dest);
     do_check_true(result.isDenied());
     do_check_true(result.isAllowed());
-    
+
     // Remove both rules.
     manager.removeRule(RULE_TYPE_ALLOW, rawRule, noStore);
     manager.removeRule(RULE_TYPE_DENY, rawRule, noStore);
-    
+
     result = manager.checkRequest(origin, dest);
     do_check_false(result.isDenied());
     do_check_false(result.isAllowed());
@@ -310,7 +310,7 @@ function test_2() {
   // addRule
   // addTemporaryRule
   // removeRule
-  
+
 /*
  * Test both persistent and temporary rules whenever adding rules. A
  * single remove should remove from both.
@@ -327,18 +327,18 @@ function test_2() {
                "dest"           : {"d" : {"h" : "www.example.com"}},
                "origin-to-dest" : {"o" : {"h" : "*.foo.com"},
                                    "d" : {"h" : "www.example.com"}}};
-  
+
   for (var i in rules) {
     // Resetting the policy manager is useful for debugging failures.
     // var manager = new PolicyManager();
     // manager.loadPolicies();
-    
+
     print("Starting: " + i);
     var rawRule = rules[i];
     // Add a rule as both persistent and temporary.
     manager.addRule(RULE_TYPE_ALLOW, rawRule, noStore);
     manager.addTemporaryRule(RULE_TYPE_ALLOW, rawRule, noStore);
-  
+
     result = manager.checkRequest(origin, dest);
     do_check_false(result.isDenied());
     do_check_true(result.isAllowed());
@@ -346,80 +346,80 @@ function test_2() {
 
     // Remove the rule we just added.
     manager.removeRule(RULE_TYPE_ALLOW, rawRule, noStore);
-    
-    for (var i in manager._policies) {
-      print("print policy: " + i);
-      manager._policies[i].policy.print(0, print);
+
+    for (var i in manager._rulesets) {
+      print("print ruleset: " + i);
+      manager._rulesets[i].ruleset.print(0, print);
     }
-    
+
     result = manager.checkRequest(origin, dest);
     do_check_false(result.isDenied());
     do_check_false(result.isAllowed());
-    
+
     // Remove the same rule twice in a row.
     manager.removeRule(RULE_TYPE_ALLOW, rawRule, noStore);
-    
+
     result = manager.checkRequest(origin, dest);
     do_check_false(result.isDenied());
     do_check_false(result.isAllowed());
-    
-    for (var i in manager._policies) {
-      print("print policy: " + i);
-      manager._policies[i].policy.print(0, print);
+
+    for (var i in manager._rulesets) {
+      print("print ruleset: " + i);
+      manager._rulesets[i].ruleset.print(0, print);
     }
-    
+
     // Add the original allow rules back.
     manager.addRule(RULE_TYPE_ALLOW, rawRule, noStore);
     manager.addTemporaryRule(RULE_TYPE_ALLOW, rawRule, noStore);
-    
-    for (var i in manager._policies) {
-      print("print policy: " + i);
-      manager._policies[i].policy.print(0, print);
+
+    for (var i in manager._rulesets) {
+      print("print ruleset: " + i);
+      manager._rulesets[i].ruleset.print(0, print);
     }
-  
+
     result = manager.checkRequest(origin, dest);
     do_check_false(result.isDenied());
     do_check_true(result.isAllowed());
-  
+
     // Add the same rule details but as a deny rule.
     manager.addRule(RULE_TYPE_DENY, rawRule, noStore);
     manager.addTemporaryRule(RULE_TYPE_DENY, rawRule, noStore);
-  
-    for (var i in manager._policies) {
-      print("print policy: " + i);
-      manager._policies[i].policy.print(0, print);
+
+    for (var i in manager._rulesets) {
+      print("print ruleset: " + i);
+      manager._rulesets[i].ruleset.print(0, print);
     }
-  
+
     result = manager.checkRequest(origin, dest);
     do_check_true(result.isDenied());
     do_check_true(result.isAllowed());
-    
+
     // Add the same rule again.
     manager.addRule(RULE_TYPE_DENY, rawRule, noStore);
     manager.addTemporaryRule(RULE_TYPE_DENY, rawRule, noStore);
-  
+
     result = manager.checkRequest(origin, dest);
     do_check_true(result.isDenied());
     do_check_true(result.isAllowed());
     do_check_eq(result.matchedDenyRules.length, 2);
-    
+
     // Add same rule as an allow rule.
     manager.addRule(RULE_TYPE_ALLOW, rawRule, noStore);
     manager.addTemporaryRule(RULE_TYPE_ALLOW, rawRule, noStore);
-  
-    for (var i in manager._policies) {
-      print("print policy: " + i);
-      manager._policies[i].policy.print(0, print);
+
+    for (var i in manager._rulesets) {
+      print("print ruleset: " + i);
+      manager._rulesets[i].ruleset.print(0, print);
     }
-  
+
     result = manager.checkRequest(origin, dest);
     do_check_true(result.isDenied());
     do_check_true(result.isAllowed());
-    
+
     // Remove both rules.
     manager.removeRule(RULE_TYPE_ALLOW, rawRule, noStore);
     manager.removeRule(RULE_TYPE_DENY, rawRule, noStore);
-    
+
     result = manager.checkRequest(origin, dest);
     do_check_false(result.isDenied());
     do_check_false(result.isAllowed());
diff --git a/tests/xpcshell/test_policystorage.js b/tests/xpcshell/test_policystorage.js
index a98eb40..531d488 100644
--- a/tests/xpcshell/test_policystorage.js
+++ b/tests/xpcshell/test_policystorage.js
@@ -1,6 +1,6 @@
 
-Components.utils.import("resource://requestpolicy/Policy.jsm");
-Components.utils.import("resource://requestpolicy/PolicyStorage.jsm");
+Components.utils.import("resource://requestpolicy/Ruleset.jsm");
+Components.utils.import("resource://requestpolicy/RulesetStorage.jsm");
 
 // We expect JSON data to represent the following data structure.
 var exampleJsonObj = {
@@ -34,21 +34,21 @@ function run_test() {
 
 function test_1() {
   var filename = "foo.json";
-  
+
   var jsonData = JSON.stringify(exampleJsonObj);
-  var rawPolicy = new RawPolicy(jsonData);
-  
+  var rawRuleset = new RawRuleset(jsonData);
+
   // Write it to the file. This will create the file in the policies directory.
-  PolicyStorage.saveRawPolicyToFile(rawPolicy, filename);
-  
+  RulesetStorage.saveRawRulesetToFile(rawRuleset, filename);
+
   // Read it back from the file.
-  var readPolicy = PolicyStorage.loadRawPolicyFromFile(filename);
-  
-  jsonData = JSON.stringify(readPolicy);
+  var readRuleset = RulesetStorage.loadRawRulesetFromFile(filename);
+
+  jsonData = JSON.stringify(readRuleset);
   var readJsonObj = JSON.parse(jsonData);
-  
+
   do_check_true(objectsAreEqual(readJsonObj, exampleJsonObj));
-  
+
   deleteFileFromProfile(filename);
 }
 
@@ -59,98 +59,98 @@ function test_2() {
                "dest"           : {"d" : {"h" : "www.example.com"}},
                "origin-to-dest" : {"o" : {"h" : "*.foo.com"},
                                    "d" : {"h" : "www.example.com"}}};
-  
-  var rawPolicy = new RawPolicy();
-
-  do_check_eq(Object.keys(rawPolicy._metadata).length, 1);
-  do_check_eq(rawPolicy._metadata.version, 1);
-  do_check_eq(rawPolicy._entries["allow"].length, 0);
-  do_check_eq(rawPolicy._entries["deny"].length, 0);
-  
+
+  var rawRuleset = new RawRuleset();
+
+  do_check_eq(Object.keys(rawRuleset._metadata).length, 1);
+  do_check_eq(rawRuleset._metadata.version, 1);
+  do_check_eq(rawRuleset._entries["allow"].length, 0);
+  do_check_eq(rawRuleset._entries["deny"].length, 0);
+
   // Write it to a file and read it back.
-  PolicyStorage.saveRawPolicyToFile(rawPolicy, filename);
-  rawPolicy = PolicyStorage.loadRawPolicyFromFile(filename);
+  RulesetStorage.saveRawRulesetToFile(rawRuleset, filename);
+  rawRuleset = RulesetStorage.loadRawRulesetFromFile(filename);
 
-  do_check_eq(Object.keys(rawPolicy._metadata).length, 1);
-  do_check_eq(rawPolicy._metadata.version, 1);
-  do_check_eq(rawPolicy._entries["allow"].length, 0);
-  do_check_eq(rawPolicy._entries["deny"].length, 0);
+  do_check_eq(Object.keys(rawRuleset._metadata).length, 1);
+  do_check_eq(rawRuleset._metadata.version, 1);
+  do_check_eq(rawRuleset._entries["allow"].length, 0);
+  do_check_eq(rawRuleset._entries["deny"].length, 0);
 
   // Add all of the rules as allow rules.
   for (var name in Iterator(rules, true)) {
     // Do it twice to trigger bugs/check for duplicates.
-    rawPolicy.addRule(RULE_TYPE_ALLOW, rules[name]);
-    rawPolicy.addRule(RULE_TYPE_ALLOW, rules[name]);
+    rawRuleset.addRule(RULE_TYPE_ALLOW, rules[name]);
+    rawRuleset.addRule(RULE_TYPE_ALLOW, rules[name]);
   }
-  
+
   // Write it to a file and read it back.
-  PolicyStorage.saveRawPolicyToFile(rawPolicy, filename);
-  rawPolicy = PolicyStorage.loadRawPolicyFromFile(filename);
+  RulesetStorage.saveRawRulesetToFile(rawRuleset, filename);
+  rawRuleset = RulesetStorage.loadRawRulesetFromFile(filename);
+
+  do_check_eq(rawRuleset._entries["allow"].length, 3);
+  do_check_eq(rawRuleset._entries["deny"].length, 0);
 
-  do_check_eq(rawPolicy._entries["allow"].length, 3);
-  do_check_eq(rawPolicy._entries["deny"].length, 0);
-  
   // Add all of the rules as deny rules.
   for (var name in Iterator(rules, true)) {
     // Do it twice to trigger bugs/check for duplicates.
-    rawPolicy.addRule(RULE_TYPE_DENY, rules[name]);
-    rawPolicy.addRule(RULE_TYPE_DENY, rules[name]);
+    rawRuleset.addRule(RULE_TYPE_DENY, rules[name]);
+    rawRuleset.addRule(RULE_TYPE_DENY, rules[name]);
   }
-  
+
   // Write it to a file and read it back.
-  PolicyStorage.saveRawPolicyToFile(rawPolicy, filename);
-  rawPolicy = PolicyStorage.loadRawPolicyFromFile(filename);
+  RulesetStorage.saveRawRulesetToFile(rawRuleset, filename);
+  rawRuleset = RulesetStorage.loadRawRulesetFromFile(filename);
 
-  do_check_eq(rawPolicy._entries["allow"].length, 3);
-  do_check_eq(rawPolicy._entries["deny"].length, 3);
+  do_check_eq(rawRuleset._entries["allow"].length, 3);
+  do_check_eq(rawRuleset._entries["deny"].length, 3);
 
   // Remove one of the deny rules.
-  rawPolicy.removeRule(RULE_TYPE_DENY, rules["origin"]);
+  rawRuleset.removeRule(RULE_TYPE_DENY, rules["origin"]);
 
   // Write it to a file and read it back.
-  PolicyStorage.saveRawPolicyToFile(rawPolicy, filename);
-  rawPolicy = PolicyStorage.loadRawPolicyFromFile(filename);
+  RulesetStorage.saveRawRulesetToFile(rawRuleset, filename);
+  rawRuleset = RulesetStorage.loadRawRulesetFromFile(filename);
 
-  do_check_eq(rawPolicy._entries["allow"].length, 3);
-  do_check_eq(rawPolicy._entries["deny"].length, 2);
+  do_check_eq(rawRuleset._entries["allow"].length, 3);
+  do_check_eq(rawRuleset._entries["deny"].length, 2);
 
   // Remove all of the deny rules.
   for (var name in Iterator(rules, true)) {
     // Do it twice to trigger bugs/check for duplicates.
-    rawPolicy.removeRule(RULE_TYPE_DENY, rules[name]);
-    rawPolicy.removeRule(RULE_TYPE_DENY, rules[name]);
+    rawRuleset.removeRule(RULE_TYPE_DENY, rules[name]);
+    rawRuleset.removeRule(RULE_TYPE_DENY, rules[name]);
   }
 
   // Write it to a file and read it back.
-  PolicyStorage.saveRawPolicyToFile(rawPolicy, filename);
-  rawPolicy = PolicyStorage.loadRawPolicyFromFile(filename);
+  RulesetStorage.saveRawRulesetToFile(rawRuleset, filename);
+  rawRuleset = RulesetStorage.loadRawRulesetFromFile(filename);
 
-  do_check_eq(rawPolicy._entries["allow"].length, 3);
-  do_check_eq(rawPolicy._entries["deny"].length, 0);
+  do_check_eq(rawRuleset._entries["allow"].length, 3);
+  do_check_eq(rawRuleset._entries["deny"].length, 0);
 
   // Remove one of the allow rules.
-  rawPolicy.removeRule(RULE_TYPE_ALLOW, rules["dest"]);
+  rawRuleset.removeRule(RULE_TYPE_ALLOW, rules["dest"]);
 
   // Write it to a file and read it back.
-  PolicyStorage.saveRawPolicyToFile(rawPolicy, filename);
-  rawPolicy = PolicyStorage.loadRawPolicyFromFile(filename);
+  RulesetStorage.saveRawRulesetToFile(rawRuleset, filename);
+  rawRuleset = RulesetStorage.loadRawRulesetFromFile(filename);
 
-  do_check_eq(rawPolicy._entries["allow"].length, 2);
-  do_check_eq(rawPolicy._entries["deny"].length, 0);
+  do_check_eq(rawRuleset._entries["allow"].length, 2);
+  do_check_eq(rawRuleset._entries["deny"].length, 0);
 
   // Remove all of the allow rules.
   for (var name in Iterator(rules, true)) {
     // Do it twice to trigger bugs/check for duplicates.
-    rawPolicy.removeRule(RULE_TYPE_ALLOW, rules[name]);
-    rawPolicy.removeRule(RULE_TYPE_ALLOW, rules[name]);
+    rawRuleset.removeRule(RULE_TYPE_ALLOW, rules[name]);
+    rawRuleset.removeRule(RULE_TYPE_ALLOW, rules[name]);
   }
 
   // Write it to a file and read it back.
-  PolicyStorage.saveRawPolicyToFile(rawPolicy, filename);
-  rawPolicy = PolicyStorage.loadRawPolicyFromFile(filename);
+  RulesetStorage.saveRawRulesetToFile(rawRuleset, filename);
+  rawRuleset = RulesetStorage.loadRawRulesetFromFile(filename);
+
+  do_check_eq(rawRuleset._entries["allow"].length, 0);
+  do_check_eq(rawRuleset._entries["deny"].length, 0);
 
-  do_check_eq(rawPolicy._entries["allow"].length, 0);
-  do_check_eq(rawPolicy._entries["deny"].length, 0);
-  
   deleteFileFromProfile(filename);
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/requestpolicy.git



More information about the Pkg-mozext-commits mailing list