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

Commit

Permalink
Merge pull request #641 from willkg/1192812-ios
Browse files Browse the repository at this point in the history
[bug 1192812] Fix firefox for ios inferring
  • Loading branch information
willkg committed Aug 20, 2015
2 parents 0ffd945 + f73179b commit 6ecf455
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
2 changes: 1 addition & 1 deletion fjord/base/browsers.py
Expand Up @@ -105,7 +105,7 @@ def parse_ua(ua):
platform = platform_parts.pop(0)
platform_version = UNKNOWN

while platform in ['X11', 'Ubuntu', 'U', 'iPad', 'iPhone']:
while platform in ['X11', 'Ubuntu', 'U', 'iPod touch', 'iPad', 'iPhone']:
platform = platform_parts.pop(0)

if platform == 'Windows':
Expand Down
8 changes: 8 additions & 0 deletions fjord/base/tests/user_agent_data.json
Expand Up @@ -190,5 +190,13 @@
"platform": "iPhone OS",
"platform_version": "8.3",
"mobile": true
},
{
"user_agent": "Mozilla/5.0 (iPod touch; CPU iPhone OS 8_4 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) FxiOS/1.0 Mobile/12H143 Safari/600.1.4",
"browser": "Firefox for iOS",
"browser_version": "1.0",
"platform": "iPhone OS",
"platform_version": "8.4",
"mobile": true
}
]
38 changes: 38 additions & 0 deletions fjord/feedback/tests/test_views.py
Expand Up @@ -377,6 +377,44 @@ def test_urls_product_inferred_platform_firefoxdev(self):
eq_(u'Firefox dev', feedback.product)
eq_(u'Windows Vista', feedback.browser_platform)

def test_urls_product_inferred_platform_fxios(self):
"""Test firefoxdev platform gets inferred"""
ProductFactory(
enabled=True,
display_name=u'Firefox for iOS',
db_name=u'Firefox for iOS',
slug=u'fxios',
on_dashboard=False,
on_picker=False,
browser=u'Firefox for iOS',
)

# Test that we infer the platform if the products are the
# same.
ua = (
'Mozilla/5.0 (iPod touch; CPU iPhone OS 8_4 like Mac OS X) '
'AppleWebKit/600.1.4 (KHTML, like Gecko) FxiOS/1.0 '
'Mobile/12H143 Safari/600.1.4'
)
url = reverse('feedback', args=('fxios',))
resp = self.client.post(
url,
{
'happy': 1,
'description': u'Firefox for iOS rocks!',
'url': u'http://mozilla.org/'
},
HTTP_USER_AGENT=ua)

self.assertRedirects(resp, reverse('thanks'))
assert models.Response.objects.count() == 1
feedback = models.Response.objects.latest(field_name='id')
assert feedback.locale == 'en-US'
assert feedback.product == 'Firefox for iOS'
assert feedback.browser == 'Firefox for iOS'
assert feedback.browser_version == '1.0'
assert feedback.browser_platform == 'iPhone OS'

def test_urls_product_not_inferred_platform_firefoxdev(self):
"""Test firefoxdev platform doesn't get inferred if not Firefox"""
amount = models.Response.objects.count()
Expand Down

0 comments on commit 6ecf455

Please sign in to comment.