[Attachment Support] Expose HTMLAttachmentElement.uniqueIdentifier to bindings
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Jan 2018 04:08:21 +0000 (04:08 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Jan 2018 04:08:21 +0000 (04:08 +0000)
https://bugs.webkit.org/show_bug.cgi?id=181420
<rdar://problem/36365827>

Reviewed by Alex Christensen.

Source/WebCore:

Add a new IDL definition for uniqueIdentifier on HTMLAttachmentElement. This allows clients to relate attachment
elements in the DOM to _WKAttachments delivered via Objective-C SPI.

Adjusted existing tests in WKAttachmentTests.

* html/HTMLAttachmentElement.idl:

Tools:

Adjusts some existing API tests to verify that attachment elements' uniqueIdentifiers match the uniqueIdentifier
of corresponding _WKAttachments.

* TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm:
(TestWebKitAPI::TEST):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226612 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/html/HTMLAttachmentElement.idl
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm

index 36df354..3c45f93 100644 (file)
@@ -1,3 +1,18 @@
+2018-01-08  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        [Attachment Support] Expose HTMLAttachmentElement.uniqueIdentifier to bindings
+        https://bugs.webkit.org/show_bug.cgi?id=181420
+        <rdar://problem/36365827>
+
+        Reviewed by Alex Christensen.
+
+        Add a new IDL definition for uniqueIdentifier on HTMLAttachmentElement. This allows clients to relate attachment
+        elements in the DOM to _WKAttachments delivered via Objective-C SPI.
+
+        Adjusted existing tests in WKAttachmentTests.
+
+        * html/HTMLAttachmentElement.idl:
+
 2018-01-08  Don Olmstead  <don.olmstead@sony.com>
 
         AccessibilityARIAGrid does not compile when accessibility is disabled
index 4178b4b..d2f709f 100644 (file)
@@ -28,4 +28,5 @@
     EnabledAtRuntime=AttachmentElement,
 ] interface HTMLAttachmentElement : HTMLElement {
     attribute File? file;
+    readonly attribute DOMString uniqueIdentifier;
 };
index 4589099..6d74bf0 100644 (file)
@@ -1,3 +1,17 @@
+2018-01-08  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        [Attachment Support] Expose HTMLAttachmentElement.uniqueIdentifier to bindings
+        https://bugs.webkit.org/show_bug.cgi?id=181420
+        <rdar://problem/36365827>
+
+        Reviewed by Alex Christensen.
+
+        Adjusts some existing API tests to verify that attachment elements' uniqueIdentifiers match the uniqueIdentifier
+        of corresponding _WKAttachments.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm:
+        (TestWebKitAPI::TEST):
+
 2018-01-08  Alex Christensen  <achristensen@webkit.org>
 
         Add WKNavigationDelegate SPI exposing WebProcess crash reason
index 8dd3866..7af784c 100644 (file)
@@ -570,6 +570,7 @@ TEST(WKAttachmentTests, AttachmentUpdatesWhenInsertingRichMarkup)
     EXPECT_FALSE([webView hasAttribute:@"webkitattachmentbloburl" forQuerySelector:@"attachment"]);
     EXPECT_FALSE([webView hasAttribute:@"webkitattachmentpath" forQuerySelector:@"attachment"]);
     EXPECT_FALSE([webView hasAttribute:@"webkitattachmentid" forQuerySelector:@"attachment"]);
+    EXPECT_WK_STREQ([attachment uniqueIdentifier], [webView stringByEvaluatingJavaScript:@"document.querySelector('attachment').uniqueIdentifier"]);
     {
         ObserveAttachmentUpdatesForScope observer(webView.get());
         [webView stringByEvaluatingJavaScript:@"document.querySelector('attachment').remove()"];
@@ -589,6 +590,7 @@ TEST(WKAttachmentTests, AttachmentUpdatesWhenCuttingAndPasting)
         observer.expectAttachmentUpdates(@[], @[attachment.get()]);
     }
     [attachment expectRequestedDataToBe:testHTMLData()];
+    EXPECT_WK_STREQ([attachment uniqueIdentifier], [webView stringByEvaluatingJavaScript:@"document.querySelector('attachment').uniqueIdentifier"]);
     [webView _synchronouslyExecuteEditCommand:@"SelectAll" argument:nil];
     {
         ObserveAttachmentUpdatesForScope observer(webView.get());
@@ -617,6 +619,7 @@ TEST(WKAttachmentTests, AttachmentDataForEmptyFile)
         observer.expectAttachmentUpdates(@[], @[attachment.get()]);
     }
     [attachment expectRequestedDataToBe:[NSData data]];
+    EXPECT_WK_STREQ([attachment uniqueIdentifier], [webView stringByEvaluatingJavaScript:@"document.querySelector('attachment').uniqueIdentifier"]);
     {
         ObserveAttachmentUpdatesForScope scope(webView.get());
         [webView _synchronouslyExecuteEditCommand:@"DeleteBackward" argument:nil];
@@ -697,6 +700,7 @@ TEST(WKAttachmentTests, InPlaceImageAttachmentParagraphInsertion)
     [webView expectUpdatesAfterCommand:@"DeleteBackward" withArgument:nil expectedRemovals:@[] expectedInsertions:@[]];
 
     [attachment expectRequestedDataToBe:imageData.get()];
+    EXPECT_WK_STREQ([attachment uniqueIdentifier], [webView stringByEvaluatingJavaScript:@"document.querySelector('attachment').uniqueIdentifier"]);
     [webView waitForAttachmentElementSizeToBecome:CGSizeMake(215, 174)];
 
     [webView expectUpdatesAfterCommand:@"DeleteForward" withArgument:nil expectedRemovals:@[attachment.get()] expectedInsertions:@[]];
@@ -843,6 +847,7 @@ TEST(WKAttachmentTests, InsertPastedImageAsAttachment)
     auto size = platformImageWithData([attachment synchronouslyRequestData:nil]).size;
     EXPECT_EQ(215., size.width);
     EXPECT_EQ(174., size.height);
+    EXPECT_WK_STREQ([attachment uniqueIdentifier], [webView stringByEvaluatingJavaScript:@"document.querySelector('attachment').uniqueIdentifier"]);
 
     {
         ObserveAttachmentUpdatesForScope observer(webView.get());
@@ -869,6 +874,7 @@ TEST(WKAttachmentTests, InsertPastedAttributedStringContainingImage)
     [attachment expectRequestedDataToBe:testImageData()];
     EXPECT_WK_STREQ("Lorem ipsum  dolor sit amet.", [webView stringByEvaluatingJavaScript:@"document.body.textContent"]);
     EXPECT_WK_STREQ("image/png", [webView valueOfAttribute:@"type" forQuerySelector:@"attachment"]);
+    EXPECT_WK_STREQ([attachment uniqueIdentifier], [webView stringByEvaluatingJavaScript:@"document.querySelector('attachment').uniqueIdentifier"]);
 
     {
         ObserveAttachmentUpdatesForScope observer(webView.get());
@@ -914,6 +920,10 @@ TEST(WKAttachmentTests, InsertPastedAttributedStringContainingMultipleAttachment
     EXPECT_WK_STREQ("application/octet-stream", zipAttachmentType);
 #endif
 
+    EXPECT_WK_STREQ([imageAttachment uniqueIdentifier], [webView stringByEvaluatingJavaScript:@"document.querySelectorAll('attachment')[0].uniqueIdentifier"]);
+    EXPECT_WK_STREQ([pdfAttachment uniqueIdentifier], [webView stringByEvaluatingJavaScript:@"document.querySelectorAll('attachment')[1].uniqueIdentifier"]);
+    EXPECT_WK_STREQ([zipAttachment uniqueIdentifier], [webView stringByEvaluatingJavaScript:@"document.querySelectorAll('attachment')[2].uniqueIdentifier"]);
+
     {
         ObserveAttachmentUpdatesForScope observer(webView.get());
         [webView _synchronouslyExecuteEditCommand:@"SelectAll" argument:nil];