var appDir = new PROT_ApplicationDirectory(); var file = appDir.getAppDirFileInterface(); 
var file = Cc["@mozilla.org/file/directory_service;1"] .getService(Ci.nsIProperties) .get("ProfD", Ci.nsILocalFile); /* profile directory */ 
function TEST_PROT_UrlCryptoKeyManager() {  if (G_GDEBUG) {    var z = "urlcryptokeymanager UNITTEST";    G_debugService.enableZone(z);    G_Debug(z, "Starting");    // Let's not clobber any real keyfile out there    var kf = "keytest.txt";    // Let's be able to clean up after ourselves    function removeTestFile(f) {      var appDir = new PROT_ApplicationDirectory();      var file = appDir.getAppDirFileInterface();      file.append(f);      if (file.exists())        file.remove(false /* do not recurse */);    };    removeTestFile(kf);    var km = new PROT_UrlCryptoKeyManager(kf, true /* testing */);    // CASE: simulate nothing on disk, then get something from server    G_Assert(z, !km.hasKey_(), "KM already has key?");    km.maybeLoadOldKey();    G_Assert(z, !km.hasKey_(), "KM loaded non-existent key?");    km.onGetKeyResponse(null);    G_Assert(z, !km.hasKey_(), "KM got key from null response?");    km.onGetKeyResponse("");    G_Assert(z, !km.hasKey_(), "KM got key from empty response?");    km.onGetKeyResponse("aslkaslkdf:34:a230\nskdjfaljsie");    G_Assert(z, !km.hasKey_(), "KM got key from garbage response?");        var realResponse = "clientkey:24:zGbaDbx1pxoYe7siZYi8VA==\n" +                       "wrappedkey:24:MTr1oDt6TSOFQDTvKCWz9PEn";    km.onGetKeyResponse(realResponse);    // Will have written it to file as a side effect    G_Assert(z, km.hasKey_(), "KM couldn't get key from real response?");    G_Assert(z, km.clientKey_ == "zGbaDbx1pxoYe7siZYi8VA==",              "Parsed wrong client key from response?");    G_Assert(z, km.wrappedKey_ == "MTr1oDt6TSOFQDTvKCWz9PEn",              "Parsed wrong wrapped key from response?");    // CASE: simulate something on disk, then get something from server        km = new PROT_UrlCryptoKeyManager(kf, true /* testing */);    G_Assert(z, !km.hasKey_(), "KM already has key?");    km.maybeLoadOldKey();    G_Assert(z, km.hasKey_(), "KM couldn't load existing key from disk?");    G_Assert(z, km.clientKey_ == "zGbaDbx1pxoYe7siZYi8VA==",              "Parsed wrong client key from disk?");    G_Assert(z, km.wrappedKey_ == "MTr1oDt6TSOFQDTvKCWz9PEn",              "Parsed wrong wrapped key from disk?");    var realResponse2 = "clientkey:24:dtmbEN1kgN/LmuEoYifaFw==\n" +                        "wrappedkey:24:MTpPH3pnLDKihecOci+0W5dk";    km.onGetKeyResponse(realResponse2);    // Will have written it to disk    G_Assert(z, km.hasKey_(), "KM couldn't replace key from server response?");    G_Assert(z, km.clientKey_ == "dtmbEN1kgN/LmuEoYifaFw==",             "Replace client key from server failed?");    G_Assert(z, km.wrappedKey_ == "MTpPH3pnLDKihecOci+0W5dk",              "Replace wrapped key from server failed?");    // CASE: check overwriting a key on disk    km = new PROT_UrlCryptoKeyManager(kf, true /* testing */);    G_Assert(z, !km.hasKey_(), "KM already has key?");    km.maybeLoadOldKey();    G_Assert(z, km.hasKey_(), "KM couldn't load existing key from disk?");    G_Assert(z, km.clientKey_ == "dtmbEN1kgN/LmuEoYifaFw==",             "Replace client on from disk failed?");    G_Assert(z, km.wrappedKey_ == "MTpPH3pnLDKihecOci+0W5dk",              "Replace wrapped key on disk failed?");    // Test that we only fetch at most two getkey's per lifetime of the manager    km = new PROT_UrlCryptoKeyManager(kf, true /* testing */);    km.reKey();    for (var i = 0; i < km.MAX_REKEY_TRIES; i++)      G_Assert(z, km.maybeReKey(), "Couldn't rekey?");    G_Assert(z, !km.maybeReKey(), "Rekeyed when max hit");        removeTestFile(kf);    G_Debug(z, "PASSED");    }}
5459	/local1/tlutelli/issta_data/temp/all_js/javascript/2007_temp/2007/5459/7e1e7f7fdea29fefb52eae966515f3ed1240c8ca/url-crypto-key-manager.js/clean/toolkit/components/url-classifier/content/url-crypto-key-manager.js