extensions/cookie/test/unit/test_permmanager_removeall.js

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

     1 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 function run_test() {
     5   // setup a profile directory
     6   var dir = do_get_profile();
     8   // initialize the permission manager service
     9   var pm = Cc["@mozilla.org/permissionmanager;1"].
    10            getService(Ci.nsIPermissionManager);
    12   // get the db file
    13   var file = dir.clone();
    14   file.append("permissions.sqlite");
    15   do_check_true(file.exists());
    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();
    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();
    34   // remove all should not throw
    35   pm.removeAll();
    36 }

mercurial