⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 270168 in webkit


Ignore:
Timestamp:
Nov 26, 2020, 4:36:54 PM (6 years ago)
Author:
commit-queue@webkit.org
Message:

[WPE][GTK] Use Internet Explorer quirk for Google Docs
​https://bugs.webkit.org/show_bug.cgi?id=219278

Patch by Michael Catanzaro <Michael Catanzaro> on 2020-11-26
Reviewed by Carlos Garcia Campos.

Source/WebCore:

Since r266584, we've suffered from an annoying unsupported browser warning when using Google
Docs. We don't have many options to avoid it. I'm afraid that Firefox or Chrome quirks are
too risky, since these seem to tempt Google into using web platform features that WebKit
does not support. The safest quirk is the macOS platform quirk, but that doesn't work well
here because it breaks various keyboard shortcuts like Ctrl+A and Ctrl+Z. So an Internet
Explorer quirk is really the last card we have left.

I think this is the safest Google quirk we've ever had, in that it's pretty unlikely that
Google will try to send Internet Explorer anything that doesn't work in WebKit. However, it
will break eventually, whenever Google decides that Internet Explorer is no longer
supported. I guess that date is probably at least five years away, so we can only hope that
Google drops this anticompetitive nonsense before then.

P.S. Let's also switch Google Drive to this new quirk. The unsupported browser warning on
Google Drive seems to be completely independent, but the IE quirk seems safer that the
existing Firefox quirk, so why not?

  • platform/UserAgentQuirks.cpp:

(WebCore::isGoogle):
(WebCore::urlRequiresInternetExplorerBrowser):
(WebCore::urlRequiresWindowsPlatform):
(WebCore::urlRequiresLinuxDesktopPlatform):
(WebCore::UserAgentQuirks::quirksForURL):
(WebCore::UserAgentQuirks::stringForQuirk):

  • platform/UserAgentQuirks.h:
  • platform/glib/UserAgentGLib.cpp:

(WebCore::buildUserAgentString):

Tools:

  • TestWebKitAPI/Tests/WebCore/UserAgentQuirks.cpp:

(TestWebKitAPI::assertUserAgentForURLHasChromeBrowserQuirk):
(TestWebKitAPI::assertUserAgentForURLHasFirefoxBrowserQuirk):
(TestWebKitAPI::assertUserAgentForURLHasInternetExplorerBrowserQuirk):
(TestWebKitAPI::assertUserAgentForURLHasWindowsPlatformQuirk):
(TestWebKitAPI::TEST):

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r270167 r270168  
     12020-11-26  Michael Catanzaro  <mcatanzaro@gnome.org>
     2
     3        [WPE][GTK] Use Internet Explorer quirk for Google Docs
     4        https://bugs.webkit.org/show_bug.cgi?id=219278
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        Since r266584, we've suffered from an annoying unsupported browser warning when using Google
     9        Docs. We don't have many options to avoid it. I'm afraid that Firefox or Chrome quirks are
     10        too risky, since these seem to tempt Google into using web platform features that WebKit
     11        does not support. The safest quirk is the macOS platform quirk, but that doesn't work well
     12        here because it breaks various keyboard shortcuts like Ctrl+A and Ctrl+Z. So an Internet
     13        Explorer quirk is really the last card we have left.
     14
     15        I think this is the safest Google quirk we've ever had, in that it's pretty unlikely that
     16        Google will try to send Internet Explorer anything that doesn't work in WebKit. However, it
     17        will break eventually, whenever Google decides that Internet Explorer is no longer
     18        supported. I guess that date is probably at least five years away, so we can only hope that
     19        Google drops this anticompetitive nonsense before then.
     20
     21        P.S. Let's also switch Google Drive to this new quirk. The unsupported browser warning on
     22        Google Drive seems to be completely independent, but the IE quirk seems safer that the
     23        existing Firefox quirk, so why not?
     24
     25        * platform/UserAgentQuirks.cpp:
     26        (WebCore::isGoogle):
     27        (WebCore::urlRequiresInternetExplorerBrowser):
     28        (WebCore::urlRequiresWindowsPlatform):
     29        (WebCore::urlRequiresLinuxDesktopPlatform):
     30        (WebCore::UserAgentQuirks::quirksForURL):
     31        (WebCore::UserAgentQuirks::stringForQuirk):
     32        * platform/UserAgentQuirks.h:
     33        * platform/glib/UserAgentGLib.cpp:
     34        (WebCore::buildUserAgentString):
     35
    1362020-11-26  Darin Adler  <darin@apple.com>
    237
  • trunk/Source/WebCore/platform/UserAgentQuirks.cpp

    r269955 r270168  
    3939{
    4040    String domain = url.host().toString();
    41 
    42     // Google uses accounts.youtube.com for its login service.
    43     if (domain == "accounts.youtube.com")
    44         return true;
    45 
    4641    String baseDomain = topPrivatelyControlledDomain(domain);
    4742
    … …  
    9994    String domain = url.host().toString();
    10095
     96    // Red Hat Bugzilla displays a warning page when performing searches with WebKitGTK's standard
     97    // user agent.
     98    if (domain == "bugzilla.redhat.com")
     99        return true;
     100
     101    return false;
     102}
     103
     104static bool urlRequiresInternetExplorerBrowser(const URL& url)
     105{
     106    String domain = url.host().toString();
     107
     108    // This quirk actually has nothing to do with YouTube. It's needed to avoid
     109    // unsupported browser warnings on Google Docs. Why do we need this weird
     110    // quirk? We cannot use Chrome or Firefox quirks because Google then uses
     111    // features that don't work in WebKit. And we can't use our macOS platform
     112    // quirk because Google then expects command keys and doesn't support basic
     113    // keyboard shortcuts. We could pretend to be Edge, but adding Chromium is
     114    // likely to break in the same way as a Chrome quirk. So that leaves us
     115    // with IE browser as the final reasonable option. This will break
     116    // eventually, but hopefully not for a long time, because we are probably
     117    // out of options when it does.
     118    if (domain == "accounts.youtube.com" || domain == "docs.google.com")
     119        return true;
     120
    101121    // Google Drive shows an unsupported browser warning with WebKitGTK's
    102122    // standard user agent.
    103123    if (domain == "drive.google.com")
    104         return true;
    105 
    106     // Red Hat Bugzilla displays a warning page when performing searches with WebKitGTK's standard
    107     // user agent.
    108     if (domain == "bugzilla.redhat.com")
    109124        return true;
    110125
    … …  
    149164}
    150165
     166static bool urlRequiresWindowsPlatform(const URL& url)
     167{
     168    return urlRequiresInternetExplorerBrowser(url);
     169}
     170
    151171static bool urlRequiresLinuxDesktopPlatform(const URL& url)
    152172{
    153     return isGoogle(url) && chassisType() != WTF::ChassisType::Mobile;
     173    return isGoogle(url) && !urlRequiresInternetExplorerBrowser(url) && chassisType() != WTF::ChassisType::Mobile;
    154174}
    155175
    … …  
    164184    else if (urlRequiresFirefoxBrowser(url))
    165185        quirks.add(UserAgentQuirks::NeedsFirefoxBrowser);
     186    else if (urlRequiresInternetExplorerBrowser(url))
     187        quirks.add(UserAgentQuirks::NeedsInternetExplorerBrowser);
    166188
    167189    if (urlRequiresMacintoshPlatform(url))
    168190        quirks.add(UserAgentQuirks::NeedsMacintoshPlatform);
     191    else if (urlRequiresWindowsPlatform(url))
     192        quirks.add(UserAgentQuirks::NeedsWindowsPlatform);
    169193    else if (urlRequiresLinuxDesktopPlatform(url))
    170194        quirks.add(UserAgentQuirks::NeedsLinuxDesktopPlatform);
    … …  
    181205    case NeedsFirefoxBrowser:
    182206        return "; rv:80.0) Gecko/20100101 Firefox/80.0"_s;
     207    case NeedsInternetExplorerBrowser:
     208        return "; Trident/7.0; rv:11.0) like Gecko"_s;
    183209    case NeedsMacintoshPlatform:
    184210        return "Macintosh; Intel Mac OS X 10_15"_s;
     211    case NeedsWindowsPlatform:
     212        return "Windows NT 10.0"_s;
    185213    case NeedsLinuxDesktopPlatform:
    186214        return "X11; Linux x86_64"_s;
  • trunk/Source/WebCore/platform/UserAgentQuirks.h

    r257128 r270168  
    3636        NeedsChromeBrowser,
    3737        NeedsFirefoxBrowser,
     38        NeedsInternetExplorerBrowser,
    3839        NeedsMacintoshPlatform,
     40        NeedsWindowsPlatform,
    3941        NeedsLinuxDesktopPlatform,
    4042
  • trunk/Source/WebCore/platform/glib/UserAgentGLib.cpp

    r269947 r270168  
    9090    if (quirks.contains(UserAgentQuirks::NeedsMacintoshPlatform))
    9191        uaString.append(UserAgentQuirks::stringForQuirk(UserAgentQuirks::NeedsMacintoshPlatform));
     92    else if (quirks.contains(UserAgentQuirks::NeedsWindowsPlatform))
     93        uaString.append(UserAgentQuirks::stringForQuirk(UserAgentQuirks::NeedsWindowsPlatform));
    9294    else if (quirks.contains(UserAgentQuirks::NeedsLinuxDesktopPlatform))
    9395        uaString.append(UserAgentQuirks::stringForQuirk(UserAgentQuirks::NeedsLinuxDesktopPlatform));
    … …  
    103105    if (quirks.contains(UserAgentQuirks::NeedsFirefoxBrowser)) {
    104106        uaString.append(UserAgentQuirks::stringForQuirk(UserAgentQuirks::NeedsFirefoxBrowser));
     107        return uaString.toString();
     108    }
     109    if (quirks.contains(UserAgentQuirks::NeedsInternetExplorerBrowser)) {
     110        uaString.append(UserAgentQuirks::stringForQuirk(UserAgentQuirks::NeedsInternetExplorerBrowser));
    105111        return uaString.toString();
    106112    }
  • trunk/Tools/ChangeLog

    r270142 r270168  
     12020-11-26  Michael Catanzaro  <mcatanzaro@gnome.org>
     2
     3        [WPE][GTK] Use Internet Explorer quirk for Google Docs
     4        https://bugs.webkit.org/show_bug.cgi?id=219278
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        * TestWebKitAPI/Tests/WebCore/UserAgentQuirks.cpp:
     9        (TestWebKitAPI::assertUserAgentForURLHasChromeBrowserQuirk):
     10        (TestWebKitAPI::assertUserAgentForURLHasFirefoxBrowserQuirk):
     11        (TestWebKitAPI::assertUserAgentForURLHasInternetExplorerBrowserQuirk):
     12        (TestWebKitAPI::assertUserAgentForURLHasWindowsPlatformQuirk):
     13        (TestWebKitAPI::TEST):
     14
    1152020-11-21  Jiewen Tan  <jiewen_tan@apple.com>
    216
  • trunk/Tools/TestWebKitAPI/Tests/WebCore/UserAgentQuirks.cpp

    r269955 r270168  
    4242    EXPECT_FALSE(uaString.contains("Firefox"));
    4343    EXPECT_FALSE(uaString.contains("Version"));
     44    EXPECT_FALSE(uaString.contains("Trident"));
    4445}
    4546
    … …  
    5354    EXPECT_TRUE(uaString.contains("Firefox"));
    5455    EXPECT_FALSE(uaString.contains("Version"));
     56    EXPECT_FALSE(uaString.contains("Trident"));
     57}
     58
     59static void assertUserAgentForURLHasInternetExplorerBrowserQuirk(const char* url)
     60{
     61    String uaString = standardUserAgentForURL(URL({ }, url));
     62
     63    EXPECT_FALSE(uaString.contains("Chrome"));
     64    EXPECT_FALSE(uaString.contains("Safari"));
     65    EXPECT_FALSE(uaString.contains("Chromium"));
     66    EXPECT_FALSE(uaString.contains("Firefox"));
     67    EXPECT_FALSE(uaString.contains("Version"));
     68    EXPECT_TRUE(uaString.contains("Trident"));
    5569}
    5670
    … …  
    6377    EXPECT_FALSE(uaString.contains("Mac OS X"));
    6478    EXPECT_FALSE(uaString.contains("Windows"));
     79    EXPECT_FALSE(uaString.contains("Chrome"));
     80    EXPECT_FALSE(uaString.contains("FreeBSD"));
     81}
     82
     83static void assertUserAgentForURLHasWindowsPlatformQuirk(const char* url)
     84{
     85    String uaString = standardUserAgentForURL(URL({ }, url));
     86
     87    EXPECT_FALSE(uaString.contains("Macintosh"));
     88    EXPECT_FALSE(uaString.contains("Mac OS X"));
     89    EXPECT_FALSE(uaString.contains("Linux"));
     90    EXPECT_TRUE(uaString.contains("Windows"));
    6591    EXPECT_FALSE(uaString.contains("Chrome"));
    6692    EXPECT_FALSE(uaString.contains("FreeBSD"));
    … …  
    81107TEST(UserAgentTest, Quirks)
    82108{
    83     // A site with not quirks should return a null String.
     109    // A site with no quirks should return a null String.
    84110    String uaString = standardUserAgentForURL(URL({ }, "http://www.webkit.org/"));
    85111    EXPECT_TRUE(uaString.isNull());
    … …  
    96122    assertUserAgentForURLHasChromeBrowserQuirk("http://bankofamerica.com/");
    97123
    98     assertUserAgentForURLHasFirefoxBrowserQuirk("http://drive.google.com/");
    99124    assertUserAgentForURLHasFirefoxBrowserQuirk("http://bugzilla.redhat.com/");
     125
     126    assertUserAgentForURLHasInternetExplorerBrowserQuirk("http://accounts.youtube.com/");
     127    assertUserAgentForURLHasInternetExplorerBrowserQuirk("http://docs.google.com/");
     128    assertUserAgentForURLHasInternetExplorerBrowserQuirk("http://drive.google.com/");
     129
     130    assertUserAgentForURLHasWindowsPlatformQuirk("http://accounts.youtube.com/");
     131    assertUserAgentForURLHasWindowsPlatformQuirk("http://docs.google.com/");
     132    assertUserAgentForURLHasWindowsPlatformQuirk("http://drive.google.com/");
    100133
    101134    assertUserAgentForURLHasLinuxPlatformQuirk("http://www.google.com/");
    … …  
    105138    assertUserAgentForURLHasLinuxPlatformQuirk("http://drive.google.com/");
    106139    assertUserAgentForURLHasLinuxPlatformQuirk("http://fonts.googleapis.com/");
    107     assertUserAgentForURLHasLinuxPlatformQuirk("http://accounts.youtube.com/");
    108     assertUserAgentForURLHasLinuxPlatformQuirk("http://docs.google.com/");
    109140
    110141    assertUserAgentForURLHasMacPlatformQuirk("http://www.yahoo.com/");
Note: See TracChangeset for help on using the changeset viewer.