tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_bug415367.js (1381B)


      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 */
      5 
      6 function test_uri(obj) {
      7  var uri = null;
      8  var failed = false;
      9  var message = "";
     10  try {
     11    uri = Services.io.newURI(obj.uri);
     12    if (!obj.result) {
     13      failed = true;
     14      message = obj.uri + " should not be accepted as a valid URI";
     15    }
     16  } catch (ex) {
     17    if (obj.result) {
     18      failed = true;
     19      message = obj.uri + " should be accepted as a valid URI";
     20    }
     21  }
     22  if (failed) {
     23    do_throw(message);
     24  }
     25  if (obj.result) {
     26    Assert.notEqual(uri, null);
     27    Assert.equal(uri.spec, obj.uri);
     28  }
     29 }
     30 
     31 function run_test() {
     32  var tests = [
     33    { uri: "chrome://blah/content/blah.xul", result: true },
     34    { uri: "chrome://blah/content/:/blah/blah.xul", result: true },
     35    { uri: "chrome://blah/content/%252e./blah/blah.xul", result: true },
     36    { uri: "chrome://blah/content/%252e%252e/blah/blah.xul", result: true },
     37    { uri: "chrome://blah/content/blah.xul?param=%252e./blah/", result: true },
     38    { uri: "chrome://blah/content/blah.xul?param=:/blah/", result: true },
     39    {
     40      uri: "chrome://blah/content/blah.xul?param=%252e%252e/blah/",
     41      result: true,
     42    },
     43  ];
     44  for (var i = 0; i < tests.length; ++i) {
     45    test_uri(tests[i]);
     46  }
     47 }