1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/extensions/cookie/test/unit/test_permmanager_removeall.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,36 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +function run_test() { 1.8 + // setup a profile directory 1.9 + var dir = do_get_profile(); 1.10 + 1.11 + // initialize the permission manager service 1.12 + var pm = Cc["@mozilla.org/permissionmanager;1"]. 1.13 + getService(Ci.nsIPermissionManager); 1.14 + 1.15 + // get the db file 1.16 + var file = dir.clone(); 1.17 + file.append("permissions.sqlite"); 1.18 + do_check_true(file.exists()); 1.19 + 1.20 + // corrupt the file 1.21 + var ostream = Cc["@mozilla.org/network/file-output-stream;1"]. 1.22 + createInstance(Ci.nsIFileOutputStream); 1.23 + ostream.init(file, 0x02, 0666, 0); 1.24 + var conv = Cc["@mozilla.org/intl/converter-output-stream;1"]. 1.25 + createInstance(Ci.nsIConverterOutputStream); 1.26 + conv.init(ostream, "UTF-8", 0, 0); 1.27 + for (var i = 0; i < file.fileSize; ++i) 1.28 + conv.writeString("a"); 1.29 + conv.close(); 1.30 + 1.31 + // prepare an empty hostperm.1 file so that it can be used for importing 1.32 + var hostperm = dir.clone(); 1.33 + hostperm.append("hostperm.1"); 1.34 + ostream.init(hostperm, 0x02 | 0x08, 0666, 0); 1.35 + ostream.close(); 1.36 + 1.37 + // remove all should not throw 1.38 + pm.removeAll(); 1.39 +}