Title: [242001] releases/WebKitGTK/webkit-2.22
Revision
242001
Author
ape...@igalia.com
Date
2019-02-23 17:06:25 -0800 (Sat, 23 Feb 2019)

Log Message

Merged r241480 - Further restricting webarchive loads
https://bugs.webkit.org/show_bug.cgi?id=194567
<rdar://problem/47610130>

Reviewed by Youenn Fablet.

Source/WebCore:

This patch futher restricts main frame webarchive loads to the followings:
1) loaded by clients;
2) loaded by drag;
3) reloaded from any of the previous two.

It moves setAlwaysAllowLocalWebarchive, which is used for testing only, from Document
to FrameLoader such that the option is remembered during redirections.

Covered by API tests.

* dom/Document.h:
(WebCore::Document::setAlwaysAllowLocalWebarchive): Deleted.
(WebCore::Document::alwaysAllowLocalWebarchive const): Deleted.
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::disallowWebArchive const):
* loader/DocumentLoader.h:
(WebCore::DocumentLoader::setAllowsWebArchiveForMainFrame):
(WebCore::DocumentLoader::allowsWebArchiveForMainFrame):
* loader/FrameLoadRequest.h:
(WebCore::FrameLoadRequest::setIsRequestFromClientOrUserInput):
(WebCore::FrameLoadRequest::isRequestFromClientOrUserInput):
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::load):
(WebCore::FrameLoader::reload):
* loader/FrameLoader.h:
(WebCore::FrameLoader::setAlwaysAllowLocalWebarchive):
(WebCore::FrameLoader::alwaysAllowLocalWebarchive const):
* page/DragController.cpp:
(WebCore::DragController::performDragOperation):
* testing/Internals.cpp:
(WebCore::Internals::setAlwaysAllowLocalWebarchive const):
* testing/Internals.h:
* testing/Internals.idl:

Source/WebKit:

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::loadRequest):
Set a flag to indicate a load is started from clients.

Tools:

Besides adding API tests, this patch also enhances DragAndDropSimulator to allow
navigations on drop.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/mac/LoadWebArchive.mm: Added.
(-[TestLoadWebArchiveNavigationDelegate webView:didFinishNavigation:]):
(-[TestLoadWebArchiveNavigationDelegate webView:didFailProvisionalNavigation:withError:]):
(-[TestLoadWebArchiveNavigationDelegate webView:createWebViewWithConfiguration:forNavigationAction:windowFeatures:]):
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/mac/helloworld.webarchive: Added.
* TestWebKitAPI/Tests/mac/load-web-archive-1.html: Added.
* TestWebKitAPI/Tests/mac/load-web-archive-2.html: Added.
* TestWebKitAPI/cocoa/DragAndDropSimulator.h:
* TestWebKitAPI/mac/DragAndDropSimulatorMac.mm:
(-[DragAndDropSimulator initWithWebViewFrame:configuration:]):
(-[DragAndDropSimulator _webView:dragDestinationActionMaskForDraggingInfo:]):

LayoutTests:

* platform/mac/fast/loader/webarchive-encoding-respected.html:
* webarchive/loading/cache-expired-subresource.html:
* webarchive/loading/_javascript_-url-iframe-crash.html:
* webarchive/loading/mainresource-null-mimetype-crash.html:
* webarchive/loading/missing-data.html:
* webarchive/loading/object.html:
* webarchive/loading/test-loading-archive-subresource-null-mimetype.html:
* webarchive/loading/test-loading-archive-subresource.html:
* webarchive/loading/test-loading-archive.html:
* webarchive/loading/test-loading-top-archive.html:
* webarchive/loading/video-in-webarchive.html:

Modified Paths

Added Paths

Diff

Modified: releases/WebKitGTK/webkit-2.22/LayoutTests/ChangeLog (242000 => 242001)


--- releases/WebKitGTK/webkit-2.22/LayoutTests/ChangeLog	2019-02-24 01:06:03 UTC (rev 242000)
+++ releases/WebKitGTK/webkit-2.22/LayoutTests/ChangeLog	2019-02-24 01:06:25 UTC (rev 242001)
@@ -1,3 +1,23 @@
+2019-02-12  Jiewen Tan  <jiewen_...@apple.com>
+
+        Further restricting webarchive loads
+        https://bugs.webkit.org/show_bug.cgi?id=194567
+        <rdar://problem/47610130>
+
+        Reviewed by Youenn Fablet.
+
+        * platform/mac/fast/loader/webarchive-encoding-respected.html:
+        * webarchive/loading/cache-expired-subresource.html:
+        * webarchive/loading/_javascript_-url-iframe-crash.html:
+        * webarchive/loading/mainresource-null-mimetype-crash.html:
+        * webarchive/loading/missing-data.html:
+        * webarchive/loading/object.html:
+        * webarchive/loading/test-loading-archive-subresource-null-mimetype.html:
+        * webarchive/loading/test-loading-archive-subresource.html:
+        * webarchive/loading/test-loading-archive.html:
+        * webarchive/loading/test-loading-top-archive.html:
+        * webarchive/loading/video-in-webarchive.html:
+
 2019-02-08  Chris Fleizach  <cfleiz...@apple.com>
 
         AXObjectCache::childrenChanged shouldn't update layout or style during another style recalc

Modified: releases/WebKitGTK/webkit-2.22/LayoutTests/platform/mac/fast/loader/webarchive-encoding-respected.html (242000 => 242001)


--- releases/WebKitGTK/webkit-2.22/LayoutTests/platform/mac/fast/loader/webarchive-encoding-respected.html	2019-02-24 01:06:03 UTC (rev 242000)
+++ releases/WebKitGTK/webkit-2.22/LayoutTests/platform/mac/fast/loader/webarchive-encoding-respected.html	2019-02-24 01:06:25 UTC (rev 242001)
@@ -4,7 +4,7 @@
 	testRunner.dumpChildFramesAsText();
 }
 if (window.internals)
-    internals.setAlwaysAllowLocalWebarchive();
+    internals.setAlwaysAllowLocalWebarchive(true);
 </script>
 The webarchive in this iframe is utf-8 encoded and will only display properly if the webarchive's encoding is respected.<br>
 <iframe src=""

Modified: releases/WebKitGTK/webkit-2.22/LayoutTests/webarchive/loading/cache-expired-subresource.html (242000 => 242001)


--- releases/WebKitGTK/webkit-2.22/LayoutTests/webarchive/loading/cache-expired-subresource.html	2019-02-24 01:06:03 UTC (rev 242000)
+++ releases/WebKitGTK/webkit-2.22/LayoutTests/webarchive/loading/cache-expired-subresource.html	2019-02-24 01:06:25 UTC (rev 242001)
@@ -5,7 +5,7 @@
         testRunner.waitUntilDone();
     }
     if (window.internals)
-        internals.setAlwaysAllowLocalWebarchive();
+        internals.setAlwaysAllowLocalWebarchive(true);
     
     function frameLoaded() {
         if (window.testRunner)

Modified: releases/WebKitGTK/webkit-2.22/LayoutTests/webarchive/loading/_javascript_-url-iframe-crash.html (242000 => 242001)


--- releases/WebKitGTK/webkit-2.22/LayoutTests/webarchive/loading/_javascript_-url-iframe-crash.html	2019-02-24 01:06:03 UTC (rev 242000)
+++ releases/WebKitGTK/webkit-2.22/LayoutTests/webarchive/loading/_javascript_-url-iframe-crash.html	2019-02-24 01:06:25 UTC (rev 242001)
@@ -4,7 +4,8 @@
         testRunner.dumpAsText();
         testRunner.waitUntilDone();
     }
-    
+    if (window.internals)
+        internals.setAlwaysAllowLocalWebarchive(true);
     window.location="resources/_javascript_-url-iframe-crash.webarchive";
 </script>
 </html>

Modified: releases/WebKitGTK/webkit-2.22/LayoutTests/webarchive/loading/mainresource-null-mimetype-crash.html (242000 => 242001)


--- releases/WebKitGTK/webkit-2.22/LayoutTests/webarchive/loading/mainresource-null-mimetype-crash.html	2019-02-24 01:06:03 UTC (rev 242000)
+++ releases/WebKitGTK/webkit-2.22/LayoutTests/webarchive/loading/mainresource-null-mimetype-crash.html	2019-02-24 01:06:25 UTC (rev 242001)
@@ -5,7 +5,7 @@
         testRunner.waitUntilDone();
     }
     if (window.internals)
-        internals.setAlwaysAllowLocalWebarchive();
+        internals.setAlwaysAllowLocalWebarchive(true);
     _onload_ = function() {
         frame = document.createElement("iframe");
         frame.src = ""

Modified: releases/WebKitGTK/webkit-2.22/LayoutTests/webarchive/loading/missing-data.html (242000 => 242001)


--- releases/WebKitGTK/webkit-2.22/LayoutTests/webarchive/loading/missing-data.html	2019-02-24 01:06:03 UTC (rev 242000)
+++ releases/WebKitGTK/webkit-2.22/LayoutTests/webarchive/loading/missing-data.html	2019-02-24 01:06:25 UTC (rev 242001)
@@ -4,7 +4,7 @@
         testRunner.dumpAsText();
     }
     if (window.internals)
-        internals.setAlwaysAllowLocalWebarchive();
+        internals.setAlwaysAllowLocalWebarchive(true);
     _onload_ = function() {
         frame = document.createElement("iframe");
         frame.src = ""

Modified: releases/WebKitGTK/webkit-2.22/LayoutTests/webarchive/loading/object.html (242000 => 242001)


--- releases/WebKitGTK/webkit-2.22/LayoutTests/webarchive/loading/object.html	2019-02-24 01:06:03 UTC (rev 242000)
+++ releases/WebKitGTK/webkit-2.22/LayoutTests/webarchive/loading/object.html	2019-02-24 01:06:25 UTC (rev 242001)
@@ -3,6 +3,7 @@
     testRunner.dumpAsText();
     testRunner.waitUntilDone();
 }
-
+if (window.internals)
+    internals.setAlwaysAllowLocalWebarchive(true);
 window.location="resources/object.webarchive";
 </script>

Modified: releases/WebKitGTK/webkit-2.22/LayoutTests/webarchive/loading/test-loading-archive-subresource-null-mimetype.html (242000 => 242001)


--- releases/WebKitGTK/webkit-2.22/LayoutTests/webarchive/loading/test-loading-archive-subresource-null-mimetype.html	2019-02-24 01:06:03 UTC (rev 242000)
+++ releases/WebKitGTK/webkit-2.22/LayoutTests/webarchive/loading/test-loading-archive-subresource-null-mimetype.html	2019-02-24 01:06:25 UTC (rev 242001)
@@ -6,7 +6,7 @@
         testRunner.waitUntilDone();
     }
     if (window.internals)
-        internals.setAlwaysAllowLocalWebarchive();
+        internals.setAlwaysAllowLocalWebarchive(true);
     function frameLoaded() {
         if (window.testRunner)
             testRunner.notifyDone();

Modified: releases/WebKitGTK/webkit-2.22/LayoutTests/webarchive/loading/test-loading-archive-subresource.html (242000 => 242001)


--- releases/WebKitGTK/webkit-2.22/LayoutTests/webarchive/loading/test-loading-archive-subresource.html	2019-02-24 01:06:03 UTC (rev 242000)
+++ releases/WebKitGTK/webkit-2.22/LayoutTests/webarchive/loading/test-loading-archive-subresource.html	2019-02-24 01:06:25 UTC (rev 242001)
@@ -4,6 +4,8 @@
         testRunner.dumpAsText();
         testRunner.waitUntilDone();
     }
+    if (window.internals)
+        internals.setAlwaysAllowLocalWebarchive(false);
 
     function frameLoaded() {
         if (window.testRunner)

Modified: releases/WebKitGTK/webkit-2.22/LayoutTests/webarchive/loading/test-loading-archive.html (242000 => 242001)


--- releases/WebKitGTK/webkit-2.22/LayoutTests/webarchive/loading/test-loading-archive.html	2019-02-24 01:06:03 UTC (rev 242000)
+++ releases/WebKitGTK/webkit-2.22/LayoutTests/webarchive/loading/test-loading-archive.html	2019-02-24 01:06:25 UTC (rev 242001)
@@ -6,7 +6,7 @@
         testRunner.waitUntilDone();
     }
     if (window.internals)
-        internals.setAlwaysAllowLocalWebarchive();
+        internals.setAlwaysAllowLocalWebarchive(true);
     function frameLoaded() {
         if (window.testRunner)
             testRunner.notifyDone();

Modified: releases/WebKitGTK/webkit-2.22/LayoutTests/webarchive/loading/test-loading-top-archive.html (242000 => 242001)


--- releases/WebKitGTK/webkit-2.22/LayoutTests/webarchive/loading/test-loading-top-archive.html	2019-02-24 01:06:03 UTC (rev 242000)
+++ releases/WebKitGTK/webkit-2.22/LayoutTests/webarchive/loading/test-loading-top-archive.html	2019-02-24 01:06:25 UTC (rev 242001)
@@ -4,6 +4,8 @@
         testRunner.waitUntilDone();
         testRunner.dumpAsText();
     }
+    if (window.internals)
+        internals.setAlwaysAllowLocalWebarchive(true);
     window.location="resources/top.webarchive";
 </script>
 </html>

Modified: releases/WebKitGTK/webkit-2.22/LayoutTests/webarchive/loading/video-in-webarchive.html (242000 => 242001)


--- releases/WebKitGTK/webkit-2.22/LayoutTests/webarchive/loading/video-in-webarchive.html	2019-02-24 01:06:03 UTC (rev 242000)
+++ releases/WebKitGTK/webkit-2.22/LayoutTests/webarchive/loading/video-in-webarchive.html	2019-02-24 01:06:25 UTC (rev 242001)
@@ -3,5 +3,7 @@
     testRunner.dumpAsText();
     testRunner.waitUntilDone();
 }
+if (window.internals)
+    internals.setAlwaysAllowLocalWebarchive(true);
 window.location="resources/video-in-webarchive.webarchive";
 </script>

Modified: releases/WebKitGTK/webkit-2.22/Source/WebCore/ChangeLog (242000 => 242001)


--- releases/WebKitGTK/webkit-2.22/Source/WebCore/ChangeLog	2019-02-24 01:06:03 UTC (rev 242000)
+++ releases/WebKitGTK/webkit-2.22/Source/WebCore/ChangeLog	2019-02-24 01:06:25 UTC (rev 242001)
@@ -1,3 +1,45 @@
+2019-02-12  Jiewen Tan  <jiewen_...@apple.com>
+
+        Further restricting webarchive loads
+        https://bugs.webkit.org/show_bug.cgi?id=194567
+        <rdar://problem/47610130>
+
+        Reviewed by Youenn Fablet.
+
+        This patch futher restricts main frame webarchive loads to the followings:
+        1) loaded by clients;
+        2) loaded by drag;
+        3) reloaded from any of the previous two.
+
+        It moves setAlwaysAllowLocalWebarchive, which is used for testing only, from Document
+        to FrameLoader such that the option is remembered during redirections.
+
+        Covered by API tests.
+
+        * dom/Document.h:
+        (WebCore::Document::setAlwaysAllowLocalWebarchive): Deleted.
+        (WebCore::Document::alwaysAllowLocalWebarchive const): Deleted.
+        * loader/DocumentLoader.cpp:
+        (WebCore::DocumentLoader::disallowWebArchive const):
+        * loader/DocumentLoader.h:
+        (WebCore::DocumentLoader::setAllowsWebArchiveForMainFrame):
+        (WebCore::DocumentLoader::allowsWebArchiveForMainFrame):
+        * loader/FrameLoadRequest.h:
+        (WebCore::FrameLoadRequest::setIsRequestFromClientOrUserInput):
+        (WebCore::FrameLoadRequest::isRequestFromClientOrUserInput):
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::load):
+        (WebCore::FrameLoader::reload):
+        * loader/FrameLoader.h:
+        (WebCore::FrameLoader::setAlwaysAllowLocalWebarchive):
+        (WebCore::FrameLoader::alwaysAllowLocalWebarchive const):
+        * page/DragController.cpp:
+        (WebCore::DragController::performDragOperation):
+        * testing/Internals.cpp:
+        (WebCore::Internals::setAlwaysAllowLocalWebarchive const):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
 2019-02-08  Chris Fleizach  <cfleiz...@apple.com>
 
         AXObjectCache::childrenChanged shouldn't update layout or style during another style recalc

Modified: releases/WebKitGTK/webkit-2.22/Source/WebCore/dom/Document.h (242000 => 242001)


--- releases/WebKitGTK/webkit-2.22/Source/WebCore/dom/Document.h	2019-02-24 01:06:03 UTC (rev 242000)
+++ releases/WebKitGTK/webkit-2.22/Source/WebCore/dom/Document.h	2019-02-24 01:06:25 UTC (rev 242001)
@@ -1483,9 +1483,7 @@
     void setAsRunningUserScripts() { m_isRunningUserScripts = true; }
     bool isRunningUserScripts() const { return m_isRunningUserScripts; }
 
-    // Used in webarchive loading tests.
-    void setAlwaysAllowLocalWebarchive() { m_alwaysAllowLocalWebarchive = true; }
-    bool alwaysAllowLocalWebarchive() const { return m_alwaysAllowLocalWebarchive; }
+    void frameWasDisconnectedFromOwner();
 
 protected:
     enum ConstructionFlags { Synthesized = 1, NonRenderedPlaceholder = 1 << 1 };
@@ -2007,8 +2005,6 @@
     std::unique_ptr<UserGestureIndicator> m_temporaryUserGesture;
 
     bool m_isRunningUserScripts { false };
-
-    bool m_alwaysAllowLocalWebarchive { false };
 };
 
 Element* eventTargetElementForDocument(Document*);

Modified: releases/WebKitGTK/webkit-2.22/Source/WebCore/loader/DocumentLoader.cpp (242000 => 242001)


--- releases/WebKitGTK/webkit-2.22/Source/WebCore/loader/DocumentLoader.cpp	2019-02-24 01:06:03 UTC (rev 242000)
+++ releases/WebKitGTK/webkit-2.22/Source/WebCore/loader/DocumentLoader.cpp	2019-02-24 01:06:25 UTC (rev 242001)
@@ -843,8 +843,11 @@
     });
 }
 
-// Prevent web archives from loading if it is remote or it is not the main frame because they
-// can claim to be from any domain and thus avoid cross-domain security checks (4120255, 45524528).
+// Prevent web archives from loading if
+// 1) it is remote;
+// 2) it is not the main frame;
+// 3) it is not any of { loaded by clients; loaded by drag; reloaded from any of the previous two };
+// because they can claim to be from any domain and thus avoid cross-domain security checks (4120255, 45524528, 47610130).
 bool DocumentLoader::disallowWebArchive() const
 {
     using MIMETypeHashSet = HashSet<String, ASCIICaseInsensitiveHash>;
@@ -874,11 +877,11 @@
     if (!SchemeRegistry::shouldTreatURLSchemeAsLocal(m_request.url().protocol().toStringWithoutCopying()))
         return true;
 
-    if (!frame() || frame()->isMainFrame())
+    if (!frame() || (frame()->isMainFrame() && m_allowsWebArchiveForMainFrame))
         return false;
 
     // On purpose of maintaining existing tests.
-    if (!frame()->document() || frame()->document()->topDocument().alwaysAllowLocalWebarchive())
+    if (frame()->mainFrame().loader().alwaysAllowLocalWebarchive())
         return false;
     return true;
 }

Modified: releases/WebKitGTK/webkit-2.22/Source/WebCore/loader/DocumentLoader.h (242000 => 242001)


--- releases/WebKitGTK/webkit-2.22/Source/WebCore/loader/DocumentLoader.h	2019-02-24 01:06:03 UTC (rev 242000)
+++ releases/WebKitGTK/webkit-2.22/Source/WebCore/loader/DocumentLoader.h	2019-02-24 01:06:25 UTC (rev 242001)
@@ -328,7 +328,10 @@
 
     WEBCORE_EXPORT void setCustomHeaderFields(Vector<HTTPHeaderField>&& fields);
     const Vector<HTTPHeaderField>& customHeaderFields() { return m_customHeaderFields; }
-    
+
+    void setAllowsWebArchiveForMainFrame(bool allowsWebArchiveForMainFrame) { m_allowsWebArchiveForMainFrame = allowsWebArchiveForMainFrame; }
+    bool allowsWebArchiveForMainFrame() const { return m_allowsWebArchiveForMainFrame; }
+
 protected:
     WEBCORE_EXPORT DocumentLoader(const ResourceRequest&, const SubstituteData&);
 
@@ -540,6 +543,8 @@
 #ifndef NDEBUG
     bool m_hasEverBeenAttached { false };
 #endif
+
+    bool m_allowsWebArchiveForMainFrame { false };
 };
 
 inline void DocumentLoader::recordMemoryCacheLoadForFutureClientNotification(const ResourceRequest& request)

Modified: releases/WebKitGTK/webkit-2.22/Source/WebCore/loader/FrameLoadRequest.h (242000 => 242001)


--- releases/WebKitGTK/webkit-2.22/Source/WebCore/loader/FrameLoadRequest.h	2019-02-24 01:06:03 UTC (rev 242000)
+++ releases/WebKitGTK/webkit-2.22/Source/WebCore/loader/FrameLoadRequest.h	2019-02-24 01:06:25 UTC (rev 242001)
@@ -90,6 +90,9 @@
     bool isSystemPreview() const { return m_systemPreviewInfo.isSystemPreview; }
     const IntRect& systemPreviewRect() const { return m_systemPreviewInfo.systemPreviewRect; }
 
+    void setIsRequestFromClientOrUserInput() { m_isRequestFromClientOrUserInput = true; }
+    bool isRequestFromClientOrUserInput() const { return m_isRequestFromClientOrUserInput; }
+
 private:
     Ref<Document> m_requester;
     Ref<SecurityOrigin> m_requesterSecurityOrigin;
@@ -110,6 +113,7 @@
     InitiatedByMainFrame m_initiatedByMainFrame { InitiatedByMainFrame::Unknown };
     bool m_isCrossOriginWindowOpenNavigation { false };
     SystemPreviewInfo m_systemPreviewInfo;
+    bool m_isRequestFromClientOrUserInput { false };
 };
 
 } // namespace WebCore

Modified: releases/WebKitGTK/webkit-2.22/Source/WebCore/loader/FrameLoader.cpp (242000 => 242001)


--- releases/WebKitGTK/webkit-2.22/Source/WebCore/loader/FrameLoader.cpp	2019-02-24 01:06:03 UTC (rev 242000)
+++ releases/WebKitGTK/webkit-2.22/Source/WebCore/loader/FrameLoader.cpp	2019-02-24 01:06:25 UTC (rev 242001)
@@ -1466,6 +1466,7 @@
         request.setSubstituteData(defaultSubstituteDataForURL(request.resourceRequest().url()));
 
     Ref<DocumentLoader> loader = m_client.createDocumentLoader(request.resourceRequest(), request.substituteData());
+    loader->setAllowsWebArchiveForMainFrame(request.isRequestFromClientOrUserInput());
     addSameSiteInfoToRequestIfNeeded(loader->request());
     applyShouldOpenExternalURLsPolicyToNewDocumentLoader(m_frame, loader, request);
 
@@ -1740,6 +1741,7 @@
     // Create a new document loader for the reload, this will become m_documentLoader eventually,
     // but first it has to be the "policy" document loader, and then the "provisional" document loader.
     Ref<DocumentLoader> loader = m_client.createDocumentLoader(initialRequest, defaultSubstituteDataForURL(initialRequest.url()));
+    loader->setAllowsWebArchiveForMainFrame(m_documentLoader->allowsWebArchiveForMainFrame());
     applyShouldOpenExternalURLsPolicyToNewDocumentLoader(m_frame, loader, InitiatedByMainFrame::Unknown, m_documentLoader->shouldOpenExternalURLsPolicyToPropagate());
 
     loader->setUserContentExtensionsEnabled(!options.contains(ReloadOption::DisableContentBlockers));

Modified: releases/WebKitGTK/webkit-2.22/Source/WebCore/loader/FrameLoader.h (242000 => 242001)


--- releases/WebKitGTK/webkit-2.22/Source/WebCore/loader/FrameLoader.h	2019-02-24 01:06:03 UTC (rev 242000)
+++ releases/WebKitGTK/webkit-2.22/Source/WebCore/loader/FrameLoader.h	2019-02-24 01:06:25 UTC (rev 242001)
@@ -311,6 +311,10 @@
     bool shouldSuppressTextInputFromEditing() const;
     bool isReloadingFromOrigin() const { return m_loadType == FrameLoadType::ReloadFromOrigin; }
 
+    // Used in webarchive loading tests.
+    void setAlwaysAllowLocalWebarchive(bool alwaysAllowLocalWebarchive) { m_alwaysAllowLocalWebarchive = alwaysAllowLocalWebarchive; }
+    bool alwaysAllowLocalWebarchive() const { return m_alwaysAllowLocalWebarchive; }
+
 private:
     enum FormSubmissionCacheLoadPolicy {
         MayAttemptCacheOnlyLoadForFormSubmissionItem,
@@ -474,6 +478,8 @@
 
     URL m_previousURL;
     RefPtr<HistoryItem> m_requestedHistoryItem;
+
+    bool m_alwaysAllowLocalWebarchive { false };
 };
 
 // This function is called by createWindow() in JSDOMWindowBase.cpp, for example, for

Modified: releases/WebKitGTK/webkit-2.22/Source/WebCore/page/DragController.cpp (242000 => 242001)


--- releases/WebKitGTK/webkit-2.22/Source/WebCore/page/DragController.cpp	2019-02-24 01:06:03 UTC (rev 242000)
+++ releases/WebKitGTK/webkit-2.22/Source/WebCore/page/DragController.cpp	2019-02-24 01:06:25 UTC (rev 242001)
@@ -290,7 +290,9 @@
         return false;
 
     m_client.willPerformDragDestinationAction(DragDestinationActionLoad, dragData);
-    m_page.mainFrame().loader().load(FrameLoadRequest(m_page.mainFrame(), { urlString }, shouldOpenExternalURLsPolicy));
+    FrameLoadRequest frameLoadRequest { m_page.mainFrame(), { urlString }, shouldOpenExternalURLsPolicy };
+    frameLoadRequest.setIsRequestFromClientOrUserInput();
+    m_page.mainFrame().loader().load(WTFMove(frameLoadRequest));
     return true;
 }
 

Modified: releases/WebKitGTK/webkit-2.22/Source/WebCore/testing/Internals.cpp (242000 => 242001)


--- releases/WebKitGTK/webkit-2.22/Source/WebCore/testing/Internals.cpp	2019-02-24 01:06:03 UTC (rev 242000)
+++ releases/WebKitGTK/webkit-2.22/Source/WebCore/testing/Internals.cpp	2019-02-24 01:06:25 UTC (rev 242001)
@@ -4693,12 +4693,12 @@
     ResourceLoadObserver::shared().notifyObserver();
 }
 
-void Internals::setAlwaysAllowLocalWebarchive() const
+void Internals::setAlwaysAllowLocalWebarchive(bool alwaysAllowLocalWebarchive)
 {
-    auto* document = contextDocument();
-    if (!document)
+    auto* localFrame = frame();
+    if (!localFrame)
         return;
-    document->setAlwaysAllowLocalWebarchive();
+    localFrame->loader().setAlwaysAllowLocalWebarchive(alwaysAllowLocalWebarchive);
 }
 
 } // namespace WebCore

Modified: releases/WebKitGTK/webkit-2.22/Source/WebCore/testing/Internals.h (242000 => 242001)


--- releases/WebKitGTK/webkit-2.22/Source/WebCore/testing/Internals.h	2019-02-24 01:06:03 UTC (rev 242000)
+++ releases/WebKitGTK/webkit-2.22/Source/WebCore/testing/Internals.h	2019-02-24 01:06:25 UTC (rev 242001)
@@ -731,7 +731,7 @@
 
     void notifyResourceLoadObserver();
 
-    void setAlwaysAllowLocalWebarchive() const;
+    void setAlwaysAllowLocalWebarchive(bool);
 
 private:
     explicit Internals(Document&);

Modified: releases/WebKitGTK/webkit-2.22/Source/WebCore/testing/Internals.idl (242000 => 242001)


--- releases/WebKitGTK/webkit-2.22/Source/WebCore/testing/Internals.idl	2019-02-24 01:06:03 UTC (rev 242000)
+++ releases/WebKitGTK/webkit-2.22/Source/WebCore/testing/Internals.idl	2019-02-24 01:06:25 UTC (rev 242001)
@@ -667,5 +667,5 @@
 
     void notifyResourceLoadObserver();
 
-    void setAlwaysAllowLocalWebarchive();
+    void setAlwaysAllowLocalWebarchive(boolean alwaysAllowLocalWebarchive);
 };

Modified: releases/WebKitGTK/webkit-2.22/Source/WebKit/ChangeLog (242000 => 242001)


--- releases/WebKitGTK/webkit-2.22/Source/WebKit/ChangeLog	2019-02-24 01:06:03 UTC (rev 242000)
+++ releases/WebKitGTK/webkit-2.22/Source/WebKit/ChangeLog	2019-02-24 01:06:25 UTC (rev 242001)
@@ -1,3 +1,15 @@
+2019-02-12  Jiewen Tan  <jiewen_...@apple.com>
+
+        Further restricting webarchive loads
+        https://bugs.webkit.org/show_bug.cgi?id=194567
+        <rdar://problem/47610130>
+
+        Reviewed by Youenn Fablet.
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::loadRequest):
+        Set a flag to indicate a load is started from clients.
+
 2019-02-08  Adrian Perez de Castro  <ape...@igalia.com>
 
         Unreviewed. Release WebKitGTK+ 2.22.6 and WPE WebKit 2.22.4

Modified: releases/WebKitGTK/webkit-2.22/Source/WebKit/WebProcess/WebPage/WebPage.cpp (242000 => 242001)


--- releases/WebKitGTK/webkit-2.22/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2019-02-24 01:06:03 UTC (rev 242000)
+++ releases/WebKitGTK/webkit-2.22/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2019-02-24 01:06:25 UTC (rev 242001)
@@ -1278,6 +1278,7 @@
     ShouldOpenExternalURLsPolicy externalURLsPolicy = static_cast<ShouldOpenExternalURLsPolicy>(loadParameters.shouldOpenExternalURLsPolicy);
     frameLoadRequest.setShouldOpenExternalURLsPolicy(externalURLsPolicy);
     frameLoadRequest.setShouldTreatAsContinuingLoad(loadParameters.shouldTreatAsContinuingLoad);
+    frameLoadRequest.setIsRequestFromClientOrUserInput();
 
     corePage()->userInputBridge().loadRequest(WTFMove(frameLoadRequest));
 

Modified: releases/WebKitGTK/webkit-2.22/Tools/ChangeLog (242000 => 242001)


--- releases/WebKitGTK/webkit-2.22/Tools/ChangeLog	2019-02-24 01:06:03 UTC (rev 242000)
+++ releases/WebKitGTK/webkit-2.22/Tools/ChangeLog	2019-02-24 01:06:25 UTC (rev 242001)
@@ -1,3 +1,28 @@
+2019-02-12  Jiewen Tan  <jiewen_...@apple.com>
+
+        Further restricting webarchive loads
+        https://bugs.webkit.org/show_bug.cgi?id=194567
+        <rdar://problem/47610130>
+
+        Reviewed by Youenn Fablet.
+
+        Besides adding API tests, this patch also enhances DragAndDropSimulator to allow
+        navigations on drop.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/mac/LoadWebArchive.mm: Added.
+        (-[TestLoadWebArchiveNavigationDelegate webView:didFinishNavigation:]):
+        (-[TestLoadWebArchiveNavigationDelegate webView:didFailProvisionalNavigation:withError:]):
+        (-[TestLoadWebArchiveNavigationDelegate webView:createWebViewWithConfiguration:forNavigationAction:windowFeatures:]):
+        (TestWebKitAPI::TEST):
+        * TestWebKitAPI/Tests/mac/helloworld.webarchive: Added.
+        * TestWebKitAPI/Tests/mac/load-web-archive-1.html: Added.
+        * TestWebKitAPI/Tests/mac/load-web-archive-2.html: Added.
+        * TestWebKitAPI/cocoa/DragAndDropSimulator.h:
+        * TestWebKitAPI/mac/DragAndDropSimulatorMac.mm:
+        (-[DragAndDropSimulator initWithWebViewFrame:configuration:]):
+        (-[DragAndDropSimulator _webView:dragDestinationActionMaskForDraggingInfo:]):
+
 2019-02-16  Pablo Saavedra  <psaave...@igalia.com>
 
         [GTK] Update-webkitgtk-libs for Webkit GTK 2.22 can not be generated anymore

Modified: releases/WebKitGTK/webkit-2.22/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (242000 => 242001)


--- releases/WebKitGTK/webkit-2.22/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2019-02-24 01:06:03 UTC (rev 242000)
+++ releases/WebKitGTK/webkit-2.22/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2019-02-24 01:06:25 UTC (rev 242001)
@@ -245,6 +245,9 @@
 		57303BCA20082C0100355965 /* CBORWriterTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 57303BAB2006C55400355965 /* CBORWriterTest.cpp */; };
 		57303BCB2008376500355965 /* CBORReaderTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 57303BC220071E2200355965 /* CBORReaderTest.cpp */; };
 		574F55CF204D37C5002948C6 /* LocalAuthenticator.mm in Sources */ = {isa = PBXBuildFile; fileRef = 574F55CE204D3763002948C6 /* LocalAuthenticator.mm */; };
+		573255A522139BC700396AE8 /* helloworld.webarchive in Copy Resources */ = {isa = PBXBuildFile; fileRef = 573255A422139B9000396AE8 /* helloworld.webarchive */; };
+		573255A622139BC700396AE8 /* load-web-archive-1.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 573255A222139B8F00396AE8 /* load-web-archive-1.html */; };
+		573255A722139BC700396AE8 /* load-web-archive-2.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 573255A322139B9000396AE8 /* load-web-archive-2.html */; };
 		574F55D2204D47F0002948C6 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 574F55D0204D471C002948C6 /* Security.framework */; };
 		57599E211F07191900A3FB8C /* IndexedDBStructuredCloneBackwardCompatibility.mm in Sources */ = {isa = PBXBuildFile; fileRef = 57599E201F07191700A3FB8C /* IndexedDBStructuredCloneBackwardCompatibility.mm */; };
 		57599E271F071AA000A3FB8C /* IndexedDBStructuredCloneBackwardCompatibility.sqlite3 in Copy Resources */ = {isa = PBXBuildFile; fileRef = 57599E241F07192C00A3FB8C /* IndexedDBStructuredCloneBackwardCompatibility.sqlite3 */; };
@@ -252,6 +255,7 @@
 		57599E2A1F071AA000A3FB8C /* IndexedDBStructuredCloneBackwardCompatibilityRead.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 57599E251F07192C00A3FB8C /* IndexedDBStructuredCloneBackwardCompatibilityRead.html */; };
 		57599E2B1F071AA000A3FB8C /* IndexedDBStructuredCloneBackwardCompatibilityWrite.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 57599E231F07192C00A3FB8C /* IndexedDBStructuredCloneBackwardCompatibilityWrite.html */; };
 		5769C50B1D9B0002000847FB /* SerializedCryptoKeyWrap.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5769C50A1D9B0001000847FB /* SerializedCryptoKeyWrap.mm */; };
+		5778D05622110A2600899E3B /* LoadWebArchive.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5778D05522110A2600899E3B /* LoadWebArchive.mm */; };
 		578CBD67204FB2C80083B9F2 /* LocalAuthentication.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 578CBD66204FB2C70083B9F2 /* LocalAuthentication.framework */; };
 		57901FB11CAF142D00ED64F9 /* LoadInvalidURLRequest.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 57901FB01CAF141C00ED64F9 /* LoadInvalidURLRequest.html */; };
 		5797FE311EB15A6800B2F4A0 /* NavigationClientDefaultCrypto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5797FE2F1EB15A5F00B2F4A0 /* NavigationClientDefaultCrypto.cpp */; };
@@ -1032,6 +1036,7 @@
 				07E1F6A21FFC44FA0096C7EC /* getDisplayMedia.html in Copy Resources */,
 				074994421EA5034B000DA44E /* getUserMedia.html in Copy Resources */,
 				F46A095B1ED8A6E600D4AA55 /* gif-and-file-input.html in Copy Resources */,
+				573255A522139BC700396AE8 /* helloworld.webarchive in Copy Resources */,
 				9B4F8FA7159D52DD002D9F94 /* HTMLCollectionNamedItem.html in Copy Resources */,
 				9B26FCCA159D16DE00CC3765 /* HTMLFormCollectionNamedItem.html in Copy Resources */,
 				BCBD3737125ABBEB00D2C29F /* icon.png in Copy Resources */,
@@ -1094,6 +1099,8 @@
 				8361F1781E610B4E00759B25 /* link-with-download-attribute-with-slashes.html in Copy Resources */,
 				8349D3C41DB9728E004A9F65 /* link-with-download-attribute.html in Copy Resources */,
 				378E64791632707400B6C676 /* link-with-title.html in Copy Resources */,
+				573255A622139BC700396AE8 /* load-web-archive-1.html in Copy Resources */,
+				573255A722139BC700396AE8 /* load-web-archive-2.html in Copy Resources */,
 				57901FB11CAF142D00ED64F9 /* LoadInvalidURLRequest.html in Copy Resources */,
 				8C10AF98206467920018FD90 /* localstorage-empty-string-value.html in Copy Resources */,
 				51E6A8961D2F1CA700C004B6 /* LocalStorageClear.html in Copy Resources */,
@@ -1530,6 +1537,9 @@
 		57303BAB2006C55400355965 /* CBORWriterTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CBORWriterTest.cpp; sourceTree = "<group>"; };
 		57303BAC2006C56000355965 /* CBORValueTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CBORValueTest.cpp; sourceTree = "<group>"; };
 		57303BC220071E2200355965 /* CBORReaderTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CBORReaderTest.cpp; sourceTree = "<group>"; };
+		573255A222139B8F00396AE8 /* load-web-archive-1.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "load-web-archive-1.html"; sourceTree = "<group>"; };
+		573255A322139B9000396AE8 /* load-web-archive-2.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "load-web-archive-2.html"; sourceTree = "<group>"; };
+		573255A422139B9000396AE8 /* helloworld.webarchive */ = {isa = PBXFileReference; lastKnownFileType = file.bplist; path = helloworld.webarchive; sourceTree = "<group>"; };
 		5735F0251F3A4EA6000EE801 /* TestWebKitAPI-iOS.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "TestWebKitAPI-iOS.entitlements"; sourceTree = "<group>"; };
 		574F55CE204D3763002948C6 /* LocalAuthenticator.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = LocalAuthenticator.mm; sourceTree = "<group>"; };
 		574F55D0204D471C002948C6 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
@@ -1539,6 +1549,7 @@
 		57599E251F07192C00A3FB8C /* IndexedDBStructuredCloneBackwardCompatibilityRead.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = IndexedDBStructuredCloneBackwardCompatibilityRead.html; sourceTree = "<group>"; };
 		57599E261F07192C00A3FB8C /* IndexedDBStructuredCloneBackwardCompatibility.sqlite3-shm */ = {isa = PBXFileReference; lastKnownFileType = file; path = "IndexedDBStructuredCloneBackwardCompatibility.sqlite3-shm"; sourceTree = "<group>"; };
 		5769C50A1D9B0001000847FB /* SerializedCryptoKeyWrap.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SerializedCryptoKeyWrap.mm; sourceTree = "<group>"; };
+		5778D05522110A2600899E3B /* LoadWebArchive.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = LoadWebArchive.mm; sourceTree = "<group>"; };
 		578CBD66204FB2C70083B9F2 /* LocalAuthentication.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = LocalAuthentication.framework; path = System/Library/Frameworks/LocalAuthentication.framework; sourceTree = SDKROOT; };
 		57901FAC1CAF12C200ED64F9 /* LoadInvalidURLRequest.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LoadInvalidURLRequest.mm; sourceTree = "<group>"; };
 		57901FAE1CAF137100ED64F9 /* LoadInvalidURLRequest.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LoadInvalidURLRequest.mm; sourceTree = "<group>"; };
@@ -3206,6 +3217,7 @@
 				F4BFA68C1E4AD08000154298 /* LegacyDragAndDropTests.mm */,
 				7A7B0E7E1EAFE454006AB8AE /* LimitTitleSize.mm */,
 				57901FAE1CAF137100ED64F9 /* LoadInvalidURLRequest.mm */,
+				5778D05522110A2600899E3B /* LoadWebArchive.mm */,
 				CDA315961ED53651009F60D3 /* MediaPlaybackSleepAssertion.mm */,
 				E1220D9F155B25480013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.mm */,
 				517E7DFB15110EA600D0B008 /* MemoryCachePruneWithinResourceLoadDelegate.mm */,
@@ -3260,6 +3272,7 @@
 				1A7E8B351812093600AEB74A /* FragmentNavigation.html */,
 				F47728981E4AE3AD007ABF6A /* full-page-contenteditable.html */,
 				CDBFCC421A9FF44800A7B691 /* FullscreenZoomInitialFrame.html */,
+				573255A422139B9000396AE8 /* helloworld.webarchive */,
 				9B4F8FA6159D52CA002D9F94 /* HTMLCollectionNamedItem.html */,
 				9B26FCB4159D15E700CC3765 /* HTMLFormCollectionNamedItem.html */,
 				57F56A5B1C7F8A4000F31D7E /* IsNavigationActionTrusted.html */,
@@ -3266,6 +3279,8 @@
 				C2CF975816CEC69E0054E99D /* JSContextBackForwardCache1.html */,
 				C2CF975916CEC69E0054E99D /* JSContextBackForwardCache2.html */,
 				F42DA5151D8CEFDB00336F40 /* large-input-field-focus-onload.html */,
+				573255A222139B8F00396AE8 /* load-web-archive-1.html */,
+				573255A322139B9000396AE8 /* load-web-archive-2.html */,
 				57901FB01CAF141C00ED64F9 /* LoadInvalidURLRequest.html */,
 				CDA315991ED540A5009F60D3 /* MediaPlaybackSleepAssertion.html */,
 				E1220DC9155B287D0013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.html */,
@@ -3834,6 +3849,7 @@
 				7C83E0C01D0A652700FEBCF3 /* LoadInvalidURLRequest.mm in Sources */,
 				7CCE7F001A411AE600447C4C /* LoadPageOnCrash.cpp in Sources */,
 				574F55CF204D37C5002948C6 /* LocalAuthenticator.mm in Sources */,
+				5778D05622110A2600899E3B /* LoadWebArchive.mm in Sources */,
 				51E6A8941D2F1C0A00C004B6 /* LocalStorageClear.mm in Sources */,
 				CA38459620AE17A900990D3B /* LocalStorageDatabaseTracker.mm in Sources */,
 				46C519DA1D355AB200DAA51A /* LocalStorageNullEntries.mm in Sources */,

Added: releases/WebKitGTK/webkit-2.22/Tools/TestWebKitAPI/Tests/mac/LoadWebArchive.mm (0 => 242001)


--- releases/WebKitGTK/webkit-2.22/Tools/TestWebKitAPI/Tests/mac/LoadWebArchive.mm	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.22/Tools/TestWebKitAPI/Tests/mac/LoadWebArchive.mm	2019-02-24 01:06:25 UTC (rev 242001)
@@ -0,0 +1,210 @@
+/*
+ * Copyright (C) 2019 Apple Inc. 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. 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.
+ */
+
+#import "config.h"
+
+#import "DragAndDropSimulator.h"
+#import "PlatformUtilities.h"
+#import "Test.h"
+#import "TestWKWebView.h"
+#import <WebKit/WKDragDestinationAction.h>
+#import <WebKit/WKNavigationPrivate.h>
+#import <WebKit/WKWebView.h>
+#import <WebKit/WKWebViewPrivate.h>
+#import <wtf/RetainPtr.h>
+#import <wtf/text/WTFString.h>
+
+#if WK_API_ENABLED
+
+static bool navigationComplete = false;
+static bool navigationFail = false;
+static String finalURL;
+static id<WKNavigationDelegate> gDelegate;
+static RetainPtr<WKWebView> newWebView;
+
+@interface TestLoadWebArchiveNavigationDelegate : NSObject <WKNavigationDelegate, WKUIDelegate>
+@end
+
+@implementation TestLoadWebArchiveNavigationDelegate
+
+- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation
+{
+    navigationComplete = true;
+    finalURL = navigation._request.URL.lastPathComponent;
+}
+
+- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error
+{
+    navigationFail = true;
+    finalURL = navigation._request.URL.lastPathComponent;
+}
+
+- (WKWebView *)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration forNavigationAction:(WKNavigationAction *)navigationAction windowFeatures:(WKWindowFeatures *)windowFeatures
+{
+    newWebView = adoptNS([[WKWebView alloc] initWithFrame:CGRectMake(0, 0, 800, 600) configuration:configuration]);
+    [newWebView setNavigationDelegate:gDelegate];
+
+    return newWebView.get();
+}
+
+@end
+
+namespace TestWebKitAPI {
+
+TEST(LoadWebArchive, FailNavigation1)
+{
+    // Using `document.location.href = '';`.
+    RetainPtr<NSURL> testURL = [[NSBundle mainBundle] URLForResource:@"load-web-archive-1" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"];
+
+    auto webView = adoptNS([[WKWebView alloc] init]);
+    auto delegate = adoptNS([[TestLoadWebArchiveNavigationDelegate alloc] init]);
+    [webView setNavigationDelegate:delegate.get()];
+
+    navigationFail = false;
+    [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
+    Util::run(&navigationFail);
+
+    EXPECT_WK_STREQ(finalURL, "helloworld.webarchive");
+}
+
+TEST(LoadWebArchive, FailNavigation2)
+{
+    // Using `window.open('helloworld.webarchive');`.
+    RetainPtr<NSURL> testURL = [[NSBundle mainBundle] URLForResource:@"load-web-archive-2" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"];
+
+    auto delegate = adoptNS([[TestLoadWebArchiveNavigationDelegate alloc] init]);
+    gDelegate = delegate.get();
+
+    auto webView = adoptNS([[WKWebView alloc] init]);
+    [webView setNavigationDelegate:delegate.get()];
+    [webView setUIDelegate:delegate.get()];
+
+    navigationFail = false;
+    [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
+    Util::run(&navigationFail);
+
+    EXPECT_WK_STREQ(finalURL, "helloworld.webarchive");
+}
+
+TEST(LoadWebArchive, ClientNavigationSucceed)
+{
+    RetainPtr<NSURL> testURL = [[NSBundle mainBundle] URLForResource:@"helloworld" withExtension:@"webarchive" subdirectory:@"TestWebKitAPI.resources"];
+
+    auto webView = adoptNS([[WKWebView alloc] init]);
+    auto delegate = adoptNS([[TestLoadWebArchiveNavigationDelegate alloc] init]);
+    [webView setNavigationDelegate:delegate.get()];
+
+    navigationComplete = false;
+    [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
+    Util::run(&navigationComplete);
+
+    EXPECT_WK_STREQ(finalURL, "helloworld.webarchive");
+}
+
+TEST(LoadWebArchive, ClientNavigationReload)
+{
+    RetainPtr<NSURL> testURL = [[NSBundle mainBundle] URLForResource:@"helloworld" withExtension:@"webarchive" subdirectory:@"TestWebKitAPI.resources"];
+
+    auto webView = adoptNS([[WKWebView alloc] init]);
+    auto delegate = adoptNS([[TestLoadWebArchiveNavigationDelegate alloc] init]);
+    [webView setNavigationDelegate:delegate.get()];
+
+    navigationComplete = false;
+    [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
+    Util::run(&navigationComplete);
+    EXPECT_WK_STREQ(finalURL, "helloworld.webarchive");
+
+    navigationComplete = false;
+    [webView reload];
+    Util::run(&navigationComplete);
+    EXPECT_WK_STREQ(finalURL, "");
+}
+
+TEST(LoadWebArchive, DragNavigationSucceed)
+{
+    RetainPtr<NSURL> webArchiveURL = [[NSBundle mainBundle] URLForResource:@"helloworld" withExtension:@"webarchive" subdirectory:@"TestWebKitAPI.resources"];
+    RetainPtr<NSURL> simpleURL = [[NSBundle mainBundle] URLForResource:@"simple" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"];
+
+    NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
+    [pasteboard clearContents];
+    [pasteboard declareTypes:@[NSFilenamesPboardType] owner:nil];
+    [pasteboard setPropertyList:@[webArchiveURL.get().path] forType:NSFilenamesPboardType];
+
+    auto simulator = adoptNS([[DragAndDropSimulator alloc] initWithWebViewFrame:CGRectMake(0, 0, 320, 500)]);
+    [simulator setExternalDragPasteboard:pasteboard];
+    [simulator setDragDestinationAction:WKDragDestinationActionAny];
+
+    auto webView = [simulator webView];
+    auto delegate = adoptNS([[TestLoadWebArchiveNavigationDelegate alloc] init]);
+    [webView setNavigationDelegate:delegate.get()];
+
+    navigationComplete = false;
+    [webView loadRequest:[NSURLRequest requestWithURL:simpleURL.get()]];
+    Util::run(&navigationComplete);
+    EXPECT_WK_STREQ(finalURL, "simple.html");
+
+    navigationComplete = false;
+    [simulator runFrom:CGPointMake(0, 0) to:CGPointMake(50, 50)];
+    Util::run(&navigationComplete);
+    EXPECT_WK_STREQ(finalURL, "helloworld.webarchive");
+}
+
+TEST(LoadWebArchive, DragNavigationReload)
+{
+    RetainPtr<NSURL> webArchiveURL = [[NSBundle mainBundle] URLForResource:@"helloworld" withExtension:@"webarchive" subdirectory:@"TestWebKitAPI.resources"];
+    RetainPtr<NSURL> simpleURL = [[NSBundle mainBundle] URLForResource:@"simple" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"];
+
+    NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
+    [pasteboard clearContents];
+    [pasteboard declareTypes:@[NSFilenamesPboardType] owner:nil];
+    [pasteboard setPropertyList:@[webArchiveURL.get().path] forType:NSFilenamesPboardType];
+
+    auto simulator = adoptNS([[DragAndDropSimulator alloc] initWithWebViewFrame:CGRectMake(0, 0, 320, 500)]);
+    [simulator setExternalDragPasteboard:pasteboard];
+    [simulator setDragDestinationAction:WKDragDestinationActionAny];
+
+    auto webView = [simulator webView];
+    auto delegate = adoptNS([[TestLoadWebArchiveNavigationDelegate alloc] init]);
+    [webView setNavigationDelegate:delegate.get()];
+
+    navigationComplete = false;
+    [webView loadRequest:[NSURLRequest requestWithURL:simpleURL.get()]];
+    Util::run(&navigationComplete);
+    EXPECT_WK_STREQ(finalURL, "simple.html");
+
+    navigationComplete = false;
+    [simulator runFrom:CGPointMake(0, 0) to:CGPointMake(50, 50)];
+    Util::run(&navigationComplete);
+    EXPECT_WK_STREQ(finalURL, "helloworld.webarchive");
+
+    navigationComplete = false;
+    [webView reload];
+    Util::run(&navigationComplete);
+    EXPECT_WK_STREQ(finalURL, "");
+}
+
+} // namespace TestWebKitAPI
+
+#endif // WK_API_ENABLED

Added: releases/WebKitGTK/webkit-2.22/Tools/TestWebKitAPI/Tests/mac/helloworld.webarchive (0 => 242001)


--- releases/WebKitGTK/webkit-2.22/Tools/TestWebKitAPI/Tests/mac/helloworld.webarchive	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.22/Tools/TestWebKitAPI/Tests/mac/helloworld.webarchive	2019-02-24 01:06:25 UTC (rev 242001)
@@ -0,0 +1,4 @@
+bplist00\xD1_WebMainResource\xD4	
+_WebResourceTextEncodingName_WebResourceData^WebResourceURL_WebResourceMIMETypeUUTF-8O)<HTML><BODY>
+Hello, World!
+</BODY></HTML>_+file:///Users/andersca/test/helloworld.htmlYtext/html&DVe{\x81\xAD\xDB\xE5
\ No newline at end of file

Added: releases/WebKitGTK/webkit-2.22/Tools/TestWebKitAPI/Tests/mac/load-web-archive-1.html (0 => 242001)


--- releases/WebKitGTK/webkit-2.22/Tools/TestWebKitAPI/Tests/mac/load-web-archive-1.html	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.22/Tools/TestWebKitAPI/Tests/mac/load-web-archive-1.html	2019-02-24 01:06:25 UTC (rev 242001)
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<html>
+<script>
+    document.location.href = '';
+</script>
+</html>

Added: releases/WebKitGTK/webkit-2.22/Tools/TestWebKitAPI/Tests/mac/load-web-archive-2.html (0 => 242001)


--- releases/WebKitGTK/webkit-2.22/Tools/TestWebKitAPI/Tests/mac/load-web-archive-2.html	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.22/Tools/TestWebKitAPI/Tests/mac/load-web-archive-2.html	2019-02-24 01:06:25 UTC (rev 242001)
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<html>
+<script>
+    window.open('helloworld.webarchive');
+</script>
+</html>

Modified: releases/WebKitGTK/webkit-2.22/Tools/TestWebKitAPI/cocoa/DragAndDropSimulator.h (242000 => 242001)


--- releases/WebKitGTK/webkit-2.22/Tools/TestWebKitAPI/cocoa/DragAndDropSimulator.h	2019-02-24 01:06:03 UTC (rev 242000)
+++ releases/WebKitGTK/webkit-2.22/Tools/TestWebKitAPI/cocoa/DragAndDropSimulator.h	2019-02-24 01:06:25 UTC (rev 242001)
@@ -82,6 +82,7 @@
 @property (nonatomic, readonly) NSArray<_WKAttachment *> *insertedAttachments;
 @property (nonatomic, readonly) NSArray<_WKAttachment *> *removedAttachments;
 @property (nonatomic, readonly) TestWKWebView *webView;
+@property (nonatomic) WKDragDestinationAction dragDestinationAction;
 
 #if PLATFORM(IOS)
 

Modified: releases/WebKitGTK/webkit-2.22/Tools/TestWebKitAPI/ios/DragAndDropSimulatorIOS.mm (242000 => 242001)


--- releases/WebKitGTK/webkit-2.22/Tools/TestWebKitAPI/ios/DragAndDropSimulatorIOS.mm	2019-02-24 01:06:03 UTC (rev 242000)
+++ releases/WebKitGTK/webkit-2.22/Tools/TestWebKitAPI/ios/DragAndDropSimulatorIOS.mm	2019-02-24 01:06:25 UTC (rev 242001)
@@ -325,6 +325,7 @@
 
 - (instancetype)initWithWebViewFrame:(CGRect)frame configuration:(WKWebViewConfiguration *)configuration
 {
+    self.dragDestinationAction = WKDragDestinationActionAny & ~WKDragDestinationActionLoad;
     if (configuration)
         return [self initWithWebView:[[[TestWKWebView alloc] initWithFrame:frame configuration:configuration] autorelease]];
 
@@ -690,6 +691,11 @@
     [_removedAttachments addObject:attachment];
 }
 
+- (WKDragDestinationAction)_webView:(WKWebView *)webView dragDestinationActionMaskForDraggingInfo:(id)draggingInfo
+{
+    return self.dragDestinationAction;
+}
+
 #pragma mark - _WKInputDelegate
 
 - (BOOL)_webView:(WKWebView *)webView focusShouldStartInputSession:(id <_WKFocusedElementInfo>)info

Modified: releases/WebKitGTK/webkit-2.22/Tools/TestWebKitAPI/mac/DragAndDropSimulatorMac.mm (242000 => 242001)


--- releases/WebKitGTK/webkit-2.22/Tools/TestWebKitAPI/mac/DragAndDropSimulatorMac.mm	2019-02-24 01:06:03 UTC (rev 242000)
+++ releases/WebKitGTK/webkit-2.22/Tools/TestWebKitAPI/mac/DragAndDropSimulatorMac.mm	2019-02-24 01:06:25 UTC (rev 242001)
@@ -103,6 +103,7 @@
     if (self = [super init]) {
         _webView = adoptNS([[DragAndDropTestWKWebView alloc] initWithFrame:frame configuration:configuration ?: [[[WKWebViewConfiguration alloc] init] autorelease] simulator:self]);
         [_webView setUIDelegate:self];
+        self.dragDestinationAction = WKDragDestinationActionAny & ~WKDragDestinationActionLoad;
     }
     return self;
 }
@@ -245,6 +246,11 @@
     _willEndDraggingHandler = makeBlockPtr(willEndDraggingHandler);
 }
 
+- (WKDragDestinationAction)_webView:(WKWebView *)webView dragDestinationActionMaskForDraggingInfo:(id)draggingInfo
+{
+    return self.dragDestinationAction;
+}
+
 @end
 
 #endif // ENABLE(DRAG_SUPPORT) && PLATFORM(MAC) && WK_API_ENABLED
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to