add: do_check_eq(handlerInfo.type, "nonexistent/type");   
context: function run_test() {  // It doesn't matter whether or not this nsIFile is actually executable,  // only that it has a path and exists.  Since we don't know any executable  // that exists on all platforms (except possibly the application being  // tested, but there doesn't seem to be a way to get a reference to that  // from the directory service), we use the temporary directory itself.  var executable = HandlerServiceTest._dirSvc.get("TmpD", Ci.nsIFile);  var localHandler = {    name: "Local Handler",    executable: executable,    interfaces: [Ci.nsIHandlerApp, Ci.nsILocalHandlerApp, Ci.nsISupports],    QueryInterface: function(iid) {      if (!this.interfaces.some( function(v) { return iid.equals(v) } ))        throw Cr.NS_ERROR_NO_INTERFACE;      return this;    }  };    var webHandler = {    name: "Web Handler",    uriTemplate: "http://www.example.com/?%s",    interfaces: [Ci.nsIHandlerApp, Ci.nsIWebHandlerApp, Ci.nsISupports],    QueryInterface: function(iid) {      if (!this.interfaces.some( function(v) { return iid.equals(v) } ))        throw Cr.NS_ERROR_NO_INTERFACE;      return this;    }  };    var handlerSvc = Cc["@mozilla.org/uriloader/handler-service;1"].                   getService(Ci.nsIHandlerService);  var mimeSvc = Cc["@mozilla.org/uriloader/external-helper-app-service;1"].                getService(Ci.nsIMIMEService);  //**************************************************************************//  // Default Properties  // Get a handler info for a MIME type that neither the application nor  // the OS knows about and make sure its properties are set to the proper  // default values.  var handlerInfo = mimeSvc.getFromTypeAndExtension("nonexistent/type", null);  // Make sure it's also an nsIHandlerInfo.  do_check_true(handlerInfo instanceof Ci.nsIHandlerInfo);  do_check_eq(handlerInfo.MIMEType, "nonexistent/type");  // These three properties are the ones the handler service knows how to store.  do_check_eq(handlerInfo.preferredAction, Ci.nsIHandlerInfo.saveToDisk);  do_check_eq(handlerInfo.preferredApplicationHandler, null);  do_check_true(handlerInfo.alwaysAskBeforeHandling);  // These properties are initialized to default values by the service,  // so we might as well make sure they're initialized to the right defaults.  do_check_eq(handlerInfo.description, "");  do_check_eq(handlerInfo.hasDefaultHandler, false);  do_check_eq(handlerInfo.defaultDescription, "");  // FIXME: test a default protocol handler.  //**************************************************************************//  // Round-Trip Data Integrity  // Test round-trip data integrity by setting the properties of the handler  // info object to different values, telling the handler service to store the  // object, and then retrieving a new info object for the same type and making  // sure its properties are identical.  handlerInfo.preferredAction = Ci.nsIHandlerInfo.useHelperApp;  handlerInfo.preferredApplicationHandler = localHandler;  handlerInfo.alwaysAskBeforeHandling = false;  handlerSvc.store(handlerInfo);  handlerInfo = mimeSvc.getFromTypeAndExtension("nonexistent/type", null);  do_check_eq(handlerInfo.preferredAction, Ci.nsIHandlerInfo.useHelperApp);  do_check_neq(handlerInfo.preferredApplicationHandler, null);  var preferredHandler = handlerInfo.preferredApplicationHandler;  do_check_eq(typeof preferredHandler, "object");  do_check_eq(preferredHandler.name, "Local Handler");  do_check_true(preferredHandler instanceof Ci.nsILocalHandlerApp);  preferredHandler.QueryInterface(Ci.nsILocalHandlerApp);  do_check_eq(preferredHandler.executable.path, localHandler.executable.path);  do_check_false(handlerInfo.alwaysAskBeforeHandling);  // Make sure we can store and retrieve a handler info object with no preferred  // handler.  var noPreferredHandlerInfo =    mimeSvc.getFromTypeAndExtension("nonexistent/no-preferred-handler", null);  handlerSvc.store(noPreferredHandlerInfo);  noPreferredHandlerInfo =    mimeSvc.getFromTypeAndExtension("nonexistent/no-preferred-handler", null);  do_check_eq(noPreferredHandlerInfo.preferredApplicationHandler, null);  // Make sure that the handler service removes an existing handler record  // if we store a handler info object with no preferred handler.  var removePreferredHandlerInfo =    mimeSvc.getFromTypeAndExtension("nonexistent/rem-preferred-handler", null);  removePreferredHandlerInfo.preferredApplicationHandler = localHandler;  handlerSvc.store(removePreferredHandlerInfo);  removePreferredHandlerInfo =    mimeSvc.getFromTypeAndExtension("nonexistent/rem-preferred-handler", null);  removePreferredHandlerInfo.preferredApplicationHandler = null;  handlerSvc.store(removePreferredHandlerInfo);  removePreferredHandlerInfo =    mimeSvc.getFromTypeAndExtension("nonexistent/rem-preferred-handler", null);  do_check_eq(removePreferredHandlerInfo.preferredApplicationHandler, null);  // FIXME: test round trip integrity for a protocol.  // FIXME: test round trip integrity for a handler info with a web handler.}
meta: 8395	/local1/tlutelli/issta_data/temp/all_js/javascript/2007_temp/2007/8395/236dc4d48894f79946ebdc449c894ae96b75f636/test_handlerService.js/buggy/uriloader/exthandler/tests/unit/test_handlerService.js