chrome/test/unit/test_bug415367.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 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
michael@0 4 */
michael@0 5
michael@0 6 var gIOS = Cc["@mozilla.org/network/io-service;1"]
michael@0 7 .getService(Ci.nsIIOService);
michael@0 8
michael@0 9 function test_uri(obj)
michael@0 10 {
michael@0 11 var uri = null;
michael@0 12 var failed = false;
michael@0 13 var message = "";
michael@0 14 try {
michael@0 15 uri = gIOS.newURI(obj.uri, null, null);
michael@0 16 if (!obj.result) {
michael@0 17 failed = true;
michael@0 18 message = obj.uri + " should not be accepted as a valid URI";
michael@0 19 }
michael@0 20 }
michael@0 21 catch (ex) {
michael@0 22 if (obj.result) {
michael@0 23 failed = true;
michael@0 24 message = obj.uri + " should be accepted as a valid URI";
michael@0 25 }
michael@0 26 }
michael@0 27 if (failed)
michael@0 28 do_throw(message);
michael@0 29 if (obj.result) {
michael@0 30 do_check_true(uri != null);
michael@0 31 do_check_eq(uri.spec, obj.uri);
michael@0 32 }
michael@0 33 }
michael@0 34
michael@0 35 function run_test()
michael@0 36 {
michael@0 37 var tests = [
michael@0 38 {uri: "chrome://blah/content/blah.xul", result: true},
michael@0 39 {uri: "chrome://blah/content/:/blah/blah.xul", result: false},
michael@0 40 {uri: "chrome://blah/content/%252e./blah/blah.xul", result: false},
michael@0 41 {uri: "chrome://blah/content/%252e%252e/blah/blah.xul", result: false},
michael@0 42 {uri: "chrome://blah/content/blah.xul?param=%252e./blah/", result: true},
michael@0 43 {uri: "chrome://blah/content/blah.xul?param=:/blah/", result: true},
michael@0 44 {uri: "chrome://blah/content/blah.xul?param=%252e%252e/blah/", result: true},
michael@0 45 ];
michael@0 46 for (var i = 0; i < tests.length; ++ i)
michael@0 47 test_uri(tests[i]);
michael@0 48 }

mercurial