<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[207406] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/207406">207406</a></dd>
<dt>Author</dt> <dd>mcatanzaro@igalia.com</dd>
<dt>Date</dt> <dd>2016-10-17 04:30:17 -0700 (Mon, 17 Oct 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Move user agent quirks to cross-platform location
https://bugs.webkit.org/show_bug.cgi?id=163508
Reviewed by Carlos Garcia Campos.
Source/WebCore:
Tested by Tools/TestWebKitAPI/Tests/WebCore/UserAgentQuirks.cpp.
* PlatformGTK.cmake:
* platform/UserAgent.h: Renamed from Source/WebCore/platform/gtk/UserAgentGtk.h.
* platform/UserAgentQuirks.cpp: Added. Moved from UserAgentGtk.cpp.
(WebCore::urlRequiresChromeBrowser): Sneakily tighten up Google domain detection, it should
only apply to sites if the base domain matches google.*, not any base domain that starts
with google.
(WebCore::urlRequiresMacintoshPlatform):
(WebCore::UserAgentQuirks::quirksForURL):
(WebCore::UserAgentQuirks::stringForQuirk):
* platform/UserAgentQuirks.h: Moved from UserAgentGtk.cpp. prepare-ChangeLog thinks it was
renamed from Source/WebCore/platform/efl/UserAgentEfl.h, but prepare-ChangeLog is dumb.
(WebCore::UserAgentQuirks::UserAgentQuirks):
(WebCore::UserAgentQuirks::add):
(WebCore::UserAgentQuirks::contains):
(WebCore::UserAgentQuirks::isEmpty):
* platform/efl/UserAgentEfl.cpp:
(WebCore::standardUserAgentForURL):
* platform/gtk/UserAgentGtk.cpp:
(WebCore::buildUserAgentString):
(WebCore::standardUserAgentForURL):
(): Deleted.
(WebCore::UserAgentQuirks::UserAgentQuirks): Deleted.
(WebCore::UserAgentQuirks::add): Deleted.
(WebCore::UserAgentQuirks::contains): Deleted.
(WebCore::UserAgentQuirks::isEmpty): Deleted.
(WebCore::urlRequiresChromeBrowser): Deleted.
(WebCore::urlRequiresMacintoshPlatform): Deleted.
Source/WebKit2:
#include <WebCore/UserAgent.h> instead of <WebCore/UserAgentGtk.h>.
* UIProcess/API/gtk/WebKitSettings.cpp:
* UIProcess/efl/WebPageProxyEfl.cpp:
* UIProcess/gtk/WebPageProxyGtk.cpp:
* WebProcess/WebPage/gtk/WebPageGtk.cpp:
Tools:
Move the test to a cross-platform location and improve it to better check the full list of
sites we have defined quirks for.
* TestWebKitAPI/PlatformGTK.cmake:
* TestWebKitAPI/Tests/WebCore/UserAgentQuirks.cpp: Renamed from Tools/TestWebKitAPI/Tests/WebCore/gtk/UserAgentQuirks.cpp.
(TestWebKitAPI::assertUserAgentForURLHasChromeBrowserQuirk):
(TestWebKitAPI::assertUserAgentForURLHasMacPlatformQuirk):
(TestWebKitAPI::TEST):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorePlatformGTKcmake">trunk/Source/WebCore/PlatformGTK.cmake</a></li>
<li><a href="#trunkSourceWebCoreplatformeflUserAgentEflcpp">trunk/Source/WebCore/platform/efl/UserAgentEfl.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgtkUserAgentGtkcpp">trunk/Source/WebCore/platform/gtk/UserAgentGtk.cpp</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkWebKitSettingscpp">trunk/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcesseflWebPageProxyEflcpp">trunk/Source/WebKit2/UIProcess/efl/WebPageProxyEfl.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessgtkWebPageProxyGtkcpp">trunk/Source/WebKit2/UIProcess/gtk/WebPageProxyGtk.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPagegtkWebPageGtkcpp">trunk/Source/WebKit2/WebProcess/WebPage/gtk/WebPageGtk.cpp</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPIPlatformGTKcmake">trunk/Tools/TestWebKitAPI/PlatformGTK.cmake</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformUserAgenth">trunk/Source/WebCore/platform/UserAgent.h</a></li>
<li><a href="#trunkSourceWebCoreplatformUserAgentQuirkscpp">trunk/Source/WebCore/platform/UserAgentQuirks.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformUserAgentQuirksh">trunk/Source/WebCore/platform/UserAgentQuirks.h</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebCoreUserAgentQuirkscpp">trunk/Tools/TestWebKitAPI/Tests/WebCore/UserAgentQuirks.cpp</a></li>
</ul>
<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformeflUserAgentEflh">trunk/Source/WebCore/platform/efl/UserAgentEfl.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgtkUserAgentGtkh">trunk/Source/WebCore/platform/gtk/UserAgentGtk.h</a></li>
<li>trunk/Tools/TestWebKitAPI/Tests/WebCore/gtk/</li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (207405 => 207406)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-10-17 10:52:02 UTC (rev 207405)
+++ trunk/Source/WebCore/ChangeLog        2016-10-17 11:30:17 UTC (rev 207406)
</span><span class="lines">@@ -1,3 +1,40 @@
</span><ins>+2016-10-17 Michael Catanzaro <mcatanzaro@igalia.com>
+
+ Move user agent quirks to cross-platform location
+ https://bugs.webkit.org/show_bug.cgi?id=163508
+
+ Reviewed by Carlos Garcia Campos.
+
+ Tested by Tools/TestWebKitAPI/Tests/WebCore/UserAgentQuirks.cpp.
+
+ * PlatformGTK.cmake:
+ * platform/UserAgent.h: Renamed from Source/WebCore/platform/gtk/UserAgentGtk.h.
+ * platform/UserAgentQuirks.cpp: Added. Moved from UserAgentGtk.cpp.
+ (WebCore::urlRequiresChromeBrowser): Sneakily tighten up Google domain detection, it should
+ only apply to sites if the base domain matches google.*, not any base domain that starts
+ with google.
+ (WebCore::urlRequiresMacintoshPlatform):
+ (WebCore::UserAgentQuirks::quirksForURL):
+ (WebCore::UserAgentQuirks::stringForQuirk):
+ * platform/UserAgentQuirks.h: Moved from UserAgentGtk.cpp. prepare-ChangeLog thinks it was
+ renamed from Source/WebCore/platform/efl/UserAgentEfl.h, but prepare-ChangeLog is dumb.
+ (WebCore::UserAgentQuirks::UserAgentQuirks):
+ (WebCore::UserAgentQuirks::add):
+ (WebCore::UserAgentQuirks::contains):
+ (WebCore::UserAgentQuirks::isEmpty):
+ * platform/efl/UserAgentEfl.cpp:
+ (WebCore::standardUserAgentForURL):
+ * platform/gtk/UserAgentGtk.cpp:
+ (WebCore::buildUserAgentString):
+ (WebCore::standardUserAgentForURL):
+ (): Deleted.
+ (WebCore::UserAgentQuirks::UserAgentQuirks): Deleted.
+ (WebCore::UserAgentQuirks::add): Deleted.
+ (WebCore::UserAgentQuirks::contains): Deleted.
+ (WebCore::UserAgentQuirks::isEmpty): Deleted.
+ (WebCore::urlRequiresChromeBrowser): Deleted.
+ (WebCore::urlRequiresMacintoshPlatform): Deleted.
+
</ins><span class="cx"> 2016-10-17 Alberto Garcia <berto@igalia.com>
</span><span class="cx">
</span><span class="cx"> [GTK] gobject-introspection on package build with webkit2gtk fails without active X session
</span></span></pre></div>
<a id="trunkSourceWebCorePlatformGTKcmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/PlatformGTK.cmake (207405 => 207406)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/PlatformGTK.cmake        2016-10-17 10:52:02 UTC (rev 207405)
+++ trunk/Source/WebCore/PlatformGTK.cmake        2016-10-17 11:30:17 UTC (rev 207406)
</span><span class="lines">@@ -84,6 +84,7 @@
</span><span class="cx"> loader/soup/SubresourceLoaderSoup.cpp
</span><span class="cx">
</span><span class="cx"> platform/KillRingNone.cpp
</span><ins>+ platform/UserAgentQuirks.cpp
</ins><span class="cx">
</span><span class="cx"> platform/audio/glib/AudioBusGLib.cpp
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformUserAgenthfromrev207405trunkSourceWebCoreplatformgtkUserAgentGtkh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/UserAgent.h (from rev 207405, trunk/Source/WebCore/platform/gtk/UserAgentGtk.h) (0 => 207406)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/UserAgent.h         (rev 0)
+++ trunk/Source/WebCore/platform/UserAgent.h        2016-10-17 11:30:17 UTC (rev 207406)
</span><span class="lines">@@ -0,0 +1,44 @@
</span><ins>+/*
+ * Copyright (C) 2012, 2014, 2016 Igalia S.L.
+ * Copyright (C) 2014 Apple Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if PLATFORM(COCOA)
+// FIXME: Remove Source/WebCore/page/cocoa/UserAgent.h
+#include_next "UserAgent.h"
+#else
+
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+class URL;
+
+String standardUserAgent(const String& applicationName = emptyString(), const String& applicationVersion = emptyString());
+String standardUserAgentForURL(const URL&);
+
+}
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformUserAgentQuirkscpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/UserAgentQuirks.cpp (0 => 207406)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/UserAgentQuirks.cpp         (rev 0)
+++ trunk/Source/WebCore/platform/UserAgentQuirks.cpp        2016-10-17 11:30:17 UTC (rev 207406)
</span><span class="lines">@@ -0,0 +1,110 @@
</span><ins>+/*
+ * 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
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "UserAgentQuirks.h"
+
+#include "PublicSuffix.h"
+#include "URL.h"
+
+namespace WebCore {
+
+// When editing the quirks in this file, be sure to update
+// Tools/TestWebKitAPI/Tests/WebCore/UserAgentQuirks.cpp.
+
+// Be careful with this quirk: it's an invitation for sites to use JavaScript
+// that works in Chrome that WebKit cannot handle. Prefer other quirks instead.
+static bool urlRequiresChromeBrowser(const URL& url)
+{
+ String baseDomain = topPrivatelyControlledDomain(url.host());
+
+ // Needed for fonts on many sites to work with WebKit.
+ // https://bugs.webkit.org/show_bug.cgi?id=147296
+ if (baseDomain == "typekit.net" || baseDomain == "typekit.com")
+ return true;
+
+ // Shut off Chrome ads. Avoid missing features on maps.google.com. Avoid
+ // receiving a terrible fallback version of calendar.google.com. Receive a
+ // fancier plus.google.com.
+ if (baseDomain.startsWith("google."))
+ return true;
+
+ // Needed for YouTube 360 with WebKitGTK+ and WPE (requires ENABLE_MEDIA_SOURCE).
+ if (baseDomain == "youtube.com")
+ return true;
+
+ // Slack completely blocks users with WebKitGTK+'s standard user agent.
+ if (baseDomain == "slack.com")
+ return true;
+
+ return false;
+}
+
+static bool urlRequiresMacintoshPlatform(const URL& url)
+{
+ String baseDomain = topPrivatelyControlledDomain(url.host());
+
+ // At least finance.yahoo.com displays a mobile version with WebKitGTK+'s standard user agent.
+ if (baseDomain == "yahoo.com")
+ return true;
+
+ // taobao.com displays a mobile version with WebKitGTK+'s standard user agent.
+ if (baseDomain == "taobao.com")
+ return true;
+
+ // web.whatsapp.com completely blocks users with WebKitGTK+'s standard user agent.
+ if (baseDomain == "whatsapp.com")
+ return true;
+
+ return false;
+}
+
+UserAgentQuirks UserAgentQuirks::quirksForURL(const URL& url)
+{
+ ASSERT(!url.isNull());
+ UserAgentQuirks quirks;
+ if (urlRequiresChromeBrowser(url))
+ quirks.add(UserAgentQuirks::NeedsChromeBrowser);
+ if (urlRequiresMacintoshPlatform(url))
+ quirks.add(UserAgentQuirks::NeedsMacintoshPlatform);
+ return quirks;
+}
+
+String UserAgentQuirks::stringForQuirk(UserAgentQuirk quirk)
+{
+ switch (quirk) {
+ case NeedsChromeBrowser:
+ // Get versions from https://chromium.googlesource.com/chromium/src.git
+ return ASCIILiteral("Chrome/56.0.2891.4");
+ case NeedsMacintoshPlatform:
+ return ASCIILiteral("Macintosh; Intel Mac OS X 10_12");
+ case NumUserAgentQuirks:
+ default:
+ ASSERT_NOT_REACHED();
+ }
+ return ASCIILiteral("");
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformUserAgentQuirkshfromrev207405trunkSourceWebCoreplatformeflUserAgentEflh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/UserAgentQuirks.h (from rev 207405, trunk/Source/WebCore/platform/efl/UserAgentEfl.h) (0 => 207406)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/UserAgentQuirks.h         (rev 0)
+++ trunk/Source/WebCore/platform/UserAgentQuirks.h        2016-10-17 11:30:17 UTC (rev 207406)
</span><span class="lines">@@ -0,0 +1,73 @@
</span><ins>+/*
+ * 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
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <wtf/Assertions.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+class URL;
+
+class UserAgentQuirks {
+public:
+ enum UserAgentQuirk {
+ NeedsChromeBrowser,
+ NeedsMacintoshPlatform,
+
+ NumUserAgentQuirks
+ };
+
+ UserAgentQuirks()
+ : m_quirks(0)
+ {
+ COMPILE_ASSERT(sizeof(m_quirks) * 8 >= NumUserAgentQuirks, not_enough_room_for_quirks);
+ }
+
+ void add(UserAgentQuirk quirk)
+ {
+ ASSERT(quirk >= 0);
+ ASSERT_WITH_SECURITY_IMPLICATION(quirk < NumUserAgentQuirks);
+
+ m_quirks |= (1 << quirk);
+ }
+
+ bool contains(UserAgentQuirk quirk) const
+ {
+ return m_quirks & (1 << quirk);
+ }
+
+ bool isEmpty() const { return !m_quirks; }
+
+ static UserAgentQuirks quirksForURL(const URL&);
+
+ static String stringForQuirk(UserAgentQuirk);
+
+private:
+ uint32_t m_quirks;
+};
+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformeflUserAgentEflcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/efl/UserAgentEfl.cpp (207405 => 207406)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/efl/UserAgentEfl.cpp        2016-10-17 10:52:02 UTC (rev 207405)
+++ trunk/Source/WebCore/platform/efl/UserAgentEfl.cpp        2016-10-17 11:30:17 UTC (rev 207406)
</span><span class="lines">@@ -24,7 +24,7 @@
</span><span class="cx"> */
</span><span class="cx">
</span><span class="cx"> #include "config.h"
</span><del>-#include "UserAgentEfl.h"
</del><ins>+#include "UserAgent.h"
</ins><span class="cx">
</span><span class="cx"> #include <wtf/NeverDestroyed.h>
</span><span class="cx">
</span><span class="lines">@@ -75,5 +75,11 @@
</span><span class="cx"> return standardUserAgentString + ' ' + applicationName + '/' + finalApplicationVersion;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+String standardUserAgentForURL(const URL&)
+{
+ // Disable user agent quirks for now.
+ return String();
+}
+
</ins><span class="cx"> } // namespace WebCore
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformeflUserAgentEflh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/efl/UserAgentEfl.h (207405 => 207406)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/efl/UserAgentEfl.h        2016-10-17 10:52:02 UTC (rev 207405)
+++ trunk/Source/WebCore/platform/efl/UserAgentEfl.h        2016-10-17 11:30:17 UTC (rev 207406)
</span><span class="lines">@@ -1,38 +0,0 @@
</span><del>-/*
- * Copyright (C) 2015 Naver Corp. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef UserAgentEfl_h
-#define UserAgentEfl_h
-
-#include <wtf/text/WTFString.h>
-
-namespace WebCore {
-
-String standardUserAgent(const String& applicationName = emptyString(), const String& applicationVersion = emptyString());
-
-}
-
-#endif // UserAgentEfl_h
-
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformgtkUserAgentGtkcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/gtk/UserAgentGtk.cpp (207405 => 207406)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/gtk/UserAgentGtk.cpp        2016-10-17 10:52:02 UTC (rev 207405)
+++ trunk/Source/WebCore/platform/gtk/UserAgentGtk.cpp        2016-10-17 11:30:17 UTC (rev 207406)
</span><span class="lines">@@ -24,10 +24,10 @@
</span><span class="cx"> */
</span><span class="cx">
</span><span class="cx"> #include "config.h"
</span><del>-#include "UserAgentGtk.h"
</del><ins>+#include "UserAgent.h"
</ins><span class="cx">
</span><del>-#include "PublicSuffix.h"
</del><span class="cx"> #include "URL.h"
</span><ins>+#include "UserAgentQuirks.h"
</ins><span class="cx"> #include <wtf/NeverDestroyed.h>
</span><span class="cx"> #include <wtf/text/StringBuilder.h>
</span><span class="cx">
</span><span class="lines">@@ -43,40 +43,6 @@
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><del>-class UserAgentQuirks {
-public:
- enum UserAgentQuirk {
- NeedsChromeBrowser,
- NeedsMacintoshPlatform,
-
- NumUserAgentQuirks
- };
-
- UserAgentQuirks()
- : m_quirks(0)
- {
- COMPILE_ASSERT(sizeof(m_quirks) * 8 >= NumUserAgentQuirks, not_enough_room_for_quirks);
- }
-
- void add(UserAgentQuirk quirk)
- {
- ASSERT(quirk >= 0);
- ASSERT_WITH_SECURITY_IMPLICATION(quirk < NumUserAgentQuirks);
-
- m_quirks |= (1 << quirk);
- }
-
- bool contains(UserAgentQuirk quirk) const
- {
- return m_quirks & (1 << quirk);
- }
-
- bool isEmpty() const { return !m_quirks; }
-
-private:
- uint32_t m_quirks;
-};
-
</del><span class="cx"> static const char* platformForUAString()
</span><span class="cx"> {
</span><span class="cx"> #if OS(MAC_OS_X)
</span><span class="lines">@@ -115,16 +81,12 @@
</span><span class="cx"> uaString.append('(');
</span><span class="cx">
</span><span class="cx"> if (quirks.contains(UserAgentQuirks::NeedsMacintoshPlatform))
</span><del>- uaString.appendLiteral("Macintosh");
- else
</del><ins>+ uaString.append(UserAgentQuirks::stringForQuirk(UserAgentQuirks::NeedsMacintoshPlatform));
+ else {
</ins><span class="cx"> uaString.append(platformForUAString());
</span><del>-
- uaString.appendLiteral("; ");
-
- if (quirks.contains(UserAgentQuirks::NeedsMacintoshPlatform))
- uaString.appendLiteral("Intel Mac OS X 10_12");
- else
</del><ins>+ uaString.appendLiteral("; ");
</ins><span class="cx"> uaString.append(platformVersionForUAString());
</span><ins>+ }
</ins><span class="cx">
</span><span class="cx"> uaString.appendLiteral(") AppleWebKit/");
</span><span class="cx"> uaString.append(versionForUAString());
</span><span class="lines">@@ -131,9 +93,10 @@
</span><span class="cx"> uaString.appendLiteral(" (KHTML, like Gecko) ");
</span><span class="cx">
</span><span class="cx"> // Note that Chrome UAs advertise *both* Chrome and Safari.
</span><del>- // We set a meaningful value only for the first two digits here.
- if (quirks.contains(UserAgentQuirks::NeedsChromeBrowser))
- uaString.append("Chrome/54.0.2704.106 ");
</del><ins>+ if (quirks.contains(UserAgentQuirks::NeedsChromeBrowser)) {
+ uaString.append(UserAgentQuirks::stringForQuirk(UserAgentQuirks::NeedsChromeBrowser));
+ uaString.appendLiteral(" ");
+ }
</ins><span class="cx">
</span><span class="cx"> // Version/X is mandatory *before* Safari/X to be a valid Safari UA. See
</span><span class="cx"> // https://bugs.webkit.org/show_bug.cgi?id=133403 for details.
</span><span class="lines">@@ -169,58 +132,9 @@
</span><span class="cx"> return standardUserAgentStatic() + ' ' + applicationName + '/' + finalApplicationVersion;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-// Be careful with this quirk: it's an invitation for sites to use JavaScript we can't handle.
-static bool urlRequiresChromeBrowser(const URL& url)
-{
- String baseDomain = topPrivatelyControlledDomain(url.host());
-
- // Needed for fonts on many sites, https://bugs.webkit.org/show_bug.cgi?id=147296
- if (baseDomain == "typekit.net" || baseDomain == "typekit.com")
- return true;
-
- // Shut off Chrome ads. Avoid missing features on maps.google.com.
- if (baseDomain.startsWith("google"))
- return true;
-
- // Needed for YouTube 360 (requires ENABLE_MEDIA_SOURCE).
- if (baseDomain == "youtube.com")
- return true;
-
- // Slack completely blocks users with our standard user agent.
- if (baseDomain == "slack.com")
- return true;
-
- return false;
-}
-
-static bool urlRequiresMacintoshPlatform(const URL& url)
-{
- String baseDomain = topPrivatelyControlledDomain(url.host());
-
- // At least finance.yahoo.com displays a mobile version with our standard user agent.
- if (baseDomain == "yahoo.com")
- return true;
-
- // taobao.com displays a mobile version with our standard user agent.
- if (baseDomain == "taobao.com")
- return true;
-
- // web.whatsapp.com completely blocks users with our standard user agent.
- if (baseDomain == "whatsapp.com")
- return true;
-
- return false;
-}
-
</del><span class="cx"> String standardUserAgentForURL(const URL& url)
</span><span class="cx"> {
</span><del>- ASSERT(!url.isNull());
- UserAgentQuirks quirks;
- if (urlRequiresChromeBrowser(url))
- quirks.add(UserAgentQuirks::NeedsChromeBrowser);
- if (urlRequiresMacintoshPlatform(url))
- quirks.add(UserAgentQuirks::NeedsMacintoshPlatform);
-
</del><ins>+ auto quirks = UserAgentQuirks::quirksForURL(url);
</ins><span class="cx"> // The null string means we don't need a specific UA for the given URL.
</span><span class="cx"> return quirks.isEmpty() ? String() : buildUserAgentString(quirks);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgtkUserAgentGtkh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/gtk/UserAgentGtk.h (207405 => 207406)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/gtk/UserAgentGtk.h        2016-10-17 10:52:02 UTC (rev 207405)
+++ trunk/Source/WebCore/platform/gtk/UserAgentGtk.h        2016-10-17 11:30:17 UTC (rev 207406)
</span><span class="lines">@@ -1,40 +0,0 @@
</span><del>-/*
- * Copyright (C) 2012, 2014 Igalia S.L.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef UserAgentGtk_h
-#define UserAgentGtk_h
-
-#include <wtf/text/WTFString.h>
-
-namespace WebCore {
-class URL;
-
-String standardUserAgent(const String& applicationName = emptyString(), const String& applicationVersion = emptyString());
-String standardUserAgentForURL(const URL&);
-
-}
-
-#endif // UserAgentGtk_h
-
</del></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (207405 => 207406)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-10-17 10:52:02 UTC (rev 207405)
+++ trunk/Source/WebKit2/ChangeLog        2016-10-17 11:30:17 UTC (rev 207406)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2016-10-17 Michael Catanzaro <mcatanzaro@igalia.com>
+
+ Move user agent quirks to cross-platform location
+ https://bugs.webkit.org/show_bug.cgi?id=163508
+
+ Reviewed by Carlos Garcia Campos.
+
+ #include <WebCore/UserAgent.h> instead of <WebCore/UserAgentGtk.h>.
+
+ * UIProcess/API/gtk/WebKitSettings.cpp:
+ * UIProcess/efl/WebPageProxyEfl.cpp:
+ * UIProcess/gtk/WebPageProxyGtk.cpp:
+ * WebProcess/WebPage/gtk/WebPageGtk.cpp:
+
</ins><span class="cx"> 2016-10-17 Carlos Garcia Campos <cgarcia@igalia.com>
</span><span class="cx">
</span><span class="cx"> [SOUP] Downloads should always sniff contents
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkWebKitSettingscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp (207405 => 207406)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp        2016-10-17 10:52:02 UTC (rev 207405)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp        2016-10-17 11:30:17 UTC (rev 207406)
</span><span class="lines">@@ -36,7 +36,7 @@
</span><span class="cx"> #include "WebKitSettingsPrivate.h"
</span><span class="cx"> #include "WebPageProxy.h"
</span><span class="cx"> #include "WebPreferences.h"
</span><del>-#include <WebCore/UserAgentGtk.h>
</del><ins>+#include <WebCore/UserAgent.h>
</ins><span class="cx"> #include <glib/gi18n-lib.h>
</span><span class="cx"> #include <wtf/text/CString.h>
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcesseflWebPageProxyEflcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/efl/WebPageProxyEfl.cpp (207405 => 207406)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/efl/WebPageProxyEfl.cpp        2016-10-17 10:52:02 UTC (rev 207405)
+++ trunk/Source/WebKit2/UIProcess/efl/WebPageProxyEfl.cpp        2016-10-17 11:30:17 UTC (rev 207406)
</span><span class="lines">@@ -29,7 +29,7 @@
</span><span class="cx"> #include "EwkView.h"
</span><span class="cx"> #include "NativeWebKeyboardEvent.h"
</span><span class="cx"> #include "NotImplemented.h"
</span><del>-#include "UserAgentEfl.h"
</del><ins>+#include "UserAgent.h"
</ins><span class="cx"> #include "WebPageMessages.h"
</span><span class="cx"> #include "WebProcessProxy.h"
</span><span class="cx"> #include "WebView.h"
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessgtkWebPageProxyGtkcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/gtk/WebPageProxyGtk.cpp (207405 => 207406)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/gtk/WebPageProxyGtk.cpp        2016-10-17 10:52:02 UTC (rev 207405)
+++ trunk/Source/WebKit2/UIProcess/gtk/WebPageProxyGtk.cpp        2016-10-17 11:30:17 UTC (rev 207406)
</span><span class="lines">@@ -34,7 +34,7 @@
</span><span class="cx"> #include "WebPasteboardProxy.h"
</span><span class="cx"> #include "WebProcessProxy.h"
</span><span class="cx"> #include "WebsiteDataStore.h"
</span><del>-#include <WebCore/UserAgentGtk.h>
</del><ins>+#include <WebCore/UserAgent.h>
</ins><span class="cx"> #include <gtk/gtkx.h>
</span><span class="cx"> #include <wtf/NeverDestroyed.h>
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPagegtkWebPageGtkcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/gtk/WebPageGtk.cpp (207405 => 207406)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/gtk/WebPageGtk.cpp        2016-10-17 10:52:02 UTC (rev 207405)
+++ trunk/Source/WebKit2/WebProcess/WebPage/gtk/WebPageGtk.cpp        2016-10-17 11:30:17 UTC (rev 207406)
</span><span class="lines">@@ -46,7 +46,7 @@
</span><span class="cx"> #include <WebCore/PasteboardHelper.h>
</span><span class="cx"> #include <WebCore/PlatformKeyboardEvent.h>
</span><span class="cx"> #include <WebCore/Settings.h>
</span><del>-#include <WebCore/UserAgentGtk.h>
</del><ins>+#include <WebCore/UserAgent.h>
</ins><span class="cx"> #include <wtf/glib/GUniquePtr.h>
</span><span class="cx">
</span><span class="cx"> using namespace WebCore;
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (207405 => 207406)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2016-10-17 10:52:02 UTC (rev 207405)
+++ trunk/Tools/ChangeLog        2016-10-17 11:30:17 UTC (rev 207406)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2016-10-17 Michael Catanzaro <mcatanzaro@igalia.com>
+
+ Move user agent quirks to cross-platform location
+ https://bugs.webkit.org/show_bug.cgi?id=163508
+
+ Reviewed by Carlos Garcia Campos.
+
+ Move the test to a cross-platform location and improve it to better check the full list of
+ sites we have defined quirks for.
+
+ * TestWebKitAPI/PlatformGTK.cmake:
+ * TestWebKitAPI/Tests/WebCore/UserAgentQuirks.cpp: Renamed from Tools/TestWebKitAPI/Tests/WebCore/gtk/UserAgentQuirks.cpp.
+ (TestWebKitAPI::assertUserAgentForURLHasChromeBrowserQuirk):
+ (TestWebKitAPI::assertUserAgentForURLHasMacPlatformQuirk):
+ (TestWebKitAPI::TEST):
+
</ins><span class="cx"> 2016-10-17 Carlos Garcia Campos <cgarcia@igalia.com>
</span><span class="cx">
</span><span class="cx"> [SOUP] Downloads should always sniff contents
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPIPlatformGTKcmake"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/PlatformGTK.cmake (207405 => 207406)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/PlatformGTK.cmake        2016-10-17 10:52:02 UTC (rev 207405)
+++ trunk/Tools/TestWebKitAPI/PlatformGTK.cmake        2016-10-17 11:30:17 UTC (rev 207406)
</span><span class="lines">@@ -125,21 +125,17 @@
</span><span class="cx"> set_tests_properties(TestWebKit2 PROPERTIES TIMEOUT 60)
</span><span class="cx"> set_target_properties(TestWebKit2 PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${TESTWEBKITAPI_RUNTIME_OUTPUT_DIRECTORY}/WebKit2)
</span><span class="cx">
</span><del>-set(TestWebCoreGtk_SOURCES
- ${TESTWEBKITAPI_DIR}/Tests/WebCore/gtk/UserAgentQuirks.cpp
-)
-
</del><span class="cx"> add_executable(TestWebCore
</span><span class="cx"> ${test_main_SOURCES}
</span><del>- ${TestWebCoreGtk_SOURCES}
</del><span class="cx"> ${TESTWEBKITAPI_DIR}/TestsController.cpp
</span><ins>+ ${TESTWEBKITAPI_DIR}/Tests/WebCore/FileSystem.cpp
</ins><span class="cx"> ${TESTWEBKITAPI_DIR}/Tests/WebCore/HTMLParserIdioms.cpp
</span><span class="cx"> ${TESTWEBKITAPI_DIR}/Tests/WebCore/LayoutUnit.cpp
</span><ins>+ ${TESTWEBKITAPI_DIR}/Tests/WebCore/PublicSuffix.cpp
+ ${TESTWEBKITAPI_DIR}/Tests/WebCore/SharedBuffer.cpp
</ins><span class="cx"> ${TESTWEBKITAPI_DIR}/Tests/WebCore/URL.cpp
</span><span class="cx"> ${TESTWEBKITAPI_DIR}/Tests/WebCore/URLParser.cpp
</span><del>- ${TESTWEBKITAPI_DIR}/Tests/WebCore/SharedBuffer.cpp
- ${TESTWEBKITAPI_DIR}/Tests/WebCore/FileSystem.cpp
- ${TESTWEBKITAPI_DIR}/Tests/WebCore/PublicSuffix.cpp
</del><ins>+ ${TESTWEBKITAPI_DIR}/Tests/WebCore/UserAgentQuirks.cpp
</ins><span class="cx"> )
</span><span class="cx">
</span><span class="cx"> target_link_libraries(TestWebCore ${test_webcore_LIBRARIES})
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebCoreUserAgentQuirkscppfromrev207405trunkToolsTestWebKitAPITestsWebCoregtkUserAgentQuirkscpp"></a>
<div class="copfile"><h4>Copied: trunk/Tools/TestWebKitAPI/Tests/WebCore/UserAgentQuirks.cpp (from rev 207405, trunk/Tools/TestWebKitAPI/Tests/WebCore/gtk/UserAgentQuirks.cpp) (0 => 207406)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebCore/UserAgentQuirks.cpp         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/UserAgentQuirks.cpp        2016-10-17 11:30:17 UTC (rev 207406)
</span><span class="lines">@@ -0,0 +1,93 @@
</span><ins>+/*
+ * Copyright (C) 2014 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#include <WebCore/URL.h>
+#include <WebCore/UserAgent.h>
+
+using namespace WebCore;
+
+namespace TestWebKitAPI {
+
+static void assertUserAgentForURLHasChromeBrowserQuirk(const char* url)
+{
+ String uaString = standardUserAgentForURL(URL(ParsedURLString, url));
+
+#if !OS(MAC_OS_X)
+ EXPECT_FALSE(uaString.contains("Macintosh"));
+ EXPECT_FALSE(uaString.contains("Mac OS X"));
+#endif
+#if OS(LINUX)
+ EXPECT_TRUE(uaString.contains("Linux"));
+#endif
+#if OS(WINDOWS)
+ EXPECT_TRUE(uaString.contains("Windows"));
+#endif
+
+ EXPECT_TRUE(uaString.contains("Chrome"));
+ EXPECT_TRUE(uaString.contains("Safari"));
+ EXPECT_FALSE(uaString.contains("Chromium"));
+}
+
+static void assertUserAgentForURLHasMacPlatformQuirk(const char* url)
+{
+ String uaString = standardUserAgentForURL(URL(ParsedURLString, url));
+
+ EXPECT_TRUE(uaString.contains("Macintosh"));
+ EXPECT_TRUE(uaString.contains("Mac OS X"));
+ EXPECT_FALSE(uaString.contains("Linux"));
+ EXPECT_FALSE(uaString.contains("Windows"));
+ EXPECT_FALSE(uaString.contains("Chrome"));
+}
+
+TEST(UserAgentTest, Quirks)
+{
+ // A site with not quirks should return a null String.
+ String uaString = standardUserAgentForURL(URL(ParsedURLString, "http://www.webkit.org/"));
+ EXPECT_TRUE(uaString.isNull());
+
+ // Google quirk should not affect sites with similar domains.
+ uaString = standardUserAgentForURL(URL(ParsedURLString, "http://www.googleblog.com/"));
+ EXPECT_FALSE(uaString.contains("Chrome"));
+
+ assertUserAgentForURLHasChromeBrowserQuirk("http://typekit.com/");
+ assertUserAgentForURLHasChromeBrowserQuirk("http://typekit.net/");
+ assertUserAgentForURLHasChromeBrowserQuirk("http://www.google.com/");
+ assertUserAgentForURLHasChromeBrowserQuirk("http://www.google.es/");
+ assertUserAgentForURLHasChromeBrowserQuirk("http://calendar.google.com/");
+ assertUserAgentForURLHasChromeBrowserQuirk("http://maps.google.com/");
+ assertUserAgentForURLHasChromeBrowserQuirk("http://plus.google.com/");
+ assertUserAgentForURLHasChromeBrowserQuirk("http://www.youtube.com/");
+ assertUserAgentForURLHasChromeBrowserQuirk("http://www.slack.com/");
+
+ assertUserAgentForURLHasMacPlatformQuirk("http://www.yahoo.com/");
+ assertUserAgentForURLHasMacPlatformQuirk("http://finance.yahoo.com/");
+ assertUserAgentForURLHasMacPlatformQuirk("http://intl.taobao.com/");
+ assertUserAgentForURLHasMacPlatformQuirk("http://www.whatsapp.com/");
+ assertUserAgentForURLHasMacPlatformQuirk("http://web.whatsapp.com/");
+}
+
+} // namespace TestWebKitAPI
</ins></span></pre>
</div>
</div>
</body>
</html>