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

     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