Skip to content
  • dimich@chromium.org's avatar
    DragData::asURL() shouldn't do file validity checks · 69fcf7b7
    dimich@chromium.org authored
    https://bugs.webkit.org/show_bug.cgi?id=38711
    
    Patch by Daniel Cheng <dcheng@chromium.org> on 2010-05-18
    Reviewed by Darin Adler, Jian Li.
    
    WebCore:
    
    There's no point to trying to make sure the file is valid in
    DragData::asURL(). It's better to ask for forgiveness than to ask for
    permission, since asking for permission is prone to race conditions
    and results in unnecessary I/O.  Consumers of this function either:
    - need to verify the file exists themselves (e.g. the loader)
    - don't care about file validity (rich text drag-and-drop)
    
    * platform/chromium/DragDataChromium.cpp:
    (WebCore::DragData::asURL):
    
    WebKit/mac:
    
    Change [NSPasteboard _web_bestURL] to still return a file URL for paths
    that don't exist. Callers who care about the existence of the file or
    whether or not it is a directory should check themselves when they
    want to use the file. The directory check has been left in for now,
    since the Mac implementation of ResourceHandle, which uses this function
    indirectly via DragController::performDrag) handles directories somewhat
    non-intuitively: it opens the parent directory in the Finder, rather
    than opening the directory itself.
    
    * Misc/WebNSPasteboardExtras.mm:
    (-[NSPasteboard _web_bestURL]):
    
    LayoutTests:
    
    Several layout tests depended on the fact that dropping a file would
    never trigger navigation. This never happened to occur in the past,
    since it just so happened that the filenames used in the tests never
    resolved to files that exist. Since DragData::asURL() no longer tries
    to verify file existence, the layout tests were updated to either
    suppress navigation or log any navigation that should occur as part of
    the test.
    
    * editing/pasteboard/file-input-files-access-expected.txt:
    * editing/pasteboard/script-tests/file-input-files-access.js:
    (runTest.window.onbeforeunload):
    (runTest):
    * http/tests/security/clipboard/script-tests/clipboard-file-access.js:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@59689 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    69fcf7b7