|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 function run_test() { |
|
5 // setup a profile directory |
|
6 var dir = do_get_profile(); |
|
7 |
|
8 // initialize the permission manager service |
|
9 var pm = Cc["@mozilla.org/permissionmanager;1"]. |
|
10 getService(Ci.nsIPermissionManager); |
|
11 |
|
12 // get the db file |
|
13 var file = dir.clone(); |
|
14 file.append("permissions.sqlite"); |
|
15 do_check_true(file.exists()); |
|
16 |
|
17 // corrupt the file |
|
18 var ostream = Cc["@mozilla.org/network/file-output-stream;1"]. |
|
19 createInstance(Ci.nsIFileOutputStream); |
|
20 ostream.init(file, 0x02, 0666, 0); |
|
21 var conv = Cc["@mozilla.org/intl/converter-output-stream;1"]. |
|
22 createInstance(Ci.nsIConverterOutputStream); |
|
23 conv.init(ostream, "UTF-8", 0, 0); |
|
24 for (var i = 0; i < file.fileSize; ++i) |
|
25 conv.writeString("a"); |
|
26 conv.close(); |
|
27 |
|
28 // prepare an empty hostperm.1 file so that it can be used for importing |
|
29 var hostperm = dir.clone(); |
|
30 hostperm.append("hostperm.1"); |
|
31 ostream.init(hostperm, 0x02 | 0x08, 0666, 0); |
|
32 ostream.close(); |
|
33 |
|
34 // remove all should not throw |
|
35 pm.removeAll(); |
|
36 } |