|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 const NS_APP_USER_PROFILE_50_DIR = "ProfD"; |
|
6 |
|
7 const Ci = Components.interfaces; |
|
8 const Cc = Components.classes; |
|
9 const Cr = Components.results; |
|
10 const Cu = Components.utils; |
|
11 |
|
12 function do_check_throws(f, result, stack) |
|
13 { |
|
14 if (!stack) |
|
15 stack = Components.stack.caller; |
|
16 |
|
17 try { |
|
18 f(); |
|
19 } catch (exc) { |
|
20 if (exc.result == result) |
|
21 return; |
|
22 do_throw("expected result " + result + ", caught " + exc, stack); |
|
23 } |
|
24 do_throw("expected result " + result + ", none thrown", stack); |
|
25 } |
|
26 |
|
27 var dirSvc = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties); |
|
28 |
|
29 // Register current test directory as provider for the profile directory. |
|
30 var provider = { |
|
31 getFile: function(prop, persistent) { |
|
32 persistent.value = true; |
|
33 if (prop == NS_APP_USER_PROFILE_50_DIR) |
|
34 return dirSvc.get("CurProcD", Ci.nsIFile); |
|
35 throw Cr.NS_ERROR_FAILURE; |
|
36 }, |
|
37 QueryInterface: function(iid) { |
|
38 if (iid.equals(Ci.nsIDirectoryServiceProvider) || |
|
39 iid.equals(Ci.nsISupports)) { |
|
40 return this; |
|
41 } |
|
42 throw Cr.NS_ERROR_NO_INTERFACE; |
|
43 } |
|
44 }; |
|
45 dirSvc.QueryInterface(Ci.nsIDirectoryService).registerProvider(provider); |