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.

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

mercurial