Skip to content
This repository has been archived by the owner on Mar 15, 2018. It is now read-only.

Commit

Permalink
do not autofill firefox platform/version for searching within other a…
Browse files Browse the repository at this point in the history
…pplications (bug 715968)
  • Loading branch information
cvan committed Jan 9, 2012
1 parent ce31237 commit 807cbb2
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 27 deletions.
58 changes: 31 additions & 27 deletions media/js/impala/search.js
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
47 changes: 47 additions & 0 deletions media/js/zamboni/tests/search_tests.js
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
8 changes: 8 additions & 0 deletions templates/qunit/qunit.html
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,14 @@ <h3>Select a license for your Persona.</h3>
</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>
Expand Down

0 comments on commit 807cbb2

Please sign in to comment.