Title: [210209] releases/WebKitGTK/webkit-2.14
Revision
210209
Author
[email protected]
Date
2016-12-30 02:06:49 -0800 (Fri, 30 Dec 2016)

Log Message

Merge r210207 - [GTK] Improve user agent construction
https://bugs.webkit.org/show_bug.cgi?id=142074

Reviewed by Carlos Garcia Campos.

Source/WebCore:

Using the macOS quirk rather than the Chrome quirk for Google domains was a mistake: it
broke Hangouts in a different way than the Chrome quirk, and also prevents use of the nice
Earth mode on Google Maps. Google is making it really hard to develop a sane quirk.
Eventually I settled on the combination of two quirks: (1) Firefox browser, and (2) Linux
x86_64 platform. See the bug for full discussion on why these quirks are the best way to
make Google domains work properly in WebKit. This is an extremely sad state of affairs, but
I'm confident it is the best option. Note this effectively includes a rollout of r210168.

Also, fix a bug that caused an extra space to be inserted in the middle of the user agent.

* platform/UserAgentQuirks.cpp:
(WebCore::isGoogle):
(WebCore::urlRequiresFirefoxBrowser):
(WebCore::urlRequiresMacintoshPlatform):
(WebCore::urlRequiresLinuxDesktopPlatform):
(WebCore::UserAgentQuirks::quirksForURL):
(WebCore::UserAgentQuirks::stringForQuirk):
(WebCore::UserAgentQuirks::firefoxRevisionString):
* platform/UserAgentQuirks.h:
* platform/gtk/UserAgentGtk.cpp:
(WebCore::buildUserAgentString):

Tools:

* TestWebKitAPI/Tests/WebCore/UserAgentQuirks.cpp:
(TestWebKitAPI::assertUserAgentForURLHasChromeBrowserQuirk):
(TestWebKitAPI::assertUserAgentForURLHasFirefoxBrowserQuirk):
(TestWebKitAPI::assertUserAgentForURLHasLinuxPlatformQuirk):
(TestWebKitAPI::assertUserAgentForURLHasMacPlatformQuirk):
(TestWebKitAPI::TEST):

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/ChangeLog (210208 => 210209)


--- releases/WebKitGTK/webkit-2.14/Source/WebCore/ChangeLog	2016-12-30 09:39:26 UTC (rev 210208)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/ChangeLog	2016-12-30 10:06:49 UTC (rev 210209)
@@ -1,3 +1,32 @@
+2016-12-30  Michael Catanzaro  <[email protected]>
+
+        [GTK] Improve user agent construction
+        https://bugs.webkit.org/show_bug.cgi?id=142074
+
+        Reviewed by Carlos Garcia Campos.
+
+        Using the macOS quirk rather than the Chrome quirk for Google domains was a mistake: it
+        broke Hangouts in a different way than the Chrome quirk, and also prevents use of the nice
+        Earth mode on Google Maps. Google is making it really hard to develop a sane quirk.
+        Eventually I settled on the combination of two quirks: (1) Firefox browser, and (2) Linux
+        x86_64 platform. See the bug for full discussion on why these quirks are the best way to
+        make Google domains work properly in WebKit. This is an extremely sad state of affairs, but
+        I'm confident it is the best option. Note this effectively includes a rollout of r210168.
+
+        Also, fix a bug that caused an extra space to be inserted in the middle of the user agent.
+
+        * platform/UserAgentQuirks.cpp:
+        (WebCore::isGoogle):
+        (WebCore::urlRequiresFirefoxBrowser):
+        (WebCore::urlRequiresMacintoshPlatform):
+        (WebCore::urlRequiresLinuxDesktopPlatform):
+        (WebCore::UserAgentQuirks::quirksForURL):
+        (WebCore::UserAgentQuirks::stringForQuirk):
+        (WebCore::UserAgentQuirks::firefoxRevisionString):
+        * platform/UserAgentQuirks.h:
+        * platform/gtk/UserAgentGtk.cpp:
+        (WebCore::buildUserAgentString):
+
 2016-09-30  Said Abou-Hallawa  <[email protected]>
 
         Unreviewed, fix 32-bit build.

Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/gtk/UserAgentGtk.cpp (210208 => 210209)


--- releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/gtk/UserAgentGtk.cpp	2016-12-30 09:39:26 UTC (rev 210208)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/gtk/UserAgentGtk.cpp	2016-12-30 10:06:49 UTC (rev 210209)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012, 2014 Igalia S.L.
+ * Copyright (C) 2012, 2014, 2016 Igalia S.L.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -47,7 +47,9 @@
 public:
     enum UserAgentQuirk {
         NeedsChromeBrowser,
+        NeedsFirefoxBrowser,
         NeedsMacintoshPlatform,
+        NeedsLinuxDesktopPlatform,
 
         NumUserAgentQuirks
     };
@@ -116,6 +118,8 @@
 
     if (quirks.contains(UserAgentQuirks::NeedsMacintoshPlatform))
         uaString.appendLiteral("Macintosh");
+    else if (quirks.contains(UserAgentQuirks::NeedsLinuxDesktopPlatform))
+        uaString.appendLiteral("X11");
     else
         uaString.append(platformForUAString());
 
@@ -123,22 +127,31 @@
 
     if (quirks.contains(UserAgentQuirks::NeedsMacintoshPlatform))
         uaString.appendLiteral("Intel Mac OS X 10_12");
+    else if (quirks.contains(UserAgentQuirks::NeedsLinuxDesktopPlatform))
+        uaString.appendLiteral("Linux x86_64");
     else
         uaString.append(platformVersionForUAString());
 
-    uaString.appendLiteral(") AppleWebKit/");
-    uaString.append(versionForUAString());
-    uaString.appendLiteral(" (KHTML, like Gecko) ");
+    if (quirks.contains(UserAgentQuirks::NeedsFirefoxBrowser))
+        uaString.appendLiteral("; rv:50.0) ");
+    else {
+        uaString.appendLiteral(") AppleWebKit/");
+        uaString.append(versionForUAString());
+        uaString.appendLiteral(" (KHTML, like Gecko) ");
+    }
 
     // Note that Chrome UAs advertise *both* Chrome and Safari.
-    // We set a meaningful value only for the first two digits here.
     if (quirks.contains(UserAgentQuirks::NeedsChromeBrowser))
-        uaString.append("Chrome/54.0.2704.106 ");
+        uaString.appendLiteral("Chrome/56.0.2891.4 ");
+    else if (quirks.contains(UserAgentQuirks::NeedsFirefoxBrowser))
+        uaString.appendLiteral("Gecko/20100101 Firefox/50.0");
 
-    // Version/X is mandatory *before* Safari/X to be a valid Safari UA. See
-    // https://bugs.webkit.org/show_bug.cgi?id=133403 for details.
-    uaString.appendLiteral(" Version/10.0 Safari/");
-    uaString.append(versionForUAString());
+    if (!quirks.contains(UserAgentQuirks::NeedsFirefoxBrowser)) {
+        // Version/X is mandatory *before* Safari/X to be a valid Safari UA. See
+        // https://bugs.webkit.org/show_bug.cgi?id=133403 for details.
+        uaString.appendLiteral("Version/10.0 Safari/");
+        uaString.append(versionForUAString());
+    }
 
     return uaString.toString();
 }
@@ -169,6 +182,27 @@
     return standardUserAgentStatic() + ' ' + applicationName + '/' + finalApplicationVersion;
 }
 
+static bool isGoogle(const URL& url)
+{
+    String baseDomain = topPrivatelyControlledDomain(url.host());
+
+    // Our Google UA is *very* complicated to get right. Read
+    // https://webkit.org/b/142074 carefully before changing. Test that Earth
+    // view is available in Google Maps. Test Google Calendar. Test downloading
+    // the Hangouts browser plugin. Change platformVersionForUAString() to
+    // return "FreeBSD amd64" and test Maps and Calendar again.
+    if (baseDomain.startsWith("google."))
+        return true;
+    if (baseDomain == "gstatic.com")
+        return true;
+    if (baseDomain == "googleapis.com")
+        return true;
+    if (baseDomain == "googleusercontent.com")
+        return true;
+
+    return false;
+}
+
 // Be careful with this quirk: it's an invitation for sites to use _javascript_ we can't handle.
 static bool urlRequiresChromeBrowser(const URL& url)
 {
@@ -189,15 +223,15 @@
     return false;
 }
 
+static bool urlRequiresFirefoxBrowser(const URL& url)
+{
+    return isGoogle(url);
+}
+
 static bool urlRequiresMacintoshPlatform(const URL& url)
 {
     String baseDomain = topPrivatelyControlledDomain(url.host());
 
-    // Avoid receiving terrible fallbacks version of calendar.google.com and
-    // maps.google.com on certain platforms. https://webkit.org/b/142074
-    if (baseDomain.startsWith("google."))
-        return true;
-
     // At least finance.yahoo.com displays a mobile version with our standard user agent.
     if (baseDomain == "yahoo.com")
         return true;
@@ -213,14 +247,26 @@
     return false;
 }
 
+static bool urlRequiresLinuxDesktopPlatform(const URL& url)
+{
+    return isGoogle(url);
+}
+
 String standardUserAgentForURL(const URL& url)
 {
     ASSERT(!url.isNull());
+
     UserAgentQuirks quirks;
+
     if (urlRequiresChromeBrowser(url))
         quirks.add(UserAgentQuirks::NeedsChromeBrowser);
+    else if (urlRequiresFirefoxBrowser(url))
+        quirks.add(UserAgentQuirks::NeedsFirefoxBrowser);
+
     if (urlRequiresMacintoshPlatform(url))
         quirks.add(UserAgentQuirks::NeedsMacintoshPlatform);
+    else if (urlRequiresLinuxDesktopPlatform(url))
+        quirks.add(UserAgentQuirks::NeedsLinuxDesktopPlatform);
 
     // The null string means we don't need a specific UA for the given URL.
     return quirks.isEmpty() ? String() : buildUserAgentString(quirks);

Modified: releases/WebKitGTK/webkit-2.14/Tools/ChangeLog (210208 => 210209)


--- releases/WebKitGTK/webkit-2.14/Tools/ChangeLog	2016-12-30 09:39:26 UTC (rev 210208)
+++ releases/WebKitGTK/webkit-2.14/Tools/ChangeLog	2016-12-30 10:06:49 UTC (rev 210209)
@@ -1,3 +1,17 @@
+2016-12-30  Michael Catanzaro  <[email protected]>
+
+        [GTK] Improve user agent construction
+        https://bugs.webkit.org/show_bug.cgi?id=142074
+
+        Reviewed by Carlos Garcia Campos.
+
+        * TestWebKitAPI/Tests/WebCore/UserAgentQuirks.cpp:
+        (TestWebKitAPI::assertUserAgentForURLHasChromeBrowserQuirk):
+        (TestWebKitAPI::assertUserAgentForURLHasFirefoxBrowserQuirk):
+        (TestWebKitAPI::assertUserAgentForURLHasLinuxPlatformQuirk):
+        (TestWebKitAPI::assertUserAgentForURLHasMacPlatformQuirk):
+        (TestWebKitAPI::TEST):
+
 2016-12-27  Michael Catanzaro  <[email protected]>
 
         [GTK] Improve user agent construction

Modified: releases/WebKitGTK/webkit-2.14/Tools/TestWebKitAPI/Tests/WebCore/gtk/UserAgentQuirks.cpp (210208 => 210209)


--- releases/WebKitGTK/webkit-2.14/Tools/TestWebKitAPI/Tests/WebCore/gtk/UserAgentQuirks.cpp	2016-12-30 09:39:26 UTC (rev 210208)
+++ releases/WebKitGTK/webkit-2.14/Tools/TestWebKitAPI/Tests/WebCore/gtk/UserAgentQuirks.cpp	2016-12-30 10:06:49 UTC (rev 210209)
@@ -44,19 +44,28 @@
     EXPECT_TRUE(uaString.contains("Mac OS X"));
     EXPECT_FALSE(uaString.contains("Linux"));
     EXPECT_FALSE(uaString.contains("Chrome"));
+    EXPECT_FALSE(uaString.contains("Firefox"));
 
-    // google domains require Chrome in the UA
+    // google domains require Firefox in the UA
     uaString = standardUserAgentForURL(URL(ParsedURLString, "http://www.google.es/"));
-    EXPECT_TRUE(uaString.contains("Macintosh"));
-    EXPECT_TRUE(uaString.contains("Mac OS X"));
-    EXPECT_FALSE(uaString.contains("Linux"));
     EXPECT_FALSE(uaString.contains("Chrome"));
+    EXPECT_FALSE(uaString.contains("Safari"));
+    EXPECT_FALSE(uaString.contains("Chromium"));
+    EXPECT_FALSE(uaString.contains("AppleWebKit"));
+    EXPECT_TRUE(uaString.contains("Firefox"));
+    EXPECT_FALSE(uaString.contains("Macintosh"));
+    EXPECT_FALSE(uaString.contains("Mac OS X"));
+    EXPECT_FALSE(uaString.contains("Windows"));
 
     uaString = standardUserAgentForURL(URL(ParsedURLString, "http://maps.google.com/"));
-    EXPECT_TRUE(uaString.contains("Macintosh"));
-    EXPECT_TRUE(uaString.contains("Mac OS X"));
-    EXPECT_FALSE(uaString.contains("Linux"));
     EXPECT_FALSE(uaString.contains("Chrome"));
+    EXPECT_FALSE(uaString.contains("Safari"));
+    EXPECT_FALSE(uaString.contains("Chromium"));
+    EXPECT_FALSE(uaString.contains("AppleWebKit"));
+    EXPECT_TRUE(uaString.contains("Firefox"));
+    EXPECT_FALSE(uaString.contains("Macintosh"));
+    EXPECT_FALSE(uaString.contains("Mac OS X"));
+    EXPECT_FALSE(uaString.contains("Windows"));
 
     // Slack requires Chrome in the UA
     uaString = standardUserAgentForURL(URL(ParsedURLString, "http://www.slack.com/"));
@@ -64,6 +73,7 @@
     EXPECT_FALSE(uaString.contains("Mac OS X"));
     EXPECT_TRUE(uaString.contains("Linux"));
     EXPECT_TRUE(uaString.contains("Chrome"));
+    EXPECT_FALSE(uaString.contains("Firefox"));
 }
 
 } // namespace TestWebKitAPI
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to