netwerk/test/unit/test_nestedabout_serialize.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/netwerk/test/unit/test_nestedabout_serialize.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,35 @@
     1.4 +const BinaryInputStream =
     1.5 +  Components.Constructor("@mozilla.org/binaryinputstream;1",
     1.6 +                         "nsIBinaryInputStream", "setInputStream");
     1.7 +const BinaryOutputStream =
     1.8 +  Components.Constructor("@mozilla.org/binaryoutputstream;1",
     1.9 +                         "nsIBinaryOutputStream", "setOutputStream");
    1.10 +
    1.11 +const Pipe =
    1.12 +  Components.Constructor("@mozilla.org/pipe;1", "nsIPipe", "init");
    1.13 +
    1.14 +const kNestedAboutCID = "{2f277c00-0eaf-4ddb-b936-41326ba48aae}";
    1.15 +
    1.16 +function run_test()
    1.17 +{
    1.18 +  var ios = Cc["@mozilla.org/network/io-service;1"].createInstance(Ci.nsIIOService);
    1.19 +
    1.20 +  var baseURI = ios.newURI("http://example.com/", "UTF-8", null);
    1.21 +
    1.22 +  // This depends on the redirector for about:license having the
    1.23 +  // nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT flag.
    1.24 +  var aboutLicense = ios.newURI("about:license", "UTF-8", baseURI);
    1.25 +
    1.26 +  var pipe = new Pipe(false, false, 0, 0, null);
    1.27 +  var output = new BinaryOutputStream(pipe.outputStream);
    1.28 +  var input = new BinaryInputStream(pipe.inputStream);
    1.29 +  output.QueryInterface(Ci.nsIObjectOutputStream);
    1.30 +  input.QueryInterface(Ci.nsIObjectInputStream);
    1.31 +
    1.32 +  output.writeCompoundObject(aboutLicense, Ci.nsIURI, true);
    1.33 +  var copy = input.readObject(true);
    1.34 +  copy.QueryInterface(Ci.nsIURI);
    1.35 +
    1.36 +  do_check_eq(copy.asciiSpec, aboutLicense.asciiSpec);
    1.37 +  do_check_true(copy.equals(aboutLicense));
    1.38 +}

mercurial