Title: [170636] releases/WebKitGTK/webkit-2.4
Revision
170636
Author
[email protected]
Date
2014-07-01 05:07:08 -0700 (Tue, 01 Jul 2014)

Log Message

Merge r169799 - [GTK] Use a different user agent string depending on the site
https://bugs.webkit.org/show_bug.cgi?id=132681

Reviewed by Anders Carlsson.

Source/WebCore:
We have changed the user agent string several times to try to fix
broken websites that require specific things in the UA string to
properly work. But everytime we change the UA string to fix a
website we break others. We could use different UA string
depending on the website. UserAgentGtk code has also been cleaned
up, using NeverDestroyed instead of DEPRECATED_DEFINE_STATIC_LOCAL
and avoiding unneeded conversions to UTF-8.

* platform/gtk/UserAgentGtk.cpp:
(WebCore::UserAgentQuirks::UserAgentQuirks): New helper private
class to handle user agent quirks.
(WebCore::UserAgentQuirks::add):
(WebCore::UserAgentQuirks::contains):
(WebCore::UserAgentQuirks::isEmpty):
(WebCore::platformForUAString): Bring back this method that was
removed to always pretend to be Macintosh.
(WebCore::platformVersionForUAString): Return a different platform
version depending on the actual platform.
(WebCore::versionForUAString): Return the WebKit version.
(WebCore::buildUserAgentString): Helper function to build the user
agent taking into account the UserAgentQuirks received.
(WebCore::standardUserAgentStatic): Standard user agent string
when no quirks are present.
(WebCore::standardUserAgent):
(WebCore::standardUserAgentForURL): New method that returns the
user agent string for the given URL.
* platform/gtk/UserAgentGtk.h:

Source/WebKit2:
* UIProcess/API/gtk/WebKitSettings.cpp:
(webkit_settings_class_init): Enable site specific quirks setting
by default.
* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::userAgent): Pass the given URL to WebPage.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::userAgent): Try to get the user agent for the
URL received falling back to the current one otherwise.
* WebProcess/WebPage/WebPage.h:
(WebKit::WebPage::platformUserAgent): Added.
* WebProcess/WebPage/efl/WebPageEfl.cpp:
(WebKit::WebPage::platformUserAgent): Return null String.
* WebProcess/WebPage/gtk/WebPageGtk.cpp:
(WebKit::WebPage::platformUserAgent): Use WebCore::standardUserAgentForURL() when site specific quirks
setting is enabled.
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::platformUserAgent): Return null String.
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::platformUserAgent): Return null String.

Tools:
Add a unit test to check user agent quirks.

* TestWebKitAPI/PlatformGTK.cmake:
* TestWebKitAPI/Tests/WebCore/gtk/UserAgentQuirks.cpp: Added.
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitSettings.cpp:
(testWebKitSettings): Site specific quirks setting is now enabled
by default.

Modified Paths

Added Paths

Diff

Modified: releases/WebKitGTK/webkit-2.4/Source/WebCore/ChangeLog (170635 => 170636)


--- releases/WebKitGTK/webkit-2.4/Source/WebCore/ChangeLog	2014-07-01 11:32:36 UTC (rev 170635)
+++ releases/WebKitGTK/webkit-2.4/Source/WebCore/ChangeLog	2014-07-01 12:07:08 UTC (rev 170636)
@@ -1,3 +1,38 @@
+2014-06-11  Carlos Garcia Campos  <[email protected]>
+
+        [GTK] Use a different user agent string depending on the site
+        https://bugs.webkit.org/show_bug.cgi?id=132681
+
+        Reviewed by Anders Carlsson.
+
+        We have changed the user agent string several times to try to fix
+        broken websites that require specific things in the UA string to
+        properly work. But everytime we change the UA string to fix a
+        website we break others. We could use different UA string
+        depending on the website. UserAgentGtk code has also been cleaned
+        up, using NeverDestroyed instead of DEPRECATED_DEFINE_STATIC_LOCAL
+        and avoiding unneeded conversions to UTF-8.
+
+        * platform/gtk/UserAgentGtk.cpp:
+        (WebCore::UserAgentQuirks::UserAgentQuirks): New helper private
+        class to handle user agent quirks.
+        (WebCore::UserAgentQuirks::add):
+        (WebCore::UserAgentQuirks::contains):
+        (WebCore::UserAgentQuirks::isEmpty):
+        (WebCore::platformForUAString): Bring back this method that was
+        removed to always pretend to be Macintosh.
+        (WebCore::platformVersionForUAString): Return a different platform
+        version depending on the actual platform.
+        (WebCore::versionForUAString): Return the WebKit version.
+        (WebCore::buildUserAgentString): Helper function to build the user
+        agent taking into account the UserAgentQuirks received.
+        (WebCore::standardUserAgentStatic): Standard user agent string
+        when no quirks are present.
+        (WebCore::standardUserAgent):
+        (WebCore::standardUserAgentForURL): New method that returns the
+        user agent string for the given URL.
+        * platform/gtk/UserAgentGtk.h:
+
 2014-06-13  Sergio Villar Senin  <[email protected]>
 
         [Gtk] [Stable] Fix the "Safari" part of the UA

Modified: releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/gtk/UserAgentGtk.cpp (170635 => 170636)


--- releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/gtk/UserAgentGtk.cpp	2014-07-01 11:32:36 UTC (rev 170635)
+++ releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/gtk/UserAgentGtk.cpp	2014-07-01 12:07:08 UTC (rev 170636)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 Igalia S.L.
+ * 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
@@ -26,7 +26,9 @@
 #include "config.h"
 #include "UserAgentGtk.h"
 
-#include <glib.h>
+#include "URL.h"
+#include <wtf/NeverDestroyed.h>
+#include <wtf/text/StringBuilder.h>
 
 #if OS(UNIX)
 #include <sys/utsname.h>
@@ -34,6 +36,39 @@
 
 namespace WebCore {
 
+class UserAgentQuirks {
+public:
+    enum UserAgentQuirk {
+        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;
+};
+
 static const char* cpuDescriptionForUAString()
 {
 #if CPU(PPC) || CPU(PPC64)
@@ -47,18 +82,76 @@
 #endif
 }
 
-static String platformVersionForUAString()
+static const char* platformForUAString()
 {
-    DEFINE_STATIC_LOCAL(String, uaOSVersion, (String()));
-    if (!uaOSVersion.isEmpty())
-        return uaOSVersion;
+#if PLATFORM(X11)
+    return "X11";
+#elif OS(WINDOWS)
+    return "";
+#elif PLATFORM(MAC)
+    return "Macintosh";
+#elif defined(GDK_WINDOWING_DIRECTFB)
+    return "DirectFB";
+#else
+    return "Unknown";
+#endif
+}
 
-    // We will always claim to be Safari in Mac OS X, since Safari in Linux triggers the iOS path on
-    // some websites.
-    uaOSVersion = String::format("%s Mac OS X", cpuDescriptionForUAString());
+static const String platformVersionForUAString()
+{
+#if OS(UNIX)
+    struct utsname name;
+    uname(&name);
+    static NeverDestroyed<const String> uaOSVersion(String::format("%s %s", name.sysname, name.machine));
     return uaOSVersion;
+#else
+    // We will always claim to be Safari in Mac OS X, since Safari in Linux triggers the iOS path on some websites.
+    static NeverDestroyed<const String> uaOSVersion(String::format("%s Mac OS X", cpuDescriptionForUAString()));
+    return uaOSVersion;
+#endif
 }
 
+static const String versionForUAString()
+{
+    static NeverDestroyed<const String> uaVersion(String::format("%i.%i", USER_AGENT_GTK_MAJOR_VERSION, USER_AGENT_GTK_MINOR_VERSION));
+    return uaVersion;
+}
+
+static String buildUserAgentString(const UserAgentQuirks& quirks)
+{
+    StringBuilder uaString;
+    uaString.appendLiteral("Mozilla/5.0 ");
+    uaString.append('(');
+
+    if (quirks.contains(UserAgentQuirks::NeedsMacintoshPlatform))
+        uaString.appendLiteral("Macintosh");
+    else
+        uaString.append(platformForUAString());
+
+    uaString.appendLiteral("; ");
+
+    if (quirks.contains(UserAgentQuirks::NeedsMacintoshPlatform)) {
+        uaString.append(cpuDescriptionForUAString());
+        uaString.appendLiteral(" Mac OS X");
+    } else
+        uaString.append(platformVersionForUAString());
+
+    uaString.appendLiteral(") AppleWebKit/");
+    uaString.append(versionForUAString());
+    // 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(" (KHTML, like Gecko) Version/8.0 Safari/");
+    uaString.append(versionForUAString());
+
+    return uaString.toString();
+}
+
+static const String standardUserAgentStatic()
+{
+    static NeverDestroyed<const String> uaStatic(buildUserAgentString(UserAgentQuirks()));
+    return uaStatic;
+}
+
 String standardUserAgent(const String& applicationName, const String& applicationVersion)
 {
     // Create a default user agent string with a liberal interpretation of
@@ -69,19 +162,29 @@
     // browsers that are "Safari" but not running on OS X are the Safari iOS browse. Getting this
     // wrong can cause sites to load the wrong _javascript_, CSS, or custom fonts. In some cases
     // sites won't load resources at all.
-    DEFINE_STATIC_LOCAL(const CString, uaVersion, (String::format("%i.%i", USER_AGENT_GTK_MAJOR_VERSION, USER_AGENT_GTK_MINOR_VERSION).utf8()));
-    DEFINE_STATIC_LOCAL(const String, staticUA, (String::format("Mozilla/5.0 (Macintosh; %s) AppleWebKit/%s (KHTML, like Gecko) Version/8.0 Safari/%s",
-        platformVersionForUAString().utf8().data(), uaVersion.data(), uaVersion.data())));
-
     if (applicationName.isEmpty())
-        return staticUA;
+        return standardUserAgentStatic();
 
     String finalApplicationVersion = applicationVersion;
     if (finalApplicationVersion.isEmpty())
-        finalApplicationVersion = uaVersion.data();
+        finalApplicationVersion = versionForUAString();
 
-    return String::format("%s %s/%s", staticUA.utf8().data(), applicationName.utf8().data(), finalApplicationVersion.utf8().data());
+    return standardUserAgentStatic() + ' ' + applicationName + '/' + finalApplicationVersion;
 }
 
+String standardUserAgentForURL(const URL& url)
+{
+    ASSERT(!url.isNull());
+    UserAgentQuirks quirks;
+    if (url.host().endsWith(".yahoo.com")) {
+        // www.yahoo.com redirects to the mobile version when Linux is present in the UA,
+        // use always Macintosh as platform. See https://bugs.webkit.org/show_bug.cgi?id=125444.
+        quirks.add(UserAgentQuirks::NeedsMacintoshPlatform);
+    }
+
+    // The null string means we don't need a specific UA for the given URL.
+    return quirks.isEmpty() ? String() : buildUserAgentString(quirks);
+}
+
 } // namespace WebCore
 

Modified: releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/gtk/UserAgentGtk.h (170635 => 170636)


--- releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/gtk/UserAgentGtk.h	2014-07-01 11:32:36 UTC (rev 170635)
+++ releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/gtk/UserAgentGtk.h	2014-07-01 12:07:08 UTC (rev 170636)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 Igalia S.L.
+ * 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
@@ -26,12 +26,13 @@
 #ifndef UserAgentGtk_h
 #define UserAgentGtk_h
 
-#include <wtf/text/CString.h>
 #include <wtf/text/WTFString.h>
 
 namespace WebCore {
+class URL;
 
-String standardUserAgent(const String& applicationName = "", const String& applicationVersion = "");
+String standardUserAgent(const String& applicationName = emptyString(), const String& applicationVersion = emptyString());
+String standardUserAgentForURL(const URL&);
 
 }
 

Modified: releases/WebKitGTK/webkit-2.4/Source/WebKit2/ChangeLog (170635 => 170636)


--- releases/WebKitGTK/webkit-2.4/Source/WebKit2/ChangeLog	2014-07-01 11:32:36 UTC (rev 170635)
+++ releases/WebKitGTK/webkit-2.4/Source/WebKit2/ChangeLog	2014-07-01 12:07:08 UTC (rev 170636)
@@ -1,3 +1,30 @@
+2014-06-11  Carlos Garcia Campos  <[email protected]>
+
+        [GTK] Use a different user agent string depending on the site
+        https://bugs.webkit.org/show_bug.cgi?id=132681
+
+        Reviewed by Anders Carlsson.
+
+        * UIProcess/API/gtk/WebKitSettings.cpp:
+        (webkit_settings_class_init): Enable site specific quirks setting
+        by default.
+        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+        (WebKit::WebFrameLoaderClient::userAgent): Pass the given URL to WebPage.
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::userAgent): Try to get the user agent for the
+        URL received falling back to the current one otherwise.
+        * WebProcess/WebPage/WebPage.h:
+        (WebKit::WebPage::platformUserAgent): Added.
+        * WebProcess/WebPage/efl/WebPageEfl.cpp:
+        (WebKit::WebPage::platformUserAgent): Return null String.
+        * WebProcess/WebPage/gtk/WebPageGtk.cpp:
+        (WebKit::WebPage::platformUserAgent): Use WebCore::standardUserAgentForURL() when site specific quirks
+        setting is enabled.
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::platformUserAgent): Return null String.
+        * WebProcess/WebPage/mac/WebPageMac.mm:
+        (WebKit::WebPage::platformUserAgent): Return null String.
+
 2014-05-26  Carlos Garcia Campos  <[email protected]>
 
         [GTK] WebProcess leaked when closing pages with network process enabled

Modified: releases/WebKitGTK/webkit-2.4/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp (170635 => 170636)


--- releases/WebKitGTK/webkit-2.4/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp	2014-07-01 11:32:36 UTC (rev 170635)
+++ releases/WebKitGTK/webkit-2.4/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp	2014-07-01 12:07:08 UTC (rev 170636)
@@ -1064,13 +1064,15 @@
      * workarounds. By turning on site-specific quirks, WebKit will
      * special-case this and other cases to make some specific sites work.
      */
-    g_object_class_install_property(gObjectClass,
-                                    PROP_ENABLE_SITE_SPECIFIC_QUIRKS,
-                                    g_param_spec_boolean("enable-site-specific-quirks",
-                                                         _("Enable Site Specific Quirks"),
-                                                         _("Enables the site-specific compatibility workarounds"),
-                                                         FALSE,
-                                                         readWriteConstructParamFlags));
+    g_object_class_install_property(
+        gObjectClass,
+        PROP_ENABLE_SITE_SPECIFIC_QUIRKS,
+        g_param_spec_boolean(
+            "enable-site-specific-quirks",
+            _("Enable Site Specific Quirks"),
+            _("Enables the site-specific compatibility workarounds"),
+            TRUE,
+            readWriteConstructParamFlags));
 
     /**
      * WebKitSettings:enable-page-cache:

Modified: releases/WebKitGTK/webkit-2.4/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp (170635 => 170636)


--- releases/WebKitGTK/webkit-2.4/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp	2014-07-01 11:32:36 UTC (rev 170635)
+++ releases/WebKitGTK/webkit-2.4/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp	2014-07-01 12:07:08 UTC (rev 170636)
@@ -1146,13 +1146,13 @@
         title.string(), url.string(), m_frame->frameID()), 0);
 }
 
-String WebFrameLoaderClient::userAgent(const URL&)
+String WebFrameLoaderClient::userAgent(const URL& url)
 {
     WebPage* webPage = m_frame->page();
     if (!webPage)
         return String();
 
-    return webPage->userAgent();
+    return webPage->userAgent(url);
 }
 
 void WebFrameLoaderClient::savePlatformDataToCachedFrame(CachedFrame*)

Modified: releases/WebKitGTK/webkit-2.4/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (170635 => 170636)


--- releases/WebKitGTK/webkit-2.4/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2014-07-01 11:32:36 UTC (rev 170635)
+++ releases/WebKitGTK/webkit-2.4/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2014-07-01 12:07:08 UTC (rev 170636)
@@ -2169,6 +2169,15 @@
     m_userAgent = userAgent;
 }
 
+String WebPage::userAgent(const URL& url) const
+{
+    String userAgent = platformUserAgent(url);
+    if (!userAgent.isEmpty())
+        return userAgent;
+
+    return m_userAgent;
+}
+
 void WebPage::suspendActiveDOMObjectsAndAnimations()
 {
     m_page->suspendActiveDOMObjectsAndAnimations();

Modified: releases/WebKitGTK/webkit-2.4/Source/WebKit2/WebProcess/WebPage/WebPage.h (170635 => 170636)


--- releases/WebKitGTK/webkit-2.4/Source/WebKit2/WebProcess/WebPage/WebPage.h	2014-07-01 11:32:36 UTC (rev 170635)
+++ releases/WebKitGTK/webkit-2.4/Source/WebKit2/WebProcess/WebPage/WebPage.h	2014-07-01 12:07:08 UTC (rev 170636)
@@ -124,6 +124,7 @@
     class SharedBuffer;
     class SubstituteData;
     class TextCheckingRequest;
+    class URL;
     class VisibleSelection;
     struct KeypressCommand;
     struct TextCheckingResult;
@@ -227,7 +228,8 @@
     void didCommitLoad(WebFrame*);
     void didFinishLoad(WebFrame*);
     void show();
-    String userAgent() const { return m_userAgent; }
+    String userAgent(const WebCore::URL&) const;
+    String platformUserAgent(const WebCore::URL&) const;
     WebCore::IntRect windowResizerRect() const;
     WebCore::KeyboardUIMode keyboardUIMode();
 

Modified: releases/WebKitGTK/webkit-2.4/Source/WebKit2/WebProcess/WebPage/efl/WebPageEfl.cpp (170635 => 170636)


--- releases/WebKitGTK/webkit-2.4/Source/WebKit2/WebProcess/WebPage/efl/WebPageEfl.cpp	2014-07-01 11:32:36 UTC (rev 170635)
+++ releases/WebKitGTK/webkit-2.4/Source/WebKit2/WebProcess/WebPage/efl/WebPageEfl.cpp	2014-07-01 12:07:08 UTC (rev 170636)
@@ -220,4 +220,9 @@
     frame.editor().cancelComposition();
 }
 
+String WebPage::platformUserAgent(const URL&) const
+{
+    return String();
+}
+
 } // namespace WebKit

Modified: releases/WebKitGTK/webkit-2.4/Source/WebKit2/WebProcess/WebPage/gtk/WebPageGtk.cpp (170635 => 170636)


--- releases/WebKitGTK/webkit-2.4/Source/WebKit2/WebProcess/WebPage/gtk/WebPageGtk.cpp	2014-07-01 11:32:36 UTC (rev 170635)
+++ releases/WebKitGTK/webkit-2.4/Source/WebKit2/WebProcess/WebPage/gtk/WebPageGtk.cpp	2014-07-01 12:07:08 UTC (rev 170636)
@@ -42,6 +42,7 @@
 #include <WebCore/PasteboardHelper.h>
 #include <WebCore/PlatformKeyboardEvent.h>
 #include <WebCore/Settings.h>
+#include <WebCore/UserAgentGtk.h>
 #include <wtf/gobject/GUniquePtr.h>
 
 using namespace WebCore;
@@ -168,4 +169,12 @@
 }
 #endif
 
+String WebPage::platformUserAgent(const URL& url) const
+{
+    if (url.isNull() || !m_page->settings().needsSiteSpecificQuirks())
+        return String();
+
+    return WebCore::standardUserAgentForURL(url);
+}
+
 } // namespace WebKit

Modified: releases/WebKitGTK/webkit-2.4/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm (170635 => 170636)


--- releases/WebKitGTK/webkit-2.4/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm	2014-07-01 11:32:36 UTC (rev 170635)
+++ releases/WebKitGTK/webkit-2.4/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm	2014-07-01 12:07:08 UTC (rev 170636)
@@ -877,4 +877,9 @@
     m_page->setPageScaleFactor(newScale, m_page->mainFrame().view()->scrollPosition());
 }
 
+String WebPage::platformUserAgent(const URL&) const
+{
+    return String();
+}
+
 } // namespace WebKit

Modified: releases/WebKitGTK/webkit-2.4/Tools/ChangeLog (170635 => 170636)


--- releases/WebKitGTK/webkit-2.4/Tools/ChangeLog	2014-07-01 11:32:36 UTC (rev 170635)
+++ releases/WebKitGTK/webkit-2.4/Tools/ChangeLog	2014-07-01 12:07:08 UTC (rev 170636)
@@ -1,3 +1,19 @@
+2014-06-11  Carlos Garcia Campos  <[email protected]>
+
+        [GTK] Use a different user agent string depending on the site
+        https://bugs.webkit.org/show_bug.cgi?id=132681
+
+        Reviewed by Anders Carlsson.
+
+        Add a unit test to check user agent quirks.
+
+        * TestWebKitAPI/PlatformGTK.cmake:
+        * TestWebKitAPI/Tests/WebCore/gtk/UserAgentQuirks.cpp: Added.
+        (TestWebKitAPI::TEST):
+        * TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitSettings.cpp:
+        (testWebKitSettings): Site specific quirks setting is now enabled
+        by default.
+
 2014-06-13  Sergio Villar Senin  <[email protected]>
 
         [Gtk] [Stable] Fix the "Safari" part of the UA

Modified: releases/WebKitGTK/webkit-2.4/Tools/TestWebKitAPI/GNUmakefile.am (170635 => 170636)


--- releases/WebKitGTK/webkit-2.4/Tools/TestWebKitAPI/GNUmakefile.am	2014-07-01 11:32:36 UTC (rev 170635)
+++ releases/WebKitGTK/webkit-2.4/Tools/TestWebKitAPI/GNUmakefile.am	2014-07-01 12:07:08 UTC (rev 170636)
@@ -112,8 +112,7 @@
 noinst_PROGRAMS += \
 	Programs/TestWebKitAPI/WTF/TestWTF \
 	Programs/TestWebKitAPI/_javascript_Core/TestJavaScriptCore \
-	Programs/TestWebKitAPI/WebCore/TestWebCore \
-	Programs/TestWebKitAPI/WebCoreGtk/TestWebCoreGtk
+	Programs/TestWebKitAPI/WebCore/TestWebCore
 
 if ENABLE_WEBKIT1
 noinst_PROGRAMS += \
@@ -285,8 +284,10 @@
 
 Programs_TestWebKitAPI_WebCore_TestWebCore_CPPFLAGS = \
 	$(Libraries_libTestWebKitAPIMain_la_CPPFLAGS) \
-	-I$(srcdir)/Source/WebCore/platform/network/soup \
-	-I$(top_builddir)/DerivedSources/WebCore/include \
+	$(platform_cppflags) \
+	$(platformgtk_cppflags) \
+	$(webcore_cppflags) \
+	$(webcoregtk_cppflags) \
 	$(LIBSOUP_CFLAGS)
 
 Programs_TestWebKitAPI_WebCore_TestWebCore_CXXFLAGS = \
@@ -324,40 +325,6 @@
 	-no-install
 
 Programs_TestWebKitAPI_WebCore_TestWebCore_SOURCES = \
-	Tools/TestWebKitAPI/Tests/WebCore/URL.cpp \
-	Tools/TestWebKitAPI/Tests/WebCore/LayoutUnit.cpp
-
-Programs_TestWebKitAPI_WebCoreGtk_TestWebCoreGtk_CPPFLAGS = \
-	$(Programs_TestWebKitAPI_WTF_TestWTF_CPPFLAGS) \
-	$(platform_cppflags) \
-	$(platformgtk_cppflags) \
-	$(webcore_cppflags) \
-	$(webcoregtk_cppflags) \
-	$(FREETYPE_CFLAGS) \
-	$(GLIB_CFLAGS) \
-	$(GTK_CFLAGS) \
-	$(LIBSOUP_CFLAGS)
-
-Programs_TestWebKitAPI_WebCoreGtk_TestWebCoreGtk_CXXFLAGS = \
-	-DGTEST_HAS_RTTI=0 \
-	$(global_cxxflags)
-
-Programs_TestWebKitAPI_WebCoreGtk_TestWebCoreGtk_LDADD = \
-	Libraries/libTestWebKitAPIMain.la \
-	Libraries/libgtest.la \
-	libjavascriptcoregtk-@WEBKITGTK_API_MAJOR_VERSION@.@[email protected] \
-	libPlatformGtk.la \
-	libWebCore.la \
-	libWebCoreGtk.la \
-	$(FREETYPE_LIBS) \
-	$(GLIB_LIBS) \
-	$(GTK_LIBS) \
-	$(LIBSOUP_LIBS)
-
-Programs_TestWebKitAPI_WebCoreGtk_TestWebCoreGtk_LDFLAGS = \
-	$(Programs_TestWebKitAPI_WTF_TestWTF_LDFLAGS)
-
-Programs_TestWebKitAPI_WebCoreGtk_TestWebCoreGtk_SOURCES = \
 	Source/WebCore/platform/graphics/IntPoint.cpp \
 	Source/WebCore/platform/graphics/IntRect.cpp \
 	Source/WebCore/platform/graphics/IntSize.cpp \
@@ -365,7 +332,10 @@
 	Source/WebCore/platform/graphics/gtk/IntRectGtk.cpp \
 	Source/WebCore/platform/gtk/GtkInputMethodFilter.cpp \
 	Tools/TestWebKitAPI/config.h \
-	Tools/TestWebKitAPI/Tests/gtk/InputMethodFilter.cpp
+	Tools/TestWebKitAPI/Tests/gtk/InputMethodFilter.cpp \
+	Tools/TestWebKitAPI/Tests/WebCore/gtk/UserAgentQuirks.cpp \
+	Tools/TestWebKitAPI/Tests/WebCore/URL.cpp \
+	Tools/TestWebKitAPI/Tests/WebCore/LayoutUnit.cpp
 
 Programs_TestWebKitAPI_WebKitGtk_testapplicationcache_SOURCES = \
 	Tools/TestWebKitAPI/Tests/WebKitGtk/testapplicationcache.c

Added: releases/WebKitGTK/webkit-2.4/Tools/TestWebKitAPI/Tests/WebCore/gtk/UserAgentQuirks.cpp (0 => 170636)


--- releases/WebKitGTK/webkit-2.4/Tools/TestWebKitAPI/Tests/WebCore/gtk/UserAgentQuirks.cpp	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.4/Tools/TestWebKitAPI/Tests/WebCore/gtk/UserAgentQuirks.cpp	2014-07-01 12:07:08 UTC (rev 170636)
@@ -0,0 +1,48 @@
+/*
+ * 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/UserAgentGtk.h>
+
+using namespace WebCore;
+
+namespace TestWebKitAPI {
+
+TEST(WebCore, UserAgentQuirksTest)
+{
+    // A site with not quirks should return a null String.
+    String uaString = standardUserAgentForURL(URL(ParsedURLString, "http://www.webkit.org/"));
+    EXPECT_TRUE(uaString.isNull());
+
+    // www.yahoo.com requires MAC OS platform in the UA.
+    uaString = standardUserAgentForURL(URL(ParsedURLString, "http://www.yahoo.com/"));
+    EXPECT_TRUE(uaString.contains("Macintosh"));
+    EXPECT_TRUE(uaString.contains("Mac OS X"));
+    EXPECT_FALSE(uaString.contains("Linux"));
+}
+
+} // namespace TestWebKitAPI

Modified: releases/WebKitGTK/webkit-2.4/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitSettings.cpp (170635 => 170636)


--- releases/WebKitGTK/webkit-2.4/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitSettings.cpp	2014-07-01 11:32:36 UTC (rev 170635)
+++ releases/WebKitGTK/webkit-2.4/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitSettings.cpp	2014-07-01 12:07:08 UTC (rev 170636)
@@ -233,10 +233,10 @@
     webkit_settings_set_draw_compositing_indicators(settings, TRUE);
     g_assert(webkit_settings_get_draw_compositing_indicators(settings));
 
-    // By default, site specific quirks are disabled.
+    // By default, site specific quirks are enabled.
+    g_assert(webkit_settings_get_enable_site_specific_quirks(settings));
+    webkit_settings_set_enable_site_specific_quirks(settings, FALSE);
     g_assert(!webkit_settings_get_enable_site_specific_quirks(settings));
-    webkit_settings_set_enable_site_specific_quirks(settings, TRUE);
-    g_assert(webkit_settings_get_enable_site_specific_quirks(settings));
 
     // By default, page cache is enabled.
     g_assert(webkit_settings_get_enable_page_cache(settings));
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to