Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
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 | } |