netwerk/test/unit/test_gre_resources.js

Thu, 15 Jan 2015 15:59:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:59:08 +0100
branch
TOR_BUG_9701
changeset 10
ac0c01689b40
permissions
-rw-r--r--

Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 // test that things that are expected to be in gre-resources are still there
     3 var ios = Cc["@mozilla.org/network/io-service;1"]. getService(Ci.nsIIOService);
     5 function wrapInputStream(input)
     6 {
     7   var nsIScriptableInputStream = Components.interfaces.nsIScriptableInputStream;
     8   var factory = Components.classes["@mozilla.org/scriptableinputstream;1"];
     9   var wrapper = factory.createInstance(nsIScriptableInputStream);
    10   wrapper.init(input);
    11   return wrapper;
    12 }
    14 function check_file(file) {
    15   var channel = ios.newChannel("resource://gre-resources/"+file, null, null);
    16   try {
    17     let instr = wrapInputStream(channel.open());
    18     do_check_true(instr.read(1024).length > 0)
    19   } catch (e) {
    20     do_throw("Failed to read " + file + " from gre-resources:"+e)
    21   }
    22 }
    24 function run_test() {
    25   for each(let file in ["charsetData.properties"])
    26     check_file(file)
    27 }

mercurial