toolkit/components/search/tests/xpcshell/test_invalid_engine_from_dir.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/components/search/tests/xpcshell/test_invalid_engine_from_dir.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,37 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 +   http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +const Ci = Components.interfaces;
     1.8 +
     1.9 +/*
    1.10 + * Test that invalid engine files with xml extensions will not break
    1.11 + * initialization. See Bug 940446.
    1.12 + */
    1.13 +function run_test() {
    1.14 +  do_test_pending();
    1.15 +
    1.16 +  removeMetadata();
    1.17 +  removeCacheFile();
    1.18 +
    1.19 +  do_check_false(Services.search.isInitialized);
    1.20 +
    1.21 +  let engineFile = gProfD.clone();
    1.22 +  engineFile.append("searchplugins");
    1.23 +  engineFile.append("test-search-engine.xml");
    1.24 +  engineFile.parent.create(Ci.nsIFile.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY);
    1.25 +
    1.26 +  // Copy the invalid engine to the test profile.
    1.27 +  let engineTemplateFile = do_get_file("data/invalid-engine.xml");
    1.28 +  engineTemplateFile.copyTo(engineFile.parent, "test-search-engine.xml");
    1.29 +
    1.30 +  Services.search.init(function search_initialized(aStatus) {
    1.31 +    // The invalid engine should have been skipped and should not
    1.32 +    // have caused an exception.
    1.33 +    do_check_true(Components.isSuccessCode(aStatus));
    1.34 +    do_check_true(Services.search.isInitialized);
    1.35 +
    1.36 +    removeMetadata();
    1.37 +    removeCacheFile();
    1.38 +    do_test_finished();
    1.39 +  });
    1.40 +}

mercurial