Changeset 234885 in webkit


Ignore:
Timestamp:
Aug 15, 2018 7:26:05 AM (6 years ago)
Author:
Wenson Hsieh
Message:

[Attachment SPI] Remove attachment display mode options
https://bugs.webkit.org/show_bug.cgi?id=188596

Reviewed by Dan Bernstein.

Source/WebCore:

Remove the ability to specify an "in-place" or "icon" representation for attachment elements, as well as logic
needed to allow an attachment element to render image or video elements in a shadow root. The requirements that
initially drove this effort are obviated by r227068, which allows Mail to intercept and provide a custom scheme
for images inserted into the document via rich editing operations.

Removed some existing API tests in _WKAttachmentTests that exercised this functionality.

  • editing/Editor.cpp:

(WebCore::Editor::insertAttachmentFromFile):

  • editing/cocoa/WebContentReaderCocoa.mm:

(WebCore::createFragmentForImageAttachment):
(WebCore::replaceRichContentWithAttachments):

  • html/AttachmentTypes.h:

(WebCore::AttachmentDisplayOptions::encode const):
(WebCore::AttachmentDisplayOptions::decode):

Remove logic for encoding the attachment display mode. While this leaves AttachmentDisplayOptions completely
empty, I haven't removed AttachmentDisplayOptions as well in this patch, since it's not clear that we won't be
needing any mechanism for influencing the display of attachment elements inserted via native SPI.

(): Deleted.

  • html/HTMLAttachmentElement.cpp:

(WebCore::HTMLAttachmentElement::createElementRenderer):
(WebCore::HTMLAttachmentElement::setFile):
(WebCore::HTMLAttachmentElement::parseAttribute):
(WebCore::HTMLAttachmentElement::invalidateShadowRootChildrenIfNecessary): Deleted.
(WebCore::HTMLAttachmentElement::attachmentRenderer const): Deleted.
(WebCore::HTMLAttachmentElement::updateDisplayMode): Deleted.
(WebCore::HTMLAttachmentElement::ensureInnerImage): Deleted.
(WebCore::HTMLAttachmentElement::ensureInnerVideo): Deleted.
(WebCore::HTMLAttachmentElement::innerImage const): Deleted.
(WebCore::HTMLAttachmentElement::innerVideo const): Deleted.
(WebCore::HTMLAttachmentElement::populateShadowRootIfNecessary): Deleted.

Remove logic for building the shadow root to house inline media elements.

  • html/HTMLAttachmentElement.h:

The renderer of the attachment element is once again always a RenderAttachment, so we can remove
attachmentRenderer() altogether and revert to overriding renderer() to return a RenderAttachment*.

  • page/DragController.cpp:

(WebCore::DragController::startDrag):

  • rendering/RenderAttachment.h:

(WebCore::HTMLAttachmentElement::renderer const):

Source/WebKit:

Remove attachment display mode from WebKit. Note that _WKAttachmentDisplayOptions needs to remain in the private
header for source compatibility with Mail.

  • UIProcess/API/Cocoa/_WKAttachment.mm:

(-[_WKAttachmentDisplayOptions coreDisplayOptions]): Deleted.

  • WebProcess/WebPage/WebPage.cpp:

(WebKit::WebPage::setAttachmentDisplayOptions):

Tools:

Remove API tests and API test helpers for verifying the behavior of in-place media attachment elements.

  • TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm:

(-[TestWKWebView synchronouslyInsertAttachmentWithFilename:contentType:data:]):
(TestWebKitAPI::TEST):
(testVideoData): Deleted.
(displayOptionsWithMode): Deleted.
(-[TestWKWebView synchronouslyInsertAttachmentWithFilename:contentType:data:options:]): Deleted.

LayoutTests:

Remove a layout test which verified that attachment elements with -webkit-appearance: none would render
child elements. This was only used to implement in-place attachment display modes.

  • fast/attachment/attachment-without-appearance-expected.html: Removed.
  • fast/attachment/attachment-without-appearance.html: Removed.
  • platform/gtk/TestExpectations:
Location:
trunk
Files:
2 deleted
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r234884 r234885  
     12018-08-15  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [Attachment SPI] Remove attachment display mode options
     4        https://bugs.webkit.org/show_bug.cgi?id=188596
     5
     6        Reviewed by Dan Bernstein.
     7
     8        Remove a layout test which verified that attachment elements with `-webkit-appearance: none` would render
     9        child elements. This was only used to implement in-place attachment display modes.
     10
     11        * fast/attachment/attachment-without-appearance-expected.html: Removed.
     12        * fast/attachment/attachment-without-appearance.html: Removed.
     13        * platform/gtk/TestExpectations:
     14
    1152018-08-15  Ali Juma  <ajuma@chromium.org>
    216
  • trunk/LayoutTests/platform/gtk/TestExpectations

    r234821 r234885  
    33863386webkit.org/b/179052 compositing/contents-format/subpixel-antialiased-nested-layer.html [ Failure ]
    33873387
    3388 webkit.org/b/180371 fast/attachment/attachment-without-appearance.html [ ImageOnlyFailure ]
    3389 
    33903388webkit.org/b/180749 http/wpt/offscreen-canvas/transferToImageBitmap-webgl.html [ ImageOnlyFailure ]
    33913389
  • trunk/Source/WebCore/ChangeLog

    r234884 r234885  
     12018-08-15  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [Attachment SPI] Remove attachment display mode options
     4        https://bugs.webkit.org/show_bug.cgi?id=188596
     5
     6        Reviewed by Dan Bernstein.
     7
     8        Remove the ability to specify an "in-place" or "icon" representation for attachment elements, as well as logic
     9        needed to allow an attachment element to render image or video elements in a shadow root. The requirements that
     10        initially drove this effort are obviated by r227068, which allows Mail to intercept and provide a custom scheme
     11        for images inserted into the document via rich editing operations.
     12
     13        Removed some existing API tests in _WKAttachmentTests that exercised this functionality.
     14
     15        * editing/Editor.cpp:
     16        (WebCore::Editor::insertAttachmentFromFile):
     17        * editing/cocoa/WebContentReaderCocoa.mm:
     18        (WebCore::createFragmentForImageAttachment):
     19        (WebCore::replaceRichContentWithAttachments):
     20        * html/AttachmentTypes.h:
     21        (WebCore::AttachmentDisplayOptions::encode const):
     22        (WebCore::AttachmentDisplayOptions::decode):
     23
     24        Remove logic for encoding the attachment display mode. While this leaves AttachmentDisplayOptions completely
     25        empty, I haven't removed AttachmentDisplayOptions as well in this patch, since it's not clear that we won't be
     26        needing any mechanism for influencing the display of attachment elements inserted via native SPI.
     27
     28        (): Deleted.
     29        * html/HTMLAttachmentElement.cpp:
     30        (WebCore::HTMLAttachmentElement::createElementRenderer):
     31        (WebCore::HTMLAttachmentElement::setFile):
     32        (WebCore::HTMLAttachmentElement::parseAttribute):
     33        (WebCore::HTMLAttachmentElement::invalidateShadowRootChildrenIfNecessary): Deleted.
     34        (WebCore::HTMLAttachmentElement::attachmentRenderer const): Deleted.
     35        (WebCore::HTMLAttachmentElement::updateDisplayMode): Deleted.
     36        (WebCore::HTMLAttachmentElement::ensureInnerImage): Deleted.
     37        (WebCore::HTMLAttachmentElement::ensureInnerVideo): Deleted.
     38        (WebCore::HTMLAttachmentElement::innerImage const): Deleted.
     39        (WebCore::HTMLAttachmentElement::innerVideo const): Deleted.
     40        (WebCore::HTMLAttachmentElement::populateShadowRootIfNecessary): Deleted.
     41
     42        Remove logic for building the shadow root to house inline media elements.
     43
     44        * html/HTMLAttachmentElement.h:
     45
     46        The renderer of the attachment element is once again always a `RenderAttachment`, so we can remove
     47        `attachmentRenderer()` altogether and revert to overriding `renderer()` to return a `RenderAttachment*`.
     48
     49        * page/DragController.cpp:
     50        (WebCore::DragController::startDrag):
     51        * rendering/RenderAttachment.h:
     52        (WebCore::HTMLAttachmentElement::renderer const):
     53
    1542018-08-15  Ali Juma  <ajuma@chromium.org>
    255
  • trunk/Source/WebCore/editing/Editor.cpp

    r234808 r234885  
    38743874}
    38753875
    3876 void Editor::insertAttachmentFromFile(const String& identifier, const AttachmentDisplayOptions& options, const String& filename, const String& contentType, Ref<File>&& file)
     3876void Editor::insertAttachmentFromFile(const String& identifier, const AttachmentDisplayOptions&, const String& filename, const String& contentType, Ref<File>&& file)
    38773877{
    38783878    auto attachment = HTMLAttachmentElement::create(HTMLNames::attachmentTag, document());
     
    38823882    attachment->setUniqueIdentifier(identifier);
    38833883    attachment->setFile(WTFMove(file));
    3884     attachment->updateDisplayMode(options.mode);
    38853884
    38863885    auto fragmentToInsert = document().createDocumentFragment();
  • trunk/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm

    r234348 r234885  
    210210    auto attachment = HTMLAttachmentElement::create(HTMLNames::attachmentTag, document);
    211211    attachment->setFile(File::create(blob, AtomicString("image")), HTMLAttachmentElement::UpdateDisplayAttributes::Yes);
    212     attachment->updateDisplayMode(AttachmentDisplayMode::InPlace);
    213212
    214213    auto fragment = document.createDocumentFragment();
     
    226225#if ENABLE(ATTACHMENT_ELEMENT)
    227226    struct AttachmentReplacementInfo {
    228         AttachmentDisplayMode displayMode;
    229227        Ref<File> file;
    230228        Ref<Element> elementToReplace;
     
    258256            title = AtomicString("media");
    259257
    260         attachmentReplacementInfo.append({ AttachmentDisplayMode::InPlace, File::create(*blob, title), image });
     258        attachmentReplacementInfo.append({ File::create(*blob, title), image });
    261259    }
    262260
     
    278276            title = AtomicString("file");
    279277
    280         attachmentReplacementInfo.append({ AttachmentDisplayMode::AsIcon, File::create(*blob, title), object });
     278        attachmentReplacementInfo.append({ File::create(*blob, title), object });
    281279    }
    282280
     
    290288        auto attachment = HTMLAttachmentElement::create(HTMLNames::attachmentTag, fragment.document());
    291289        attachment->setFile(WTFMove(file), HTMLAttachmentElement::UpdateDisplayAttributes::Yes);
    292         attachment->updateDisplayMode(info.displayMode);
    293290        parent->replaceChild(attachment, elementToReplace);
    294291    }
  • trunk/Source/WebCore/html/AttachmentTypes.h

    r226604 r234885  
    3535class SharedBuffer;
    3636
    37 enum class AttachmentDisplayMode {
    38     Auto,
    39     InPlace,
    40     AsIcon
    41 };
    42 
    4337struct AttachmentDisplayOptions {
    44     AttachmentDisplayMode mode { AttachmentDisplayMode::Auto };
    45 
    4638    template<class Encoder> void encode(Encoder&) const;
    4739    template<class Decoder> static std::optional<AttachmentDisplayOptions> decode(Decoder&);
     
    5042template<class Encoder> inline void AttachmentDisplayOptions::encode(Encoder& encoder) const
    5143{
    52     encoder.encodeEnum(mode);
     44    UNUSED_PARAM(encoder);
    5345}
    5446
    5547template<class Decoder> inline std::optional<AttachmentDisplayOptions> AttachmentDisplayOptions::decode(Decoder& decoder)
    5648{
    57     AttachmentDisplayMode mode;
    58     if (!decoder.decodeEnum(mode))
    59         return std::nullopt;
    60 
    61     return {{ mode }};
     49    UNUSED_PARAM(decoder);
     50    return AttachmentDisplayOptions();
    6251}
    6352
  • trunk/Source/WebCore/html/HTMLAttachmentElement.cpp

    r229694 r234885  
    3636#include "FileReaderLoaderClient.h"
    3737#include "Frame.h"
    38 #include "HTMLImageElement.h"
    3938#include "HTMLNames.h"
    40 #include "HTMLVideoElement.h"
    41 #include "MIMETypeRegistry.h"
    4239#include "RenderAttachment.h"
    43 #include "RenderBlockFlow.h"
    44 #include "ShadowRoot.h"
    4540#include "SharedBuffer.h"
    4641#include <pal/FileSizeFormatter.h>
    4742#include <wtf/IsoMallocInlines.h>
    48 
    49 #if PLATFORM(COCOA)
    50 #include "UTIUtilities.h"
    51 #endif
    5243
    5344namespace WebCore {
     
    10293RenderPtr<RenderElement> HTMLAttachmentElement::createElementRenderer(RenderStyle&& style, const RenderTreePosition&)
    10394{
    104     if (!style.hasAppearance()) {
    105         // If this attachment element doesn't have an appearance, defer rendering to child elements.
    106         return createRenderer<RenderBlockFlow>(*this, WTFMove(style));
    107     }
    108 
    10995    return createRenderer<RenderAttachment>(*this, WTFMove(style));
    11096}
     
    136122    }
    137123
    138     if (auto* renderAttachment = attachmentRenderer())
    139         renderAttachment->invalidate();
    140 
    141     invalidateShadowRootChildrenIfNecessary();
    142     populateShadowRootIfNecessary();
    143 }
    144 
    145 void HTMLAttachmentElement::invalidateShadowRootChildrenIfNecessary()
    146 {
    147     if (auto image = innerImage()) {
    148         image->setAttributeWithoutSynchronization(srcAttr, emptyString());
    149         image->setInlineStyleProperty(CSSPropertyDisplay, CSSValueNone, true);
    150     }
    151     if (auto video = innerVideo()) {
    152         video->setAttributeWithoutSynchronization(srcAttr, emptyString());
    153         video->setInlineStyleProperty(CSSPropertyDisplay, CSSValueNone, true);
    154     }
    155 }
    156 
    157 RenderAttachment* HTMLAttachmentElement::attachmentRenderer() const
    158 {
    159     auto* renderer = this->renderer();
    160     return is<RenderAttachment>(renderer) ? downcast<RenderAttachment>(renderer) : nullptr;
     124    if (auto* renderer = this->renderer())
     125        renderer->invalidate();
    161126}
    162127
     
    179144{
    180145    if (name == progressAttr || name == subtitleAttr || name == titleAttr || name == typeAttr) {
    181         if (auto* renderAttachment = attachmentRenderer())
    182             renderAttachment->invalidate();
     146        if (auto* renderer = this->renderer())
     147            renderer->invalidate();
    183148    }
    184149
     
    204169}
    205170
    206 void HTMLAttachmentElement::updateDisplayMode(AttachmentDisplayMode mode)
    207 {
    208     mode = mode == AttachmentDisplayMode::Auto ? defaultDisplayMode() : mode;
    209 
    210     switch (mode) {
    211     case AttachmentDisplayMode::InPlace:
    212         populateShadowRootIfNecessary();
    213         setInlineStyleProperty(CSSPropertyWebkitAppearance, CSSValueNone, true);
    214         setInlineStyleProperty(CSSPropertyDisplay, CSSValueInlineBlock, true);
    215         break;
    216     case AttachmentDisplayMode::AsIcon:
    217         removeInlineStyleProperty(CSSPropertyWebkitAppearance);
    218         removeInlineStyleProperty(CSSPropertyDisplay);
    219         break;
    220     default:
    221         ASSERT_NOT_REACHED();
    222         break;
    223     }
    224 
    225     invalidateStyleAndRenderersForSubtree();
    226 }
    227 
    228171void HTMLAttachmentElement::updateFileWithData(Ref<SharedBuffer>&& data, std::optional<String>&& newContentType, std::optional<String>&& newFilename)
    229172{
     
    232175    auto file = File::create(Blob::create(WTFMove(data), contentType), filename);
    233176    setFile(WTFMove(file), UpdateDisplayAttributes::Yes);
    234 }
    235 
    236 Ref<HTMLImageElement> HTMLAttachmentElement::ensureInnerImage()
    237 {
    238     if (auto image = innerImage())
    239         return *image;
    240 
    241     auto image = HTMLImageElement::create(document());
    242     ensureUserAgentShadowRoot().appendChild(image);
    243     return image;
    244 }
    245 
    246 Ref<HTMLVideoElement> HTMLAttachmentElement::ensureInnerVideo()
    247 {
    248     if (auto video = innerVideo())
    249         return *video;
    250 
    251     auto video = HTMLVideoElement::create(document());
    252     ensureUserAgentShadowRoot().appendChild(video);
    253     return video;
    254 }
    255 
    256 RefPtr<HTMLImageElement> HTMLAttachmentElement::innerImage() const
    257 {
    258     if (auto root = userAgentShadowRoot())
    259         return childrenOfType<HTMLImageElement>(*root).first();
    260     return nullptr;
    261 }
    262 
    263 RefPtr<HTMLVideoElement> HTMLAttachmentElement::innerVideo() const
    264 {
    265     if (auto root = userAgentShadowRoot())
    266         return childrenOfType<HTMLVideoElement>(*root).first();
    267     return nullptr;
    268 }
    269 
    270 void HTMLAttachmentElement::populateShadowRootIfNecessary()
    271 {
    272     if (!m_file)
    273         return;
    274 
    275     auto mimeType = attachmentType();
    276 
    277 #if PLATFORM(COCOA)
    278     if (isDeclaredUTI(mimeType))
    279         mimeType = MIMETypeFromUTI(mimeType);
    280 #endif
    281 
    282     if (mimeType.isEmpty())
    283         return;
    284 
    285     if (MIMETypeRegistry::isSupportedImageMIMEType(mimeType) || MIMETypeRegistry::isPDFMIMEType(mimeType)) {
    286         auto image = ensureInnerImage();
    287         if (image->attributeWithoutSynchronization(srcAttr).isEmpty()) {
    288             image->setAttributeWithoutSynchronization(srcAttr, DOMURL::createObjectURL(document(), *m_file));
    289             image->setAttributeWithoutSynchronization(draggableAttr, AtomicString("false"));
    290             image->setInlineStyleProperty(CSSPropertyDisplay, CSSValueInline, true);
    291             image->setInlineStyleProperty(CSSPropertyMaxWidth, 100, CSSPrimitiveValue::UnitType::CSS_PERCENTAGE, true);
    292         }
    293 
    294     } else if (MIMETypeRegistry::isSupportedMediaMIMEType(mimeType)) {
    295         auto video = ensureInnerVideo();
    296         if (video->attributeWithoutSynchronization(srcAttr).isEmpty()) {
    297             video->setAttributeWithoutSynchronization(srcAttr, DOMURL::createObjectURL(document(), *m_file));
    298             video->setAttributeWithoutSynchronization(controlsAttr, emptyString());
    299             video->setInlineStyleProperty(CSSPropertyDisplay, CSSValueInline, true);
    300             video->setInlineStyleProperty(CSSPropertyMaxWidth, 100, CSSPrimitiveValue::UnitType::CSS_PERCENTAGE, true);
    301         }
    302     }
    303177}
    304178
  • trunk/Source/WebCore/html/HTMLAttachmentElement.h

    r229694 r234885  
    5454    void setUniqueIdentifier(const String& uniqueIdentifier) { m_uniqueIdentifier = uniqueIdentifier; }
    5555
    56     WEBCORE_EXPORT void updateDisplayMode(AttachmentDisplayMode);
    5756    WEBCORE_EXPORT void updateFileWithData(Ref<SharedBuffer>&& data, std::optional<String>&& newContentType = std::nullopt, std::optional<String>&& newFilename = std::nullopt);
    5857
     
    6463    String attachmentPath() const;
    6564
    66     RenderAttachment* attachmentRenderer() const;
     65    RenderAttachment* renderer() const;
    6766
    6867    WEBCORE_EXPORT void requestInfo(Function<void(const AttachmentInfo&)>&& callback);
     
    7473
    7574    RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) final;
    76     Ref<HTMLImageElement> ensureInnerImage();
    77     Ref<HTMLVideoElement> ensureInnerVideo();
    78     RefPtr<HTMLImageElement> innerImage() const;
    79     RefPtr<HTMLVideoElement> innerVideo() const;
    80 
    81     void populateShadowRootIfNecessary();
    82     void invalidateShadowRootChildrenIfNecessary();
    83 
    84     AttachmentDisplayMode defaultDisplayMode() const
    85     {
    86         // FIXME: For now, all attachment elements automatically display using a file icon.
    87         // In a followup patch, we'll change the default behavior to use in-place presentation
    88         // for certain image MIME types.
    89         return AttachmentDisplayMode::AsIcon;
    90     }
    91 
    9275    bool shouldSelectOnMouseDown() final {
    9376#if PLATFORM(IOS)
  • trunk/Source/WebCore/page/DragController.cpp

    r234801 r234885  
    10891089    if (is<HTMLAttachmentElement>(element) && m_dragSourceAction & DragSourceActionAttachment) {
    10901090        auto& attachment = downcast<HTMLAttachmentElement>(element);
    1091         auto* attachmentRenderer = attachment.attachmentRenderer();
     1091        auto* attachmentRenderer = attachment.renderer();
    10921092
    10931093        src.editor().setIgnoreSelectionChanges(true);
  • trunk/Source/WebCore/rendering/RenderAttachment.h

    r225252 r234885  
    6060};
    6161
     62inline RenderAttachment* HTMLAttachmentElement::renderer() const
     63{
     64    return downcast<RenderAttachment>(HTMLElement::renderer());
     65}
     66
    6267} // namespace WebCore
    6368
  • trunk/Source/WebKit/ChangeLog

    r234875 r234885  
     12018-08-15  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [Attachment SPI] Remove attachment display mode options
     4        https://bugs.webkit.org/show_bug.cgi?id=188596
     5
     6        Reviewed by Dan Bernstein.
     7
     8        Remove attachment display mode from WebKit. Note that _WKAttachmentDisplayOptions needs to remain in the private
     9        header for source compatibility with Mail.
     10
     11        * UIProcess/API/Cocoa/_WKAttachment.mm:
     12        (-[_WKAttachmentDisplayOptions coreDisplayOptions]): Deleted.
     13        * WebProcess/WebPage/WebPage.cpp:
     14        (WebKit::WebPage::setAttachmentDisplayOptions):
     15
    1162018-08-14 Sihui Liu <sihui_liu@apple.com>
    217
  • trunk/Source/WebKit/UIProcess/API/Cocoa/_WKAttachment.mm

    r226824 r234885  
    4040@implementation _WKAttachmentDisplayOptions : NSObject
    4141
    42 - (instancetype)init
    43 {
    44     if (self = [super init])
    45         _mode = _WKAttachmentDisplayModeAuto;
    46 
    47     return self;
    48 }
    49 
    5042- (WebCore::AttachmentDisplayOptions)coreDisplayOptions
    5143{
    52     WebCore::AttachmentDisplayMode mode;
    53     switch (self.mode) {
    54     case _WKAttachmentDisplayModeAuto:
    55         mode = WebCore::AttachmentDisplayMode::Auto;
    56         break;
    57     case _WKAttachmentDisplayModeAsIcon:
    58         mode = WebCore::AttachmentDisplayMode::AsIcon;
    59         break;
    60     case _WKAttachmentDisplayModeInPlace:
    61         mode = WebCore::AttachmentDisplayMode::InPlace;
    62         break;
    63     default:
    64         ASSERT_NOT_REACHED();
    65         mode = WebCore::AttachmentDisplayMode::Auto;
    66     }
    67     return { mode };
     44    return { };
    6845}
    6946
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp

    r234704 r234885  
    61066106}
    61076107
    6108 void WebPage::setAttachmentDisplayOptions(const String& identifier, const AttachmentDisplayOptions& options, CallbackID callbackID)
    6109 {
    6110     if (auto attachment = attachmentElementWithIdentifier(identifier)) {
    6111         attachment->document().updateLayout();
    6112         attachment->updateDisplayMode(options.mode);
    6113     }
     6108void WebPage::setAttachmentDisplayOptions(const String&, const AttachmentDisplayOptions&, CallbackID callbackID)
     6109{
    61146110    send(Messages::WebPageProxy::VoidCallback(callbackID));
    61156111}
  • trunk/Tools/ChangeLog

    r234881 r234885  
     12018-08-15  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [Attachment SPI] Remove attachment display mode options
     4        https://bugs.webkit.org/show_bug.cgi?id=188596
     5
     6        Reviewed by Dan Bernstein.
     7
     8        Remove API tests and API test helpers for verifying the behavior of in-place media attachment elements.
     9
     10        * TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm:
     11        (-[TestWKWebView synchronouslyInsertAttachmentWithFilename:contentType:data:]):
     12        (TestWebKitAPI::TEST):
     13        (testVideoData): Deleted.
     14        (displayOptionsWithMode): Deleted.
     15        (-[TestWKWebView synchronouslyInsertAttachmentWithFilename:contentType:data:options:]): Deleted.
     16
    1172018-08-14  Devin Rousso  <drousso@apple.com>
    218
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm

    r234731 r234885  
    189189}
    190190
    191 static NSData *testVideoData()
    192 {
    193     NSURL *url = [[NSBundle mainBundle] URLForResource:@"test" withExtension:@"mp4" subdirectory:@"TestWebKitAPI.resources"];
    194     return [NSData dataWithContentsOfURL:url];
    195 }
    196 
    197191static NSURL *testPDFFileURL()
    198192{
     
    203197{
    204198    return [NSData dataWithContentsOfURL:testPDFFileURL()];
    205 }
    206 
    207 static _WKAttachmentDisplayOptions *displayOptionsWithMode(_WKAttachmentDisplayMode mode)
    208 {
    209     _WKAttachmentDisplayOptions *options = [[[_WKAttachmentDisplayOptions alloc] init] autorelease];
    210     options.mode = mode;
    211     return options;
    212199}
    213200
     
    251238}
    252239
    253 - (_WKAttachment *)synchronouslyInsertAttachmentWithFilename:(NSString *)filename contentType:(NSString *)contentType data:(NSData *)data options:(_WKAttachmentDisplayOptions *)options
     240- (_WKAttachment *)synchronouslyInsertAttachmentWithFilename:(NSString *)filename contentType:(NSString *)contentType data:(NSData *)data
    254241{
    255242    __block bool done = false;
    256     RetainPtr<_WKAttachment> attachment = [self _insertAttachmentWithFilename:filename contentType:contentType data:data options:options completion:^(BOOL) {
     243    RetainPtr<_WKAttachment> attachment = [self _insertAttachmentWithFilename:filename contentType:contentType data:data options:nil completion:^(BOOL) {
    257244        done = true;
    258245    }];
     
    506493        ObserveAttachmentUpdatesForScope observer(webView.get());
    507494        // Use the given content type for the attachment element's type.
    508         firstAttachment = [webView synchronouslyInsertAttachmentWithFilename:@"foo" contentType:@"text/html" data:testHTMLData() options:nil];
     495        firstAttachment = [webView synchronouslyInsertAttachmentWithFilename:@"foo" contentType:@"text/html" data:testHTMLData()];
    509496        EXPECT_WK_STREQ(@"foo", [webView valueOfAttribute:@"title" forQuerySelector:@"attachment"]);
    510497        EXPECT_WK_STREQ(@"text/html", [webView valueOfAttribute:@"type" forQuerySelector:@"attachment"]);
     
    523510        // Since no content type is explicitly specified, compute it from the file extension.
    524511        [webView _executeEditCommand:@"DeleteBackward" argument:nil completion:nil];
    525         secondAttachment = [webView synchronouslyInsertAttachmentWithFilename:@"bar.png" contentType:nil data:testImageData() options:nil];
     512        secondAttachment = [webView synchronouslyInsertAttachmentWithFilename:@"bar.png" contentType:nil data:testImageData()];
    526513        EXPECT_WK_STREQ(@"bar.png", [webView valueOfAttribute:@"title" forQuerySelector:@"attachment"]);
    527514        EXPECT_WK_STREQ(@"image/png", [webView valueOfAttribute:@"type" forQuerySelector:@"attachment"]);
     
    543530    {
    544531        ObserveAttachmentUpdatesForScope observer(webView.get());
    545         attachment = [webView synchronouslyInsertAttachmentWithFilename:@"foo.txt" contentType:@"text/plain" data:testHTMLData() options:nil];
     532        attachment = [webView synchronouslyInsertAttachmentWithFilename:@"foo.txt" contentType:@"text/plain" data:testHTMLData()];
    546533        observer.expectAttachmentUpdates(@[ ], @[attachment.get()]);
    547534    }
     
    570557    {
    571558        ObserveAttachmentUpdatesForScope observer(webView.get());
    572         attachment = [webView synchronouslyInsertAttachmentWithFilename:@"foo.txt" contentType:@"text/plain" data:testHTMLData() options:nil];
     559        attachment = [webView synchronouslyInsertAttachmentWithFilename:@"foo.txt" contentType:@"text/plain" data:testHTMLData()];
    573560        observer.expectAttachmentUpdates(@[ ], @[attachment.get()]);
    574561    }
     
    596583    {
    597584        ObserveAttachmentUpdatesForScope observer(webView.get());
    598         attachment = [webView synchronouslyInsertAttachmentWithFilename:@"foo.txt" contentType:@"text/plain" data:testHTMLData() options:nil];
     585        attachment = [webView synchronouslyInsertAttachmentWithFilename:@"foo.txt" contentType:@"text/plain" data:testHTMLData()];
    599586        observer.expectAttachmentUpdates(@[ ], @[attachment.get()]);
    600587    }
     
    620607    {
    621608        ObserveAttachmentUpdatesForScope observer(webView.get());
    622         attachment = [webView synchronouslyInsertAttachmentWithFilename:@"foo.txt" contentType:@"text/plain" data:testHTMLData() options:nil];
     609        attachment = [webView synchronouslyInsertAttachmentWithFilename:@"foo.txt" contentType:@"text/plain" data:testHTMLData()];
    623610        observer.expectAttachmentUpdates(@[ ], @[attachment.get()]);
    624611    }
     
    664651    {
    665652        ObserveAttachmentUpdatesForScope observer(webView.get());
    666         attachment = [webView synchronouslyInsertAttachmentWithFilename:@"foo.txt" contentType:@"text/plain" data:testHTMLData() options:nil];
     653        attachment = [webView synchronouslyInsertAttachmentWithFilename:@"foo.txt" contentType:@"text/plain" data:testHTMLData()];
    667654        observer.expectAttachmentUpdates(@[], @[attachment.get()]);
    668655    }
     
    693680    {
    694681        ObserveAttachmentUpdatesForScope observer(webView.get());
    695         attachment = [webView synchronouslyInsertAttachmentWithFilename:@"empty.txt" contentType:@"text/plain" data:[NSData data] options:nil];
     682        attachment = [webView synchronouslyInsertAttachmentWithFilename:@"empty.txt" contentType:@"text/plain" data:[NSData data]];
    696683        observer.expectAttachmentUpdates(@[], @[attachment.get()]);
    697684    }
     
    706693}
    707694
    708 TEST(WKAttachmentTests, InsertedImageSizeIsClampedByMaxWidth)
    709 {
    710     auto webView = webViewForTestingAttachments(CGSizeMake(100, 100));
    711     RetainPtr<NSData> imageData = testImageData();
    712     RetainPtr<_WKAttachment> attachment;
    713     {
    714         ObserveAttachmentUpdatesForScope observer(webView.get());
    715         attachment = [webView synchronouslyInsertAttachmentWithFilename:@"icon.png" contentType:@"image/png" data:imageData.get() options:displayOptionsWithMode(_WKAttachmentDisplayModeInPlace)];
    716         [attachment expectRequestedDataToBe:imageData.get()];
    717         observer.expectAttachmentUpdates(@[], @[attachment.get()]);
    718     }
    719     [webView waitForAttachmentElementSizeToBecome:CGSizeMake(84, 67)];
    720 }
    721 
    722695TEST(WKAttachmentTests, MultipleSimultaneousAttachmentDataRequests)
    723696{
     
    727700    {
    728701        ObserveAttachmentUpdatesForScope observer(webView.get());
    729         attachment = [webView synchronouslyInsertAttachmentWithFilename:@"foo.txt" contentType:@"text/plain" data:htmlData.get() options:nil];
     702        attachment = [webView synchronouslyInsertAttachmentWithFilename:@"foo.txt" contentType:@"text/plain" data:htmlData.get()];
    730703        observer.expectAttachmentUpdates(@[], @[attachment.get()]);
    731704    }
     
    749722}
    750723
    751 TEST(WKAttachmentTests, InPlaceImageAttachmentToggleDisplayMode)
    752 {
    753     auto webView = webViewForTestingAttachments();
    754     RetainPtr<NSData> imageData = testImageData();
     724TEST(WKAttachmentTests, ChangeAttachmentDataAndFileInformation)
     725{
     726    auto webView = webViewForTestingAttachments();
    755727    RetainPtr<_WKAttachment> attachment;
    756728    {
    757         ObserveAttachmentUpdatesForScope observer(webView.get());
    758         attachment = [webView synchronouslyInsertAttachmentWithFilename:@"icon.png" contentType:@"image/png" data:imageData.get() options:displayOptionsWithMode(_WKAttachmentDisplayModeAsIcon)];
    759         [attachment expectRequestedDataToBe:imageData.get()];
    760         observer.expectAttachmentUpdates(@[], @[attachment.get()]);
    761     }
    762     CGSize iconAttachmentSize = [webView attachmentElementSize];
    763 
    764     [attachment synchronouslySetDisplayOptions:displayOptionsWithMode(_WKAttachmentDisplayModeInPlace) error:nil];
    765     [attachment expectRequestedDataToBe:imageData.get()];
    766     [webView waitForAttachmentElementSizeToBecome:CGSizeMake(215, 174)];
    767 
    768     [attachment synchronouslySetDisplayOptions:displayOptionsWithMode(_WKAttachmentDisplayModeAsIcon) error:nil];
    769     [attachment expectRequestedDataToBe:imageData.get()];
    770     [webView waitForAttachmentElementSizeToBecome:iconAttachmentSize];
    771 
    772     [attachment synchronouslySetDisplayOptions:displayOptionsWithMode(_WKAttachmentDisplayModeInPlace) error:nil];
    773     [attachment expectRequestedDataToBe:imageData.get()];
    774     [webView waitForAttachmentElementSizeToBecome:CGSizeMake(215, 174)];
    775 }
    776 
    777 TEST(WKAttachmentTests, InPlaceImageAttachmentParagraphInsertion)
    778 {
    779     auto webView = webViewForTestingAttachments();
    780     RetainPtr<NSData> imageData = testImageData();
    781     RetainPtr<_WKAttachment> attachment;
    782     {
    783         ObserveAttachmentUpdatesForScope observer(webView.get());
    784         attachment = [webView synchronouslyInsertAttachmentWithFilename:@"icon.png" contentType:@"image/png" data:imageData.get() options:displayOptionsWithMode(_WKAttachmentDisplayModeInPlace)];
    785         observer.expectAttachmentUpdates(@[], @[attachment.get()]);
    786     }
    787     [webView expectUpdatesAfterCommand:@"InsertParagraph" withArgument:nil expectedRemovals:@[] expectedInsertions:@[]];
    788     [webView expectUpdatesAfterCommand:@"DeleteBackward" withArgument:nil expectedRemovals:@[] expectedInsertions:@[]];
    789     [webView stringByEvaluatingJavaScript:@"getSelection().collapse(document.body)"];
    790     [webView expectUpdatesAfterCommand:@"InsertParagraph" withArgument:nil expectedRemovals:@[] expectedInsertions:@[]];
    791     [webView expectUpdatesAfterCommand:@"DeleteBackward" withArgument:nil expectedRemovals:@[] expectedInsertions:@[]];
    792 
    793     [attachment expectRequestedDataToBe:imageData.get()];
    794     EXPECT_WK_STREQ([attachment uniqueIdentifier], [webView stringByEvaluatingJavaScript:@"document.querySelector('attachment').uniqueIdentifier"]);
    795     [webView waitForAttachmentElementSizeToBecome:CGSizeMake(215, 174)];
    796 
    797     [webView expectUpdatesAfterCommand:@"DeleteForward" withArgument:nil expectedRemovals:@[attachment.get()] expectedInsertions:@[]];
    798 }
    799 
    800 TEST(WKAttachmentTests, InPlaceVideoAttachmentInsertionWithinList)
    801 {
    802     auto webView = webViewForTestingAttachments();
    803     RetainPtr<NSData> videoData = testVideoData();
    804     RetainPtr<_WKAttachment> attachment;
    805 
    806     [webView _synchronouslyExecuteEditCommand:@"InsertOrderedList" argument:nil];
    807     {
    808         ObserveAttachmentUpdatesForScope observer(webView.get());
    809         attachment = [webView synchronouslyInsertAttachmentWithFilename:@"test.mp4" contentType:@"video/mp4" data:videoData.get() options:displayOptionsWithMode(_WKAttachmentDisplayModeInPlace)];
    810         observer.expectAttachmentUpdates(@[], @[attachment.get()]);
    811     }
    812     [webView waitForAttachmentElementSizeToBecome:CGSizeMake(320, 240)];
    813 
    814     [webView expectUpdatesAfterCommand:@"DeleteBackward" withArgument:nil expectedRemovals:@[attachment.get()] expectedInsertions:@[]];
    815     [webView expectUpdatesAfterCommand:@"Undo" withArgument:nil expectedRemovals:@[] expectedInsertions:@[attachment.get()]];
    816     [webView expectUpdatesAfterCommand:@"InsertOrderedList" withArgument:nil expectedRemovals:@[] expectedInsertions:@[]];
    817 
    818     [webView waitForAttachmentElementSizeToBecome:CGSizeMake(320, 240)];
    819     [attachment expectRequestedDataToBe:videoData.get()];
    820 }
    821 
    822 TEST(WKAttachmentTests, InPlacePDFAttachmentCutAndPaste)
    823 {
    824     auto webView = webViewForTestingAttachments();
    825     RetainPtr<NSData> pdfData = testPDFData();
    826     RetainPtr<_WKAttachment> attachment;
    827     {
    828         ObserveAttachmentUpdatesForScope observer(webView.get());
    829         attachment = [webView synchronouslyInsertAttachmentWithFilename:@"test.pdf" contentType:@"application/pdf" data:pdfData.get() options:displayOptionsWithMode(_WKAttachmentDisplayModeInPlace)];
    830         observer.expectAttachmentUpdates(@[], @[attachment.get()]);
    831         [webView waitForAttachmentElementSizeToBecome:CGSizeMake(130, 29)];
    832     }
    833 
    834     [webView _synchronouslyExecuteEditCommand:@"SelectAll" argument:nil];
    835     [webView expectUpdatesAfterCommand:@"Cut" withArgument:nil expectedRemovals:@[attachment.get()] expectedInsertions:@[]];
    836 
    837     [webView expectUpdatesAfterCommand:@"Paste" withArgument:nil expectedRemovals:@[] expectedInsertions:@[attachment.get()]];
    838     [webView waitForAttachmentElementSizeToBecome:CGSizeMake(130, 29)];
    839     [attachment expectRequestedDataToBe:pdfData.get()];
    840 }
    841 
    842 TEST(WKAttachmentTests, ChangeAttachmentDataAndFileInformation)
    843 {
    844     auto webView = webViewForTestingAttachments();
    845     RetainPtr<_WKAttachment> attachment;
    846     {
    847729        RetainPtr<NSData> pdfData = testPDFData();
    848730        ObserveAttachmentUpdatesForScope observer(webView.get());
    849         attachment = [webView synchronouslyInsertAttachmentWithFilename:@"test.pdf" contentType:@"application/pdf" data:pdfData.get() options:displayOptionsWithMode(_WKAttachmentDisplayModeAsIcon)];
     731        attachment = [webView synchronouslyInsertAttachmentWithFilename:@"test.pdf" contentType:@"application/pdf" data:pdfData.get()];
    850732        [attachment expectRequestedDataToBe:pdfData.get()];
    851733        EXPECT_WK_STREQ(@"test.pdf", [webView valueOfAttribute:@"title" forQuerySelector:@"attachment"]);
     
    865747        RetainPtr<NSData> textData = testHTMLData();
    866748        ObserveAttachmentUpdatesForScope observer(webView.get());
    867         [attachment synchronouslySetDisplayOptions:displayOptionsWithMode(_WKAttachmentDisplayModeAsIcon) error:nil];
    868749        // The new content type should be inferred from the file name.
    869750        [attachment synchronouslySetData:textData.get() newContentType:nil newFilename:@"foo.txt" error:nil];
     
    881762        EXPECT_WK_STREQ(@"foo.txt", [webView valueOfAttribute:@"title" forQuerySelector:@"attachment"]);
    882763        EXPECT_WK_STREQ(@"text/plain", [webView valueOfAttribute:@"type" forQuerySelector:@"attachment"]);
    883         observer.expectAttachmentUpdates(@[], @[]);
    884     }
    885     [webView expectUpdatesAfterCommand:@"DeleteBackward" withArgument:nil expectedRemovals:@[attachment.get()] expectedInsertions:@[]];
    886 }
    887 
    888 TEST(WKAttachmentTests, ChangeAttachmentDataUpdatesWithInPlaceDisplay)
    889 {
    890     auto webView = webViewForTestingAttachments();
    891     RetainPtr<_WKAttachment> attachment;
    892     {
    893         RetainPtr<NSData> pdfData = testPDFData();
    894         ObserveAttachmentUpdatesForScope observer(webView.get());
    895         attachment = [webView synchronouslyInsertAttachmentWithFilename:@"test.pdf" contentType:@"application/pdf" data:pdfData.get() options:displayOptionsWithMode(_WKAttachmentDisplayModeInPlace)];
    896         [webView waitForAttachmentElementSizeToBecome:CGSizeMake(130, 29)];
    897         [attachment expectRequestedDataToBe:pdfData.get()];
    898         EXPECT_WK_STREQ(@"test.pdf", [webView valueOfAttribute:@"title" forQuerySelector:@"attachment"]);
    899         EXPECT_WK_STREQ(@"application/pdf", [webView valueOfAttribute:@"type" forQuerySelector:@"attachment"]);
    900         observer.expectAttachmentUpdates(@[], @[attachment.get()]);
    901     }
    902     {
    903         RetainPtr<NSData> videoData = testVideoData();
    904         ObserveAttachmentUpdatesForScope observer(webView.get());
    905         [attachment synchronouslySetData:videoData.get() newContentType:@"video/mp4" newFilename:@"test.mp4" error:nil];
    906         [webView waitForAttachmentElementSizeToBecome:CGSizeMake(320, 240)];
    907         [attachment expectRequestedDataToBe:videoData.get()];
    908         EXPECT_WK_STREQ(@"test.mp4", [webView valueOfAttribute:@"title" forQuerySelector:@"attachment"]);
    909         EXPECT_WK_STREQ(@"video/mp4", [webView valueOfAttribute:@"type" forQuerySelector:@"attachment"]);
    910         observer.expectAttachmentUpdates(@[], @[]);
    911     }
    912     {
    913         RetainPtr<NSData> imageData = testImageData();
    914         ObserveAttachmentUpdatesForScope observer(webView.get());
    915         [attachment synchronouslySetData:imageData.get() newContentType:@"image/png" newFilename:@"icon.png" error:nil];
    916         [webView waitForAttachmentElementSizeToBecome:CGSizeMake(215, 174)];
    917         [attachment expectRequestedDataToBe:imageData.get()];
    918         EXPECT_WK_STREQ(@"icon.png", [webView valueOfAttribute:@"title" forQuerySelector:@"attachment"]);
    919         EXPECT_WK_STREQ(@"image/png", [webView valueOfAttribute:@"type" forQuerySelector:@"attachment"]);
    920764        observer.expectAttachmentUpdates(@[], @[]);
    921765    }
     
    1055899    {
    1056900        ObserveAttachmentUpdatesForScope observer(webView.get());
    1057         originalAttachment = [webView synchronouslyInsertAttachmentWithFilename:@"foo.txt" contentType:@"text/plain" data:data.get() options:nil];
     901        originalAttachment = [webView synchronouslyInsertAttachmentWithFilename:@"foo.txt" contentType:@"text/plain" data:data.get()];
    1058902        EXPECT_EQ(0U, observer.observer().removed.count);
    1059903        observer.expectAttachmentUpdates(@[], @[originalAttachment.get()]);
     
    1091935    {
    1092936        ObserveAttachmentUpdatesForScope observer(webView.get());
    1093         originalAttachment = [webView synchronouslyInsertAttachmentWithFilename:@"foo.txt" contentType:@"text/plain" data:originalData.get() options:nil];
     937        originalAttachment = [webView synchronouslyInsertAttachmentWithFilename:@"foo.txt" contentType:@"text/plain" data:originalData.get()];
    1094938        EXPECT_EQ(0U, observer.observer().removed.count);
    1095939        observer.expectAttachmentUpdates(@[], @[originalAttachment.get()]);
     
    13871231    {
    13881232        ObserveAttachmentUpdatesForScope observer(webView.get());
    1389         attachment = [webView synchronouslyInsertAttachmentWithFilename:@"document.pdf" contentType:@"application/pdf" data:data.get() options:displayOptionsWithMode(_WKAttachmentDisplayModeAsIcon)];
     1233        attachment = [webView synchronouslyInsertAttachmentWithFilename:@"document.pdf" contentType:@"application/pdf" data:data.get()];
    13901234        observer.expectAttachmentUpdates(@[], @[attachment.get()]);
    13911235    }
     
    14091253}
    14101254
    1411 TEST(WKAttachmentTestsIOS, DragInPlaceVideoAttachmentElement)
    1412 {
    1413     auto webView = webViewForTestingAttachments();
    1414     auto data = retainPtr(testVideoData());
    1415     RetainPtr<_WKAttachment> attachment;
    1416     {
    1417         ObserveAttachmentUpdatesForScope observer(webView.get());
    1418         attachment = [webView synchronouslyInsertAttachmentWithFilename:@"video.mp4" contentType:@"video/mp4" data:data.get() options:displayOptionsWithMode(_WKAttachmentDisplayModeInPlace)];
    1419         observer.expectAttachmentUpdates(@[], @[attachment.get()]);
    1420     }
    1421 
    1422     [webView waitForAttachmentElementSizeToBecome:CGSizeMake(320, 240)];
    1423     [attachment expectRequestedDataToBe:data.get()];
    1424     EXPECT_WK_STREQ("video.mp4", [webView valueOfAttribute:@"title" forQuerySelector:@"attachment"]);
    1425     EXPECT_WK_STREQ("video/mp4", [webView valueOfAttribute:@"type" forQuerySelector:@"attachment"]);
    1426 
    1427     [webView evaluateJavaScript:@"getSelection().removeAllRanges()" completionHandler:nil];
    1428     auto dragAndDropSimulator = adoptNS([[DragAndDropSimulator alloc] initWithWebView:webView.get()]);
    1429     [dragAndDropSimulator runFrom:CGPointMake(25, 25) to:CGPointMake(-100, -100)];
    1430 
    1431     EXPECT_EQ(1U, [dragAndDropSimulator sourceItemProviders].count);
    1432     NSItemProvider *itemProvider = [dragAndDropSimulator sourceItemProviders].firstObject;
    1433     EXPECT_EQ(UIPreferredPresentationStyleAttachment, itemProvider.preferredPresentationStyle);
    1434     [itemProvider expectType:(NSString *)kUTTypeMPEG4 withData:data.get()];
    1435     EXPECT_WK_STREQ("video.mp4", [itemProvider suggestedName]);
    1436     [dragAndDropSimulator endDataTransfer];
    1437 }
    1438 
    14391255TEST(WKAttachmentTestsIOS, MoveAttachmentElementAsIconByDragging)
    14401256{
     
    14441260    {
    14451261        ObserveAttachmentUpdatesForScope observer(webView.get());
    1446         attachment = [webView synchronouslyInsertAttachmentWithFilename:@"document.pdf" contentType:@"application/pdf" data:data.get() options:displayOptionsWithMode(_WKAttachmentDisplayModeAsIcon)];
     1262        attachment = [webView synchronouslyInsertAttachmentWithFilename:@"document.pdf" contentType:@"application/pdf" data:data.get()];
    14471263        observer.expectAttachmentUpdates(@[], @[attachment.get()]);
    14481264    }
     
    14651281}
    14661282
    1467 TEST(WKAttachmentTestsIOS, MoveInPlaceAttachmentElementByDragging)
    1468 {
    1469     auto webView = webViewForTestingAttachments();
    1470     auto data = retainPtr(testImageData());
    1471     RetainPtr<_WKAttachment> attachment;
    1472     {
    1473         ObserveAttachmentUpdatesForScope observer(webView.get());
    1474         attachment = [webView synchronouslyInsertAttachmentWithFilename:@"icon.png" contentType:@"image/png" data:data.get() options:displayOptionsWithMode(_WKAttachmentDisplayModeInPlace)];
    1475         observer.expectAttachmentUpdates(@[], @[attachment.get()]);
    1476     }
    1477 
    1478     [webView waitForAttachmentElementSizeToBecome:CGSizeMake(215, 174)];
    1479     [webView _executeEditCommand:@"InsertParagraph" argument:nil completion:nil];
    1480     [webView _executeEditCommand:@"InsertHTML" argument:@"<strong>text</strong>" completion:nil];
    1481     [webView _synchronouslyExecuteEditCommand:@"InsertParagraph" argument:nil];
    1482     [webView expectElementTag:@"ATTACHMENT" toComeBefore:@"STRONG"];
    1483 
    1484     auto dragAndDropSimulator = adoptNS([[DragAndDropSimulator alloc] initWithWebView:webView.get()]);
    1485     [dragAndDropSimulator runFrom:CGPointMake(25, 25) to:CGPointMake(25, 425)];
    1486 
    1487     attachment = [[dragAndDropSimulator insertedAttachments] firstObject];
    1488     [attachment expectRequestedDataToBe:data.get()];
    1489     EXPECT_WK_STREQ("icon.png", [webView valueOfAttribute:@"title" forQuerySelector:@"attachment"]);
    1490     EXPECT_WK_STREQ("image/png", [webView valueOfAttribute:@"type" forQuerySelector:@"attachment"]);
    1491 
    1492     [webView expectElementTag:@"STRONG" toComeBefore:@"ATTACHMENT"];
    1493     [dragAndDropSimulator endDataTransfer];
    1494 }
    1495 
    14961283#endif // PLATFORM(IOS)
    14971284
Note: See TracChangeset for help on using the changeset viewer.