chrome/test/unit/test_bug415367.js

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     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