toolkit/components/filepicker/test/unit/test_filecomplete.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

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 }

mercurial