| Differences between
and this patch
- a/Source/WebCore/ChangeLog +15 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2016-10-20  Chris Dumez  <cdumez@apple.com>
2
3
        "Download Linked File" context menu action should use 'download' attribute as suggested filename
4
        https://bugs.webkit.org/show_bug.cgi?id=163742
5
        <rdar://problem/28840734>
6
7
        Reviewed by NOBODY (OOPS!).
8
9
        Add convenience method to HitTestResult to return the URL element's
10
        download attribute.
11
12
        * rendering/HitTestResult.cpp:
13
        (WebCore::HitTestResult::URLElementDownloadAttribute):
14
        * rendering/HitTestResult.h:
15
1
2016-10-20  Myles C. Maxfield  <mmaxfield@apple.com>
16
2016-10-20  Myles C. Maxfield  <mmaxfield@apple.com>
2
17
3
        Improve error message when passing a null ArrayBuffer to bufferData()
18
        Improve error message when passing a null ArrayBuffer to bufferData()
- a/Source/WebKit2/ChangeLog +28 lines
Lines 1-3 a/Source/WebKit2/ChangeLog_sec1
1
2016-10-20  Chris Dumez  <cdumez@apple.com>
2
3
        "Download Linked File" context menu action should use 'download' attribute as suggested filename
4
        https://bugs.webkit.org/show_bug.cgi?id=163742
5
        <rdar://problem/28840734>
6
7
        Reviewed by NOBODY (OOPS!).
8
9
        Update "Download Linked File" context menu action to use the anchor
10
        element's 'download' attribute as suggested filename for the download.
11
12
        * NetworkProcess/NetworkProcess.cpp:
13
        (WebKit::NetworkProcess::downloadRequest):
14
        * NetworkProcess/NetworkProcess.h:
15
        * NetworkProcess/NetworkProcess.messages.in:
16
        * Shared/WebHitTestResultData.cpp:
17
        (WebKit::WebHitTestResultData::WebHitTestResultData):
18
        (WebKit::WebHitTestResultData::encode):
19
        (WebKit::WebHitTestResultData::decode):
20
        * Shared/WebHitTestResultData.h:
21
        * UIProcess/WebPageProxy.cpp:
22
        (WebKit::WebPageProxy::contextMenuItemSelected):
23
        * UIProcess/WebProcessPool.cpp:
24
        (WebKit::WebProcessPool::download):
25
        * UIProcess/WebProcessPool.h:
26
        * WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp:
27
        (WebKit::InjectedBundleHitTestResult::linkSuggestedFilename):
28
1
2016-10-20  Carlos Garcia Campos  <cgarcia@igalia.com>
29
2016-10-20  Carlos Garcia Campos  <cgarcia@igalia.com>
2
30
3
        [GTK] Avoid strstr() when checking (E)GL extensions
31
        [GTK] Avoid strstr() when checking (E)GL extensions
- a/Source/WebCore/rendering/HitTestResult.cpp +8 lines
Lines 786-791 Element* HitTestResult::innerNonSharedElement() const a/Source/WebCore/rendering/HitTestResult.cpp_sec1
786
    return node->parentElement();
786
    return node->parentElement();
787
}
787
}
788
788
789
const AtomicString& HitTestResult::URLElementDownloadAttribute() const
790
{
791
    auto* urlElement = URLElement();
792
    if (!is<HTMLAnchorElement>(urlElement))
793
        return nullAtom;
794
    return urlElement->attributeWithoutSynchronization(HTMLNames::downloadAttr);
795
}
796
789
bool HitTestResult::mediaSupportsEnhancedFullscreen() const
797
bool HitTestResult::mediaSupportsEnhancedFullscreen() const
790
{
798
{
791
#if PLATFORM(MAC) && ENABLE(VIDEO) && ENABLE(VIDEO_PRESENTATION_MODE)
799
#if PLATFORM(MAC) && ENABLE(VIDEO) && ENABLE(VIDEO_PRESENTATION_MODE)
- a/Source/WebCore/rendering/HitTestResult.h +2 lines
Lines 66-71 public: a/Source/WebCore/rendering/HitTestResult.h_sec1
66
    Scrollbar* scrollbar() const { return m_scrollbar.get(); }
66
    Scrollbar* scrollbar() const { return m_scrollbar.get(); }
67
    bool isOverWidget() const { return m_isOverWidget; }
67
    bool isOverWidget() const { return m_isOverWidget; }
68
68
69
    WEBCORE_EXPORT const AtomicString& URLElementDownloadAttribute() const;
70
69
    // Forwarded from HitTestLocation
71
    // Forwarded from HitTestLocation
70
    bool isRectBasedTest() const { return m_hitTestLocation.isRectBasedTest(); }
72
    bool isRectBasedTest() const { return m_hitTestLocation.isRectBasedTest(); }
71
73
- a/Source/WebKit2/NetworkProcess/NetworkProcess.cpp -2 / +2 lines
Lines 459-467 void NetworkProcess::deleteWebsiteDataForOrigins(SessionID sessionID, OptionSet< a/Source/WebKit2/NetworkProcess/NetworkProcess.cpp_sec1
459
    completionHandler();
459
    completionHandler();
460
}
460
}
461
461
462
void NetworkProcess::downloadRequest(SessionID sessionID, DownloadID downloadID, const ResourceRequest& request)
462
void NetworkProcess::downloadRequest(SessionID sessionID, DownloadID downloadID, const ResourceRequest& request, const String& suggestedFilename)
463
{
463
{
464
    downloadManager().startDownload(sessionID, downloadID, request);
464
    downloadManager().startDownload(sessionID, downloadID, request, suggestedFilename);
465
}
465
}
466
466
467
void NetworkProcess::resumeDownload(SessionID sessionID, DownloadID downloadID, const IPC::DataReference& resumeData, const String& path, const WebKit::SandboxExtension::Handle& sandboxExtensionHandle)
467
void NetworkProcess::resumeDownload(SessionID sessionID, DownloadID downloadID, const IPC::DataReference& resumeData, const String& path, const WebKit::SandboxExtension::Handle& sandboxExtensionHandle)
- a/Source/WebKit2/NetworkProcess/NetworkProcess.h -1 / +1 lines
Lines 170-176 private: a/Source/WebKit2/NetworkProcess/NetworkProcess.h_sec1
170
    // FIXME: This should take a session ID so we can identify which disk cache to delete.
170
    // FIXME: This should take a session ID so we can identify which disk cache to delete.
171
    void clearDiskCache(std::chrono::system_clock::time_point modifiedSince, std::function<void ()> completionHandler);
171
    void clearDiskCache(std::chrono::system_clock::time_point modifiedSince, std::function<void ()> completionHandler);
172
172
173
    void downloadRequest(WebCore::SessionID, DownloadID, const WebCore::ResourceRequest&);
173
    void downloadRequest(WebCore::SessionID, DownloadID, const WebCore::ResourceRequest&, const String& suggestedFilename);
174
    void resumeDownload(WebCore::SessionID, DownloadID, const IPC::DataReference& resumeData, const String& path, const SandboxExtension::Handle&);
174
    void resumeDownload(WebCore::SessionID, DownloadID, const IPC::DataReference& resumeData, const String& path, const SandboxExtension::Handle&);
175
    void cancelDownload(DownloadID);
175
    void cancelDownload(DownloadID);
176
#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
176
#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
- a/Source/WebKit2/NetworkProcess/NetworkProcess.messages.in -1 / +1 lines
Lines 41-47 messages -> NetworkProcess LegacyReceiver { a/Source/WebKit2/NetworkProcess/NetworkProcess.messages.in_sec1
41
    DeleteWebsiteData(WebCore::SessionID sessionID, OptionSet<WebKit::WebsiteDataType> websiteDataTypes, std::chrono::system_clock::time_point modifiedSince, uint64_t callbackID)
41
    DeleteWebsiteData(WebCore::SessionID sessionID, OptionSet<WebKit::WebsiteDataType> websiteDataTypes, std::chrono::system_clock::time_point modifiedSince, uint64_t callbackID)
42
    DeleteWebsiteDataForOrigins(WebCore::SessionID sessionID, OptionSet<WebKit::WebsiteDataType> websiteDataTypes, Vector<WebCore::SecurityOriginData> origins, Vector<String> cookieHostNames, uint64_t callbackID)
42
    DeleteWebsiteDataForOrigins(WebCore::SessionID sessionID, OptionSet<WebKit::WebsiteDataType> websiteDataTypes, Vector<WebCore::SecurityOriginData> origins, Vector<String> cookieHostNames, uint64_t callbackID)
43
43
44
    DownloadRequest(WebCore::SessionID sessionID, WebKit::DownloadID downloadID, WebCore::ResourceRequest request)
44
    DownloadRequest(WebCore::SessionID sessionID, WebKit::DownloadID downloadID, WebCore::ResourceRequest request, String suggestedFilename)
45
    ResumeDownload(WebCore::SessionID sessionID, WebKit::DownloadID downloadID, IPC::DataReference resumeData, String path, WebKit::SandboxExtension::Handle sandboxExtensionHandle)
45
    ResumeDownload(WebCore::SessionID sessionID, WebKit::DownloadID downloadID, IPC::DataReference resumeData, String path, WebKit::SandboxExtension::Handle sandboxExtensionHandle)
46
    CancelDownload(WebKit::DownloadID downloadID)
46
    CancelDownload(WebKit::DownloadID downloadID)
47
47
- a/Source/WebKit2/Shared/WebHitTestResultData.cpp +4 lines
Lines 46-51 WebHitTestResultData::WebHitTestResultData(const WebCore::HitTestResult& hitTest a/Source/WebKit2/Shared/WebHitTestResultData.cpp_sec1
46
    , absoluteMediaURL(hitTestResult.absoluteMediaURL().string())
46
    , absoluteMediaURL(hitTestResult.absoluteMediaURL().string())
47
    , linkLabel(hitTestResult.textContent())
47
    , linkLabel(hitTestResult.textContent())
48
    , linkTitle(hitTestResult.titleDisplayString())
48
    , linkTitle(hitTestResult.titleDisplayString())
49
    , linkSuggestedFilename(hitTestResult.URLElementDownloadAttribute())
49
    , isContentEditable(hitTestResult.isContentEditable())
50
    , isContentEditable(hitTestResult.isContentEditable())
50
    , elementBoundingBox(elementBoundingBoxInWindowCoordinates(hitTestResult))
51
    , elementBoundingBox(elementBoundingBoxInWindowCoordinates(hitTestResult))
51
    , isScrollbar(hitTestResult.scrollbar())
52
    , isScrollbar(hitTestResult.scrollbar())
Lines 65-70 WebHitTestResultData::WebHitTestResultData(const WebCore::HitTestResult& hitTest a/Source/WebKit2/Shared/WebHitTestResultData.cpp_sec2
65
    , absoluteMediaURL(hitTestResult.absoluteMediaURL().string())
66
    , absoluteMediaURL(hitTestResult.absoluteMediaURL().string())
66
    , linkLabel(hitTestResult.textContent())
67
    , linkLabel(hitTestResult.textContent())
67
    , linkTitle(hitTestResult.titleDisplayString())
68
    , linkTitle(hitTestResult.titleDisplayString())
69
    , linkSuggestedFilename(hitTestResult.URLElementDownloadAttribute())
68
    , isContentEditable(hitTestResult.isContentEditable())
70
    , isContentEditable(hitTestResult.isContentEditable())
69
    , elementBoundingBox(elementBoundingBoxInWindowCoordinates(hitTestResult))
71
    , elementBoundingBox(elementBoundingBoxInWindowCoordinates(hitTestResult))
70
    , isScrollbar(hitTestResult.scrollbar())
72
    , isScrollbar(hitTestResult.scrollbar())
Lines 100-105 void WebHitTestResultData::encode(IPC::Encoder& encoder) const a/Source/WebKit2/Shared/WebHitTestResultData.cpp_sec3
100
    encoder << absoluteMediaURL;
102
    encoder << absoluteMediaURL;
101
    encoder << linkLabel;
103
    encoder << linkLabel;
102
    encoder << linkTitle;
104
    encoder << linkTitle;
105
    encoder << linkSuggestedFilename;
103
    encoder << isContentEditable;
106
    encoder << isContentEditable;
104
    encoder << elementBoundingBox;
107
    encoder << elementBoundingBox;
105
    encoder << isScrollbar;
108
    encoder << isScrollbar;
Lines 133-138 bool WebHitTestResultData::decode(IPC::Decoder& decoder, WebHitTestResultData& h a/Source/WebKit2/Shared/WebHitTestResultData.cpp_sec4
133
        || !decoder.decode(hitTestResultData.absoluteMediaURL)
136
        || !decoder.decode(hitTestResultData.absoluteMediaURL)
134
        || !decoder.decode(hitTestResultData.linkLabel)
137
        || !decoder.decode(hitTestResultData.linkLabel)
135
        || !decoder.decode(hitTestResultData.linkTitle)
138
        || !decoder.decode(hitTestResultData.linkTitle)
139
        || !decoder.decode(hitTestResultData.linkSuggestedFilename)
136
        || !decoder.decode(hitTestResultData.isContentEditable)
140
        || !decoder.decode(hitTestResultData.isContentEditable)
137
        || !decoder.decode(hitTestResultData.elementBoundingBox)
141
        || !decoder.decode(hitTestResultData.elementBoundingBox)
138
        || !decoder.decode(hitTestResultData.isScrollbar)
142
        || !decoder.decode(hitTestResultData.isScrollbar)
- a/Source/WebKit2/Shared/WebHitTestResultData.h +1 lines
Lines 50-55 struct WebHitTestResultData { a/Source/WebKit2/Shared/WebHitTestResultData.h_sec1
50
    String absoluteMediaURL;
50
    String absoluteMediaURL;
51
    String linkLabel;
51
    String linkLabel;
52
    String linkTitle;
52
    String linkTitle;
53
    String linkSuggestedFilename;
53
    bool isContentEditable;
54
    bool isContentEditable;
54
    WebCore::IntRect elementBoundingBox;
55
    WebCore::IntRect elementBoundingBox;
55
    bool isScrollbar;
56
    bool isScrollbar;
- a/Source/WebKit2/UIProcess/WebPageProxy.cpp -1 / +2 lines
Lines 4587-4593 void WebPageProxy::contextMenuItemSelected(const WebContextMenuItemData& item) a/Source/WebKit2/UIProcess/WebPageProxy.cpp_sec1
4587
        return;    
4587
        return;    
4588
    }
4588
    }
4589
    if (item.action() == ContextMenuItemTagDownloadLinkToDisk) {
4589
    if (item.action() == ContextMenuItemTagDownloadLinkToDisk) {
4590
        m_process->processPool().download(this, URL(URL(), m_activeContextMenuContextData.webHitTestResultData().absoluteLinkURL));
4590
        auto& hitTestResult = m_activeContextMenuContextData.webHitTestResultData();
4591
        m_process->processPool().download(this, URL(URL(), hitTestResult.absoluteLinkURL), hitTestResult.linkSuggestedFilename);
4591
        return;
4592
        return;
4592
    }
4593
    }
4593
    if (item.action() == ContextMenuItemTagDownloadMediaToDisk) {
4594
    if (item.action() == ContextMenuItemTagDownloadMediaToDisk) {
- a/Source/WebKit2/UIProcess/WebProcessPool.cpp -2 / +2 lines
Lines 814-820 Ref<WebPageProxy> WebProcessPool::createWebPage(PageClient& pageClient, Ref<API: a/Source/WebKit2/UIProcess/WebProcessPool.cpp_sec1
814
    return process->createWebPage(pageClient, WTFMove(pageConfiguration));
814
    return process->createWebPage(pageClient, WTFMove(pageConfiguration));
815
}
815
}
816
816
817
DownloadProxy* WebProcessPool::download(WebPageProxy* initiatingPage, const ResourceRequest& request)
817
DownloadProxy* WebProcessPool::download(WebPageProxy* initiatingPage, const ResourceRequest& request, const String& suggestedFilename)
818
{
818
{
819
    DownloadProxy* downloadProxy = createDownloadProxy(request);
819
    DownloadProxy* downloadProxy = createDownloadProxy(request);
820
    SessionID sessionID = initiatingPage ? initiatingPage->sessionID() : SessionID::defaultSessionID();
820
    SessionID sessionID = initiatingPage ? initiatingPage->sessionID() : SessionID::defaultSessionID();
Lines 827-833 DownloadProxy* WebProcessPool::download(WebPageProxy* initiatingPage, const Reso a/Source/WebKit2/UIProcess/WebProcessPool.cpp_sec2
827
            updatedRequest.setFirstPartyForCookies(URL(URL(), initiatingPage->pageLoadState().url()));
827
            updatedRequest.setFirstPartyForCookies(URL(URL(), initiatingPage->pageLoadState().url()));
828
        else
828
        else
829
            updatedRequest.setFirstPartyForCookies(URL());
829
            updatedRequest.setFirstPartyForCookies(URL());
830
        networkProcess()->send(Messages::NetworkProcess::DownloadRequest(sessionID, downloadProxy->downloadID(), updatedRequest), 0);
830
        networkProcess()->send(Messages::NetworkProcess::DownloadRequest(sessionID, downloadProxy->downloadID(), updatedRequest, suggestedFilename), 0);
831
        return downloadProxy;
831
        return downloadProxy;
832
    }
832
    }
833
833
- a/Source/WebKit2/UIProcess/WebProcessPool.h -1 / +1 lines
Lines 166-172 public: a/Source/WebKit2/UIProcess/WebProcessPool.h_sec1
166
166
167
    const String& injectedBundlePath() const { return m_configuration->injectedBundlePath(); }
167
    const String& injectedBundlePath() const { return m_configuration->injectedBundlePath(); }
168
168
169
    DownloadProxy* download(WebPageProxy* initiatingPage, const WebCore::ResourceRequest&);
169
    DownloadProxy* download(WebPageProxy* initiatingPage, const WebCore::ResourceRequest&, const String& suggestedFilename = { });
170
    DownloadProxy* resumeDownload(const API::Data* resumeData, const String& path);
170
    DownloadProxy* resumeDownload(const API::Data* resumeData, const String& path);
171
171
172
    void setInjectedBundleInitializationUserData(PassRefPtr<API::Object> userData) { m_injectedBundleInitializationUserData = userData; }
172
    void setInjectedBundleInitializationUserData(PassRefPtr<API::Object> userData) { m_injectedBundleInitializationUserData = userData; }
- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp -6 / +1 lines
Lines 34-41 a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp_sec1
34
#include <WebCore/Frame.h>
34
#include <WebCore/Frame.h>
35
#include <WebCore/FrameLoader.h>
35
#include <WebCore/FrameLoader.h>
36
#include <WebCore/FrameView.h>
36
#include <WebCore/FrameView.h>
37
#include <WebCore/HTMLAnchorElement.h>
38
#include <WebCore/HTMLNames.h>
39
#include <WebCore/URL.h>
37
#include <WebCore/URL.h>
40
#include <wtf/text/WTFString.h>
38
#include <wtf/text/WTFString.h>
41
39
Lines 143-152 String InjectedBundleHitTestResult::linkTitle() const a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp_sec2
143
141
144
String InjectedBundleHitTestResult::linkSuggestedFilename() const
142
String InjectedBundleHitTestResult::linkSuggestedFilename() const
145
{
143
{
146
    auto* urlElement = m_hitTestResult.URLElement();
144
    return m_hitTestResult.URLElementDownloadAttribute();
147
    if (!is<HTMLAnchorElement>(urlElement))
148
        return String();
149
    return urlElement->attributeWithoutSynchronization(HTMLNames::downloadAttr);
150
}
145
}
151
146
152
IntRect InjectedBundleHitTestResult::imageRect() const
147
IntRect InjectedBundleHitTestResult::imageRect() const
- a/Tools/ChangeLog +18 lines
Lines 1-3 a/Tools/ChangeLog_sec1
1
2016-10-20  Chris Dumez  <cdumez@apple.com>
2
3
        "Download Linked File" context menu action should use 'download' attribute as suggested filename
4
        https://bugs.webkit.org/show_bug.cgi?id=163742
5
        <rdar://problem/28840734>
6
7
        Reviewed by NOBODY (OOPS!).
8
9
        Add API test coverage.
10
11
        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
12
        * TestWebKitAPI/Tests/WebKit2/link-with-download-attribute.html: Added.
13
        * TestWebKitAPI/Tests/WebKit2/mac/ContextMenuDownload.mm: Added.
14
        (TestWebKitAPI::didFinishLoadForFrame):
15
        (TestWebKitAPI::getContextMenuFromProposedMenu):
16
        (TestWebKitAPI::decideDestinationWithSuggestedFilename):
17
        (TestWebKitAPI::TEST):
18
1
2016-10-20  Sam Weinig  <sam@webkit.org>
19
2016-10-20  Sam Weinig  <sam@webkit.org>
2
20
3
        Add convenience function that combines WTF::visit(...) with WTF::makeVisitor(...)
21
        Add convenience function that combines WTF::visit(...) with WTF::makeVisitor(...)
- a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj +8 lines
Lines 403-408 a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj_sec1
403
		7CCE7F2F1A411B1000447C4C /* WKBrowsingContextLoadDelegateTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC3C4C7014575B6A0025FB62 /* WKBrowsingContextLoadDelegateTest.mm */; };
403
		7CCE7F2F1A411B1000447C4C /* WKBrowsingContextLoadDelegateTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC3C4C7014575B6A0025FB62 /* WKBrowsingContextLoadDelegateTest.mm */; };
404
		7CEFA9661AC0B9E200B910FD /* _WKUserContentExtensionStore.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7CEFA9641AC0B9E200B910FD /* _WKUserContentExtensionStore.mm */; };
404
		7CEFA9661AC0B9E200B910FD /* _WKUserContentExtensionStore.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7CEFA9641AC0B9E200B910FD /* _WKUserContentExtensionStore.mm */; };
405
		7CFBCAE51743238F00B2BFCF /* WillLoad_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CFBCAE31743238E00B2BFCF /* WillLoad_Bundle.cpp */; };
405
		7CFBCAE51743238F00B2BFCF /* WillLoad_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CFBCAE31743238E00B2BFCF /* WillLoad_Bundle.cpp */; };
406
		8349D3C21DB96DDE004A9F65 /* ContextMenuDownload.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8349D3C11DB96DDA004A9F65 /* ContextMenuDownload.mm */; };
407
		8349D3C41DB9728E004A9F65 /* link-with-download-attribute.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 8349D3C31DB9724F004A9F65 /* link-with-download-attribute.html */; };
406
		835CF9671D25FCD6001A65D4 /* RestoreSessionStateWithoutNavigation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 835CF9661D25FCD6001A65D4 /* RestoreSessionStateWithoutNavigation.cpp */; };
408
		835CF9671D25FCD6001A65D4 /* RestoreSessionStateWithoutNavigation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 835CF9661D25FCD6001A65D4 /* RestoreSessionStateWithoutNavigation.cpp */; };
407
		837A35F11D9A1E7D00663C57 /* DownloadRequestBlobURL.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 837A35F01D9A1E6400663C57 /* DownloadRequestBlobURL.html */; };
409
		837A35F11D9A1E7D00663C57 /* DownloadRequestBlobURL.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 837A35F01D9A1E6400663C57 /* DownloadRequestBlobURL.html */; };
408
		83CF1C301C4F1B8B00688447 /* StringUtilities.mm in Sources */ = {isa = PBXBuildFile; fileRef = 83CF1C2C1C4F19AE00688447 /* StringUtilities.mm */; };
410
		83CF1C301C4F1B8B00688447 /* StringUtilities.mm in Sources */ = {isa = PBXBuildFile; fileRef = 83CF1C2C1C4F19AE00688447 /* StringUtilities.mm */; };
Lines 562-567 a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj_sec2
562
			dstPath = TestWebKitAPI.resources;
564
			dstPath = TestWebKitAPI.resources;
563
			dstSubfolderSpec = 7;
565
			dstSubfolderSpec = 7;
564
			files = (
566
			files = (
567
				8349D3C41DB9728E004A9F65 /* link-with-download-attribute.html in Copy Resources */,
565
				AD57AC221DA7466E00FF1BDE /* many-iframes.html in Copy Resources */,
568
				AD57AC221DA7466E00FF1BDE /* many-iframes.html in Copy Resources */,
566
				F415086D1DA040C50044BE9B /* play-audio-on-click.html in Copy Resources */,
569
				F415086D1DA040C50044BE9B /* play-audio-on-click.html in Copy Resources */,
567
				F4F137921D9B683E002BEC57 /* large-video-test-now-playing.html in Copy Resources */,
570
				F4F137921D9B683E002BEC57 /* large-video-test-now-playing.html in Copy Resources */,
Lines 1005-1010 a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj_sec3
1005
		7CFBCADD1743234F00B2BFCF /* WillLoad.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WillLoad.cpp; sourceTree = "<group>"; };
1008
		7CFBCADD1743234F00B2BFCF /* WillLoad.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WillLoad.cpp; sourceTree = "<group>"; };
1006
		7CFBCAE31743238E00B2BFCF /* WillLoad_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WillLoad_Bundle.cpp; sourceTree = "<group>"; };
1009
		7CFBCAE31743238E00B2BFCF /* WillLoad_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WillLoad_Bundle.cpp; sourceTree = "<group>"; };
1007
		81B50192140F232300D9EB58 /* StringBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringBuilder.cpp; sourceTree = "<group>"; };
1010
		81B50192140F232300D9EB58 /* StringBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringBuilder.cpp; sourceTree = "<group>"; };
1011
		8349D3C11DB96DDA004A9F65 /* ContextMenuDownload.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ContextMenuDownload.mm; sourceTree = "<group>"; };
1012
		8349D3C31DB9724F004A9F65 /* link-with-download-attribute.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "link-with-download-attribute.html"; sourceTree = "<group>"; };
1008
		835CF9661D25FCD6001A65D4 /* RestoreSessionStateWithoutNavigation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RestoreSessionStateWithoutNavigation.cpp; sourceTree = "<group>"; };
1013
		835CF9661D25FCD6001A65D4 /* RestoreSessionStateWithoutNavigation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RestoreSessionStateWithoutNavigation.cpp; sourceTree = "<group>"; };
1009
		837A35F01D9A1E6400663C57 /* DownloadRequestBlobURL.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = DownloadRequestBlobURL.html; sourceTree = "<group>"; };
1014
		837A35F01D9A1E6400663C57 /* DownloadRequestBlobURL.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = DownloadRequestBlobURL.html; sourceTree = "<group>"; };
1010
		83B88A331C80056D00BB2418 /* HTMLParserIdioms.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLParserIdioms.cpp; sourceTree = "<group>"; };
1015
		83B88A331C80056D00BB2418 /* HTMLParserIdioms.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLParserIdioms.cpp; sourceTree = "<group>"; };
Lines 1842-1847 a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj_sec4
1842
				4A410F4D19AF7BEF002EBAB5 /* getUserMedia.html */,
1847
				4A410F4D19AF7BEF002EBAB5 /* getUserMedia.html */,
1843
				BCBD372E125ABBE600D2C29F /* icon.png */,
1848
				BCBD372E125ABBE600D2C29F /* icon.png */,
1844
				CE3524F51B142BBB0028A7C5 /* input-focus-blur.html */,
1849
				CE3524F51B142BBB0028A7C5 /* input-focus-blur.html */,
1850
				8349D3C31DB9724F004A9F65 /* link-with-download-attribute.html */,
1845
				378E647816326FDF00B6C676 /* link-with-title.html */,
1851
				378E647816326FDF00B6C676 /* link-with-title.html */,
1846
				9361002814DC957B0061379D /* lots-of-iframes.html */,
1852
				9361002814DC957B0061379D /* lots-of-iframes.html */,
1847
				93AF4ECF1506F123007FD57E /* lots-of-images.html */,
1853
				93AF4ECF1506F123007FD57E /* lots-of-images.html */,
Lines 2031-2036 a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj_sec5
2031
		C0C5D3BB14598B6F00A802A6 /* mac */ = {
2037
		C0C5D3BB14598B6F00A802A6 /* mac */ = {
2032
			isa = PBXGroup;
2038
			isa = PBXGroup;
2033
			children = (
2039
			children = (
2040
				8349D3C11DB96DDA004A9F65 /* ContextMenuDownload.mm */,
2034
				BCAA485714A044D40088FAC4 /* EditorCommands.mm */,
2041
				BCAA485714A044D40088FAC4 /* EditorCommands.mm */,
2035
				C0C5D3BC14598B6F00A802A6 /* GetBackingScaleFactor.mm */,
2042
				C0C5D3BC14598B6F00A802A6 /* GetBackingScaleFactor.mm */,
2036
				C0C5D3BD14598B6F00A802A6 /* GetBackingScaleFactor_Bundle.mm */,
2043
				C0C5D3BD14598B6F00A802A6 /* GetBackingScaleFactor_Bundle.mm */,
Lines 2415-2420 a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj_sec6
2415
				7C83E0BE1D0A651300FEBCF3 /* IndexedDBMultiProcess.mm in Sources */,
2422
				7C83E0BE1D0A651300FEBCF3 /* IndexedDBMultiProcess.mm in Sources */,
2416
				7C83E0BF1D0A652200FEBCF3 /* IndexedDBPersistence.mm in Sources */,
2423
				7C83E0BF1D0A652200FEBCF3 /* IndexedDBPersistence.mm in Sources */,
2417
				7CCE7EFB1A411AE600447C4C /* InjectedBundleBasic.cpp in Sources */,
2424
				7CCE7EFB1A411AE600447C4C /* InjectedBundleBasic.cpp in Sources */,
2425
				8349D3C21DB96DDE004A9F65 /* ContextMenuDownload.mm in Sources */,
2418
				7CCE7EFC1A411AE600447C4C /* InjectedBundleFrameHitTest.cpp in Sources */,
2426
				7CCE7EFC1A411AE600447C4C /* InjectedBundleFrameHitTest.cpp in Sources */,
2419
				7CCE7EFD1A411AE600447C4C /* InjectedBundleInitializationUserDataCallbackWins.cpp in Sources */,
2427
				7CCE7EFD1A411AE600447C4C /* InjectedBundleInitializationUserDataCallbackWins.cpp in Sources */,
2420
				2EFF06D41D8AEDBB0004BB30 /* TestWKWebViewMac.mm in Sources */,
2428
				2EFF06D41D8AEDBB0004BB30 /* TestWKWebViewMac.mm in Sources */,
- a/Tools/TestWebKitAPI/Tests/WebKit2/link-with-download-attribute.html +10 lines
Line 0 a/Tools/TestWebKitAPI/Tests/WebKit2/link-with-download-attribute.html_sec1
1
<html>
2
    <body>
3
        <a id="testAnchor" style="display: block; height: 100%; width: 100%" download="downloadAttributeValue.txt"></a>
4
        <script>
5
            var blob = new Blob(["Hello world!"], {type: "application/octet-stream"});
6
            var link = document.getElementById("testAnchor");
7
            link.href = window.URL.createObjectURL(blob);
8
        </script>
9
    </body>
10
</html>
- a/Tools/TestWebKitAPI/Tests/WebKit2/mac/ContextMenuDownload.mm +111 lines
Line 0 a/Tools/TestWebKitAPI/Tests/WebKit2/mac/ContextMenuDownload.mm_sec1
1
/*
2
 * Copyright (C) 2011 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#include "config.h"
27
#include "JavaScriptTest.h"
28
#include "PlatformUtilities.h"
29
#include "PlatformWebView.h"
30
#include <WebKit/WKContextMenuItem.h>
31
#include <WebKit/WKDownload.h>
32
#include <WebKit/WKPage.h>
33
#include <WebKit/WKPageContextMenuClient.h>
34
#include <WebKit/WKPreferencesPrivate.h>
35
#include <WebKit/WKRetainPtr.h>
36
37
namespace TestWebKitAPI {
38
39
static bool didFinishLoad;
40
static bool didDecideDownloadDestination;
41
42
static void didFinishLoadForFrame(WKPageRef, WKFrameRef, WKTypeRef, const void*)
43
{
44
    didFinishLoad = true;
45
}
46
47
static void getContextMenuFromProposedMenu(WKPageRef page, WKArrayRef proposedMenu, WKArrayRef* newMenu, WKHitTestResultRef hitTestResult, WKTypeRef userData, const void* clientInfo)
48
{
49
    size_t count = WKArrayGetSize(proposedMenu);
50
    for (size_t i = 0; i < count; ++i) {
51
        WKContextMenuItemRef contextMenuItem = static_cast<WKContextMenuItemRef>(WKArrayGetItemAtIndex(proposedMenu, i));
52
        switch (WKContextMenuItemGetTag(contextMenuItem)) {
53
        case kWKContextMenuItemTagDownloadLinkToDisk:
54
            // Click "Download Linked File" context menu entry.
55
            WKPageSelectContextMenuItem(page, contextMenuItem);
56
            break;
57
        default:
58
            break;
59
        }
60
    }
61
}
62
63
static WKStringRef decideDestinationWithSuggestedFilename(WKContextRef, WKDownloadRef download, WKStringRef suggestedFilename, bool*, const void*)
64
{
65
    // Make sure the suggested filename is provided and matches the value of the download attribute in the HTML.
66
    EXPECT_WK_STREQ("downloadAttributeValue.txt", suggestedFilename);
67
68
    WKDownloadCancel(download);
69
    didDecideDownloadDestination = true;
70
71
    return Util::toWK("/tmp/WebKitAPITest/ContextMenuDownload").leakRef();
72
}
73
74
// Checks that the HTML download attribute is used as suggested filename when selecting
75
// the "Download Linked File" item in the context menu.
76
TEST(WebKit2, ContextMenuDownloadHTMLDownloadAttribute)
77
{
78
    WKRetainPtr<WKContextRef> context(AdoptWK, Util::createContextWithInjectedBundle());
79
80
    WKContextDownloadClientV0 client;
81
    memset(&client, 0, sizeof(client));
82
    client.base.version = 0;
83
    client.decideDestinationWithSuggestedFilename = decideDestinationWithSuggestedFilename;
84
    WKContextSetDownloadClient(context.get(), &client.base);
85
86
    WKRetainPtr<WKPageGroupRef> pageGroup(AdoptWK, WKPageGroupCreateWithIdentifier(Util::toWK("MyGroup").get()));
87
    PlatformWebView webView(context.get(), pageGroup.get());
88
89
    WKPageLoaderClientV0 loaderClient;
90
    memset(&loaderClient, 0, sizeof(loaderClient));
91
    loaderClient.base.version = 0;
92
    loaderClient.didFinishLoadForFrame = didFinishLoadForFrame;
93
    WKPageSetPageLoaderClient(webView.page(), &loaderClient.base);
94
95
    WKPageContextMenuClientV3 contextMenuClient;
96
    memset(&contextMenuClient, 0, sizeof(contextMenuClient));
97
    contextMenuClient.base.version = 3;
98
    contextMenuClient.getContextMenuFromProposedMenu = getContextMenuFromProposedMenu;
99
    WKPageSetPageContextMenuClient(webView.page(), &contextMenuClient.base);
100
101
    WKRetainPtr<WKURLRef> url(AdoptWK, Util::createURLForResource("link-with-download-attribute", "html"));
102
103
    WKPageLoadURL(webView.page(), url.get());
104
    Util::run(&didFinishLoad);
105
106
    // Right click on link.
107
    webView.simulateButtonClick(kWKEventMouseButtonRightButton, 50, 50, 0);
108
    Util::run(&didDecideDownloadDestination);
109
}
110
111
}

Return to Bug 163742