netwerk/test/unit/test_nestedabout_serialize.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 const BinaryInputStream =
     2   Components.Constructor("@mozilla.org/binaryinputstream;1",
     3                          "nsIBinaryInputStream", "setInputStream");
     4 const BinaryOutputStream =
     5   Components.Constructor("@mozilla.org/binaryoutputstream;1",
     6                          "nsIBinaryOutputStream", "setOutputStream");
     8 const Pipe =
     9   Components.Constructor("@mozilla.org/pipe;1", "nsIPipe", "init");
    11 const kNestedAboutCID = "{2f277c00-0eaf-4ddb-b936-41326ba48aae}";
    13 function run_test()
    14 {
    15   var ios = Cc["@mozilla.org/network/io-service;1"].createInstance(Ci.nsIIOService);
    17   var baseURI = ios.newURI("http://example.com/", "UTF-8", null);
    19   // This depends on the redirector for about:license having the
    20   // nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT flag.
    21   var aboutLicense = ios.newURI("about:license", "UTF-8", baseURI);
    23   var pipe = new Pipe(false, false, 0, 0, null);
    24   var output = new BinaryOutputStream(pipe.outputStream);
    25   var input = new BinaryInputStream(pipe.inputStream);
    26   output.QueryInterface(Ci.nsIObjectOutputStream);
    27   input.QueryInterface(Ci.nsIObjectInputStream);
    29   output.writeCompoundObject(aboutLicense, Ci.nsIURI, true);
    30   var copy = input.readObject(true);
    31   copy.QueryInterface(Ci.nsIURI);
    33   do_check_eq(copy.asciiSpec, aboutLicense.asciiSpec);
    34   do_check_true(copy.equals(aboutLicense));
    35 }

mercurial