modules/libjar/test/unit/test_bug278262.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 // Regression test for bug 278262 - JAR URIs should resolve relative URIs in the base section.
michael@0 2
michael@0 3 const Cc = Components.classes;
michael@0 4 const Ci = Components.interfaces;
michael@0 5 const path = "data/test_bug333423.zip";
michael@0 6
michael@0 7 function test_relative_sub() {
michael@0 8 var ios = Cc["@mozilla.org/network/io-service;1"].
michael@0 9 getService(Ci.nsIIOService);
michael@0 10
michael@0 11 var spec = "jar:" + ios.newFileURI(do_get_file(path)).spec + "!/";
michael@0 12 var base = ios.newURI(spec, null, null);
michael@0 13 var uri = ios.newURI("../modules/libjar", null, base);
michael@0 14
michael@0 15 // This is the URI we expect to see.
michael@0 16 var expected = "jar:" + ios.newFileURI(do_get_file(path)).spec +
michael@0 17 "!/modules/libjar";
michael@0 18
michael@0 19 do_check_eq(uri.spec, expected);
michael@0 20 }
michael@0 21
michael@0 22 function test_relative_base() {
michael@0 23 var ios = Cc["@mozilla.org/network/io-service;1"].
michael@0 24 getService(Ci.nsIIOService);
michael@0 25
michael@0 26 var base = ios.newFileURI(do_get_file("data/empty"));
michael@0 27 var uri = ios.newURI("jar:../" + path + "!/", null, base);
michael@0 28
michael@0 29 // This is the URI we expect to see.
michael@0 30 var expected = "jar:" + ios.newFileURI(do_get_file(path)).spec +
michael@0 31 "!/";
michael@0 32
michael@0 33 do_check_eq(uri.spec, expected);
michael@0 34 }
michael@0 35
michael@0 36 function run_test() {
michael@0 37 test_relative_sub();
michael@0 38 test_relative_base();
michael@0 39 }

mercurial