toolkit/components/search/tests/xpcshell/test_identifiers.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 /* Any copyright is dedicated to the Public Domain.
     2  *    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 /*
     5  * Test that a search engine's identifier can be extracted from the filename.
     6  */
     8 "use strict";
    10 const Ci = Components.interfaces;
    11 const SEARCH_APP_DIR = 1;
    13 function run_test() {
    14   removeMetadata();
    15   removeCacheFile();
    16   do_load_manifest("data/chrome.manifest");
    18   let url  = "chrome://testsearchplugin/locale/searchplugins/";
    19   Services.prefs.setCharPref("browser.search.jarURIs", url);
    20   Services.prefs.setBoolPref("browser.search.loadFromJars", true);
    22   updateAppInfo();
    24   run_next_test();
    25 }
    27 add_test(function test_identifier() {
    28   let engineFile = gProfD.clone();
    29   engineFile.append("searchplugins");
    30   engineFile.append("test-search-engine.xml");
    31   engineFile.parent.create(Ci.nsIFile.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY);
    33   // Copy the test engine to the test profile.
    34   let engineTemplateFile = do_get_file("data/engine.xml");
    35   engineTemplateFile.copyTo(engineFile.parent, "test-search-engine.xml");
    37   let search = Services.search.init(function initComplete(aResult) {
    38     do_print("init'd search service");
    39     do_check_true(Components.isSuccessCode(aResult));
    41     let profileEngine = Services.search.getEngineByName("Test search engine");
    42     let jarEngine = Services.search.getEngineByName("bug645970");
    44     do_check_true(profileEngine instanceof Ci.nsISearchEngine);
    45     do_check_true(jarEngine instanceof Ci.nsISearchEngine);
    47     // An engine loaded from the profile directory won't have an identifier,
    48     // because it's not built-in.
    49     do_check_eq(profileEngine.identifier, null);
    51     // An engine loaded from a JAR will have an identifier corresponding to
    52     // the filename inside the JAR. (In this case it's the same as the name.)
    53     do_check_eq(jarEngine.identifier, "bug645970");
    55     removeMetadata();
    56     removeCacheFile();
    57     run_next_test();
    58   });
    59 });

mercurial