1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/chrome/test/unit/test_bug415367.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,48 @@ 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 + 1.9 +var gIOS = Cc["@mozilla.org/network/io-service;1"] 1.10 + .getService(Ci.nsIIOService); 1.11 + 1.12 +function test_uri(obj) 1.13 +{ 1.14 + var uri = null; 1.15 + var failed = false; 1.16 + var message = ""; 1.17 + try { 1.18 + uri = gIOS.newURI(obj.uri, null, null); 1.19 + if (!obj.result) { 1.20 + failed = true; 1.21 + message = obj.uri + " should not be accepted as a valid URI"; 1.22 + } 1.23 + } 1.24 + catch (ex) { 1.25 + if (obj.result) { 1.26 + failed = true; 1.27 + message = obj.uri + " should be accepted as a valid URI"; 1.28 + } 1.29 + } 1.30 + if (failed) 1.31 + do_throw(message); 1.32 + if (obj.result) { 1.33 + do_check_true(uri != null); 1.34 + do_check_eq(uri.spec, obj.uri); 1.35 + } 1.36 +} 1.37 + 1.38 +function run_test() 1.39 +{ 1.40 + var tests = [ 1.41 + {uri: "chrome://blah/content/blah.xul", result: true}, 1.42 + {uri: "chrome://blah/content/:/blah/blah.xul", result: false}, 1.43 + {uri: "chrome://blah/content/%252e./blah/blah.xul", result: false}, 1.44 + {uri: "chrome://blah/content/%252e%252e/blah/blah.xul", result: false}, 1.45 + {uri: "chrome://blah/content/blah.xul?param=%252e./blah/", result: true}, 1.46 + {uri: "chrome://blah/content/blah.xul?param=:/blah/", result: true}, 1.47 + {uri: "chrome://blah/content/blah.xul?param=%252e%252e/blah/", result: true}, 1.48 + ]; 1.49 + for (var i = 0; i < tests.length; ++ i) 1.50 + test_uri(tests[i]); 1.51 +}