toolkit/components/search/tests/xpcshell/test_invalid_engine_from_dir.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.

michael@0 1 /* Any copyright is dedicated to the Public Domain.
michael@0 2 http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 3
michael@0 4 const Ci = Components.interfaces;
michael@0 5
michael@0 6 /*
michael@0 7 * Test that invalid engine files with xml extensions will not break
michael@0 8 * initialization. See Bug 940446.
michael@0 9 */
michael@0 10 function run_test() {
michael@0 11 do_test_pending();
michael@0 12
michael@0 13 removeMetadata();
michael@0 14 removeCacheFile();
michael@0 15
michael@0 16 do_check_false(Services.search.isInitialized);
michael@0 17
michael@0 18 let engineFile = gProfD.clone();
michael@0 19 engineFile.append("searchplugins");
michael@0 20 engineFile.append("test-search-engine.xml");
michael@0 21 engineFile.parent.create(Ci.nsIFile.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY);
michael@0 22
michael@0 23 // Copy the invalid engine to the test profile.
michael@0 24 let engineTemplateFile = do_get_file("data/invalid-engine.xml");
michael@0 25 engineTemplateFile.copyTo(engineFile.parent, "test-search-engine.xml");
michael@0 26
michael@0 27 Services.search.init(function search_initialized(aStatus) {
michael@0 28 // The invalid engine should have been skipped and should not
michael@0 29 // have caused an exception.
michael@0 30 do_check_true(Components.isSuccessCode(aStatus));
michael@0 31 do_check_true(Services.search.isInitialized);
michael@0 32
michael@0 33 removeMetadata();
michael@0 34 removeCacheFile();
michael@0 35 do_test_finished();
michael@0 36 });
michael@0 37 }

mercurial