extensions/cookie/test/unit/test_permmanager_removeall.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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 }

mercurial