Changeset 53270 in webkit


Ignore:
Timestamp:
Jan 14, 2010 10:23:18 AM (14 years ago)
Author:
bweinstein@apple.com
Message:

[DnD] effectAllowed and dropEffect can be set to bogus values.
Fixes <https://bugs.webkit.org/show_bug.cgi?id=33635>.

Reviewed by Oliver Hunt.

WebCore:

Test to make aure dropEffect and effectAllowed are being set to valid values
when they are being set (list of valid values given by HTML5 specification).

Also, drive by change to initialize dropEffect to none (as described in spec).

Test: fast/events/bogus-dropEffect-effectAllowed.html

  • dom/Clipboard.cpp:

(WebCore::Clipboard::Clipboard): Initialize m_dropEffect to "none".
(WebCore::Clipboard::setDropEffect): Check if dropEffect is being set to a valid value.
(WebCore::Clipboard::setEffectAllowed): Check if effectAllowed is being set to a valid value.

LayoutTests:

Added a test to check the handling of setting effectAllowed and
dropEffect to bogus values (that it gets ignored), and updated results
to drag-and-drop because it uses a dummy value.

  • fast/events/bogus-dropEffect-effectAllowed-expected.txt: Added.
  • fast/events/bogus-dropEffect-effectAllowed.html: Added.
  • fast/events/drag-and-drop-expected.txt:
  • fast/events/drag-and-drop.html:
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r53268 r53270  
     12010-01-14  Brian Weinstein  <bweinstein@apple.com>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        [DnD] effectAllowed and dropEffect can be set to bogus values.
     6        Fixes <https://bugs.webkit.org/show_bug.cgi?id=33635>.
     7       
     8        Added a test to check the handling of setting effectAllowed and
     9        dropEffect to bogus values (that it gets ignored), and updated results
     10        to drag-and-drop because it uses a dummy value.
     11
     12        * fast/events/bogus-dropEffect-effectAllowed-expected.txt: Added.
     13        * fast/events/bogus-dropEffect-effectAllowed.html: Added.
     14        * fast/events/drag-and-drop-expected.txt:
     15        * fast/events/drag-and-drop.html:
     16
    1172010-01-14  Adam Roben  <aroben@apple.com>
    218
  • trunk/LayoutTests/fast/events/drag-and-drop-expected.txt

    r53203 r53270  
    9393When effectAllowed == "dummy"
    9494
     95PASS event.dataTransfer.effectAllowed is "uninitialized"
    9596PASS event.dataTransfer.dropEffect is "none"
    96 PASS event.dataTransfer.dropEffect is "none"
    97 PASS event.dataTransfer.dropEffect is "none"
    98 PASS event.dataTransfer.dropEffect is "none"
     97PASS event.dataTransfer.effectAllowed is "uninitialized"
     98PASS event.dataTransfer.dropEffect is "copy"
     99PASS event.dataTransfer.effectAllowed is "uninitialized"
     100PASS event.dataTransfer.dropEffect is "move"
     101PASS event.dataTransfer.effectAllowed is "uninitialized"
     102PASS event.dataTransfer.dropEffect is "link"
     103PASS event.dataTransfer.effectAllowed is "uninitialized"
    99104PASS event.dataTransfer.dropEffect is "none"
    100105
  • trunk/LayoutTests/fast/events/drag-and-drop.html

    r53203 r53270  
    9393        if (chosenEffectAllowed === "undefined") {
    9494            // If no effectAllowed is set, we should default to uninitialized. Make sure that's the case.
     95            shouldBeEqualToString("event.dataTransfer.effectAllowed", "uninitialized");
     96           
     97            // Then set the chosenEffectAllowed so isDropEffectAllowed matches the HTML5 spec, and
     98            // doesn't need special cases for undefined.
     99            chosenEffectAllowed = "uninitialized";
     100        }
     101       
     102        if (chosenEffectAllowed === "dummy") {
     103            // If a bad effectAllowed is attempted to be set, it should never be set, and the
     104            // effectAllowed should be uninitialized.
    95105            shouldBeEqualToString("event.dataTransfer.effectAllowed", "uninitialized");
    96106           
  • trunk/WebCore/ChangeLog

    r53264 r53270  
     12010-01-14  Brian Weinstein  <bweinstein@apple.com>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        [DnD] effectAllowed and dropEffect can be set to bogus values.
     6        Fixes <https://bugs.webkit.org/show_bug.cgi?id=33635>.
     7       
     8        Test to make aure dropEffect and effectAllowed are being set to valid values
     9        when they are being set (list of valid values given by HTML5 specification).
     10       
     11        Also, drive by change to initialize dropEffect to none (as described in spec).
     12
     13        Test: fast/events/bogus-dropEffect-effectAllowed.html
     14
     15        * dom/Clipboard.cpp:
     16        (WebCore::Clipboard::Clipboard): Initialize m_dropEffect to "none".
     17        (WebCore::Clipboard::setDropEffect): Check if dropEffect is being set to a valid value.
     18        (WebCore::Clipboard::setEffectAllowed): Check if effectAllowed is being set to a valid value.
     19
    1202010-01-14  Martin Robinson  <martin.james.robinson@gmail.com>
    221
  • trunk/WebCore/dom/Clipboard.cpp

    r53203 r53270  
    3636
    3737Clipboard::Clipboard(ClipboardAccessPolicy policy, bool isForDragging)
    38     : m_policy(policy)
     38    : m_policy(policy)
     39    , m_dropEffect("none")
    3940    , m_effectAllowed("uninitialized")
    4041    , m_dragStarted(false)
     
    131132        return;
    132133
     134    // The attribute must ignore any attempts to set it to a value other than none, copy, link, and move.
     135    if (effect != "none" && effect != "copy"  && effect != "link" && effect != "move")
     136        return;
     137
    133138    if (m_policy == ClipboardReadable || m_policy == ClipboardTypesReadable)
    134139        m_dropEffect = effect;
     
    140145        return;
    141146
     147    if (dragOpFromIEOp(effect) == DragOperationPrivate) {
     148        // This means that there was no conversion, and the effectAllowed that
     149        // we are passed isn't a valid effectAllowed, so we should ignore it,
     150        // and not set m_effectAllowed.
     151
     152        // The attribute must ignore any attempts to set it to a value other than
     153        // none, copy, copyLink, copyMove, link, linkMove, move, all, and uninitialized.
     154        return;
     155    }
     156
     157
    142158    if (m_policy == ClipboardWritable)
    143159        m_effectAllowed = effect;
Note: See TracChangeset for help on using the changeset viewer.