Title: [250528] trunk/Source/WebCore
Revision
250528
Author
[email protected]
Date
2019-09-30 14:01:19 -0700 (Mon, 30 Sep 2019)

Log Message

Refine restrictions for X-Temp-Tablet HTTP header experiment
https://bugs.webkit.org/show_bug.cgi?id=202367
<rdar://problem/55849139>

Reviewed by Geoffrey Garen.

Refine restrictions for X-Temp-Tablet HTTP header experiment:
1. Only send the header if the embedding application is MobileSafari.
2. Only send the header if the first party is google.com
3. Only send the header if the current date is before 2/1/2020
4. Send the header even if using an ephemeral session

* loader/cache/CachedResourceLoader.cpp:
(WebCore::isXTempTabletHeaderExperimentOver):
(WebCore::CachedResourceLoader::CachedResourceLoader):
(WebCore::isGoogleSearch):
(WebCore::CachedResourceLoader::shouldSendXTempTabletHeader const):
(WebCore::CachedResourceLoader::requestResource):
* loader/cache/CachedResourceLoader.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (250527 => 250528)


--- trunk/Source/WebCore/ChangeLog	2019-09-30 21:00:33 UTC (rev 250527)
+++ trunk/Source/WebCore/ChangeLog	2019-09-30 21:01:19 UTC (rev 250528)
@@ -1,5 +1,27 @@
 2019-09-30  Chris Dumez  <[email protected]>
 
+        Refine restrictions for X-Temp-Tablet HTTP header experiment
+        https://bugs.webkit.org/show_bug.cgi?id=202367
+        <rdar://problem/55849139>
+
+        Reviewed by Geoffrey Garen.
+
+        Refine restrictions for X-Temp-Tablet HTTP header experiment:
+        1. Only send the header if the embedding application is MobileSafari.
+        2. Only send the header if the first party is google.com
+        3. Only send the header if the current date is before 2/1/2020
+        4. Send the header even if using an ephemeral session
+
+        * loader/cache/CachedResourceLoader.cpp:
+        (WebCore::isXTempTabletHeaderExperimentOver):
+        (WebCore::CachedResourceLoader::CachedResourceLoader):
+        (WebCore::isGoogleSearch):
+        (WebCore::CachedResourceLoader::shouldSendXTempTabletHeader const):
+        (WebCore::CachedResourceLoader::requestResource):
+        * loader/cache/CachedResourceLoader.h:
+
+2019-09-30  Chris Dumez  <[email protected]>
+
         Pages with Web Workers cannot enter the back / forward cache
         https://bugs.webkit.org/show_bug.cgi?id=202296
         <rdar://problem/55764073>

Modified: trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp (250527 => 250528)


--- trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp	2019-09-30 21:00:33 UTC (rev 250527)
+++ trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp	2019-09-30 21:01:19 UTC (rev 250528)
@@ -45,6 +45,7 @@
 #include "CrossOriginAccessControl.h"
 #include "CustomHeaderFields.h"
 #include "DOMWindow.h"
+#include "DateComponents.h"
 #include "DiagnosticLoggingClient.h"
 #include "DiagnosticLoggingKeys.h"
 #include "Document.h"
@@ -66,6 +67,7 @@
 #include "RenderElement.h"
 #include "ResourceLoadInfo.h"
 #include "ResourceTiming.h"
+#include "RuntimeApplicationChecks.h"
 #include "RuntimeEnabledFeatures.h"
 #include "ScriptController.h"
 #include "SecurityOrigin.h"
@@ -151,6 +153,16 @@
     return nullptr;
 }
 
+#if PLATFORM(IOS) && !PLATFORM(IOSMAC)
+static bool isXTempTabletHeaderExperimentOver()
+{
+    DateComponents date;
+    date.setMillisecondsSinceEpochForMonth(WallTime::now().secondsSinceEpoch().milliseconds());
+    // End of experiment is 02-01-2020.
+    return date.fullYear() > 2020 || (date.fullYear() == 2020 && date.month() >= 1);
+}
+#endif
+
 CachedResourceLoader::CachedResourceLoader(DocumentLoader* documentLoader)
     : m_document(nullptr)
     , m_documentLoader(documentLoader)
@@ -160,6 +172,9 @@
     , m_autoLoadImages(true)
     , m_imagesEnabled(true)
     , m_allowStaleResources(false)
+#if PLATFORM(IOS) && !PLATFORM(IOSMAC)
+    , m_isXTempTabletHeaderExperimentOver(isXTempTabletHeaderExperimentOver())
+#endif
 {
 }
 
@@ -779,6 +794,36 @@
     return FetchOptions::Destination::EmptyString;
 }
 
+#if PLATFORM(IOS) && !PLATFORM(IOSMAC)
+static bool isGoogleSearch(const URL& url)
+{
+    if (!url.protocolIs("https"))
+        return false;
+
+    RegistrableDomain registrableDomain(url);
+    if (!registrableDomain.string().startsWith("google."))
+        return false;
+
+    auto host = url.host();
+    return host.startsWithIgnoringASCIICase("google.") || host.startsWithIgnoringASCIICase("www.google.") || host.startsWithIgnoringASCIICase("images.google.");
+}
+
+bool CachedResourceLoader::shouldSendXTempTabletHeader(CachedResource::Type type, Frame& frame, const URL& url) const
+{
+    if (m_isXTempTabletHeaderExperimentOver || !IOSApplication::isMobileSafari())
+        return false;
+
+    if (!isGoogleSearch(url))
+        return false;
+
+    if (type == CachedResource::Type::MainResource && frame.isMainFrame())
+        return true;
+
+    auto* topDocument = frame.mainFrame().document();
+    return topDocument && isGoogleSearch(topDocument->url());
+}
+#endif
+
 ResourceErrorOr<CachedResourceHandle<CachedResource>> CachedResourceLoader::requestResource(CachedResource::Type type, CachedResourceRequest&& request, ForPreload forPreload, DeferOption defer)
 {
     if (!frame() || !frame()->page()) {
@@ -873,14 +918,8 @@
 
     // FIXME: This is temporary for <rdar://problem/55790994>.
 #if PLATFORM(IOS) && !PLATFORM(IOSMAC)
-    if (!page.sessionID().isEphemeral() && deviceHasIPadCapability() && request.resourceRequest().url().protocolIs("https")) {
-        RegistrableDomain registrableDomain(request.resourceRequest().url());
-        if (registrableDomain.string().startsWith("google.")) {
-            auto host = request.resourceRequest().url().host();
-            if (host.startsWithIgnoringASCIICase("google.") || host.startsWithIgnoringASCIICase("www.google.") || host.startsWithIgnoringASCIICase("images.google."))
-                request.resourceRequest().setHTTPHeaderField(HTTPHeaderName::XTempTablet, "1"_s);
-        }
-    }
+    if (deviceHasIPadCapability() && shouldSendXTempTabletHeader(type, frame, request.resourceRequest().url()))
+        request.resourceRequest().setHTTPHeaderField(HTTPHeaderName::XTempTablet, "1"_s);
 #endif
 
     LoadTiming loadTiming;

Modified: trunk/Source/WebCore/loader/cache/CachedResourceLoader.h (250527 => 250528)


--- trunk/Source/WebCore/loader/cache/CachedResourceLoader.h	2019-09-30 21:00:33 UTC (rev 250527)
+++ trunk/Source/WebCore/loader/cache/CachedResourceLoader.h	2019-09-30 21:01:19 UTC (rev 250528)
@@ -191,6 +191,10 @@
     bool canRequestAfterRedirection(CachedResource::Type, const URL&, const ResourceLoaderOptions&) const;
     bool canRequestInContentDispositionAttachmentSandbox(CachedResource::Type, const URL&) const;
 
+#if PLATFORM(IOS) && !PLATFORM(IOSMAC)
+    bool shouldSendXTempTabletHeader(CachedResource::Type, Frame&, const URL&) const;
+#endif
+
     HashSet<String> m_validatedURLs;
     mutable DocumentResourceMap m_documentResources;
     WeakPtr<Document> m_document;
@@ -210,6 +214,9 @@
     bool m_autoLoadImages : 1;
     bool m_imagesEnabled : 1;
     bool m_allowStaleResources : 1;
+#if PLATFORM(IOS) && !PLATFORM(IOSMAC)
+    bool m_isXTempTabletHeaderExperimentOver : 1;
+#endif
 };
 
 class ResourceCacheValidationSuppressor {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to