netwerk/test/unit/test_nestedabout_serialize.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial