Title: [257128] trunk
Revision
257128
Author
[email protected]
Date
2020-02-20 23:44:06 -0800 (Thu, 20 Feb 2020)

Log Message

[GTK] Improve user agent quirk for Google Docs and Google Drive
https://bugs.webkit.org/show_bug.cgi?id=206506

Patch by Michael Catanzaro <[email protected]> on 2020-02-20
Reviewed by Carlos Garcia Campos.

Source/WebCore:

Stop using our macOS platform quirk for Google Docs and Google Drive. It is not successfully
suppressing the unsupported browser warnings that it was added to avoid. It is also
responsible for complaints from users who do not like seeing macOS-style shortcuts with
the Command key rather than Ctrl.

Replace it with a new Firefox browser quirk. We can avoid the unsupported browser warning in
Google Docs by using this quirk on accounts.youtube.com. There's no need for any other quirk
specific to Google Docs (although removing the macOS platform quirk means we'll instead
begin using the x86_64 Linux quirk that we send to other Google domains). Google Drive will
also use this new quirk.

Also, remove a stale comment instructing developers to test downloading the Hangouts browser
plugin. We no longer support NPAPI, so Google Hangouts is a lost cause until we get WebRTC
working.

* platform/UserAgentQuirks.cpp:
(WebCore::urlRequiresFirefoxBrowser):
(WebCore::urlRequiresMacintoshPlatform):
(WebCore::urlRequiresLinuxDesktopPlatform):
(WebCore::UserAgentQuirks::quirksForURL):
(WebCore::UserAgentQuirks::stringForQuirk):
* platform/UserAgentQuirks.h:
* platform/glib/UserAgentGLib.cpp:
(WebCore::buildUserAgentString):

Tools:

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

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (257127 => 257128)


--- trunk/Source/WebCore/ChangeLog	2020-02-21 06:57:47 UTC (rev 257127)
+++ trunk/Source/WebCore/ChangeLog	2020-02-21 07:44:06 UTC (rev 257128)
@@ -1,3 +1,35 @@
+2020-02-20  Michael Catanzaro  <[email protected]>
+
+        [GTK] Improve user agent quirk for Google Docs and Google Drive
+        https://bugs.webkit.org/show_bug.cgi?id=206506
+
+        Reviewed by Carlos Garcia Campos.
+
+        Stop using our macOS platform quirk for Google Docs and Google Drive. It is not successfully
+        suppressing the unsupported browser warnings that it was added to avoid. It is also
+        responsible for complaints from users who do not like seeing macOS-style shortcuts with
+        the Command key rather than Ctrl.
+
+        Replace it with a new Firefox browser quirk. We can avoid the unsupported browser warning in
+        Google Docs by using this quirk on accounts.youtube.com. There's no need for any other quirk
+        specific to Google Docs (although removing the macOS platform quirk means we'll instead
+        begin using the x86_64 Linux quirk that we send to other Google domains). Google Drive will
+        also use this new quirk.
+
+        Also, remove a stale comment instructing developers to test downloading the Hangouts browser
+        plugin. We no longer support NPAPI, so Google Hangouts is a lost cause until we get WebRTC
+        working.
+
+        * platform/UserAgentQuirks.cpp:
+        (WebCore::urlRequiresFirefoxBrowser):
+        (WebCore::urlRequiresMacintoshPlatform):
+        (WebCore::urlRequiresLinuxDesktopPlatform):
+        (WebCore::UserAgentQuirks::quirksForURL):
+        (WebCore::UserAgentQuirks::stringForQuirk):
+        * platform/UserAgentQuirks.h:
+        * platform/glib/UserAgentGLib.cpp:
+        (WebCore::buildUserAgentString):
+
 2020-02-20  Peng Liu  <[email protected]>
 
         [Media in GPU process] Synchronize the properties of video layers in the GPU process with the hosting layer in the web process

Modified: trunk/Source/WebCore/platform/UserAgentQuirks.cpp (257127 => 257128)


--- trunk/Source/WebCore/platform/UserAgentQuirks.cpp	2020-02-21 06:57:47 UTC (rev 257127)
+++ trunk/Source/WebCore/platform/UserAgentQuirks.cpp	2020-02-21 07:44:06 UTC (rev 257128)
@@ -39,11 +39,10 @@
     String baseDomain = topPrivatelyControlledDomain(url.host().toString());
 
     // 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. Test logging out and logging in to a Google
-    // account. Change platformVersionForUAString() to return "FreeBSD amd64"
-    // and test everything again.
+    // https://webkit.org/b/142074 carefully before changing. Test that 3D
+    // view is available in Google Maps. Test Google Calendar. Test logging out
+    // and logging in to a Google account. Change platformVersionForUAString()
+    // to return "FreeBSD amd64" and test everything again.
     if (baseDomain.startsWith("google."))
         return true;
     if (baseDomain == "gstatic.com")
@@ -70,6 +69,30 @@
     return false;
 }
 
+// Prefer using the macOS platform quirk rather than the Firefox quirk. This
+// quirk is good for websites that do macOS-specific things we don't want on
+// other platforms, and when the risk of the website doing Firefox-specific
+// things is relatively low.
+static bool urlRequiresFirefoxBrowser(const URL& url)
+{
+    String domain = url.host().toString();
+
+    // This quirk actually has nothing to do with YouTube. It's needed to avoid
+    // unsupported browser warnings on Google Docs. After removing this quirk,
+    // to reproduce the warnings you will need to sign out of Google, then click
+    // on a link to a non-public document that requires signing in. The
+    // unsupported browser warning will be displayed after signing in.
+    if (domain == "accounts.youtube.com")
+        return true;
+
+    // Google Drive shows an unsupported browser warning with WebKitGTK's
+    // standard user agent.
+    if (domain == "drive.google.com")
+        return true;
+
+    return false;
+}
+
 static bool urlRequiresMacintoshPlatform(const URL& url)
 {
     String domain = url.host().toString();
@@ -104,12 +127,6 @@
         || domain == "exchange.tu-berlin.de")
         return true;
 
-    // Google Docs and Google Drive both show a scary unsupported browser
-    // warning with WebKitGTK's standard user agent.
-    if (domain == "docs.google.com"
-        || domain == "drive.google.com")
-        return true;
-
     // Bank of America shows an unsupported browser warning with WebKitGTK's
     // standard user agent.
     if (baseDomain == "bankofamerica.com")
@@ -120,10 +137,7 @@
 
 static bool urlRequiresLinuxDesktopPlatform(const URL& url)
 {
-    // docs.google.com and drive.google.com require the macOS platform quirk.
-    return isGoogle(url)
-        && url.host() != "docs.google.com"
-        && url.host() != "drive.google.com";
+    return isGoogle(url);
 }
 
 UserAgentQuirks UserAgentQuirks::quirksForURL(const URL& url)
@@ -134,6 +148,8 @@
 
     if (urlRequiresChromeBrowser(url))
         quirks.add(UserAgentQuirks::NeedsChromeBrowser);
+    else if (urlRequiresFirefoxBrowser(url))
+        quirks.add(UserAgentQuirks::NeedsFirefoxBrowser);
 
     if (urlRequiresMacintoshPlatform(url))
         quirks.add(UserAgentQuirks::NeedsMacintoshPlatform);
@@ -149,6 +165,8 @@
     case NeedsChromeBrowser:
         // Get versions from https://chromium.googlesource.com/chromium/src.git
         return "Chrome/75.0.3770.141"_s;
+    case NeedsFirefoxBrowser:
+        return "; rv:72.0) Gecko/20100101 Firefox/72.0"_s;
     case NeedsMacintoshPlatform:
         return "Macintosh; Intel Mac OS X 10_15"_s;
     case NeedsLinuxDesktopPlatform:

Modified: trunk/Source/WebCore/platform/UserAgentQuirks.h (257127 => 257128)


--- trunk/Source/WebCore/platform/UserAgentQuirks.h	2020-02-21 06:57:47 UTC (rev 257127)
+++ trunk/Source/WebCore/platform/UserAgentQuirks.h	2020-02-21 07:44:06 UTC (rev 257128)
@@ -34,6 +34,7 @@
 public:
     enum UserAgentQuirk {
         NeedsChromeBrowser,
+        NeedsFirefoxBrowser,
         NeedsMacintoshPlatform,
         NeedsLinuxDesktopPlatform,
 

Modified: trunk/Source/WebCore/platform/glib/UserAgentGLib.cpp (257127 => 257128)


--- trunk/Source/WebCore/platform/glib/UserAgentGLib.cpp	2020-02-21 06:57:47 UTC (rev 257127)
+++ trunk/Source/WebCore/platform/glib/UserAgentGLib.cpp	2020-02-21 07:44:06 UTC (rev 257128)
@@ -92,6 +92,11 @@
         uaString.append(platformVersionForUAString());
     }
 
+    if (quirks.contains(UserAgentQuirks::NeedsFirefoxBrowser)) {
+        uaString.append(UserAgentQuirks::stringForQuirk(UserAgentQuirks::NeedsFirefoxBrowser));
+        return uaString.toString();
+    }
+
     uaString.appendLiteral(") AppleWebKit/");
     uaString.append(versionForUAString());
     uaString.appendLiteral(" (KHTML, like Gecko) ");

Modified: trunk/Tools/ChangeLog (257127 => 257128)


--- trunk/Tools/ChangeLog	2020-02-21 06:57:47 UTC (rev 257127)
+++ trunk/Tools/ChangeLog	2020-02-21 07:44:06 UTC (rev 257128)
@@ -1,3 +1,14 @@
+2020-02-20  Michael Catanzaro  <[email protected]>
+
+        [GTK] Improve user agent quirk for Google Docs and Google Drive
+        https://bugs.webkit.org/show_bug.cgi?id=206506
+
+        Reviewed by Carlos Garcia Campos.
+
+        * TestWebKitAPI/Tests/WebCore/UserAgentQuirks.cpp:
+        (TestWebKitAPI::assertUserAgentForURLHasFirefoxBrowserQuirk):
+        (TestWebKitAPI::TEST):
+
 2020-02-20  Fujii Hironori  <[email protected]>
 
         check-webkit-style: Check if *_EXPORT and *_EXPORT_PRIVATE macros are used under corresponding directories

Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/UserAgentQuirks.cpp (257127 => 257128)


--- trunk/Tools/TestWebKitAPI/Tests/WebCore/UserAgentQuirks.cpp	2020-02-21 06:57:47 UTC (rev 257127)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/UserAgentQuirks.cpp	2020-02-21 07:44:06 UTC (rev 257128)
@@ -42,6 +42,16 @@
     EXPECT_FALSE(uaString.contains("Firefox"));
 }
 
+static void assertUserAgentForURLHasFirefoxBrowserQuirk(const char* url)
+{
+    String uaString = standardUserAgentForURL(URL({ }, url));
+
+    EXPECT_FALSE(uaString.contains("Chrome"));
+    EXPECT_FALSE(uaString.contains("Safari"));
+    EXPECT_FALSE(uaString.contains("Chromium"));
+    EXPECT_TRUE(uaString.contains("Firefox"));
+}
+
 static void assertUserAgentForURLHasLinuxPlatformQuirk(const char* url)
 {
     String uaString = standardUserAgentForURL(URL({ }, url));
@@ -81,10 +91,14 @@
     assertUserAgentForURLHasChromeBrowserQuirk("http://typekit.com/");
     assertUserAgentForURLHasChromeBrowserQuirk("http://typekit.net/");
 
+    assertUserAgentForURLHasFirefoxBrowserQuirk("http://accounts.youtube.com/");
+    assertUserAgentForURLHasFirefoxBrowserQuirk("http://drive.google.com/");
+
     assertUserAgentForURLHasLinuxPlatformQuirk("http://www.google.com/");
     assertUserAgentForURLHasLinuxPlatformQuirk("http://www.google.es/");
     assertUserAgentForURLHasLinuxPlatformQuirk("http://calendar.google.com/");
     assertUserAgentForURLHasLinuxPlatformQuirk("http://plus.google.com/");
+    assertUserAgentForURLHasLinuxPlatformQuirk("http://drive.google.com/");
 
     assertUserAgentForURLHasMacPlatformQuirk("http://www.yahoo.com/");
     assertUserAgentForURLHasMacPlatformQuirk("http://finance.yahoo.com/");
@@ -92,7 +106,6 @@
     assertUserAgentForURLHasMacPlatformQuirk("http://www.whatsapp.com/");
     assertUserAgentForURLHasMacPlatformQuirk("http://web.whatsapp.com/");
     assertUserAgentForURLHasMacPlatformQuirk("http://www.chase.com/");
-    assertUserAgentForURLHasMacPlatformQuirk("http://docs.google.com/");
     assertUserAgentForURLHasMacPlatformQuirk("http://drive.google.com/");
     assertUserAgentForURLHasMacPlatformQuirk("http://paypal.com/");
     assertUserAgentForURLHasMacPlatformQuirk("http://outlook.live.com/");
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to