modules/libjar/test/unit/test_bug278262.js

Fri, 16 Jan 2015 04:50:19 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 04:50:19 +0100
branch
TOR_BUG_9701
changeset 13
44a2da4a2ab2
permissions
-rw-r--r--

Replace accessor implementation with direct member state manipulation, by
request https://trac.torproject.org/projects/tor/ticket/9701#comment:32

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