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