summaryrefslogtreecommitdiffstats
path: root/netwerk/test/unit/test_bug396389.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /netwerk/test/unit/test_bug396389.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'netwerk/test/unit/test_bug396389.js')
-rw-r--r--netwerk/test/unit/test_bug396389.js71
1 files changed, 71 insertions, 0 deletions
diff --git a/netwerk/test/unit/test_bug396389.js b/netwerk/test/unit/test_bug396389.js
new file mode 100644
index 000000000..0bcfa8362
--- /dev/null
+++ b/netwerk/test/unit/test_bug396389.js
@@ -0,0 +1,71 @@
+function round_trip(uri) {
+ var objectOutStream = Cc["@mozilla.org/binaryoutputstream;1"].
+ createInstance(Ci.nsIObjectOutputStream);
+ var pipe = Cc["@mozilla.org/pipe;1"].createInstance(Ci.nsIPipe);
+ pipe.init(false, false, 0, 0xffffffff, null);
+ objectOutStream.setOutputStream(pipe.outputStream);
+ objectOutStream.writeCompoundObject(uri, Ci.nsISupports, true);
+ objectOutStream.close();
+
+ var objectInStream = Cc["@mozilla.org/binaryinputstream;1"].
+ createInstance(Ci.nsIObjectInputStream);
+ objectInStream.setInputStream(pipe.inputStream);
+ return objectInStream.readObject(true).QueryInterface(Ci.nsIURI);
+}
+
+var prefData =
+ [
+ {
+ name: "network.IDN_show_punycode",
+ newVal: false
+ },
+ {
+ name: "network.IDN.whitelist.ch",
+ newVal: true
+ }
+ ];
+
+function run_test() {
+ var ios = Cc["@mozilla.org/network/io-service;1"].
+ getService(Ci.nsIIOService);
+
+ var uri1 = ios.newURI("file:///", null, null);
+ do_check_true(uri1 instanceof Ci.nsIFileURL);
+
+ var uri2 = uri1.clone();
+ do_check_true(uri2 instanceof Ci.nsIFileURL);
+ do_check_true(uri1.equals(uri2));
+
+ var uri3 = round_trip(uri1);
+ do_check_true(uri3 instanceof Ci.nsIFileURL);
+ do_check_true(uri1.equals(uri3));
+
+ // Make sure our prefs are set such that this test actually means something
+ var prefs = Cc["@mozilla.org/preferences-service;1"].
+ getService(Ci.nsIPrefBranch);
+ for (var pref of prefData) {
+ try {
+ pref.oldVal = prefs.getBoolPref(pref.name);
+ } catch(e) {
+ }
+ prefs.setBoolPref(pref.name, pref.newVal);
+ }
+
+ try {
+ // URI stolen from
+ // http://lists.w3.org/Archives/Public/public-iri/2004Mar/0012.html
+ var uri4 = ios.newURI("http://xn--jos-dma.example.net.ch/", null, null);
+ do_check_eq(uri4.asciiHost, "xn--jos-dma.example.net.ch");
+ do_check_eq(uri4.host, "jos\u00e9.example.net.ch");
+
+ var uri5 = round_trip(uri4);
+ do_check_true(uri4.equals(uri5));
+ do_check_eq(uri4.host, uri5.host);
+ do_check_eq(uri4.asciiHost, uri5.asciiHost);
+ } finally {
+ for (var pref of prefData) {
+ if (prefs.prefHasUserValue(pref.name))
+ prefs.clearUserPref(pref.name);
+ }
+ }
+}