Further restricting webarchive loads
authorjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Feb 2019 23:07:13 +0000 (23:07 +0000)
committerjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Feb 2019 23:07:13 +0000 (23:07 +0000)
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:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@241480 268f45cc-cd09-0410-ab3c-d52691b4dbfc

34 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/mac/fast/loader/webarchive-encoding-respected.html
LayoutTests/webarchive/loading/cache-expired-subresource.html
LayoutTests/webarchive/loading/javascript-url-iframe-crash.html
LayoutTests/webarchive/loading/mainresource-null-mimetype-crash.html
LayoutTests/webarchive/loading/missing-data.html
LayoutTests/webarchive/loading/object.html
LayoutTests/webarchive/loading/test-loading-archive-subresource-null-mimetype.html
LayoutTests/webarchive/loading/test-loading-archive-subresource.html
LayoutTests/webarchive/loading/test-loading-archive.html
LayoutTests/webarchive/loading/test-loading-top-archive.html
LayoutTests/webarchive/loading/video-in-webarchive.html
Source/WebCore/ChangeLog
Source/WebCore/dom/Document.h
Source/WebCore/loader/DocumentLoader.cpp
Source/WebCore/loader/DocumentLoader.h
Source/WebCore/loader/FrameLoadRequest.h
Source/WebCore/loader/FrameLoader.cpp
Source/WebCore/loader/FrameLoader.h
Source/WebCore/page/DragController.cpp
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/mac/LoadWebArchive.mm [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/mac/helloworld.webarchive [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/mac/load-web-archive-1.html [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/mac/load-web-archive-2.html [new file with mode: 0644]
Tools/TestWebKitAPI/cocoa/DragAndDropSimulator.h
Tools/TestWebKitAPI/ios/DragAndDropSimulatorIOS.mm
Tools/TestWebKitAPI/mac/DragAndDropSimulatorMac.mm

index 5b04327..723b3a1 100644 (file)
@@ -1,3 +1,23 @@
+2019-02-12  Jiewen Tan  <jiewen_tan@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-13  John Wilander  <wilander@apple.com>
 
         Store Ad Click Attribution requests in the network process
index 727fc50..dad53bf 100644 (file)
@@ -4,7 +4,7 @@ if (window.testRunner) {
        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="resources/utf8-encoded.webarchive"></iframe>
index 20e9600..0daf00b 100644 (file)
@@ -5,7 +5,7 @@
         testRunner.waitUntilDone();
     }
     if (window.internals)
-        internals.setAlwaysAllowLocalWebarchive();
+        internals.setAlwaysAllowLocalWebarchive(true);
     
     function frameLoaded() {
         if (window.testRunner)
index 124f9fa..2d6d713 100644 (file)
@@ -4,7 +4,8 @@
         testRunner.dumpAsText();
         testRunner.waitUntilDone();
     }
-    
+    if (window.internals)
+        internals.setAlwaysAllowLocalWebarchive(true);
     window.location="resources/javascript-url-iframe-crash.webarchive";
 </script>
 </html>
index 95411fe..5757fe8 100644 (file)
@@ -5,7 +5,7 @@
         testRunner.waitUntilDone();
     }
     if (window.internals)
-        internals.setAlwaysAllowLocalWebarchive();
+        internals.setAlwaysAllowLocalWebarchive(true);
     onload = function() {
         frame = document.createElement("iframe");
         frame.src = "resources/mainresource-null-mimetype.webarchive";
index e34fd7b..6d29524 100644 (file)
@@ -4,7 +4,7 @@
         testRunner.dumpAsText();
     }
     if (window.internals)
-        internals.setAlwaysAllowLocalWebarchive();
+        internals.setAlwaysAllowLocalWebarchive(true);
     onload = function() {
         frame = document.createElement("iframe");
         frame.src = "resources/missing-data.webarchive";
index be8d5cb..3bed33c 100644 (file)
@@ -3,6 +3,7 @@ if (window.testRunner) {
     testRunner.dumpAsText();
     testRunner.waitUntilDone();
 }
-
+if (window.internals)
+    internals.setAlwaysAllowLocalWebarchive(true);
 window.location="resources/object.webarchive";
 </script>
index 23ce003..3dc29ba 100644 (file)
@@ -6,7 +6,7 @@
         testRunner.waitUntilDone();
     }
     if (window.internals)
-        internals.setAlwaysAllowLocalWebarchive();
+        internals.setAlwaysAllowLocalWebarchive(true);
     function frameLoaded() {
         if (window.testRunner)
             testRunner.notifyDone();
index 123cffa..7d023c9 100644 (file)
@@ -4,6 +4,8 @@
         testRunner.dumpAsText();
         testRunner.waitUntilDone();
     }
+    if (window.internals)
+        internals.setAlwaysAllowLocalWebarchive(false);
 
     function frameLoaded() {
         if (window.testRunner)
index 04b70e4..1ffa765 100644 (file)
@@ -6,7 +6,7 @@
         testRunner.waitUntilDone();
     }
     if (window.internals)
-        internals.setAlwaysAllowLocalWebarchive();
+        internals.setAlwaysAllowLocalWebarchive(true);
     function frameLoaded() {
         if (window.testRunner)
             testRunner.notifyDone();
index 65db63f..fd365c0 100644 (file)
@@ -4,6 +4,8 @@
         testRunner.waitUntilDone();
         testRunner.dumpAsText();
     }
+    if (window.internals)
+        internals.setAlwaysAllowLocalWebarchive(true);
     window.location="resources/top.webarchive";
 </script>
 </html>
index abc92f6..d78d367 100644 (file)
@@ -3,5 +3,7 @@ if (window.testRunner) {
     testRunner.dumpAsText();
     testRunner.waitUntilDone();
 }
+if (window.internals)
+    internals.setAlwaysAllowLocalWebarchive(true);
 window.location="resources/video-in-webarchive.webarchive";
 </script>
index 492e475..656c54d 100644 (file)
@@ -1,3 +1,45 @@
+2019-02-12  Jiewen Tan  <jiewen_tan@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-13  Jer Noble  <jer.noble@apple.com>
 
         Null-deref crash at SourceBufferPrivateAVFObjC::outputObscuredDueToInsufficientExternalProtectionChanged()
index 9bdf1b8..db8988d 100644 (file)
@@ -1547,10 +1547,6 @@ public:
 
     void frameWasDisconnectedFromOwner();
 
-    // Used in webarchive loading tests.
-    void setAlwaysAllowLocalWebarchive() { m_alwaysAllowLocalWebarchive = true; }
-    bool alwaysAllowLocalWebarchive() const { return m_alwaysAllowLocalWebarchive; }
-
 protected:
     enum ConstructionFlags { Synthesized = 1, NonRenderedPlaceholder = 1 << 1 };
     Document(Frame*, const URL&, unsigned = DefaultDocumentClass, unsigned constructionFlags = 0);
@@ -2108,8 +2104,6 @@ private:
 
     bool m_isRunningUserScripts { false };
 
-    bool m_alwaysAllowLocalWebarchive { false };
-
     Ref<UndoManager> m_undoManager;
 };
 
index f5d27f9..1b30f2d 100644 (file)
@@ -855,8 +855,11 @@ void DocumentLoader::responseReceived(const ResourceResponse& response, Completi
     });
 }
 
-// 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>;
@@ -886,11 +889,11 @@ bool DocumentLoader::disallowWebArchive() const
     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;
 }
index ed3d21c..81c6048 100644 (file)
@@ -343,7 +343,10 @@ public:
 
     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&);
 
@@ -566,6 +569,8 @@ private:
 #ifndef NDEBUG
     bool m_hasEverBeenAttached { false };
 #endif
+
+    bool m_allowsWebArchiveForMainFrame { false };
 };
 
 inline void DocumentLoader::recordMemoryCacheLoadForFutureClientNotification(const ResourceRequest& request)
index 7969957..a74c490 100644 (file)
@@ -94,6 +94,9 @@ public:
     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;
@@ -114,6 +117,7 @@ private:
     AtomicString m_downloadAttribute;
     InitiatedByMainFrame m_initiatedByMainFrame { InitiatedByMainFrame::Unknown };
     SystemPreviewInfo m_systemPreviewInfo;
+    bool m_isRequestFromClientOrUserInput { false };
 };
 
 } // namespace WebCore
index 8a9a1b4..012f24f 100644 (file)
@@ -1479,6 +1479,7 @@ void FrameLoader::load(FrameLoadRequest&& request)
         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);
 
@@ -1776,6 +1777,7 @@ void FrameLoader::reload(OptionSet<ReloadOption> options)
     // 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));
index 2b7e33b..9e140d1 100644 (file)
@@ -319,6 +319,10 @@ public:
     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,
@@ -486,6 +490,8 @@ private:
 
     URL m_previousURL;
     RefPtr<HistoryItem> m_requestedHistoryItem;
+
+    bool m_alwaysAllowLocalWebarchive { false };
 };
 
 // This function is called by createWindow() in JSDOMWindowBase.cpp, for example, for
index b02a507..c10154d 100644 (file)
@@ -284,7 +284,9 @@ bool DragController::performDragOperation(const DragData& dragData)
         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;
 }
 
index 729e9cf..21a0597 100644 (file)
@@ -4935,12 +4935,12 @@ auto Internals::getCookies() const -> Vector<CookieData>
     });
 }
 
-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
index 1151ef2..c19382f 100644 (file)
@@ -794,7 +794,7 @@ public:
     };
     Vector<CookieData> getCookies() const;
 
-    void setAlwaysAllowLocalWebarchive() const;
+    void setAlwaysAllowLocalWebarchive(bool);
 
 private:
     explicit Internals(Document&);
index f56ad64..e638512 100644 (file)
@@ -732,5 +732,5 @@ enum CompositingPolicy {
 
     sequence<CookieData> getCookies();
 
-    void setAlwaysAllowLocalWebarchive();
+    void setAlwaysAllowLocalWebarchive(boolean alwaysAllowLocalWebarchive);
 };
index 0dc9814..e0ab279 100644 (file)
@@ -1,3 +1,15 @@
+2019-02-12  Jiewen Tan  <jiewen_tan@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-13  Michael Catanzaro  <mcatanzaro@igalia.com>
 
         [WPE][GTK] Merge WebProcessPoolWPE.cpp and WebProcessPoolGtk.cpp
index 20a5a5a..331d558 100644 (file)
@@ -1401,6 +1401,7 @@ void WebPage::loadRequest(LoadParameters&& loadParameters)
     frameLoadRequest.setLockHistory(loadParameters.lockHistory);
     frameLoadRequest.setlockBackForwardList(loadParameters.lockBackForwardList);
     frameLoadRequest.setClientRedirectSourceForHistory(loadParameters.clientRedirectSourceForHistory);
+    frameLoadRequest.setIsRequestFromClientOrUserInput();
 
     corePage()->userInputBridge().loadRequest(WTFMove(frameLoadRequest));
 
index ab48431..22cc6a5 100644 (file)
@@ -1,3 +1,28 @@
+2019-02-12  Jiewen Tan  <jiewen_tan@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-13  John Wilander  <wilander@apple.com>
 
         Store Ad Click Attribution requests in the network process
index d3bd644..7c6e123 100644 (file)
                57303BC9200824D300355965 /* CBORValueTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 57303BAC2006C56000355965 /* CBORValueTest.cpp */; };
                57303BCA20082C0100355965 /* CBORWriterTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 57303BAB2006C55400355965 /* CBORWriterTest.cpp */; };
                57303BCB2008376500355965 /* CBORReaderTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 57303BC220071E2200355965 /* CBORReaderTest.cpp */; };
+               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 */; };
                57599E2B1F071AA000A3FB8C /* IndexedDBStructuredCloneBackwardCompatibilityWrite.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 57599E231F07192C00A3FB8C /* IndexedDBStructuredCloneBackwardCompatibilityWrite.html */; };
                5769C50B1D9B0002000847FB /* SerializedCryptoKeyWrap.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5769C50A1D9B0001000847FB /* SerializedCryptoKeyWrap.mm */; };
                5774AA6821FBBF7800AF2A1B /* TestLoadOptimizer.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5774AA6721FBBF7800AF2A1B /* TestLoadOptimizer.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 */; };
                579651E7216BFDED006EBFE5 /* FidoHidMessageTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 579651E6216BFD53006EBFE5 /* FidoHidMessageTest.cpp */; };
                                467C565321B5ED130057516D /* GetSessionCookie.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 */,
                                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 */,
                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>"; };
                574F55D0204D471C002948C6 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
                57599E201F07191700A3FB8C /* IndexedDBStructuredCloneBackwardCompatibility.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = IndexedDBStructuredCloneBackwardCompatibility.mm; 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>"; };
                5774AA6721FBBF7800AF2A1B /* TestLoadOptimizer.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = TestLoadOptimizer.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>"; };
                                F4BFA68C1E4AD08000154298 /* LegacyDragAndDropTests.mm */,
                                7A7B0E7E1EAFE454006AB8AE /* LimitTitleSize.mm */,
                                57901FAE1CAF137100ED64F9 /* LoadInvalidURLRequest.mm */,
+                               5778D05522110A2600899E3B /* LoadWebArchive.mm */,
                                CDA315961ED53651009F60D3 /* MediaPlaybackSleepAssertion.mm */,
                                E1220D9F155B25480013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.mm */,
                                517E7DFB15110EA600D0B008 /* MemoryCachePruneWithinResourceLoadDelegate.mm */,
                                1A7E8B351812093600AEB74A /* FragmentNavigation.html */,
                                F47728981E4AE3AD007ABF6A /* full-page-contenteditable.html */,
                                CDBFCC421A9FF44800A7B691 /* FullscreenZoomInitialFrame.html */,
+                               573255A422139B9000396AE8 /* helloworld.webarchive */,
                                9B4F8FA6159D52CA002D9F94 /* HTMLCollectionNamedItem.html */,
                                9B26FCB4159D15E700CC3765 /* HTMLFormCollectionNamedItem.html */,
                                57F56A5B1C7F8A4000F31D7E /* IsNavigationActionTrusted.html */,
                                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 */,
                                5C838F7F1DB04F900082858F /* LoadInvalidURLRequest.mm in Sources */,
                                7C83E0C01D0A652700FEBCF3 /* LoadInvalidURLRequest.mm in Sources */,
                                7CCE7F001A411AE600447C4C /* LoadPageOnCrash.cpp in Sources */,
+                               5778D05622110A2600899E3B /* LoadWebArchive.mm in Sources */,
                                51E6A8941D2F1C0A00C004B6 /* LocalStorageClear.mm in Sources */,
                                CA38459620AE17A900990D3B /* LocalStorageDatabaseTracker.mm in Sources */,
                                46C519DA1D355AB200DAA51A /* LocalStorageNullEntries.mm in Sources */,
diff --git a/Tools/TestWebKitAPI/Tests/mac/LoadWebArchive.mm b/Tools/TestWebKitAPI/Tests/mac/LoadWebArchive.mm
new file mode 100644 (file)
index 0000000..1a9a675
--- /dev/null
@@ -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 = 'helloworld.webarchive';`.
+    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
diff --git a/Tools/TestWebKitAPI/Tests/mac/helloworld.webarchive b/Tools/TestWebKitAPI/Tests/mac/helloworld.webarchive
new file mode 100644 (file)
index 0000000..5099b1a
Binary files /dev/null and b/Tools/TestWebKitAPI/Tests/mac/helloworld.webarchive differ
diff --git a/Tools/TestWebKitAPI/Tests/mac/load-web-archive-1.html b/Tools/TestWebKitAPI/Tests/mac/load-web-archive-1.html
new file mode 100644 (file)
index 0000000..4be158f
--- /dev/null
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<html>
+<script>
+    document.location.href = 'helloworld.webarchive';
+</script>
+</html>
diff --git a/Tools/TestWebKitAPI/Tests/mac/load-web-archive-2.html b/Tools/TestWebKitAPI/Tests/mac/load-web-archive-2.html
new file mode 100644 (file)
index 0000000..9c04527
--- /dev/null
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<html>
+<script>
+    window.open('helloworld.webarchive');
+</script>
+</html>
index 4be9732..8d560a9 100644 (file)
@@ -84,6 +84,7 @@ typedef NSDictionary<NSNumber *, NSValue *> *ProgressToCGPointValueMap;
 @property (nonatomic, readonly) NSArray<_WKAttachment *> *insertedAttachments;
 @property (nonatomic, readonly) NSArray<_WKAttachment *> *removedAttachments;
 @property (nonatomic, readonly) TestWKWebView *webView;
+@property (nonatomic) WKDragDestinationAction dragDestinationAction;
 
 #if PLATFORM(IOS_FAMILY)
 
index 20f32ca..3f9bc6f 100644 (file)
@@ -332,6 +332,7 @@ static NSArray *dragAndDropEventNames()
 
 - (instancetype)initWithWebViewFrame:(CGRect)frame configuration:(WKWebViewConfiguration *)configuration
 {
+    self.dragDestinationAction = WKDragDestinationActionAny & ~WKDragDestinationActionLoad;
     if (configuration)
         return [self initWithWebView:[[[TestWKWebView alloc] initWithFrame:frame configuration:configuration] autorelease]];
 
@@ -768,6 +769,11 @@ static NSArray *dragAndDropEventNames()
     [_removedAttachments addObject:attachment];
 }
 
+- (WKDragDestinationAction)_webView:(WKWebView *)webView dragDestinationActionMaskForDraggingInfo:(id)draggingInfo
+{
+    return self.dragDestinationAction;
+}
+
 #pragma mark - _WKInputDelegate
 
 - (BOOL)_webView:(WKWebView *)webView focusShouldStartInputSession:(id <_WKFocusedElementInfo>)info
index b2599e5..97d5114 100644 (file)
@@ -122,6 +122,7 @@ static NSImage *defaultExternalDragImage()
         _webView = adoptNS([[DragAndDropTestWKWebView alloc] initWithFrame:frame configuration:configuration ?: [[[WKWebViewConfiguration alloc] init] autorelease] simulator:self]);
         _filePromiseDestinationURLs = adoptNS([NSMutableArray new]);
         [_webView setUIDelegate:self];
+        self.dragDestinationAction = WKDragDestinationActionAny & ~WKDragDestinationActionLoad;
     }
     return self;
 }
@@ -470,6 +471,11 @@ static BOOL getFilePathsAndTypeIdentifiers(NSArray<NSURL *> *fileURLs, NSArray<N
     _doneWaitingForDrop = true;
 }
 
+- (WKDragDestinationAction)_webView:(WKWebView *)webView dragDestinationActionMaskForDraggingInfo:(id)draggingInfo
+{
+    return self.dragDestinationAction;
+}
+
 @end
 
 #endif // ENABLE(DRAG_SUPPORT) && PLATFORM(MAC) && WK_API_ENABLED