Bug 52785 - execCommand("Paste") doesn't work in WebKitTestRunner
Summary: execCommand("Paste") doesn't work in WebKitTestRunner
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC OS X 10.5
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-19 23:06 PST by Maciej Stachowiak
Modified: 2011-01-27 23:45 PST (History)
3 users (show)

See Also:


Attachments
Patch (14.50 KB, patch)
2011-01-27 15:42 PST, Maciej Stachowiak
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Maciej Stachowiak 2011-01-19 23:06:12 PST
execCommand("Paste") doesn't work in WebKitTestRunner

One obvious aspect is the special preference setting for this, but even with that enabled, execCommand("Paste") doesn't seem to work.
Comment 1 Alexey Proskuryakov 2011-01-20 10:38:00 PST
For whatever reason, two preferences need to be set in order for DOM paste to work. I'm told that "Allow Automated Pasting" in Safari debug menu is already broken in WebKit1 because of this, perhaps WebKitTestRunner has the same issue?
Comment 2 Ryosuke Niwa 2011-01-20 13:32:41 PST
Both javaScriptCanAccessClipboard and isDOMPasteAllowed must return true for paste to work:

static bool supportedPaste(Frame* frame)
{
    Settings* settings = frame ? frame->settings() : 0;
    return settings && (settings->javaScriptCanAccessClipboard() ? settings->isDOMPasteAllowed() : 0);
}
Comment 3 Ryosuke Niwa 2011-01-20 13:35:51 PST
(In reply to comment #1)
> For whatever reason, two preferences need to be set in order for DOM paste to work. I'm told that "Allow Automated Pasting" in Safari debug menu is already broken in WebKit1 because of this, perhaps WebKitTestRunner has the same issue?

These two preferences are really obscured.  I'd really like to unsupport these two settings and add SecurityOrigin methods (see: https://bugs.webkit.org/show_bug.cgi?id=52417).
Comment 4 Maciej Stachowiak 2011-01-27 15:42:28 PST
Created attachment 80370 [details]
Patch
Comment 5 Darin Adler 2011-01-27 15:47:40 PST
Comment on attachment 80370 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=80370&action=review

> Source/WebKit2/Shared/WebPreferencesStore.h:69
>      macro(AuthorAndUserStylesEnabled, authorAndUserStylesEnabled, Bool, bool, true) \
>      macro(PaginateDuringLayoutEnabled, paginateDuringLayoutEnabled, Bool, bool, false) \
>      macro(DOMPasteAllowed, domPasteAllowed, Bool, bool, false) \
> +    macro(JavaScriptCanAccessClipboard, javaScriptCanAccessClipboard, Bool, bool, false) \
>      macro(ShouldPrintBackgrounds, shouldPrintBackgrounds, Bool, bool, false) \

Can we keep this sorted alphabetically?

> Source/WebKit2/WebProcess/WebPage/WebPage.cpp:1268
>      settings->setAuthorAndUserStylesEnabled(store.getBoolValueForKey(WebPreferencesKey::authorAndUserStylesEnabledKey()));
>      settings->setPaginateDuringLayoutEnabled(store.getBoolValueForKey(WebPreferencesKey::paginateDuringLayoutEnabledKey()));
>      settings->setDOMPasteAllowed(store.getBoolValueForKey(WebPreferencesKey::domPasteAllowedKey()));
> +    settings->setJavaScriptCanAccessClipboard(store.getBoolValueForKey(WebPreferencesKey::javaScriptCanAccessClipboardKey()));
>      settings->setShouldPrintBackgrounds(store.getBoolValueForKey(WebPreferencesKey::shouldPrintBackgroundsKey()));

Can we keep this sorted alphabetically?
Comment 6 Maciej Stachowiak 2011-01-27 19:10:14 PST
Committed r76908: <http://trac.webkit.org/changeset/76908>
Comment 7 Maciej Stachowiak 2011-01-27 23:45:25 PST
(In reply to comment #5)
> (From update of attachment 80370 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=80370&action=review
> 
> > Source/WebKit2/Shared/WebPreferencesStore.h:69
> >      macro(AuthorAndUserStylesEnabled, authorAndUserStylesEnabled, Bool, bool, true) \
> >      macro(PaginateDuringLayoutEnabled, paginateDuringLayoutEnabled, Bool, bool, false) \
> >      macro(DOMPasteAllowed, domPasteAllowed, Bool, bool, false) \
> > +    macro(JavaScriptCanAccessClipboard, javaScriptCanAccessClipboard, Bool, bool, false) \
> >      macro(ShouldPrintBackgrounds, shouldPrintBackgrounds, Bool, bool, false) \
> 
> Can we keep this sorted alphabetically?
> 
> > Source/WebKit2/WebProcess/WebPage/WebPage.cpp:1268
> >      settings->setAuthorAndUserStylesEnabled(store.getBoolValueForKey(WebPreferencesKey::authorAndUserStylesEnabledKey()));
> >      settings->setPaginateDuringLayoutEnabled(store.getBoolValueForKey(WebPreferencesKey::paginateDuringLayoutEnabledKey()));
> >      settings->setDOMPasteAllowed(store.getBoolValueForKey(WebPreferencesKey::domPasteAllowedKey()));
> > +    settings->setJavaScriptCanAccessClipboard(store.getBoolValueForKey(WebPreferencesKey::javaScriptCanAccessClipboardKey()));
> >      settings->setShouldPrintBackgrounds(store.getBoolValueForKey(WebPreferencesKey::shouldPrintBackgroundsKey()));
> 
> Can we keep this sorted alphabetically?

I ended up not sorting because I didn't want to inject an unrelated change, but yes, I believe this can be sorted as an independent cleanup.