Changeset 270168 in webkit
- Timestamp:
- Nov 26, 2020, 4:36:54 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/platform/UserAgentQuirks.cpp (modified) (5 diffs)
-
Source/WebCore/platform/UserAgentQuirks.h (modified) (1 diff)
-
Source/WebCore/platform/glib/UserAgentGLib.cpp (modified) (2 diffs)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebCore/UserAgentQuirks.cpp (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r270167 r270168 1 2020-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 1 36 2020-11-26 Darin Adler <darin@apple.com> 2 37 -
trunk/Source/WebCore/platform/UserAgentQuirks.cpp
r269955 r270168 39 39 { 40 40 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 46 41 String baseDomain = topPrivatelyControlledDomain(domain); 47 42 … … 99 94 String domain = url.host().toString(); 100 95 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 104 static 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 101 121 // Google Drive shows an unsupported browser warning with WebKitGTK's 102 122 // standard user agent. 103 123 if (domain == "drive.google.com") 104 return true;105 106 // Red Hat Bugzilla displays a warning page when performing searches with WebKitGTK's standard107 // user agent.108 if (domain == "bugzilla.redhat.com")109 124 return true; 110 125 … … 149 164 } 150 165 166 static bool urlRequiresWindowsPlatform(const URL& url) 167 { 168 return urlRequiresInternetExplorerBrowser(url); 169 } 170 151 171 static bool urlRequiresLinuxDesktopPlatform(const URL& url) 152 172 { 153 return isGoogle(url) && chassisType() != WTF::ChassisType::Mobile;173 return isGoogle(url) && !urlRequiresInternetExplorerBrowser(url) && chassisType() != WTF::ChassisType::Mobile; 154 174 } 155 175 … … 164 184 else if (urlRequiresFirefoxBrowser(url)) 165 185 quirks.add(UserAgentQuirks::NeedsFirefoxBrowser); 186 else if (urlRequiresInternetExplorerBrowser(url)) 187 quirks.add(UserAgentQuirks::NeedsInternetExplorerBrowser); 166 188 167 189 if (urlRequiresMacintoshPlatform(url)) 168 190 quirks.add(UserAgentQuirks::NeedsMacintoshPlatform); 191 else if (urlRequiresWindowsPlatform(url)) 192 quirks.add(UserAgentQuirks::NeedsWindowsPlatform); 169 193 else if (urlRequiresLinuxDesktopPlatform(url)) 170 194 quirks.add(UserAgentQuirks::NeedsLinuxDesktopPlatform); … … 181 205 case NeedsFirefoxBrowser: 182 206 return "; rv:80.0) Gecko/20100101 Firefox/80.0"_s; 207 case NeedsInternetExplorerBrowser: 208 return "; Trident/7.0; rv:11.0) like Gecko"_s; 183 209 case NeedsMacintoshPlatform: 184 210 return "Macintosh; Intel Mac OS X 10_15"_s; 211 case NeedsWindowsPlatform: 212 return "Windows NT 10.0"_s; 185 213 case NeedsLinuxDesktopPlatform: 186 214 return "X11; Linux x86_64"_s; -
trunk/Source/WebCore/platform/UserAgentQuirks.h
r257128 r270168 36 36 NeedsChromeBrowser, 37 37 NeedsFirefoxBrowser, 38 NeedsInternetExplorerBrowser, 38 39 NeedsMacintoshPlatform, 40 NeedsWindowsPlatform, 39 41 NeedsLinuxDesktopPlatform, 40 42 -
trunk/Source/WebCore/platform/glib/UserAgentGLib.cpp
r269947 r270168 90 90 if (quirks.contains(UserAgentQuirks::NeedsMacintoshPlatform)) 91 91 uaString.append(UserAgentQuirks::stringForQuirk(UserAgentQuirks::NeedsMacintoshPlatform)); 92 else if (quirks.contains(UserAgentQuirks::NeedsWindowsPlatform)) 93 uaString.append(UserAgentQuirks::stringForQuirk(UserAgentQuirks::NeedsWindowsPlatform)); 92 94 else if (quirks.contains(UserAgentQuirks::NeedsLinuxDesktopPlatform)) 93 95 uaString.append(UserAgentQuirks::stringForQuirk(UserAgentQuirks::NeedsLinuxDesktopPlatform)); … … 103 105 if (quirks.contains(UserAgentQuirks::NeedsFirefoxBrowser)) { 104 106 uaString.append(UserAgentQuirks::stringForQuirk(UserAgentQuirks::NeedsFirefoxBrowser)); 107 return uaString.toString(); 108 } 109 if (quirks.contains(UserAgentQuirks::NeedsInternetExplorerBrowser)) { 110 uaString.append(UserAgentQuirks::stringForQuirk(UserAgentQuirks::NeedsInternetExplorerBrowser)); 105 111 return uaString.toString(); 106 112 } -
trunk/Tools/ChangeLog
r270142 r270168 1 2020-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 1 15 2020-11-21 Jiewen Tan <jiewen_tan@apple.com> 2 16 -
trunk/Tools/TestWebKitAPI/Tests/WebCore/UserAgentQuirks.cpp
r269955 r270168 42 42 EXPECT_FALSE(uaString.contains("Firefox")); 43 43 EXPECT_FALSE(uaString.contains("Version")); 44 EXPECT_FALSE(uaString.contains("Trident")); 44 45 } 45 46 … … 53 54 EXPECT_TRUE(uaString.contains("Firefox")); 54 55 EXPECT_FALSE(uaString.contains("Version")); 56 EXPECT_FALSE(uaString.contains("Trident")); 57 } 58 59 static 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")); 55 69 } 56 70 … … 63 77 EXPECT_FALSE(uaString.contains("Mac OS X")); 64 78 EXPECT_FALSE(uaString.contains("Windows")); 79 EXPECT_FALSE(uaString.contains("Chrome")); 80 EXPECT_FALSE(uaString.contains("FreeBSD")); 81 } 82 83 static 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")); 65 91 EXPECT_FALSE(uaString.contains("Chrome")); 66 92 EXPECT_FALSE(uaString.contains("FreeBSD")); … … 81 107 TEST(UserAgentTest, Quirks) 82 108 { 83 // A site with no tquirks should return a null String.109 // A site with no quirks should return a null String. 84 110 String uaString = standardUserAgentForURL(URL({ }, "http://www.webkit.org/")); 85 111 EXPECT_TRUE(uaString.isNull()); … … 96 122 assertUserAgentForURLHasChromeBrowserQuirk("http://bankofamerica.com/"); 97 123 98 assertUserAgentForURLHasFirefoxBrowserQuirk("http://drive.google.com/");99 124 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/"); 100 133 101 134 assertUserAgentForURLHasLinuxPlatformQuirk("http://www.google.com/"); … … 105 138 assertUserAgentForURLHasLinuxPlatformQuirk("http://drive.google.com/"); 106 139 assertUserAgentForURLHasLinuxPlatformQuirk("http://fonts.googleapis.com/"); 107 assertUserAgentForURLHasLinuxPlatformQuirk("http://accounts.youtube.com/");108 assertUserAgentForURLHasLinuxPlatformQuirk("http://docs.google.com/");109 140 110 141 assertUserAgentForURLHasMacPlatformQuirk("http://www.yahoo.com/");
Note:
See TracChangeset
for help on using the changeset viewer.