Permalink
Browse files

Added support for the new Windows Firefox UA style

  • Loading branch information...
1 parent d575b21 commit ee832c8ed09ed76defa1ed640de961553e99939c @gshutler committed Dec 27, 2012
Showing with 69 additions and 2 deletions.
  1. +13 −2 lib/user_agent/browsers/gecko.rb
  2. +56 −0 spec/browsers/gecko_user_agent_spec.rb
View
15 lib/user_agent/browsers/gecko.rb
@@ -22,7 +22,13 @@ def version
def platform
if comment = application.comment
- comment[0] == 'compatible' ? nil : comment[0]
+ if comment[0] == 'compatible'
+ nil
+ elsif comment[1] == 'WOW64' || comment[1] == 'Win64'
+ 'Windows'
+ else
+ comment[0]
+ end
end
end
@@ -32,7 +38,12 @@ def security
def os
if comment = application.comment
- i = comment[1] == 'U' ? 2 : 1
+ i = case comment[1]
+ when 'U'; 2
+ when 'WOW64', 'Win64'; 0
+ else 1
+ end
+
OperatingSystems.normalize_os(comment[i])
end
end
View
56 spec/browsers/gecko_user_agent_spec.rb
@@ -159,6 +159,62 @@
end
end
+describe "UserAgent: 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:16.0.1) Gecko/20121011 Firefox/16.0.1'" do
+ before do
+ @useragent = UserAgent.parse("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:16.0.1) Gecko/20121011 Firefox/16.0.1")
+ end
+
+ it_should_behave_like "Firefox browser"
+
+ it "should return '16.0.1' as its version" do
+ @useragent.version.should == "16.0.1"
+ end
+
+ it "should return '20121011' as its gecko version" do
+ @useragent.gecko.version.should == "20121011"
+ end
+
+ it "should return 'Windows' as its platform" do
+ @useragent.platform.should == "Windows"
+ end
+
+ it "should return 'Windows 7' as its os" do
+ @useragent.os.should == "Windows 7"
+ end
+
+ it "should return nil as its localization" do
+ @useragent.localization.should be_nil
+ end
+end
+
+describe "UserAgent: 'Mozilla/5.0 (Windows NT 6.1; Win64; rv:16.0.1) Gecko/20121011 Firefox/16.0.1'" do
+ before do
+ @useragent = UserAgent.parse("Mozilla/5.0 (Windows NT 6.1; Win64; rv:16.0.1) Gecko/20121011 Firefox/16.0.1")
+ end
+
+ it_should_behave_like "Firefox browser"
+
+ it "should return '16.0.1' as its version" do
+ @useragent.version.should == "16.0.1"
+ end
+
+ it "should return '20121011' as its gecko version" do
+ @useragent.gecko.version.should == "20121011"
+ end
+
+ it "should return 'Windows' as its platform" do
+ @useragent.platform.should == "Windows"
+ end
+
+ it "should return 'Windows 7' as its os" do
+ @useragent.os.should == "Windows 7"
+ end
+
+ it "should return nil as its localization" do
+ @useragent.localization.should be_nil
+ end
+end
+
describe "UserAgent: 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.0.12) Gecko/20070508 Firefox/1.5.0.12'" do
before do
@useragent = UserAgent.parse("Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.0.12) Gecko/20070508 Firefox/1.5.0.12")

0 comments on commit ee832c8

Please sign in to comment.