B2G/gecko/toolkit/components/contentprefs/tests/unit/test_contentPrefs.js
// Get/Remove Prefs By Name
Get/Remove Prefs By Name
Get / Remove Prefs By Name
function enumerateAndCheck(testName, expectedSum, expectedDomains) {
      var prefsByName = cps.getPrefsByName(testName);
      var enumerator = prefsByName.enumerator;
      var sum = 0;
      while (enumerator.hasMoreElements()) {
        var property = enumerator.getNext().QueryInterface(Components.interfaces.nsIProperty);
        sum += parseInt(property.value);
        var index = expectedDomains.indexOf(property.name);
        do_check_true(index >= 0);
        expectedDomains.splice(index, 1);
      }
      do_check_eq(sum, expectedSum);
      do_check_eq(expectedDomains.length, 0);
    }
function enumerateAndCheck ( testName , expectedSum , expectedDomains ) { var prefsByName = cps . getPrefsByName ( testName ) ; var enumerator = prefsByName . enumerator ; var sum = 0 ; while ( enumerator . hasMoreElements ( ) ) { var property = enumerator . getNext ( ) . QueryInterface ( Components . interfaces . nsIProperty ) ; sum += parseInt ( property . value ) ; var index = expectedDomains . indexOf ( property . name ) ; do_check_true ( index >= 0 ) ; expectedDomains . splice ( index , 1 ) ; } do_check_eq ( sum , expectedSum ) ; do_check_eq ( expectedDomains . length , 0 ) ; }
Get/Remove Prefs By Name
Get / Remove Prefs By Name
// remove the domain from the list of expected domains // check all domains have been removed from the array