Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | // Start by getting an empty directory. |
michael@0 | 6 | var dir = do_get_profile(); |
michael@0 | 7 | dir.append("temp"); |
michael@0 | 8 | dir.create(dir.DIRECTORY_TYPE, -1); |
michael@0 | 9 | var path = dir.path + "/"; |
michael@0 | 10 | |
michael@0 | 11 | // Now create some sample entries. |
michael@0 | 12 | var file = dir.clone(); |
michael@0 | 13 | file.append("test_file"); |
michael@0 | 14 | file.create(file.NORMAL_FILE_TYPE, -1); |
michael@0 | 15 | file = dir.clone(); |
michael@0 | 16 | file.append("other_file"); |
michael@0 | 17 | file.create(file.NORMAL_FILE_TYPE, -1); |
michael@0 | 18 | dir.append("test_dir"); |
michael@0 | 19 | dir.create(dir.DIRECTORY_TYPE, -1); |
michael@0 | 20 | |
michael@0 | 21 | var gListener = { |
michael@0 | 22 | onSearchResult: function(aSearch, aResult) { |
michael@0 | 23 | // Check that we got same search string back. |
michael@0 | 24 | do_check_eq(aResult.searchString, "test"); |
michael@0 | 25 | // Check that the search succeeded. |
michael@0 | 26 | do_check_eq(aResult.searchResult, aResult.RESULT_SUCCESS); |
michael@0 | 27 | // Check that we got two results. |
michael@0 | 28 | do_check_eq(aResult.matchCount, 2); |
michael@0 | 29 | // Check that the first result is the directory we created. |
michael@0 | 30 | do_check_eq(aResult.getValueAt(0), "test_dir"); |
michael@0 | 31 | // Check that the first result has directory style. |
michael@0 | 32 | do_check_eq(aResult.getStyleAt(0), "directory"); |
michael@0 | 33 | // Check that the second result is the file we created. |
michael@0 | 34 | do_check_eq(aResult.getValueAt(1), "test_file"); |
michael@0 | 35 | // Check that the second result has file style. |
michael@0 | 36 | do_check_eq(aResult.getStyleAt(1), "file"); |
michael@0 | 37 | } |
michael@0 | 38 | }; |
michael@0 | 39 | |
michael@0 | 40 | function run_test() |
michael@0 | 41 | { |
michael@0 | 42 | Components.classes["@mozilla.org/autocomplete/search;1?name=file"] |
michael@0 | 43 | .getService(Components.interfaces.nsIAutoCompleteSearch) |
michael@0 | 44 | .startSearch("test", path, null, gListener); |
michael@0 | 45 | } |