tor-browser

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

storage_functions_not_overwritten.window.js (1409B)


      1 ["localStorage", "sessionStorage"].forEach(function(name) {
      2    test(function() {
      3        var storage = window[name];
      4        storage.clear();
      5 
      6        runTest();
      7        function doWedgeThySelf() {
      8            storage.setItem("clear", "almost");
      9            storage.setItem("key", "too");
     10            storage.setItem("getItem", "funny");
     11            storage.setItem("removeItem", "to");
     12            storage.setItem("length", "be");
     13            storage.setItem("setItem", "true");
     14        }
     15 
     16        function runTest() {
     17            doWedgeThySelf();
     18 
     19            assert_equals(storage.getItem('clear'), "almost");
     20            assert_equals(storage.getItem('key'), "too");
     21            assert_equals(storage.getItem('getItem'), "funny");
     22            assert_equals(storage.getItem('removeItem'), "to");
     23            assert_equals(storage.getItem('length'), "be");
     24            assert_equals(storage.getItem('setItem'), "true");
     25 
     26            // Test to see if an exception is thrown for any of the built in
     27            // functions.
     28            storage.setItem("test", "123");
     29            storage.key(0);
     30            storage.getItem("test");
     31            storage.removeItem("test");
     32            storage.clear();
     33            assert_equals(storage.length, 0);
     34        }
     35 
     36    }, name + " should be not rendered unusable by setting a key with the same name as a storage function such that the function is hidden");
     37 });