1
Description: Fix test_json_cache.js to work when search plugins aren't installed
2
in to the application searchplugin directory
3
Author: Chris Coulson <chris.coulson@canonical.com>
6
Index: firefox-trunk-24.0~a1~hg20130623r136205/mozilla/toolkit/components/search/tests/xpcshell/test_json_cache.js
7
===================================================================
8
--- firefox-trunk-24.0~a1~hg20130623r136205.orig/mozilla/toolkit/components/search/tests/xpcshell/test_json_cache.js 2013-06-24 03:18:15.000000000 +0100
9
+++ firefox-trunk-24.0~a1~hg20130623r136205/mozilla/toolkit/components/search/tests/xpcshell/test_json_cache.js 2013-06-26 10:15:15.605897301 +0100
11
return _dirSvc.get(aKey, aIFace || Ci.nsIFile);
14
-let cacheTemplate, appPluginsPath, profPlugins;
15
+let cacheTemplate, appPluginsPaths, profPlugins;
18
* Test reading from search.json
20
let engineTemplateFile = do_get_file("data/engine.xml");
21
engineTemplateFile.copyTo(engineFile.parent, "test-search-engine.xml");
23
- // Add the app's searchplugins directory to the cache so it won't be ignored.
24
- let appSearchPlugins = getDir(NS_APP_SEARCH_DIR);
25
- appPluginsPath = appSearchPlugins.path;
26
- cacheTemplate.directories[appPluginsPath] = {};
27
- cacheTemplate.directories[appPluginsPath].lastModifiedTime = appSearchPlugins.lastModifiedTime;
28
- cacheTemplate.directories[appPluginsPath].engines = [];
29
+ // Add the app's searchplugins directoresy to the cache so they won't be ignored.
30
+ appPluginsPaths = [];
31
+ let searchPluginsDirList = getDir(NS_APP_SEARCH_DIR_LIST, Ci.nsISimpleEnumerator);
32
+ while (searchPluginsDirList.hasMoreElements()) {
33
+ let d = searchPluginsDirList.getNext().QueryInterface(Ci.nsIFile);
34
+ if (d.path != engineFile.parent.path && d.directoryEntries.hasMoreElements()) {
36
+ appPluginsPaths.push(path);
37
+ cacheTemplate.directories[path] = {};
38
+ cacheTemplate.directories[path].lastModifiedTime = d.lastModifiedTime;
39
+ cacheTemplate.directories[path].engines = [];
43
// Replace the profile placeholder with the correct path.
44
profPlugins = engineFile.parent.path;
46
// Check that the search.json cache matches the template
48
let cacheWritten = readJSONFile(cache);
49
- // Delete the app search plugins directory from the template since it's not currently written out.
50
- delete cacheTemplate.directories[appPluginsPath];
51
+ // Delete the app search plugins directories from the template since they're not currently written out.
52
+ for each (let path in appPluginsPaths) {
53
+ delete cacheTemplate.directories[path];
56
do_print("Check search.json");
57
isSubObjectOf(cacheTemplate, cacheWritten);
58
Index: firefox-trunk-24.0~a1~hg20130623r136205/mozilla/toolkit/components/search/tests/xpcshell/head_search.js
59
===================================================================
60
--- firefox-trunk-24.0~a1~hg20130623r136205.orig/mozilla/toolkit/components/search/tests/xpcshell/head_search.js 2013-06-24 03:18:14.000000000 +0100
61
+++ firefox-trunk-24.0~a1~hg20130623r136205/mozilla/toolkit/components/search/tests/xpcshell/head_search.js 2013-06-26 10:17:17.269899256 +0100
64
const BROWSER_SEARCH_PREF = "browser.search.";
65
const NS_APP_SEARCH_DIR = "SrchPlugns";
66
+const NS_APP_SEARCH_DIR_LIST = "SrchPluginsDL";
68
const MODE_RDONLY = FileUtils.MODE_RDONLY;
69
const MODE_WRONLY = FileUtils.MODE_WRONLY;
71
// Need to create and register a profile folder.
72
var gProfD = do_get_profile();
74
+// We register this to make the browser directory provider work
75
+// correctly for NS_APP_SEARCH_DIR_LIST. This is necessary when
76
+// the default plugins are in distribution/searchplugins rather
77
+// than the application directory
78
+Services.dirsvc.registerProvider({
79
+ QueryInterface: function(iid) {
80
+ if (iid.equals(Ci.nsISupports) ||
81
+ iid.equals(Ci.nsIDirectoryServiceProvider2) ||
82
+ iid.equals(Ci.nsIDirectoryServiceProvider)) {
86
+ throw Cr.NS_ERROR_NO_INTERFACE;
89
+ getFiles: function(prop) {
90
+ if (prop == "XREExtDL") {
92
+ QueryInterface: function(iid) {
93
+ if (iid.equals(Ci.nsISupports) ||
94
+ iid.equals(Ci.nsISimpleEnumerator)) {
98
+ throw Cr.NS_ERROR_NO_INTERFACE;
101
+ hasMoreElements: function() { return false; },
102
+ getNext: function() { throw Cr.NS_ERROR_FAILURE; }
110
dump("search test: " + text + "\n");