1 const Cc = Components.classes;
2 const Ci = Components.interfaces;
4 function round_trip(uri) {
5 var objectOutStream = Cc["@mozilla.org/binaryoutputstream;1"].
6 createInstance(Ci.nsIObjectOutputStream);
7 var pipe = Cc["@mozilla.org/pipe;1"].createInstance(Ci.nsIPipe);
8 pipe.init(false, false, 0, 0xffffffff, null);
9 objectOutStream.setOutputStream(pipe.outputStream);
10 objectOutStream.writeCompoundObject(uri, Ci.nsISupports, true);
11 objectOutStream.close();
13 var objectInStream = Cc["@mozilla.org/binaryinputstream;1"].
14 createInstance(Ci.nsIObjectInputStream);
15 objectInStream.setInputStream(pipe.inputStream);
16 return objectInStream.readObject(true).QueryInterface(Ci.nsIURI);
22 name: "network.enableIDN",
26 name: "network.IDN_show_punycode",
30 name: "network.IDN.whitelist.ch",
36 var ios = Cc["@mozilla.org/network/io-service;1"].
37 getService(Ci.nsIIOService);
39 var uri1 = ios.newURI("file:///", null, null);
40 do_check_true(uri1 instanceof Ci.nsIFileURL);
42 var uri2 = uri1.clone();
43 do_check_true(uri2 instanceof Ci.nsIFileURL);
44 do_check_true(uri1.equals(uri2));
46 var uri3 = round_trip(uri1);
47 do_check_true(uri3 instanceof Ci.nsIFileURL);
48 do_check_true(uri1.equals(uri3));
50 // Make sure our prefs are set such that this test actually means something
51 var prefs = Cc["@mozilla.org/preferences-service;1"].
52 getService(Ci.nsIPrefBranch);
53 for each (var pref in prefData) {
55 pref.oldVal = prefs.getBoolPref(pref.name);
60 prefs.setBoolPref(pref.name, pref.newVal);
65 // http://lists.w3.org/Archives/Public/public-iri/2004Mar/0012.html
66 var uri4 = ios.newURI("http://xn--jos-dma.example.net.ch/", null, null);
67 do_check_eq(uri4.asciiHost, "xn--jos-dma.example.net.ch");
68 do_check_eq(uri4.host, "jos\u00e9.example.net.ch");
70 var uri5 = round_trip(uri4);
71 do_check_true(uri4.equals(uri5));
72 do_check_eq(uri4.host, uri5.host);
73 do_check_eq(uri4.asciiHost, uri5.asciiHost);
75 for each (var pref in prefData) {
77 prefs.setBoolPref(pref.name, pref.oldVal);
79 prefs.clearUserPref(pref.name);