1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/modules/libjar/test/unit/test_bug597702.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,33 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +const Cc = Components.classes; 1.9 +const Ci = Components.interfaces; 1.10 + 1.11 +// Check that reading non existant inner jars results in the right error 1.12 + 1.13 +function run_test() { 1.14 + var file = do_get_file("data/test_bug597702.zip"); 1.15 + var ios = Cc["@mozilla.org/network/io-service;1"]. 1.16 + getService(Ci.nsIIOService); 1.17 + var outerJarBase = "jar:" + ios.newFileURI(file).spec + "!/"; 1.18 + var goodSpec = "jar:" + outerJarBase + "inner.jar!/hello"; 1.19 + var badSpec = "jar:" + outerJarBase + "jar_that_isnt_in_the.jar!/hello"; 1.20 + var goodChannel = ios.newChannel(goodSpec, null, null); 1.21 + var badChannel = ios.newChannel(badSpec, null, null); 1.22 + 1.23 + try { 1.24 + instr = goodChannel.open(); 1.25 + } catch (e) { 1.26 + do_throw("Failed to open file in inner jar"); 1.27 + } 1.28 + 1.29 + try { 1.30 + instr = badChannel.open(); 1.31 + do_throw("Failed to report that file doesn't exist"); 1.32 + } catch (e) { 1.33 + do_check_true(e.name == "NS_ERROR_FILE_NOT_FOUND"); 1.34 + } 1.35 +} 1.36 +