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