~mozillateam/firefox/firefox.disco

« back to all changes in this revision

Viewing changes to debian/testing/xpcshell-package-tests/test_ubuntu_searchplugins_real.js

  • Committer: Chris Coulson
  • Date: 2013-02-20 09:17:36 UTC
  • mto: This revision was merged to the branch mainline in revision 972.
  • Revision ID: chris.coulson@canonical.com-20130220091736-ofjaczrz2wc4nidl
* New upstream release from the beta channel
* Refresh patches
  - update debian/patches/mozilla-kde.patch
* Drop patches fixed upstream
  - remove debian/patches/ionmonkey-hardfp-support.patch
  - update debian/patches/series.in
* firefox-gnome-support needs explicit dependency on libnotify
  - update debian/control{,.in}
* Add support for autopkgtest, package the xpcshell, reftest and
  mochitest testsuites and migrate the xpcshell-tests, reftest, crashtest,
  jstestbrowser and mochitest targets to this. Note that tests that can't
  be ran as an autopkgtest (eg, if they require write permissions to the
  application directory) will still be ran at build time
  - add firefox-testsuite package in debian/control.in
  - update debian/control
  - add debian/firefox-testsuite.install.in
  - add debian/firefox-testsuite.links.in
  - update debian/build/mozbuild.mk
  - update debian/rules
  - drop xpcshell-tests, reftest, crashtest, jstestbrowser and mochitest
    targets from debian/build/testsuite.mk, add xpcshell-tests-build
    and the ability to run xpcshell-tests with our own reduced manifest
  - add debian/tests/control
  - add debian/tests/crashtest
  - add debian/tests/jstestbrowser
  - add debian/tests/mochitest
  - add debian/tests/reftest
  - add debian/tests/xpcshell-tests
  - add debian/testing/run_mochitest.in
  - add debian/testing/run_xpcshell_tests.in
  - add debian/testing/run_reftest.in
  - add debian/testing/testrunhelper.py
  - update debian/config/mozconfig.in to always build with --enable-tests
  - add debian/testing/xpcshell-build.ini
* Ensure that the directory provider returns all searchplugin paths during
  the search service xpcshell tests
  - add d/p/test-fixes/xpcshell-search-fix-browser-dirprovider.patch
  - update debian/patches/series.in
* Fix various tests that assume that either the application directory or
  test directory can be written to
  - add d/p/test-fixes/xpcshell-docshell-no-writes-to-appdir.patch
  - add d/p/test-fixes/xpcshell-contentprefs-no-writes-to-appdir.patch
  - add d/p/test-fixes/xpcshell-exthandler-no-writes-to-appdir.patch
  - add d/p/test-fixes/xpcshell-ctypes-no-writes-to-appdir.patch
  - add d/p/test-fixes/xpcshell-xpcom-no-writes-to-testdir-or-appdir.patch
  - add d/p/test-fixes/xpcshell-libpref-no-writes-to-testdir.patch
  - update debian/patches/series.in
* Export NO_PNG_PKG_MANGLE as optipng breaks tests that are dependent
  on image format / size
  - update debian/build/mozbuild.mk
* Don't test that the addon selection dialog appears in test_bug596343.js,
  as we disable this
  - add d/p/test-integration/xpcshell-disable-addon-select-dialog-test-for-adt.patch
  - update debian/patches/series
* Don't write a log file to the script directory from mochitest
  - add d/p/test-integration/mochitest-optional-websock-log.patch
  - update debian/patches/series.in
* Fix a failure in test_nodb_pluschanges.js due to const redeclaration
  - add d/p/test-fixes/xpcshell-search-fix-const-redeclaration.patch
  - update debian/patches/series.in
* Don't run the GConf-specific test_421977.js on systems where GSettings
  is available, as it will fail
  - add d/p/t-f/xpcshell-shell-disable-gconf-tests-when-using-gsettings.patch
  - update debian/patches/series.in
* Disable test_upgrade.js and test_upgrade_strictcompat.js xpcshell tests
  for now as they require write access to the application directory
  - add d/p/test-integration/xpcshell-disable-tests-which-need-appdir-write-access.patch
  - update debian/patches/series.in
* Disable test_browserGlue_distribution.js for now as it requires write
  access to the application directory
  - update d/p/test-integration/xpcshell-disable-tests-which-need-appdir-write-access.patch
* Reset the "browser" and "embed-app" content prefs after running content
  mochitests, so that the subsequent DOM browser-element tests don't
  fail
  - add d/p/test-fixes/mochitest-content-reset-permissions-when-done.patch
  - update debian/patches/series.in
* Disable various failing mochitests:
  - add debian/testing/mochitest.json
  - add debian/testing/mochitest-chrome.json
  - update debian/firefox-testsuite.install.in
* Fix issue where some tests were being added to the mochitest tests.jar
  using their absolute path in the build tree
  - add debian/patches/test-fixes/mochitest-tests-jar-fix.patch
  - update debian/patches/series.in
* Don't run the GConf specific browser_420786.js mochitest on systems where
  GSettings is available, as it will fail
  - add d/p/t-f/mochitest-shell-disable-gconf-tests-when-using-gsettings.patch
  - update debian/patches/series.in
* Don't ship the browser_bug538331.js mochitest as this isn't relevant
  when not using the Mozilla AUS
  - add d/p/test-fixes/mochitest-dont-ship-browser-postupdate-test.patch
  - update debian/patches/series.in
* Make "--test-manifest" work when running chrome, browser-chrome and a11y
  mochitests so that we can maintain a distro manifest for these
  - add d/p/test-integration/mochitest-allow-test-manifest-for-chrome.patch
  - update debian/patches/series.in
* Disable failing reftests
  - add d/p/test-overrides/reftest-disable-failing-tests.patch
  - update debian/patches/series.in
* Add vendor xpcshell tests to verify that the search service loads
  the expected number of search plugins from each language pack
  - update debian/build/mozbuild.mk
  - add debian/firefox-testsuite.dirs.in
  - update debian/firefox-testsuite.install.in
  - update debian/rules
  - add debian/testing/xpcshell-package-tests/head_package_tests.js
  - add debian/testing/xpcshell-package-tests/test_searchplugins_valid.js
  - add debian/testing/xpcshell-package-tests/test_searchplugins_valid_real.js
  - add debian/testing/xpcshell-package-tests/xpcshell.ini
  - update debian/tests/control
  - add debian/tests/xpcshell-package-tests
* Drop the hacky perl scripts that were being used to make sure the language
  packs ship the correct plugins. Add a xpcshell test instead
  - update debian/build/mozbuild.mk
  - update debian/rules
  - remove debian/build/refresh-search-modifications.pl
  - remove debian/build/verify-search-overrides.pl
  - remove debian/config/search-mods.list
  - update debian/control.in
  - remove debian/searchplugins/compute-overrides.json
  - add debian/testing/xpcshell-package-tests/test_ubuntu_searchplugins.js
  - add debian/testing/xpcshell-package-tests/test_ubuntu_searchplugins_real.js
  - update debian/testing/xpcshell-package-tests/xpcshell.ini
* Fix a test failure with the Italian Amazon search plugin 
  - update debian/searchplugins/it/amazon-it.xml
* We set intl.locale.matchOS to ensure that Firefox uses the environment
  locale. Add a test to make sure this works as expected
  - add debian/testing/xpcshell-package-tests/test_locale_matchOS.js
  - add debian/testing/xpcshell-package-tests/test_locale_matchOS_real.js
  - update debian/testing/xpcshell-package-tests/head_package_tests.js
  - update debian/testing/xpcshell-package-tests/test_searchplugins_valid.js
  - update debian/testing/xpcshell-package-tests/test_ubuntu_searchplugins.js
  - update debian/testing/xpcshell-package-tests/xpcshell.ini
  - update debian/tests/control
  - update debian/tests/crashtest
  - update debian/tests/jstestbrowser
  - update debian/tests/mochitest
  - update debian/tests/reftest
  - update debian/tests/xpcshell-package-tests
  - update debian/tests/xpcshell-tests
* We modify the user agent, so test that it is correct
  - add debian/testing/xpcshell-package-tests/test_ubuntu_useragent.js
  - update debian/testing/xpcshell-package-tests/xpcshell.ini
* LP: #974146 - Add a "Open a New Private Window" action to the desktop file
  - update debian/firefox.desktop.in
* Don't try to override the Amazon searchplugin for Kashubian or Mongolian,
  as it doesn't exist there
  - add debian/searchplugins/csb/list.txt
  - add debian/searchplugins/mn/list.txt
  - update d/t/xpcshell-package-tests/test_ubuntu_searchplugins_real.js
* Testpilot only enabled on beta now
  - update debian/firefox.install.in
* Don't run dh_scour on the testsuite package, as this screws up a lot
  of reftests and crashtests
  - update debian/build/mozbuild.mk
* Add a test to make sure all of the language packs are loadable by the
  addon manager
  - add debian/testing/xpcshell-package-tests/test_langpack_load.js
  - update debian/testing/xpcshell-package-tests/xpcshell.ini
* Add a test to make sure language pack chrome is registered correctly
  - add debian/testing/xpcshell-package-tests/test_langpack_chrome.js
  - update debian/testing/xpcshell-package-tests/xpcshell.ini
* Disable failing xpcshell tests
  - add d/p/test-overrides/xpcshell-disable-failing-tests.patch
  - update debian/patches/series.in
* Add JUnit output support for reftests
  - add d/p/test-integration/reftest-output-junit-xml.patch
  - update debian/patches/series.in
  - update debian/testing/run_reftest.in
* Allow xpcshell tests to be run with JUnit outputting, and include a fix
  to make sure that the output matches the schema
  - update debian/testing/run_xpcshell_tests.in
  - add d/p/test-integration/xpcshell-output-valid-junit-xml.patch
  - update debian/patches/series.in
* Add JUnit output support for mochitests
  - add d/p/test-integration/mochitest-output-junit-xml.patch
  - update debian/patches/series.in
  - update debian/testing/run_mochitest.in
* Turn on JUnit XML output for all tests
  - update debian/build/mozbuild.mk
  - update debian/tests/crashtest
  - update debian/tests/jstestbrowser
  - update debian/tests/mochitest
  - update debian/tests/reftest
  - update debian/tests/xpcshell-package-tests
  - update debian/tests/xpcshell-tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
const TEST_MATRIX = {
 
2
//  Locale      Amazon?   Baidu?    DDG?    Google?
 
3
    "en-US":  [ true,     false,    true,   true ],
 
4
    "af":     [ true,     false,    true,   true ],
 
5
    "ar":     [ true,     false,    true,   true ],
 
6
    "as":     [ true,     false,    true,   true ],
 
7
    "ast":    [ false,    false,    true,   true ],
 
8
    "be":     [ false,    false,    true,   true ],
 
9
    "bg":     [ true,     false,    true,   true ],
 
10
    "bn-BD":  [ false,    false,    true,   true ],
 
11
    "bn-IN":  [ true,     false,    true,   true ],
 
12
    "br":     [ true,     false,    true,   true ],
 
13
    "bs":     [ false,    false,    true,   true ],
 
14
    "ca":     [ false,    false,    true,   true ],
 
15
    "cs":     [ false,    false,    true,   true ],
 
16
    "csb":    [ false,    false,    true,   true ],
 
17
    "cy":     [ true,     false,    true,   true ],
 
18
    "da":     [ true,     false,    true,   true ],
 
19
    "de":     [ true,     false,    true,   true ],
 
20
    "el":     [ true,     false,    true,   true ],
 
21
    "en-GB":  [ true,     false,    true,   true ],
 
22
    "en-ZA":  [ true,     false,    true,   true ],
 
23
    "eo":     [ true,     false,    true,   true ],
 
24
    "es-AR":  [ true,     false,    true,   true ],
 
25
    "es-CL":  [ false,    false,    true,   true ],
 
26
    "es-ES":  [ false,    false,    true,   true ],
 
27
    "es-MX":  [ false,    false,    true,   true ],
 
28
    "et":     [ false,    false,    true,   true ],
 
29
    "eu":     [ true,     false,    true,   true ],
 
30
    "fa":     [ true,     false,    true,   true ],
 
31
    "fi":     [ false,    false,    true,   true ],
 
32
    "fr":     [ true,     false,    true,   true ],
 
33
    "fy-NL":  [ false,    false,    true,   true ],
 
34
    "ga-IE":  [ true,     false,    true,   true ],
 
35
    "gd":     [ true,     false,    true,   true ],
 
36
    "gl":     [ true,     false,    true,   true ],
 
37
    "gu-IN":  [ false,    false,    true,   true ],
 
38
    "he":     [ false,    false,    true,   true ],
 
39
    "hi-IN":  [ false,    false,    true,   true ],
 
40
    "hr":     [ true,     false,    true,   true ],
 
41
    "hu":     [ false,    false,    true,   true ],
 
42
    "hy-AM":  [ true,     false,    true,   true ],
 
43
    "id":     [ false,    false,    true,   true ],
 
44
    "is":     [ true,     false,    true,   true ],
 
45
    "it":     [ true,     false,    true,   true ],
 
46
    "ja":     [ true,     false,    true,   true ],
 
47
    "kk":     [ false,    false,    true,   true ],
 
48
    "km":     [ true,     false,    true,   true ],
 
49
    "kn":     [ true,     false,    true,   true ],
 
50
    "ko":     [ false,    false,    true,   true ],
 
51
    "ku":     [ true,     false,    true,   true ],
 
52
    "lg":     [ true,     false,    true,   true ],
 
53
    "lt":     [ true,     false,    true,   true ],
 
54
    "lv":     [ false,    false,    true,   true ],
 
55
    "mai":    [ false,    false,    true,   true ],
 
56
    "mk":     [ true,     false,    true,   true ],
 
57
    "ml":     [ false,    false,    true,   true ],
 
58
    "mn":     [ false,    false,    true,   true ],
 
59
    "mr":     [ true,     false,    true,   true ],
 
60
    "nb-NO":  [ true,     false,    true,   true ],
 
61
    "nl":     [ false,    false,    true,   true ],
 
62
    "nn-NO":  [ true,     false,    true,   true ],
 
63
    "nso":    [ true,     false,    true,   true ],
 
64
    "or":     [ true,     false,    true,   true ],
 
65
    "pa-IN":  [ false,    false,    true,   true ],
 
66
    "pl":     [ false,    false,    true,   true ],
 
67
    "pt-BR":  [ false,    false,    true,   true ],
 
68
    "pt-PT":  [ true,     false,    true,   true ],
 
69
    "ro":     [ true,     false,    true,   true ],
 
70
    "ru":     [ false,    false,    true,   true ],
 
71
    "si":     [ true,     false,    true,   true ],
 
72
    "sk":     [ false,    false,    true,   true ],
 
73
    "sl":     [ false,    false,    true,   true ],
 
74
    "sq":     [ true,     false,    true,   true ],
 
75
    "sr":     [ true,     false,    true,   true ],
 
76
    "sv-SE":  [ false,    false,    true,   true ],
 
77
    "sw":     [ true,     false,    true,   true ],
 
78
    "ta":     [ false,    false,    true,   true ],
 
79
    "te":     [ true,     false,    true,   true ],
 
80
    "th":     [ true,     false,    true,   true ],
 
81
    "tr":     [ true,     false,    true,   true ],
 
82
    "uk":     [ false,    false,    true,   true ],
 
83
    "vi":     [ false,    false,    true,   true ],
 
84
    "zh-CN":  [ true,     true,     true,   true ],
 
85
    "zh-TW":  [ false,    false,    true,   true ],
 
86
    "zu":     [ true,     false,    true,   true ]
 
87
};
 
88
 
 
89
const PLUGIN_AMAZON = 0;
 
90
const PLUGIN_BAIDU = 1;
 
91
const PLUGIN_DDG = 2;
 
92
const PLUGIN_GOOGLE = 3;
 
93
 
 
94
if (Services.prefs.getCharPref("app.update.channel") == "nightly") {
 
95
  TEST_MATRIX["bs"][PLUGIN_AMAZON] = true;
 
96
}
 
97
 
 
98
function get_query_params(aURL)
 
99
{
 
100
  let params = {};
 
101
  aURL.query.split('&').forEach(function(query) {
 
102
    let parts = query.split('=');
 
103
    do_check_eq(parts.length, 2);
 
104
    params[parts[0]] = parts[1];
 
105
  });
 
106
 
 
107
  return params;
 
108
}
 
109
 
 
110
function test_baidu(aEngine)
 
111
{
 
112
  let url = aEngine.getSubmission("foo").uri.QueryInterface(Ci.nsIURL);
 
113
 
 
114
  // We ship the upstream plugin for this one
 
115
  if (url.host == "zhidao.baidu.com") {
 
116
    return false;
 
117
  }
 
118
 
 
119
  let params = get_query_params(url);
 
120
 
 
121
  let ubuntu = "tn" in params && params["tn"] == "ubuntuu_cb" && "cl" in params && params["cl"] == 3;
 
122
 
 
123
  // We only expect to see our Baidu searchplugin
 
124
  do_check_true(ubuntu);
 
125
 
 
126
  return ubuntu;
 
127
}
 
128
 
 
129
function test_duckduckgo(aEngine)
 
130
{
 
131
  let url = aEngine.getSubmission("foo").uri.QueryInterface(Ci.nsIURL);
 
132
 
 
133
  let params = get_query_params(url);
 
134
  let ubuntu = "t" in params && params["t"] == "canonical";
 
135
 
 
136
  // We only expect to see our DDG searchplugin
 
137
  do_check_true(ubuntu);
 
138
 
 
139
  return ubuntu;
 
140
}
 
141
 
 
142
function test_amazon(aEngine)
 
143
{
 
144
  let url = aEngine.getSubmission("foo").uri.QueryInterface(Ci.nsIURL);
 
145
 
 
146
  let params = get_query_params(url);
 
147
  let ubuntu = "tag" in params && params["tag"] == "wwwcanoniccom-20";
 
148
 
 
149
  // We only expect to see our Amazon searchplugin
 
150
  do_check_true(ubuntu);
 
151
 
 
152
  return ubuntu;
 
153
}
 
154
 
 
155
function test_google(aEngine)
 
156
{
 
157
  let wanted = {
 
158
    "gl": {
 
159
      "en-GB": "uk",
 
160
      "en-ZA": "za"
 
161
    },
 
162
    "hl": {
 
163
      "ku": "en",
 
164
      "ja": "ja"
 
165
    }    
 
166
  };
 
167
 
 
168
  function check_extra_params() {
 
169
    for (let param in wanted) {
 
170
      do_check_eq(params[param], wanted[param][_SEARCHPLUGIN_TEST_LOCALE]);
 
171
    }
 
172
  }
 
173
 
 
174
  do_check_eq(Services.io.newURI(aEngine.searchForm, null, null).scheme, "https");
 
175
 
 
176
  let url = aEngine.getSubmission("foo").uri.QueryInterface(Ci.nsIURL);
 
177
  // Verify we are using a secure URL
 
178
  do_check_eq(url.scheme, "https");
 
179
 
 
180
  let params = get_query_params(url);
 
181
 
 
182
  let ubuntu = "client" in params && params["client"] == "ubuntu" && "channel" in params && params["channel"] == "fs";
 
183
 
 
184
  // We only expect to see our Google searchplugin
 
185
  do_check_true(ubuntu);
 
186
 
 
187
  check_extra_params();
 
188
 
 
189
  url = aEngine.getSubmission("foo", "application/x-suggestions+json").uri.QueryInterface(Ci.nsIURL);
 
190
  // Verify we are using a secure URL for suggestions
 
191
  do_check_eq(url.scheme, "https");
 
192
 
 
193
  params = get_query_params(url);
 
194
 
 
195
  // "client=ubuntu" fails for suggestions
 
196
  do_check_eq(params["client"], "firefox");
 
197
 
 
198
  check_extra_params();
 
199
 
 
200
  return ubuntu;
 
201
}
 
202
 
 
203
function run_test()
 
204
{
 
205
  do_check_true(!!_SEARCHPLUGIN_TEST_LOCALE);
 
206
  _XPCSHELL_PROCESS = "child-" + _SEARCHPLUGIN_TEST_LOCALE;
 
207
 
 
208
  //Services.prefs.setBoolPref("browser.search.log", true);
 
209
  Services.prefs.setCharPref("general.useragent.locale", _SEARCHPLUGIN_TEST_LOCALE);
 
210
  createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
 
211
 
 
212
  let found_Google = false;
 
213
  let found_Amazon = false;
 
214
  let found_DDG = false;
 
215
  let found_Baidu = false;
 
216
 
 
217
  do_check_true(_SEARCHPLUGIN_TEST_LOCALE in TEST_MATRIX);
 
218
 
 
219
  let want_Amazon = TEST_MATRIX[_SEARCHPLUGIN_TEST_LOCALE][PLUGIN_AMAZON];
 
220
  let want_Baidu = TEST_MATRIX[_SEARCHPLUGIN_TEST_LOCALE][PLUGIN_BAIDU];
 
221
  let want_DDG = TEST_MATRIX[_SEARCHPLUGIN_TEST_LOCALE][PLUGIN_DDG];
 
222
  let want_Google = TEST_MATRIX[_SEARCHPLUGIN_TEST_LOCALE][PLUGIN_GOOGLE];
 
223
 
 
224
  do_test_pending();
 
225
 
 
226
  Services.search.init({
 
227
    onInitComplete: function(aStatus) {
 
228
      do_check_true(Components.isSuccessCode(aStatus));
 
229
 
 
230
      Services.search.getEngines().forEach(function(engine) {
 
231
        let host = engine.getSubmission("foo").uri.host;
 
232
        if (host.match(/\.google\./)) {
 
233
          let is_ours = test_google(engine);
 
234
          do_check_true(!(is_ours && found_Google));
 
235
          found_Google = is_ours || found_Google;
 
236
        } else if (host.match(/\.amazon\./)) {
 
237
          let is_ours = test_amazon(engine);
 
238
          do_check_true(!(is_ours && found_Amazon));
 
239
          found_Amazon = is_ours || found_Amazon;
 
240
        } else if (host.match(/duckduckgo\./)) {
 
241
          let is_ours = test_duckduckgo(engine);
 
242
          do_check_true(!(is_ours && found_DDG));
 
243
          found_DDG = is_ours || found_DDG;
 
244
        } else if (host.match(/baidu\./)) {
 
245
          let is_ours = test_baidu(engine);
 
246
          do_check_true(!(is_ours && found_Baidu));
 
247
          found_Baidu = is_ours || found_Baidu;
 
248
        }
 
249
      });
 
250
 
 
251
      do_check_true(!((found_Amazon && !want_Amazon) || (!found_Amazon && want_Amazon)));
 
252
      do_check_true(!((found_Baidu && !want_Baidu) || (!found_Baidu && want_Baidu)));
 
253
      do_check_true(!((found_DDG && !want_DDG) || (!found_DDG && want_DDG)));
 
254
      do_check_true(!((found_Google && !want_Google) || (!found_Google && want_Google)));
 
255
 
 
256
      do_test_finished();
 
257
    }
 
258
  });
 
259
}