1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/netwerk/test/unit/test_bug337744.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,34 @@ 1.4 +/* verify that certain invalid URIs are not parsed by the resource 1.5 + protocol handler */ 1.6 + 1.7 +const specs = [ 1.8 + "resource:////", 1.9 + "resource:///http://www.mozilla.org/", 1.10 + "resource:///file:///", 1.11 + "resource:///..\\", 1.12 + "resource:///..\\..\\", 1.13 + "resource:///..%5C", 1.14 + "resource:///..%5c" 1.15 +]; 1.16 + 1.17 +function check_for_exception(spec) 1.18 +{ 1.19 + var ios = 1.20 + Cc["@mozilla.org/network/io-service;1"]. 1.21 + getService(Ci.nsIIOService); 1.22 + 1.23 + try { 1.24 + var channel = ios.newChannel(spec, null, null); 1.25 + } 1.26 + catch (e) { 1.27 + return; 1.28 + } 1.29 + 1.30 + do_throw("Successfully opened invalid URI: '" + spec + "'"); 1.31 +} 1.32 + 1.33 +function run_test() { 1.34 + for each (spec in specs) { 1.35 + check_for_exception(spec); 1.36 + } 1.37 +}