~mozillateam/thunderbird/thunderbird-beta.eoan

« back to all changes in this revision

Viewing changes to debian/patches/test-fixes/xpcshell-search-fix-tests-when-plugins-are-not-in-appdir.patch

  • Committer: Olivier Tilloy
  • Date: 2019-08-14 15:30:38 UTC
  • mfrom: (348.1.122 thunderbird.disco)
  • Revision ID: olivier.tilloy@canonical.com-20190814153038-cd7zq0ljnrddpgfx
Merge back changes from the thunderbird.disco stable branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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>
4
 
Forwarded: no
5
 
 
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
10
 
@@ -31,7 +31,7 @@
11
 
   return _dirSvc.get(aKey, aIFace || Ci.nsIFile);
12
 
 }
13
 
 
14
 
-let cacheTemplate, appPluginsPath, profPlugins;
15
 
+let cacheTemplate, appPluginsPaths, profPlugins;
16
 
 
17
 
 /**
18
 
  * Test reading from search.json
19
 
@@ -54,12 +54,19 @@
20
 
   let engineTemplateFile = do_get_file("data/engine.xml");
21
 
   engineTemplateFile.copyTo(engineFile.parent, "test-search-engine.xml");
22
 
 
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()) {
35
 
+      let path = d.path;
36
 
+      appPluginsPaths.push(path);
37
 
+      cacheTemplate.directories[path] = {};
38
 
+      cacheTemplate.directories[path].lastModifiedTime = d.lastModifiedTime;
39
 
+      cacheTemplate.directories[path].engines = [];
40
 
+    }
41
 
+  }
42
 
 
43
 
   // Replace the profile placeholder with the correct path.
44
 
   profPlugins = engineFile.parent.path;
45
 
@@ -163,8 +170,10 @@
46
 
         // Check that the search.json cache matches the template
47
 
 
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];
54
 
+        }
55
 
 
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
62
 
@@ -10,6 +10,7 @@
63
 
 
64
 
 const BROWSER_SEARCH_PREF = "browser.search.";
65
 
 const NS_APP_SEARCH_DIR = "SrchPlugns";
66
 
+const NS_APP_SEARCH_DIR_LIST = "SrchPluginsDL";
67
 
 
68
 
 const MODE_RDONLY = FileUtils.MODE_RDONLY;
69
 
 const MODE_WRONLY = FileUtils.MODE_WRONLY;
70
 
@@ -19,6 +20,40 @@
71
 
 // Need to create and register a profile folder.
72
 
 var gProfD = do_get_profile();
73
 
 
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)) {
83
 
+      return this;
84
 
+    }
85
 
+
86
 
+    throw Cr.NS_ERROR_NO_INTERFACE;
87
 
+  },
88
 
+
89
 
+  getFiles: function(prop) {
90
 
+    if (prop == "XREExtDL") {
91
 
+      return {
92
 
+        QueryInterface: function(iid) {
93
 
+          if (iid.equals(Ci.nsISupports) ||
94
 
+              iid.equals(Ci.nsISimpleEnumerator)) {
95
 
+            return this;
96
 
+          }
97
 
+
98
 
+          throw Cr.NS_ERROR_NO_INTERFACE;
99
 
+        },
100
 
+
101
 
+        hasMoreElements: function() { return false; },
102
 
+        getNext: function() { throw Cr.NS_ERROR_FAILURE; }
103
 
+      };
104
 
+    }
105
 
+  }
106
 
+});
107
 
+
108
 
 function dumpn(text)
109
 
 {
110
 
   dump("search test: " + text + "\n");