Title: [223167] trunk
Revision
223167
Author
rn...@webkit.org
Date
2017-10-10 21:12:30 -0700 (Tue, 10 Oct 2017)

Log Message

Enable custom pasteboard data in DumpRenderTree and WebKitTestRunner
https://bugs.webkit.org/show_bug.cgi?id=178154

Reviewed by Wenson Hsieh.

Source/WebCore:

Extracted the logic to compute the default enabled-ness of custom pasteboard data as
Settings::defaultCustomPasteboardDataEnabled() to be called by WebKit1 and WebKit2 layers.

* page/Settings.cpp:
(WebCore::Settings::defaultCustomPasteboardDataEnabled): Extracted from customPasteboardDataEnabled.
(WebCore::Settings::customPasteboardDataEnabled): Deleted. Now inlined in the header file.
* page/Settings.h:
(WebCore::Settings::customPasteboardDataEnabled):
* platform/cocoa/PasteboardCocoa.mm:
(WebCore::Pasteboard::read): Fixed a bug that we were adding MIME type to the map before checking that
we could actually read the buffer. We shouldn't skip a type (NSTIFFPboardType and kUTTypeTIFF for now)
if an equivalent type had failed to read.

Source/WebKit:

Plumbed customPasteboardDataEnabled flag to be used in WebKitTestRunner.

* Shared/WebPreferencesDefinitions.h:
* UIProcess/API/C/WKPreferences.cpp:
(WKPreferencesSetCustomPasteboardDataEnabled):
(WKPreferencesGetCustomPasteboardDataEnabled):
* UIProcess/API/C/WKPreferencesRefPrivate.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updatePreferences):

Source/WebKitLegacy/mac:

Enable custom pasteboard data by default.

* WebView/WebPreferenceKeysPrivate.h:
* WebView/WebPreferences.mm:
(+[WebPreferences initialize]):
(-[WebPreferences customPasteboardDataEnabled]): Added.
(-[WebPreferences setCustomPasteboardDataEnabled:]): Added.
* WebView/WebPreferencesPrivate.h:
* WebView/WebView.mm:
(-[WebView _preferencesChanged:]):

Tools:

Fixed the bug that LocalPasteboard would fail to load the promise type if data is set after declaring types
by delaying the call to provideDataForType until when dataForType is called.

Without this fix, fast/events/dropzone-002.html would start failing after enabling custom pasteboard data.
With this fix, fast/events/dropzone-005.html also starts passing.

* DumpRenderTree/mac/DumpRenderTree.mm:
(resetWebPreferencesToConsistentValues):
* DumpRenderTree/mac/DumpRenderTreePasteboard.mm:
(-[LocalPasteboard addTypes:owner:]):
(-[LocalPasteboard dataForType:]):
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::resetPreferencesToConsistentValues):

LayoutTests:

* editing/pasteboard/dataTransfer-setData-getData-expected.txt: Rebaselined. One more test case is passing now.
* fast/events/dropzone-002.html: Fixed the test to accept an image since we no longer drop URLs when dropping
an image avoid leaking local file paths.
* platform/mac/TestExpectations: Enabled dropzone-005.html since it started passing after fixing LocalPasteboard.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (223166 => 223167)


--- trunk/LayoutTests/ChangeLog	2017-10-11 03:49:16 UTC (rev 223166)
+++ trunk/LayoutTests/ChangeLog	2017-10-11 04:12:30 UTC (rev 223167)
@@ -1,3 +1,15 @@
+2017-10-10  Ryosuke Niwa  <rn...@webkit.org>
+
+        Enable custom pasteboard data in DumpRenderTree and WebKitTestRunner
+        https://bugs.webkit.org/show_bug.cgi?id=178154
+
+        Reviewed by Wenson Hsieh.
+
+        * editing/pasteboard/dataTransfer-setData-getData-expected.txt: Rebaselined. One more test case is passing now.
+        * fast/events/dropzone-002.html: Fixed the test to accept an image since we no longer drop URLs when dropping
+        an image avoid leaking local file paths.
+        * platform/mac/TestExpectations: Enabled dropzone-005.html since it started passing after fixing LocalPasteboard.
+
 2017-10-10  Andy Estes  <aes...@apple.com>
 
         [Payment Request] Validate that all PaymentCurrencyAmounts use the same currency code when using Apple Pay

Modified: trunk/LayoutTests/editing/pasteboard/dataTransfer-setData-getData-expected.txt (223166 => 223167)


--- trunk/LayoutTests/editing/pasteboard/dataTransfer-setData-getData-expected.txt	2017-10-11 03:49:16 UTC (rev 223166)
+++ trunk/LayoutTests/editing/pasteboard/dataTransfer-setData-getData-expected.txt	2017-10-11 04:12:30 UTC (rev 223167)
@@ -5,7 +5,7 @@
 
 --- Test set/get 'URL':
 PASS getDataResultType is "string"
-FAIL getDataResult should be http://test.com/. Was http://test.com.
+PASS getDataResult is "http://test.com/"
 --- Test set/get 'URL' with multiple URLs:
 PASS getDataResultType is "string"
 FAIL getDataResult should be http://test.com/. Was .

Modified: trunk/LayoutTests/fast/events/dropzone-002.html (223166 => 223167)


--- trunk/LayoutTests/fast/events/dropzone-002.html	2017-10-11 03:49:16 UTC (rev 223166)
+++ trunk/LayoutTests/fast/events/dropzone-002.html	2017-10-11 04:12:30 UTC (rev 223167)
@@ -32,7 +32,7 @@
 
 function changeDropZone()
 {
-    dropTarget.setAttribute("webkitdropzone", " StRinG:tExT/pLaIn sTrING:TeXt/UrI-lIsT " + dropEffectElem.options[dropEffectElem.selectedIndex].value);
+    dropTarget.setAttribute("webkitdropzone", " StRinG:tExT/pLaIn sTrING:TeXt/UrI-lIsT file:image/png " + dropEffectElem.options[dropEffectElem.selectedIndex].value);
 }
 
 function printDropEvent(e)
@@ -55,7 +55,7 @@
     var endY = dropTarget.offsetTop + dropTarget.offsetHeight / 2
     
     var numEffects = dropEffectElem.options.length;
-    
+
     for (var j = 0; j < numEffects; ++j) {
         dropEffectElem.options[j].selected = true;
         changeDropZone();

Modified: trunk/LayoutTests/platform/mac/TestExpectations (223166 => 223167)


--- trunk/LayoutTests/platform/mac/TestExpectations	2017-10-11 03:49:16 UTC (rev 223166)
+++ trunk/LayoutTests/platform/mac/TestExpectations	2017-10-11 04:12:30 UTC (rev 223167)
@@ -276,9 +276,6 @@
 
 webkit.org/b/81410 scrollbars/scrollbar-middleclick-nopaste.html
 
-# Has failed since its introduction in r105826.
-webkit.org/b/61630 fast/events/dropzone-005.html [ Failure ]
-
 # Spelling tests that are flakey.
 webkit.org/b/82555 editing/spelling/spellcheck-async-mutation.html [ Pass Failure ]
 

Modified: trunk/Source/WebCore/ChangeLog (223166 => 223167)


--- trunk/Source/WebCore/ChangeLog	2017-10-11 03:49:16 UTC (rev 223166)
+++ trunk/Source/WebCore/ChangeLog	2017-10-11 04:12:30 UTC (rev 223167)
@@ -1,3 +1,23 @@
+2017-10-10  Ryosuke Niwa  <rn...@webkit.org>
+
+        Enable custom pasteboard data in DumpRenderTree and WebKitTestRunner
+        https://bugs.webkit.org/show_bug.cgi?id=178154
+
+        Reviewed by Wenson Hsieh.
+
+        Extracted the logic to compute the default enabled-ness of custom pasteboard data as
+        Settings::defaultCustomPasteboardDataEnabled() to be called by WebKit1 and WebKit2 layers.
+
+        * page/Settings.cpp:
+        (WebCore::Settings::defaultCustomPasteboardDataEnabled): Extracted from customPasteboardDataEnabled.
+        (WebCore::Settings::customPasteboardDataEnabled): Deleted. Now inlined in the header file.
+        * page/Settings.h:
+        (WebCore::Settings::customPasteboardDataEnabled):
+        * platform/cocoa/PasteboardCocoa.mm:
+        (WebCore::Pasteboard::read): Fixed a bug that we were adding MIME type to the map before checking that
+        we could actually read the buffer. We shouldn't skip a type (NSTIFFPboardType and kUTTypeTIFF for now)
+        if an equivalent type had failed to read.
+
 2017-10-10  Andy Estes  <aes...@apple.com>
 
         [Payment Request] Validate that all PaymentCurrencyAmounts use the same currency code when using Apple Pay

Modified: trunk/Source/WebCore/page/Settings.cpp (223166 => 223167)


--- trunk/Source/WebCore/page/Settings.cpp	2017-10-11 03:49:16 UTC (rev 223166)
+++ trunk/Source/WebCore/page/Settings.cpp	2017-10-11 04:12:30 UTC (rev 223167)
@@ -144,21 +144,17 @@
     ;
 }
 
-bool Settings::customPasteboardDataEnabled()
+bool Settings::defaultCustomPasteboardDataEnabled()
 {
-    static std::once_flag initializeCustomPasteboardDataToDefaultValue;
-    std::call_once(initializeCustomPasteboardDataToDefaultValue, [] {
 #if PLATFORM(IOS) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 110300
-        gCustomPasteboardDataEnabled = IOSApplication::isMobileSafari() || dyld_get_program_sdk_version() >= DYLD_IOS_VERSION_11_3;
+    return IOSApplication::isMobileSafari() || dyld_get_program_sdk_version() >= DYLD_IOS_VERSION_11_3;
 #elif PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101300
-        gCustomPasteboardDataEnabled = MacApplication::isSafari() || dyld_get_program_sdk_version() > DYLD_MACOSX_VERSION_10_13;
+    return MacApplication::isSafari() || dyld_get_program_sdk_version() > DYLD_MACOSX_VERSION_10_13;
 #elif PLATFORM(MAC)
-        gCustomPasteboardDataEnabled = MacApplication::isSafari();
+    return MacApplication::isSafari();
 #else
-        gCustomPasteboardDataEnabled = false;
+    return false;
 #endif
-    });
-    return gCustomPasteboardDataEnabled;
 }
 
 #if PLATFORM(COCOA)

Modified: trunk/Source/WebCore/page/Settings.h (223166 => 223167)


--- trunk/Source/WebCore/page/Settings.h	2017-10-11 03:49:16 UTC (rev 223166)
+++ trunk/Source/WebCore/page/Settings.h	2017-10-11 04:12:30 UTC (rev 223167)
@@ -304,7 +304,8 @@
 #endif
 
     static void setCustomPasteboardDataEnabled(bool enabled) { gCustomPasteboardDataEnabled = enabled; }
-    WEBCORE_EXPORT static bool customPasteboardDataEnabled();
+    static bool customPasteboardDataEnabled() { return gCustomPasteboardDataEnabled; }
+    WEBCORE_EXPORT static bool defaultCustomPasteboardDataEnabled();
 
 #if ENABLE(LEGACY_ENCRYPTED_MEDIA)
     void setMediaKeysStorageDirectory(const String& directory) { m_mediaKeysStorageDirectory = directory; }

Modified: trunk/Source/WebCore/platform/cocoa/PasteboardCocoa.mm (223166 => 223167)


--- trunk/Source/WebCore/platform/cocoa/PasteboardCocoa.mm	2017-10-11 03:49:16 UTC (rev 223166)
+++ trunk/Source/WebCore/platform/cocoa/PasteboardCocoa.mm	2017-10-11 04:12:30 UTC (rev 223167)
@@ -195,7 +195,7 @@
         const char* mimeType = imageTypeToMIMEType(imageType);
         if (!mimeType)
             continue;
-        if (!existingMIMEs.add(mimeType).isNewEntry)
+        if (existingMIMEs.contains(mimeType))
             continue;
         auto buffer = readBufferForTypeWithSecurityCheck(cocoaType);
 #if PLATFORM(MAC)
@@ -204,6 +204,7 @@
 #endif
         if (!buffer)
             continue;
+        existingMIMEs.add(mimeType);
         reader.readBuffer(imageTypeToFakeFilename(imageType), mimeType, buffer.releaseNonNull());
     }
 }

Modified: trunk/Source/WebKit/ChangeLog (223166 => 223167)


--- trunk/Source/WebKit/ChangeLog	2017-10-11 03:49:16 UTC (rev 223166)
+++ trunk/Source/WebKit/ChangeLog	2017-10-11 04:12:30 UTC (rev 223167)
@@ -1,3 +1,20 @@
+2017-10-10  Ryosuke Niwa  <rn...@webkit.org>
+
+        Enable custom pasteboard data in DumpRenderTree and WebKitTestRunner
+        https://bugs.webkit.org/show_bug.cgi?id=178154
+
+        Reviewed by Wenson Hsieh.
+
+        Plumbed customPasteboardDataEnabled flag to be used in WebKitTestRunner.
+
+        * Shared/WebPreferencesDefinitions.h:
+        * UIProcess/API/C/WKPreferences.cpp:
+        (WKPreferencesSetCustomPasteboardDataEnabled):
+        (WKPreferencesGetCustomPasteboardDataEnabled):
+        * UIProcess/API/C/WKPreferencesRefPrivate.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::updatePreferences):
+
 2017-10-10  Adrian Perez de Castro  <ape...@igalia.com>
 
         [WPE] Remove the possibility of installing the old WebKit2 C API

Modified: trunk/Source/WebKit/Shared/WebPreferencesDefinitions.h (223166 => 223167)


--- trunk/Source/WebKit/Shared/WebPreferencesDefinitions.h	2017-10-11 03:49:16 UTC (rev 223166)
+++ trunk/Source/WebKit/Shared/WebPreferencesDefinitions.h	2017-10-11 04:12:30 UTC (rev 223167)
@@ -303,6 +303,7 @@
     macro(InspectorAdditionsEnabled, inspectorAdditionsEnabled, Bool, bool, false, "Web Inspector Additions", "Enable additional page APIs used by the Web Inspector frontend page") \
     macro(DirectoryUploadEnabled, directoryUploadEnabled, Bool, bool, DEFAULT_DIRECTORY_UPLOAD_ENABLED, "Directory Upload", "input.webkitdirectory / dataTransferItem.webkitGetAsEntry()") \
     macro(DataTransferItemsEnabled, dataTransferItemsEnabled, Bool, bool, DEFAULT_DATA_TRANSFER_ITEMS_ENABLED, "Data Transfer Items", "Enables DataTransferItem in the clipboard API") \
+    macro(CustomPasteboardDataEnabled, customPasteboardDataEnabled, Bool, bool, WebCore::Settings::defaultCustomPasteboardDataEnabled(), "Custom pateboard data", "Enable custom clipboard types and better security model for clipboard API.") \
     macro(WebVREnabled, webVREnabled, Bool, bool, false, "WebVR", "WebVR Module support") \
     macro(ViewportFitEnabled, viewportFitEnabled, Bool, bool, true, "Viewport Fit", "Enable viewport-fit viewport parameter") \
     \

Modified: trunk/Source/WebKit/UIProcess/API/C/WKPreferences.cpp (223166 => 223167)


--- trunk/Source/WebKit/UIProcess/API/C/WKPreferences.cpp	2017-10-11 03:49:16 UTC (rev 223166)
+++ trunk/Source/WebKit/UIProcess/API/C/WKPreferences.cpp	2017-10-11 04:12:30 UTC (rev 223167)
@@ -1680,6 +1680,16 @@
     return toImpl(preferencesRef)->dataTransferItemsEnabled();
 }
 
+void WKPreferencesSetCustomPasteboardDataEnabled(WKPreferencesRef preferencesRef, bool flag)
+{
+    toImpl(preferencesRef)->setCustomPasteboardDataEnabled(flag);
+}
+
+bool WKPreferencesGetCustomPasteboardDataEnabled(WKPreferencesRef preferencesRef)
+{
+    return toImpl(preferencesRef)->customPasteboardDataEnabled();
+}
+
 void WKPreferencesSetDownloadAttributeEnabled(WKPreferencesRef preferencesRef, bool flag)
 {
     toImpl(preferencesRef)->setDownloadAttributeEnabled(flag);

Modified: trunk/Source/WebKit/UIProcess/API/C/WKPreferencesRefPrivate.h (223166 => 223167)


--- trunk/Source/WebKit/UIProcess/API/C/WKPreferencesRefPrivate.h	2017-10-11 03:49:16 UTC (rev 223166)
+++ trunk/Source/WebKit/UIProcess/API/C/WKPreferencesRefPrivate.h	2017-10-11 04:12:30 UTC (rev 223167)
@@ -474,6 +474,10 @@
 WK_EXPORT bool WKPreferencesGetDataTransferItemsEnabled(WKPreferencesRef);
 
 // Defaults to false
+WK_EXPORT void WKPreferencesSetCustomPasteboardDataEnabled(WKPreferencesRef, bool flag);
+WK_EXPORT bool WKPreferencesGetCustomPasteboardDataEnabled(WKPreferencesRef);
+
+// Defaults to false
 WK_EXPORT void WKPreferencesSetUserTimingEnabled(WKPreferencesRef, bool flag);
 WK_EXPORT bool WKPreferencesGetUserTimingEnabled(WKPreferencesRef);
 

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (223166 => 223167)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2017-10-11 03:49:16 UTC (rev 223166)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2017-10-11 04:12:30 UTC (rev 223167)
@@ -3336,6 +3336,8 @@
 
     RuntimeEnabledFeatures::sharedFeatures().setDataTransferItemsEnabled(store.getBoolValueForKey(WebPreferencesKey::dataTransferItemsEnabledKey()));
 
+    settings.setCustomPasteboardDataEnabled(store.getBoolValueForKey(WebPreferencesKey::customPasteboardDataEnabledKey()));
+
 #if ENABLE(ATTACHMENT_ELEMENT)
     RuntimeEnabledFeatures::sharedFeatures().setAttachmentElementEnabled(store.getBoolValueForKey(WebPreferencesKey::attachmentElementEnabledKey()));
 #endif

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (223166 => 223167)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2017-10-11 03:49:16 UTC (rev 223166)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2017-10-11 04:12:30 UTC (rev 223167)
@@ -1,3 +1,21 @@
+2017-10-10  Ryosuke Niwa  <rn...@webkit.org>
+
+        Enable custom pasteboard data in DumpRenderTree and WebKitTestRunner
+        https://bugs.webkit.org/show_bug.cgi?id=178154
+
+        Reviewed by Wenson Hsieh.
+
+        Enable custom pasteboard data by default.
+
+        * WebView/WebPreferenceKeysPrivate.h:
+        * WebView/WebPreferences.mm:
+        (+[WebPreferences initialize]):
+        (-[WebPreferences customPasteboardDataEnabled]): Added.
+        (-[WebPreferences setCustomPasteboardDataEnabled:]): Added.
+        * WebView/WebPreferencesPrivate.h:
+        * WebView/WebView.mm:
+        (-[WebView _preferencesChanged:]):
+
 2017-10-10  Sam Weinig  <s...@webkit.org>
 
         Replace copyKeysToVector/copyValuesToVector with copyToVector(map.keys())/copyToVector(map.values())

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h (223166 => 223167)


--- trunk/Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h	2017-10-11 03:49:16 UTC (rev 223166)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h	2017-10-11 04:12:30 UTC (rev 223167)
@@ -171,6 +171,7 @@
 #define WebKitShadowDOMEnabledPreferenceKey @"WebKitShadowDOMEnabled"
 #define WebKitCustomElementsEnabledPreferenceKey @"WebKitCustomElementsEnabled"
 #define WebKitDataTransferItemsEnabledPreferenceKey @"WebKitDataTransferItemsEnabled"
+#define WebKitCustomPasteboardDataEnabledPreferenceKey @"WebKitCustomPasteboardDataEnabled"
 #define WebKitCacheAPIEnabledPreferenceKey @"WebKitCacheAPIEnabled"
 #define WebKitFetchAPIEnabledPreferenceKey @"WebKitFetchAPIEnabled"
 #define WebKitWritableStreamAPIEnabledPreferenceKey @"WebKitWritableStreamAPIEnabled"

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebPreferences.mm (223166 => 223167)


--- trunk/Source/WebKitLegacy/mac/WebView/WebPreferences.mm	2017-10-11 03:49:16 UTC (rev 223166)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebPreferences.mm	2017-10-11 04:12:30 UTC (rev 223167)
@@ -622,6 +622,7 @@
         [NSNumber numberWithBool:YES], WebKitShadowDOMEnabledPreferenceKey,
         [NSNumber numberWithBool:YES], WebKitCustomElementsEnabledPreferenceKey,
         [NSNumber numberWithBool:YES], WebKitDataTransferItemsEnabledPreferenceKey,
+        [NSNumber numberWithBool:Settings::defaultCustomPasteboardDataEnabled()], WebKitCustomPasteboardDataEnabledPreferenceKey,
         [NSNumber numberWithBool:YES], WebKitModernMediaControlsEnabledPreferenceKey,
 #if ENABLE(WEBGL2)
         [NSNumber numberWithBool:NO], WebKitWebGL2EnabledPreferenceKey,
@@ -2983,6 +2984,16 @@
     [self _setBoolValue:flag forKey:WebKitDataTransferItemsEnabledPreferenceKey];
 }
 
+- (BOOL)customPasteboardDataEnabled
+{
+    return [self _boolValueForKey:WebKitCustomPasteboardDataEnabledPreferenceKey];
+}
+
+- (void)setCustomPasteboardDataEnabled:(BOOL)flag
+{
+    [self _setBoolValue:flag forKey:WebKitCustomPasteboardDataEnabledPreferenceKey];
+}
+
 - (BOOL)cacheAPIEnabled
 {
     return [self _boolValueForKey:WebKitCacheAPIEnabledPreferenceKey];

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebPreferencesPrivate.h (223166 => 223167)


--- trunk/Source/WebKitLegacy/mac/WebView/WebPreferencesPrivate.h	2017-10-11 03:49:16 UTC (rev 223166)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebPreferencesPrivate.h	2017-10-11 04:12:30 UTC (rev 223167)
@@ -537,6 +537,9 @@
 - (void)setDataTransferItemsEnabled:(BOOL)flag;
 - (BOOL)dataTransferItemsEnabled;
 
+- (void)setCustomPasteboardDataEnabled:(BOOL)flag;
+- (BOOL)customPasteboardDataEnabled;
+
 - (BOOL)cacheAPIEnabled;
 - (void)setCacheAPIEnabled:(BOOL)enabled;
 

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebView.mm (223166 => 223167)


--- trunk/Source/WebKitLegacy/mac/WebView/WebView.mm	2017-10-11 03:49:16 UTC (rev 223166)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebView.mm	2017-10-11 04:12:30 UTC (rev 223167)
@@ -3066,6 +3066,8 @@
     [WAKView _setInterpolationQuality:[preferences _interpolationQuality]];
 #endif
 
+    settings.setCustomPasteboardDataEnabled([preferences customPasteboardDataEnabled]);
+
 #if ENABLE(LEGACY_ENCRYPTED_MEDIA)
     settings.setMediaKeysStorageDirectory([preferences mediaKeysStorageDirectory]);
 #endif

Modified: trunk/Tools/ChangeLog (223166 => 223167)


--- trunk/Tools/ChangeLog	2017-10-11 03:49:16 UTC (rev 223166)
+++ trunk/Tools/ChangeLog	2017-10-11 04:12:30 UTC (rev 223167)
@@ -1,3 +1,24 @@
+2017-10-10  Ryosuke Niwa  <rn...@webkit.org>
+
+        Enable custom pasteboard data in DumpRenderTree and WebKitTestRunner
+        https://bugs.webkit.org/show_bug.cgi?id=178154
+
+        Reviewed by Wenson Hsieh.
+
+        Fixed the bug that LocalPasteboard would fail to load the promise type if data is set after declaring types
+        by delaying the call to provideDataForType until when dataForType is called.
+
+        Without this fix, fast/events/dropzone-002.html would start failing after enabling custom pasteboard data.
+        With this fix, fast/events/dropzone-005.html also starts passing.
+
+        * DumpRenderTree/mac/DumpRenderTree.mm:
+        (resetWebPreferencesToConsistentValues):
+        * DumpRenderTree/mac/DumpRenderTreePasteboard.mm:
+        (-[LocalPasteboard addTypes:owner:]):
+        (-[LocalPasteboard dataForType:]):
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::resetPreferencesToConsistentValues):
+
 2017-10-10  Joanmarie Diggs  <jdi...@igalia.com>
 
         AX: [ATK] ARIA form role should be mapped to ATK_ROLE_LANDMARK; not ATK_ROLE_FORM

Modified: trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm (223166 => 223167)


--- trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm	2017-10-11 03:49:16 UTC (rev 223166)
+++ trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm	2017-10-11 04:12:30 UTC (rev 223167)
@@ -952,6 +952,7 @@
     [preferences setCustomElementsEnabled:YES];
 
     [preferences setDataTransferItemsEnabled:YES];
+    [preferences setCustomPasteboardDataEnabled:YES];
 
     [preferences setWebGL2Enabled:YES];
     [preferences setWebGPUEnabled:YES];

Modified: trunk/Tools/DumpRenderTree/mac/DumpRenderTreePasteboard.mm (223166 => 223167)


--- trunk/Tools/DumpRenderTree/mac/DumpRenderTreePasteboard.mm	2017-10-11 03:49:16 UTC (rev 223166)
+++ trunk/Tools/DumpRenderTree/mac/DumpRenderTreePasteboard.mm	2017-10-11 04:12:30 UTC (rev 223167)
@@ -42,6 +42,7 @@
 #import <wtf/RetainPtr.h>
 
 @interface LocalPasteboard : NSPasteboard {
+    RetainPtr<id> _owner;
     RetainPtr<NSString> _pasteboardName;
     NSInteger _changeCount;
 
@@ -140,13 +141,10 @@
 
 - (NSInteger)addTypes:(NSArray *)newTypes owner:(id)newOwner
 {
-    for (NSString *type in newTypes) {
+    _owner = newOwner;
+    for (NSString *type in newTypes)
         _types.add(toUTI(type));
 
-        if (newOwner && [newOwner respondsToSelector:@selector(pasteboard:provideDataForType:)])
-            [newOwner pasteboard:self provideDataForType:type];
-    }
-
     return ++_changeCount;
 }
 
@@ -194,6 +192,12 @@
 
 - (NSData *)dataForType:(NSString *)dataType
 {
+    if (NSData *data = ""
+        return data;
+
+    if (_owner && [_owner respondsToSelector:@selector(pasteboard:provideDataForType:)])
+        [_owner pasteboard:self provideDataForType:dataType];
+
     return _data.get(toUTI(dataType)).get();
 }
 

Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (223166 => 223167)


--- trunk/Tools/WebKitTestRunner/TestController.cpp	2017-10-11 03:49:16 UTC (rev 223166)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp	2017-10-11 04:12:30 UTC (rev 223167)
@@ -683,6 +683,7 @@
     WKPreferencesSetInteractiveFormValidationEnabled(preferences, true);
     WKPreferencesSetDisplayContentsEnabled(preferences, true);
     WKPreferencesSetDataTransferItemsEnabled(preferences, true);
+    WKPreferencesSetCustomPasteboardDataEnabled(preferences, true);
 
     WKPreferencesSetMockScrollbarsEnabled(preferences, options.useMockScrollbars);
     WKPreferencesSetNeedsSiteSpecificQuirks(preferences, options.needsSiteSpecificQuirks);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to