michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: const NS_APP_USER_PROFILE_50_DIR = "ProfD"; michael@0: michael@0: const Ci = Components.interfaces; michael@0: const Cc = Components.classes; michael@0: const Cr = Components.results; michael@0: const Cu = Components.utils; michael@0: michael@0: function do_check_throws(f, result, stack) michael@0: { michael@0: if (!stack) michael@0: stack = Components.stack.caller; michael@0: michael@0: try { michael@0: f(); michael@0: } catch (exc) { michael@0: if (exc.result == result) michael@0: return; michael@0: do_throw("expected result " + result + ", caught " + exc, stack); michael@0: } michael@0: do_throw("expected result " + result + ", none thrown", stack); michael@0: } michael@0: michael@0: var dirSvc = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties); michael@0: michael@0: // Register current test directory as provider for the profile directory. michael@0: var provider = { michael@0: getFile: function(prop, persistent) { michael@0: persistent.value = true; michael@0: if (prop == NS_APP_USER_PROFILE_50_DIR) michael@0: return dirSvc.get("CurProcD", Ci.nsIFile); michael@0: throw Cr.NS_ERROR_FAILURE; michael@0: }, michael@0: QueryInterface: function(iid) { michael@0: if (iid.equals(Ci.nsIDirectoryServiceProvider) || michael@0: iid.equals(Ci.nsISupports)) { michael@0: return this; michael@0: } michael@0: throw Cr.NS_ERROR_NO_INTERFACE; michael@0: } michael@0: }; michael@0: dirSvc.QueryInterface(Ci.nsIDirectoryService).registerProvider(provider);