1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/uriloader/exthandler/tests/unit/test_handlerService.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,456 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +function run_test() { 1.9 + //**************************************************************************// 1.10 + // Constants 1.11 + 1.12 + const handlerSvc = Cc["@mozilla.org/uriloader/handler-service;1"]. 1.13 + getService(Ci.nsIHandlerService); 1.14 + 1.15 + const mimeSvc = Cc["@mozilla.org/mime;1"]. 1.16 + getService(Ci.nsIMIMEService); 1.17 + 1.18 + const protoSvc = Cc["@mozilla.org/uriloader/external-protocol-service;1"]. 1.19 + getService(Ci.nsIExternalProtocolService); 1.20 + 1.21 + const prefSvc = Cc["@mozilla.org/preferences-service;1"]. 1.22 + getService(Ci.nsIPrefService); 1.23 + 1.24 + const ioService = Cc["@mozilla.org/network/io-service;1"]. 1.25 + getService(Ci.nsIIOService); 1.26 + 1.27 + const env = Cc["@mozilla.org/process/environment;1"]. 1.28 + getService(Components.interfaces.nsIEnvironment); 1.29 + 1.30 + const rootPrefBranch = prefSvc.getBranch(""); 1.31 + 1.32 + let noMailto = false; 1.33 + let isWindows = ("@mozilla.org/windows-registry-key;1" in Components.classes); 1.34 + if (isWindows) { 1.35 + // Check mailto handler from registry. 1.36 + // If registry entry is nothing, no mailto handler 1.37 + let regSvc = Cc["@mozilla.org/windows-registry-key;1"]. 1.38 + createInstance(Ci.nsIWindowsRegKey); 1.39 + try { 1.40 + regSvc.open(regSvc.ROOT_KEY_CLASSES_ROOT, 1.41 + "mailto", 1.42 + regSvc.ACCESS_READ); 1.43 + noMailto = false; 1.44 + } catch (ex) { 1.45 + noMailto = true; 1.46 + } 1.47 + regSvc.close(); 1.48 + } 1.49 + 1.50 + //**************************************************************************// 1.51 + // Sample Data 1.52 + 1.53 + // It doesn't matter whether or not this nsIFile is actually executable, 1.54 + // only that it has a path and exists. Since we don't know any executable 1.55 + // that exists on all platforms (except possibly the application being 1.56 + // tested, but there doesn't seem to be a way to get a reference to that 1.57 + // from the directory service), we use the temporary directory itself. 1.58 + var executable = HandlerServiceTest._dirSvc.get("TmpD", Ci.nsIFile); 1.59 + // XXX We could, of course, create an actual executable in the directory: 1.60 + //executable.append("localhandler"); 1.61 + //if (!executable.exists()) 1.62 + // executable.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0755); 1.63 + 1.64 + var localHandler = { 1.65 + name: "Local Handler", 1.66 + executable: executable, 1.67 + interfaces: [Ci.nsIHandlerApp, Ci.nsILocalHandlerApp, Ci.nsISupports], 1.68 + QueryInterface: function(iid) { 1.69 + if (!this.interfaces.some( function(v) { return iid.equals(v) } )) 1.70 + throw Cr.NS_ERROR_NO_INTERFACE; 1.71 + return this; 1.72 + } 1.73 + }; 1.74 + 1.75 + var webHandler = Cc["@mozilla.org/uriloader/web-handler-app;1"]. 1.76 + createInstance(Ci.nsIWebHandlerApp); 1.77 + webHandler.name = "Web Handler"; 1.78 + webHandler.uriTemplate = "http://www.example.com/?%s"; 1.79 + 1.80 + // FIXME: these tests create and manipulate enough variables that it would 1.81 + // make sense to move each test into its own scope so we don't run the risk 1.82 + // of one test stomping on another's data. 1.83 + 1.84 + 1.85 + //**************************************************************************// 1.86 + // Test Default Properties 1.87 + 1.88 + // Get a handler info for a MIME type that neither the application nor 1.89 + // the OS knows about and make sure its properties are set to the proper 1.90 + // default values. 1.91 + 1.92 + var handlerInfo = mimeSvc.getFromTypeAndExtension("nonexistent/type", null); 1.93 + 1.94 + // Make sure it's also an nsIHandlerInfo. 1.95 + do_check_true(handlerInfo instanceof Ci.nsIHandlerInfo); 1.96 + 1.97 + do_check_eq(handlerInfo.type, "nonexistent/type"); 1.98 + 1.99 + // Deprecated property, but we should still make sure it's set correctly. 1.100 + do_check_eq(handlerInfo.MIMEType, "nonexistent/type"); 1.101 + 1.102 + // These properties are the ones the handler service knows how to store. 1.103 + do_check_eq(handlerInfo.preferredAction, Ci.nsIHandlerInfo.saveToDisk); 1.104 + do_check_eq(handlerInfo.preferredApplicationHandler, null); 1.105 + do_check_eq(handlerInfo.possibleApplicationHandlers.length, 0); 1.106 + do_check_true(handlerInfo.alwaysAskBeforeHandling); 1.107 + 1.108 + // These properties are initialized to default values by the service, 1.109 + // so we might as well make sure they're initialized to the right defaults. 1.110 + do_check_eq(handlerInfo.description, ""); 1.111 + do_check_eq(handlerInfo.hasDefaultHandler, false); 1.112 + do_check_eq(handlerInfo.defaultDescription, ""); 1.113 + 1.114 + // test some default protocol info properties 1.115 + var haveDefaultHandlersVersion = false; 1.116 + try { 1.117 + // If we have a defaultHandlersVersion pref, then assume that we're in the 1.118 + // firefox tree and that we'll also have default handlers. 1.119 + // Bug 395131 has been filed to make this test work more generically 1.120 + // by providing our own prefs for this test rather than this icky 1.121 + // special casing. 1.122 + rootPrefBranch.getCharPref("gecko.handlerService.defaultHandlersVersion"); 1.123 + haveDefaultHandlersVersion = true; 1.124 + } catch (ex) {} 1.125 + 1.126 + const kExternalWarningDefault = 1.127 + "network.protocol-handler.warn-external-default"; 1.128 + prefSvc.setBoolPref(kExternalWarningDefault, true); 1.129 + 1.130 + // XXX add more thorough protocol info property checking 1.131 + 1.132 + // no OS default handler exists 1.133 + var protoInfo = protoSvc.getProtocolHandlerInfo("x-moz-rheet"); 1.134 + do_check_eq(protoInfo.preferredAction, protoInfo.alwaysAsk); 1.135 + do_check_true(protoInfo.alwaysAskBeforeHandling); 1.136 + 1.137 + // OS default exists, injected default does not exist, 1.138 + // explicit warning pref: false 1.139 + const kExternalWarningPrefPrefix = "network.protocol-handler.warn-external."; 1.140 + prefSvc.setBoolPref(kExternalWarningPrefPrefix + "http", false); 1.141 + protoInfo = protoSvc.getProtocolHandlerInfo("http"); 1.142 + do_check_eq(0, protoInfo.possibleApplicationHandlers.length); 1.143 + do_check_false(protoInfo.alwaysAskBeforeHandling); 1.144 + 1.145 + // OS default exists, injected default does not exist, 1.146 + // explicit warning pref: true 1.147 + prefSvc.setBoolPref(kExternalWarningPrefPrefix + "http", true); 1.148 + protoInfo = protoSvc.getProtocolHandlerInfo("http"); 1.149 + // OS handler isn't included in possibleApplicationHandlers, so length is 0 1.150 + // Once they become instances of nsILocalHandlerApp, this number will need 1.151 + // to change. 1.152 + do_check_eq(0, protoInfo.possibleApplicationHandlers.length); 1.153 + do_check_true(protoInfo.alwaysAskBeforeHandling); 1.154 + 1.155 + // OS default exists, injected default exists, explicit warning pref: false 1.156 + prefSvc.setBoolPref(kExternalWarningPrefPrefix + "mailto", false); 1.157 + protoInfo = protoSvc.getProtocolHandlerInfo("mailto"); 1.158 + if (haveDefaultHandlersVersion) 1.159 + do_check_eq(2, protoInfo.possibleApplicationHandlers.length); 1.160 + else 1.161 + do_check_eq(0, protoInfo.possibleApplicationHandlers.length); 1.162 + 1.163 + // Win7+ might not have a default mailto: handler 1.164 + if (noMailto) 1.165 + do_check_true(protoInfo.alwaysAskBeforeHandling); 1.166 + else 1.167 + do_check_false(protoInfo.alwaysAskBeforeHandling); 1.168 + 1.169 + // OS default exists, injected default exists, explicit warning pref: true 1.170 + prefSvc.setBoolPref(kExternalWarningPrefPrefix + "mailto", true); 1.171 + protoInfo = protoSvc.getProtocolHandlerInfo("mailto"); 1.172 + if (haveDefaultHandlersVersion) { 1.173 + do_check_eq(2, protoInfo.possibleApplicationHandlers.length); 1.174 + // Win7+ might not have a default mailto: handler, but on other platforms 1.175 + // alwaysAskBeforeHandling is expected to be false here, because although 1.176 + // the pref is true, the value in RDF is false. The injected mailto handler 1.177 + // carried over the default pref value, and so when we set the pref above 1.178 + // to true it's ignored. 1.179 + if (noMailto) 1.180 + do_check_true(protoInfo.alwaysAskBeforeHandling); 1.181 + else 1.182 + do_check_false(protoInfo.alwaysAskBeforeHandling); 1.183 + 1.184 + } else { 1.185 + do_check_eq(0, protoInfo.possibleApplicationHandlers.length); 1.186 + do_check_true(protoInfo.alwaysAskBeforeHandling); 1.187 + } 1.188 + 1.189 + if (haveDefaultHandlersVersion) { 1.190 + // Now set the value stored in RDF to true, and the pref to false, to make 1.191 + // sure we still get the right value. (Basically, same thing as above but 1.192 + // with the values reversed.) 1.193 + prefSvc.setBoolPref(kExternalWarningPrefPrefix + "mailto", false); 1.194 + protoInfo.alwaysAskBeforeHandling = true; 1.195 + handlerSvc.store(protoInfo); 1.196 + protoInfo = protoSvc.getProtocolHandlerInfo("mailto"); 1.197 + do_check_eq(2, protoInfo.possibleApplicationHandlers.length); 1.198 + do_check_true(protoInfo.alwaysAskBeforeHandling); 1.199 + } 1.200 + 1.201 + 1.202 + //**************************************************************************// 1.203 + // Test Round-Trip Data Integrity 1.204 + 1.205 + // Test round-trip data integrity by setting the properties of the handler 1.206 + // info object to different values, telling the handler service to store the 1.207 + // object, and then retrieving a new info object for the same type and making 1.208 + // sure its properties are identical. 1.209 + 1.210 + handlerInfo.preferredAction = Ci.nsIHandlerInfo.useHelperApp; 1.211 + handlerInfo.preferredApplicationHandler = localHandler; 1.212 + handlerInfo.alwaysAskBeforeHandling = false; 1.213 + 1.214 + handlerSvc.store(handlerInfo); 1.215 + 1.216 + handlerInfo = mimeSvc.getFromTypeAndExtension("nonexistent/type", null); 1.217 + 1.218 + do_check_eq(handlerInfo.preferredAction, Ci.nsIHandlerInfo.useHelperApp); 1.219 + 1.220 + do_check_neq(handlerInfo.preferredApplicationHandler, null); 1.221 + var preferredHandler = handlerInfo.preferredApplicationHandler; 1.222 + do_check_eq(typeof preferredHandler, "object"); 1.223 + do_check_eq(preferredHandler.name, "Local Handler"); 1.224 + do_check_true(preferredHandler instanceof Ci.nsILocalHandlerApp); 1.225 + preferredHandler.QueryInterface(Ci.nsILocalHandlerApp); 1.226 + do_check_eq(preferredHandler.executable.path, localHandler.executable.path); 1.227 + 1.228 + do_check_false(handlerInfo.alwaysAskBeforeHandling); 1.229 + 1.230 + // Make sure the handler service's enumerate method lists all known handlers. 1.231 + var handlerInfo2 = mimeSvc.getFromTypeAndExtension("nonexistent/type2", null); 1.232 + handlerSvc.store(handlerInfo2); 1.233 + var handlerTypes = ["nonexistent/type", "nonexistent/type2"]; 1.234 + if (haveDefaultHandlersVersion) { 1.235 + handlerTypes.push("webcal"); 1.236 + handlerTypes.push("mailto"); 1.237 + handlerTypes.push("irc"); 1.238 + handlerTypes.push("ircs"); 1.239 + } 1.240 + var handlers = handlerSvc.enumerate(); 1.241 + while (handlers.hasMoreElements()) { 1.242 + var handler = handlers.getNext().QueryInterface(Ci.nsIHandlerInfo); 1.243 + do_check_neq(handlerTypes.indexOf(handler.type), -1); 1.244 + handlerTypes.splice(handlerTypes.indexOf(handler.type), 1); 1.245 + } 1.246 + do_check_eq(handlerTypes.length, 0); 1.247 + 1.248 + // Make sure the handler service's remove method removes a handler record. 1.249 + handlerSvc.remove(handlerInfo2); 1.250 + handlers = handlerSvc.enumerate(); 1.251 + while (handlers.hasMoreElements()) 1.252 + do_check_neq(handlers.getNext().QueryInterface(Ci.nsIHandlerInfo).type, 1.253 + handlerInfo2.type); 1.254 + 1.255 + // Make sure we can store and retrieve a handler info object with no preferred 1.256 + // handler. 1.257 + var noPreferredHandlerInfo = 1.258 + mimeSvc.getFromTypeAndExtension("nonexistent/no-preferred-handler", null); 1.259 + handlerSvc.store(noPreferredHandlerInfo); 1.260 + noPreferredHandlerInfo = 1.261 + mimeSvc.getFromTypeAndExtension("nonexistent/no-preferred-handler", null); 1.262 + do_check_eq(noPreferredHandlerInfo.preferredApplicationHandler, null); 1.263 + 1.264 + // Make sure that the handler service removes an existing handler record 1.265 + // if we store a handler info object with no preferred handler. 1.266 + var removePreferredHandlerInfo = 1.267 + mimeSvc.getFromTypeAndExtension("nonexistent/rem-preferred-handler", null); 1.268 + removePreferredHandlerInfo.preferredApplicationHandler = localHandler; 1.269 + handlerSvc.store(removePreferredHandlerInfo); 1.270 + removePreferredHandlerInfo = 1.271 + mimeSvc.getFromTypeAndExtension("nonexistent/rem-preferred-handler", null); 1.272 + removePreferredHandlerInfo.preferredApplicationHandler = null; 1.273 + handlerSvc.store(removePreferredHandlerInfo); 1.274 + removePreferredHandlerInfo = 1.275 + mimeSvc.getFromTypeAndExtension("nonexistent/rem-preferred-handler", null); 1.276 + do_check_eq(removePreferredHandlerInfo.preferredApplicationHandler, null); 1.277 + 1.278 + // Make sure we can store and retrieve a handler info object with possible 1.279 + // handlers. We test both adding and removing handlers. 1.280 + 1.281 + // Get a handler info and make sure it has no possible handlers. 1.282 + var possibleHandlersInfo = 1.283 + mimeSvc.getFromTypeAndExtension("nonexistent/possible-handlers", null); 1.284 + do_check_eq(possibleHandlersInfo.possibleApplicationHandlers.length, 0); 1.285 + 1.286 + // Store and re-retrieve the handler and make sure it still has no possible 1.287 + // handlers. 1.288 + handlerSvc.store(possibleHandlersInfo); 1.289 + possibleHandlersInfo = 1.290 + mimeSvc.getFromTypeAndExtension("nonexistent/possible-handlers", null); 1.291 + do_check_eq(possibleHandlersInfo.possibleApplicationHandlers.length, 0); 1.292 + 1.293 + // Add two handlers, store the object, re-retrieve it, and make sure it has 1.294 + // two handlers. 1.295 + possibleHandlersInfo.possibleApplicationHandlers.appendElement(localHandler, 1.296 + false); 1.297 + possibleHandlersInfo.possibleApplicationHandlers.appendElement(webHandler, 1.298 + false); 1.299 + handlerSvc.store(possibleHandlersInfo); 1.300 + possibleHandlersInfo = 1.301 + mimeSvc.getFromTypeAndExtension("nonexistent/possible-handlers", null); 1.302 + do_check_eq(possibleHandlersInfo.possibleApplicationHandlers.length, 2); 1.303 + 1.304 + // Figure out which is the local and which is the web handler and the index 1.305 + // in the array of the local handler, which is the one we're going to remove 1.306 + // to test removal of a handler. 1.307 + var handler1 = possibleHandlersInfo.possibleApplicationHandlers. 1.308 + queryElementAt(0, Ci.nsIHandlerApp); 1.309 + var handler2 = possibleHandlersInfo.possibleApplicationHandlers. 1.310 + queryElementAt(1, Ci.nsIHandlerApp); 1.311 + var localPossibleHandler, webPossibleHandler, localIndex; 1.312 + if (handler1 instanceof Ci.nsILocalHandlerApp) 1.313 + [localPossibleHandler, webPossibleHandler, localIndex] = [handler1, 1.314 + handler2, 1.315 + 0]; 1.316 + else 1.317 + [localPossibleHandler, webPossibleHandler, localIndex] = [handler2, 1.318 + handler1, 1.319 + 1]; 1.320 + localPossibleHandler.QueryInterface(Ci.nsILocalHandlerApp); 1.321 + webPossibleHandler.QueryInterface(Ci.nsIWebHandlerApp); 1.322 + 1.323 + // Make sure the two handlers are the ones we stored. 1.324 + do_check_eq(localPossibleHandler.name, localHandler.name); 1.325 + do_check_true(localPossibleHandler.equals(localHandler)); 1.326 + do_check_eq(webPossibleHandler.name, webHandler.name); 1.327 + do_check_true(webPossibleHandler.equals(webHandler)); 1.328 + 1.329 + // Remove a handler, store the object, re-retrieve it, and make sure 1.330 + // it only has one handler. 1.331 + possibleHandlersInfo.possibleApplicationHandlers.removeElementAt(localIndex); 1.332 + handlerSvc.store(possibleHandlersInfo); 1.333 + possibleHandlersInfo = 1.334 + mimeSvc.getFromTypeAndExtension("nonexistent/possible-handlers", null); 1.335 + do_check_eq(possibleHandlersInfo.possibleApplicationHandlers.length, 1); 1.336 + 1.337 + // Make sure the handler is the one we didn't remove. 1.338 + webPossibleHandler = possibleHandlersInfo.possibleApplicationHandlers. 1.339 + queryElementAt(0, Ci.nsIWebHandlerApp); 1.340 + do_check_eq(webPossibleHandler.name, webHandler.name); 1.341 + do_check_true(webPossibleHandler.equals(webHandler)); 1.342 + 1.343 + ////////////////////////////////////////////////////// 1.344 + // handler info command line parameters and equality 1.345 + var localApp = Cc["@mozilla.org/uriloader/local-handler-app;1"]. 1.346 + createInstance(Ci.nsILocalHandlerApp); 1.347 + var handlerApp = localApp.QueryInterface(Ci.nsIHandlerApp); 1.348 + 1.349 + do_check_true(handlerApp.equals(localApp)); 1.350 + 1.351 + localApp.executable = executable; 1.352 + 1.353 + do_check_eq(0, localApp.parameterCount); 1.354 + localApp.appendParameter("-test1"); 1.355 + do_check_eq(1, localApp.parameterCount); 1.356 + localApp.appendParameter("-test2"); 1.357 + do_check_eq(2, localApp.parameterCount); 1.358 + do_check_true(localApp.parameterExists("-test1")); 1.359 + do_check_true(localApp.parameterExists("-test2")); 1.360 + do_check_false(localApp.parameterExists("-false")); 1.361 + localApp.clearParameters(); 1.362 + do_check_eq(0, localApp.parameterCount); 1.363 + 1.364 + var localApp2 = Cc["@mozilla.org/uriloader/local-handler-app;1"]. 1.365 + createInstance(Ci.nsILocalHandlerApp); 1.366 + 1.367 + localApp2.executable = executable; 1.368 + 1.369 + localApp.clearParameters(); 1.370 + do_check_true(localApp.equals(localApp2)); 1.371 + 1.372 + // equal: 1.373 + // cut -d 1 -f 2 1.374 + // cut -d 1 -f 2 1.375 + 1.376 + localApp.appendParameter("-test1"); 1.377 + localApp.appendParameter("-test2"); 1.378 + localApp.appendParameter("-test3"); 1.379 + localApp2.appendParameter("-test1"); 1.380 + localApp2.appendParameter("-test2"); 1.381 + localApp2.appendParameter("-test3"); 1.382 + do_check_true(localApp.equals(localApp2)); 1.383 + 1.384 + // not equal: 1.385 + // cut -d 1 -f 2 1.386 + // cut -f 1 -d 2 1.387 + 1.388 + localApp.clearParameters(); 1.389 + localApp2.clearParameters(); 1.390 + 1.391 + localApp.appendParameter("-test1"); 1.392 + localApp.appendParameter("-test2"); 1.393 + localApp.appendParameter("-test3"); 1.394 + localApp2.appendParameter("-test2"); 1.395 + localApp2.appendParameter("-test1"); 1.396 + localApp2.appendParameter("-test3"); 1.397 + do_check_false(localApp2.equals(localApp)); 1.398 + 1.399 + var str; 1.400 + str = localApp.getParameter(0) 1.401 + do_check_eq(str, "-test1"); 1.402 + str = localApp.getParameter(1) 1.403 + do_check_eq(str, "-test2"); 1.404 + str = localApp.getParameter(2) 1.405 + do_check_eq(str, "-test3"); 1.406 + 1.407 + // FIXME: test round trip integrity for a protocol. 1.408 + // FIXME: test round trip integrity for a handler info with a web handler. 1.409 + 1.410 + //**************************************************************************// 1.411 + // getTypeFromExtension tests 1.412 + 1.413 + // test nonexistent extension 1.414 + var lolType = handlerSvc.getTypeFromExtension("lolcat"); 1.415 + do_check_eq(lolType, ""); 1.416 + 1.417 + 1.418 + // add a handler for the extension 1.419 + var lolHandler = mimeSvc.getFromTypeAndExtension("application/lolcat", null); 1.420 + 1.421 + do_check_false(lolHandler.extensionExists("lolcat")); 1.422 + lolHandler.preferredAction = Ci.nsIHandlerInfo.useHelperApp; 1.423 + lolHandler.preferredApplicationHandler = localHandler; 1.424 + lolHandler.alwaysAskBeforeHandling = false; 1.425 + 1.426 + // store the handler 1.427 + do_check_false(handlerSvc.exists(lolHandler)); 1.428 + handlerSvc.store(lolHandler); 1.429 + do_check_true(handlerSvc.exists(lolHandler)); 1.430 + 1.431 + // Get a file:// string pointing to mimeTypes.rdf 1.432 + var rdfFile = HandlerServiceTest._dirSvc.get("UMimTyp", Ci.nsIFile); 1.433 + var fileHandler = ioService.getProtocolHandler("file").QueryInterface(Ci.nsIFileProtocolHandler); 1.434 + var rdfFileURI = fileHandler.getURLSpecFromFile(rdfFile); 1.435 + 1.436 + // Assign a file extenstion to the handler. handlerSvc.store() doesn't 1.437 + // actually store any file extensions added with setFileExtensions(), you 1.438 + // have to wade into RDF muck to do so. 1.439 + 1.440 + // Based on toolkit/mozapps/downloads/content/helperApps.js :: addExtension() 1.441 + var gRDF = Cc["@mozilla.org/rdf/rdf-service;1"].getService(Ci.nsIRDFService); 1.442 + var mimeSource = gRDF.GetUnicodeResource("urn:mimetype:application/lolcat"); 1.443 + var valueProperty = gRDF.GetUnicodeResource("http://home.netscape.com/NC-rdf#fileExtensions"); 1.444 + var mimeLiteral = gRDF.GetLiteral("lolcat"); 1.445 + 1.446 + var DS = gRDF.GetDataSourceBlocking(rdfFileURI); 1.447 + DS.Assert(mimeSource, valueProperty, mimeLiteral, true); 1.448 + 1.449 + 1.450 + // test now-existent extension 1.451 + lolType = handlerSvc.getTypeFromExtension("lolcat"); 1.452 + do_check_eq(lolType, "application/lolcat"); 1.453 + 1.454 + if (env.get("PERSONAL_MAILCAP")) { 1.455 + handlerInfo = mimeSvc.getFromTypeAndExtension("text/plain", null); 1.456 + do_check_eq(handlerInfo.preferredAction, Ci.nsIHandlerInfo.useSystemDefault); 1.457 + do_check_eq(handlerInfo.defaultDescription, "sed"); 1.458 + } 1.459 +}