do not autofill firefox platform/version for searching within other applications (bug 715968)
This commit is contained in:
Родитель
ce31237541
Коммит
807cbb2ba5
|
@ -1,34 +1,38 @@
|
|||
$('#search').bind('autofill', function(e) {
|
||||
var $this = $(this);
|
||||
function autofillPlatform(context) {
|
||||
var $context = $(context || document.body);
|
||||
$('#search', $context).bind('autofill', function(e) {
|
||||
var $this = $(this);
|
||||
|
||||
// Bail if we're searching within apps.
|
||||
if (!$this.find('#id_appver').length) {
|
||||
return;
|
||||
}
|
||||
// Bail if we're searching within apps.
|
||||
if (!$this.find('#id_appver').length) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Populate search form with browser version and OS.
|
||||
var gv = z.getVars(location.search),
|
||||
appver = '',
|
||||
platform = '',
|
||||
appver_defined = typeof gv.appver !== 'undefined',
|
||||
platform_defined = typeof gv.platform !== 'undefined';
|
||||
if (appver_defined) {
|
||||
appver = gv.appver;
|
||||
}
|
||||
if (platform_defined) {
|
||||
platform = gv.platform;
|
||||
}
|
||||
if (z.browser.firefox) {
|
||||
if (!appver_defined) {
|
||||
appver = z.browserVersion;
|
||||
// Populate search form with browser version and OS.
|
||||
var gv = z.getVars(location.search),
|
||||
appver = '',
|
||||
platform = '',
|
||||
appver_defined = typeof gv.appver !== 'undefined',
|
||||
platform_defined = typeof gv.platform !== 'undefined';
|
||||
if (appver_defined) {
|
||||
appver = gv.appver;
|
||||
}
|
||||
if (!platform_defined) {
|
||||
platform = z.platform;
|
||||
if (platform_defined) {
|
||||
platform = gv.platform;
|
||||
}
|
||||
}
|
||||
$this.find('#id_appver').val(appver);
|
||||
$this.find('#id_platform').val(platform);
|
||||
}).trigger('autofill');
|
||||
if (z.appMatchesUserAgent) {
|
||||
if (!appver_defined) {
|
||||
appver = z.browserVersion;
|
||||
}
|
||||
if (!platform_defined) {
|
||||
platform = z.platform;
|
||||
}
|
||||
}
|
||||
$this.find('#id_appver').val(appver);
|
||||
$this.find('#id_platform').val(platform);
|
||||
}).trigger('autofill');
|
||||
}
|
||||
autofillPlatform();
|
||||
|
||||
|
||||
$(function() {
|
||||
|
|
|
@ -1,3 +1,50 @@
|
|||
module('Autofill Platform for Search', {
|
||||
setup: function() {
|
||||
this._z = z;
|
||||
this.sandbox = tests.createSandbox('#search-box');
|
||||
},
|
||||
teardown: function() {
|
||||
z = this._z;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
test('Firefox using Firefox', function() {
|
||||
z.appMatchesUserAgent = true;
|
||||
z.appName = 'firefox';
|
||||
z.browser.firefox = true;
|
||||
z.browserVersion = '10.0';
|
||||
z.platform = 'mac';
|
||||
autofillPlatform(this.sandbox);
|
||||
equal($('input[name=appver]', this.sandbox).val(), z.browserVersion);
|
||||
equal($('input[name=platform]', this.sandbox).val(), z.platform);
|
||||
});
|
||||
|
||||
|
||||
test('Thunderbird using Firefox', function() {
|
||||
z.appMatchesUserAgent = false;
|
||||
z.appName = 'thunderbird';
|
||||
z.browser.firefox = true;
|
||||
z.browserVersion = '10.0';
|
||||
z.platform = 'mac';
|
||||
autofillPlatform(this.sandbox);
|
||||
equal($('input[name=appver]', this.sandbox).val(), '');
|
||||
equal($('input[name=platform]', this.sandbox).val(), '');
|
||||
});
|
||||
|
||||
|
||||
test('Thunderbird using Thunderbird', function() {
|
||||
z.appMatchesUserAgent = true;
|
||||
z.appName = 'thunderbird';
|
||||
z.browser.thunderbird = true;
|
||||
z.browserVersion = '10.0';
|
||||
z.platform = 'mac';
|
||||
autofillPlatform(this.sandbox);
|
||||
equal($('input[name=appver]', this.sandbox).val(), z.browserVersion);
|
||||
equal($('input[name=platform]', this.sandbox).val(), z.platform);
|
||||
});
|
||||
|
||||
|
||||
module('Pjax Search', {
|
||||
setup: function() {
|
||||
this.container = $('#pjax-results', this.sandbox);
|
||||
|
|
|
@ -237,6 +237,14 @@
|
|||
</form>
|
||||
</div>
|
||||
|
||||
<div id="search-box">
|
||||
<form id="search" action="/en-us/firefox/search/">
|
||||
<input type="text" id="search-q" name="q">
|
||||
<input type="hidden" name="appver" id="id_appver">
|
||||
<input type="hidden" name="platform" id="id_platform">
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div id="pjax-search">
|
||||
<div id="search-facets">
|
||||
<ul class="facets island pjax-trigger"></ul>
|
||||
|
|
Загрузка…
Ссылка в новой задаче