Skip to content
Permalink
Browse files
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.


Canonical link: https://commits.webkit.org/194407@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@223167 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
rniwa committed Oct 11, 2017
1 parent 3ff97ed commit 5fa086a635905343d5c04e51fa78f5f5696b2bf9
Showing 22 changed files with 145 additions and 22 deletions.
@@ -1,3 +1,15 @@
2017-10-10 Ryosuke Niwa <rniwa@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 <aestes@apple.com>

[Payment Request] Validate that all PaymentCurrencyAmounts use the same currency code when using Apple Pay
@@ -5,7 +5,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE

--- 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 .
@@ -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();
@@ -276,9 +276,6 @@ webkit.org/b/81289 canvas/philip/tests/2d.line.cap.round.html [ Failure ]

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 ]

@@ -1,3 +1,23 @@
2017-10-10 Ryosuke Niwa <rniwa@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 <aestes@apple.com>

[Payment Request] Validate that all PaymentCurrencyAmounts use the same currency code when using Apple Pay
@@ -144,21 +144,17 @@ static EditingBehaviorType editingBehaviorTypeForPlatform()
;
}

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)
@@ -304,7 +304,8 @@ class Settings : public RefCounted<Settings> {
#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; }
@@ -195,7 +195,7 @@ static ImageType cocoaTypeToImageType(const String& cocoaType)
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 @@ static ImageType cocoaTypeToImageType(const String& cocoaType)
#endif
if (!buffer)
continue;
existingMIMEs.add(mimeType);
reader.readBuffer(imageTypeToFakeFilename(imageType), mimeType, buffer.releaseNonNull());
}
}
@@ -1,3 +1,20 @@
2017-10-10 Ryosuke Niwa <rniwa@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 <aperez@igalia.com>

[WPE] Remove the possibility of installing the old WebKit2 C API
@@ -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") \
\
@@ -1680,6 +1680,16 @@ bool WKPreferencesGetDataTransferItemsEnabled(WKPreferencesRef preferencesRef)
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);
@@ -473,6 +473,10 @@ WK_EXPORT bool WKPreferencesGetDisplayContentsEnabled(WKPreferencesRef);
WK_EXPORT void WKPreferencesSetDataTransferItemsEnabled(WKPreferencesRef, bool flag);
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);
@@ -3336,6 +3336,8 @@ void WebPage::updatePreferences(const WebPreferencesStore& store)

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
@@ -1,3 +1,21 @@
2017-10-10 Ryosuke Niwa <rniwa@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 <sam@webkit.org>

Replace copyKeysToVector/copyValuesToVector with copyToVector(map.keys())/copyToVector(map.values())
@@ -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"
@@ -622,6 +622,7 @@ + (void)initialize
[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 @@ - (void)setDataTransferItemsEnabled:(BOOL)flag
[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];
@@ -537,6 +537,9 @@ extern NSString *WebPreferencesCacheModelChangedInternalNotification;
- (void)setDataTransferItemsEnabled:(BOOL)flag;
- (BOOL)dataTransferItemsEnabled;

- (void)setCustomPasteboardDataEnabled:(BOOL)flag;
- (BOOL)customPasteboardDataEnabled;

- (BOOL)cacheAPIEnabled;
- (void)setCacheAPIEnabled:(BOOL)enabled;

@@ -3066,6 +3066,8 @@ - (void)_preferencesChanged:(WebPreferences *)preferences
[WAKView _setInterpolationQuality:[preferences _interpolationQuality]];
#endif

settings.setCustomPasteboardDataEnabled([preferences customPasteboardDataEnabled]);

#if ENABLE(LEGACY_ENCRYPTED_MEDIA)
settings.setMediaKeysStorageDirectory([preferences mediaKeysStorageDirectory]);
#endif
@@ -1,3 +1,24 @@
2017-10-10 Ryosuke Niwa <rniwa@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 <jdiggs@igalia.com>

AX: [ATK] ARIA form role should be mapped to ATK_ROLE_LANDMARK; not ATK_ROLE_FORM
@@ -952,6 +952,7 @@ static void resetWebPreferencesToConsistentValues()
[preferences setCustomElementsEnabled:YES];

[preferences setDataTransferItemsEnabled:YES];
[preferences setCustomPasteboardDataEnabled:YES];

[preferences setWebGL2Enabled:YES];
[preferences setWebGPUEnabled:YES];
@@ -42,6 +42,7 @@
#import <wtf/RetainPtr.h>

@interface LocalPasteboard : NSPasteboard {
RetainPtr<id> _owner;
RetainPtr<NSString> _pasteboardName;
NSInteger _changeCount;

@@ -140,13 +141,10 @@ static bool isUTI(NSString *type)

- (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 @@ - (BOOL)setData:(NSData *)data forType:(NSString *)dataType

- (NSData *)dataForType:(NSString *)dataType
{
if (NSData *data = _data.get(toUTI(dataType)).get())
return data;

if (_owner && [_owner respondsToSelector:@selector(pasteboard:provideDataForType:)])
[_owner pasteboard:self provideDataForType:dataType];

return _data.get(toUTI(dataType)).get();
}

@@ -683,6 +683,7 @@ void TestController::resetPreferencesToConsistentValues(const TestOptions& optio
WKPreferencesSetInteractiveFormValidationEnabled(preferences, true);
WKPreferencesSetDisplayContentsEnabled(preferences, true);
WKPreferencesSetDataTransferItemsEnabled(preferences, true);
WKPreferencesSetCustomPasteboardDataEnabled(preferences, true);

WKPreferencesSetMockScrollbarsEnabled(preferences, options.useMockScrollbars);
WKPreferencesSetNeedsSiteSpecificQuirks(preferences, options.needsSiteSpecificQuirks);

0 comments on commit 5fa086a

Please sign in to comment.