Dragging & dropping a file creates an attachment element even when it's disabled
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Sep 2017 23:31:14 +0000 (23:31 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Sep 2017 23:31:14 +0000 (23:31 +0000)
https://bugs.webkit.org/show_bug.cgi?id=176769

Reviewed by Tim Horton.

Source/WebCore:

The bug that dropping a file always created an attachment element even when it's disabled by settings
was caused by WebContentReader::readFilenames always creating an attachment element. Fixed this by
checking the runtime flag. The fix is tested by drag-files-to-editable-element-as-URLs.html

To fix the bug that HTMLAttachmentElement is always exposed on the global object even when it's disabled
by settings, replaced the setting to enable attachment element by an equivalent runtime enabled flag,
and hid both the interface as well as the element behind it. Fixed various bugs in our code generator
to make this work.

Tests: editing/pasteboard/drag-files-to-editable-element-as-URLs.html
       editing/pasteboard/drag-files-to-editable-element-as-attachment.html

* bindings/js/WebCoreBuiltinNames.h: Added symbols used in the generated code.
* dom/make_event_factory.pl:
(defaultItemFactory): Replaced "runtimeConditonal" option by "runtimeEnabled".
(generateImplementation):
* dom/make_names.pl:
(defaultTagPropertyHash):
(printConstructorInterior): Return a HTMLUnknownElement if the element is disabled by a runtime flag.
(printTypeHelpers): Make is<HTMLAttachmentElement>(~) returns false when the feature is disabled by
checking whether the given element is an instance of HTMLUnknownElement.
(printWrapperFunctions): Simplified this code by matching the code for settingsConditional.
* editing/mac/EditorMac.mm:
(WebCore::Editor::WebContentReader::readFilenames): Fixed the bug that this code was always creating
an attachment element even when the feature is disabled.
* html/HTMLAttachmentElement.idl: Hide this behind a runtime flag.
* html/HTMLTagNames.in:
* page/RuntimeEnabledFeatures.h:
(WebCore::RuntimeEnabledFeatures::setAttachmentElementEnabled): Added.
(WebCore::RuntimeEnabledFeatures::attachmentElementEnabled const): Added.
* page/Settings.in: Removed attachmentElementEnabled.

Source/WebKit:

* UIProcess/API/C/WKPreferences.cpp:
(WKPreferencesSetAttachmentElementEnabled):
(WKPreferencesGetAttachmentElementEnabled):
* UIProcess/API/C/WKPreferencesRefPrivate.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updatePreferences):

Source/WebKitLegacy/mac:

* WebView/WebView.mm:
(-[WebView _preferencesChanged:]):

Tools:

Added a webkit-test-runner flag to enable attachment element via runtime flag since this feature is now hidden
behind a runtime-enabled flag which needs to be set at the time of global object initialization.

* DumpRenderTree/TestOptions.h:
(TestOptions): Added.
* DumpRenderTree/TestOptions.mm:
(TestOptions::TestOptions):
* DumpRenderTree/mac/DumpRenderTree.mm:
(setWebPreferencesForTestOptions):
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::resetPreferencesToConsistentValues):
(WTR::updateTestOptionsFromTestHeader):
* WebKitTestRunner/TestOptions.h:
(WTR::TestOptions::hasSameInitializationOptions const):
* WebKitTestRunner/cocoa/TestControllerCocoa.mm:
(WTR::TestController::platformCreateWebView):

LayoutTests:

Updated the existing attachment element tests to use the newly added webkitt-test-runner flag,
and added a new test (drag-files-to-editable-element-as-URLs.html) to make sure we don't create
an attachment element when dropping a file.

* editing/pasteboard/copy-paste-attachment-expected.txt:
* editing/pasteboard/copy-paste-attachment.html:
* editing/pasteboard/drag-files-to-editable-element-as-URLs-expected.txt: Added.
* editing/pasteboard/drag-files-to-editable-element-as-URLs.html: Copied from
drag-files-to-editable-element.html.
* editing/pasteboard/drag-files-to-editable-element-as-attachment-expected.txt: Renamed from
drag-files-to-editable-element-expected.txt.
* editing/pasteboard/drag-files-to-editable-element-as-attachment.html: Renamed from
drag-files-to-editable-element.html.
* editing/pasteboard/drag-files-to-editable-element-expected.txt: Removed.
* editing/pasteboard/drag-files-to-editable-element.html: Removed.
* fast/attachment/attachment-action-expected.html:
* fast/attachment/attachment-action.html:
* fast/attachment/attachment-borderless-expected-mismatch.html:
* fast/attachment/attachment-borderless.html:
* fast/attachment/attachment-default-icon-expected.html:
* fast/attachment/attachment-default-icon.html:
* fast/attachment/attachment-dom.html:
* fast/attachment/attachment-folder-icon-expected.html:
* fast/attachment/attachment-folder-icon.html:
* fast/attachment/attachment-icon-from-file-extension-expected.html:
* fast/attachment/attachment-icon-from-file-extension.html:
* fast/attachment/attachment-label-highlight.html:
* fast/attachment/attachment-progress.html:
* fast/attachment/attachment-rendering.html:
* fast/attachment/attachment-respects-css-size.html:
* fast/attachment/attachment-select-on-click-inside-user-select-all.html:
* fast/attachment/attachment-select-on-click.html:
* fast/attachment/attachment-subtitle-resize.html:
* fast/attachment/attachment-subtitle.html:
* fast/attachment/attachment-title.html:
* fast/attachment/attachment-type-attribute-expected.html:
* fast/attachment/attachment-type-attribute.html:
* fast/attachment/attachment-uti-expected.html:
* fast/attachment/attachment-uti.html:
* fast/attachment/attachment-wrapping-action-expected-mismatch.html:
* fast/attachment/attachment-wrapping-action.html:
* platform/gtk/TestExpectations:
* platform/win/TestExpectations:
* platform/wk2/TestExpectations:

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

63 files changed:
LayoutTests/ChangeLog
LayoutTests/accessibility/attachment-element.html
LayoutTests/accessibility/ios-simulator/attributed-string-for-range.html
LayoutTests/accessibility/mac/attachment-element-replacement-character.html
LayoutTests/editing/pasteboard/copy-paste-attachment-expected.txt
LayoutTests/editing/pasteboard/copy-paste-attachment.html
LayoutTests/editing/pasteboard/drag-and-drop-attachment-contenteditable.html
LayoutTests/editing/pasteboard/drag-files-to-editable-element-as-URLs-expected.txt [new file with mode: 0644]
LayoutTests/editing/pasteboard/drag-files-to-editable-element-as-URLs.html [new file with mode: 0644]
LayoutTests/editing/pasteboard/drag-files-to-editable-element-as-attachment-expected.txt [moved from LayoutTests/editing/pasteboard/drag-files-to-editable-element-expected.txt with 100% similarity]
LayoutTests/editing/pasteboard/drag-files-to-editable-element-as-attachment.html [moved from LayoutTests/editing/pasteboard/drag-files-to-editable-element.html with 94% similarity]
LayoutTests/fast/attachment/attachment-action-expected.html
LayoutTests/fast/attachment/attachment-action.html
LayoutTests/fast/attachment/attachment-borderless-expected-mismatch.html
LayoutTests/fast/attachment/attachment-borderless.html
LayoutTests/fast/attachment/attachment-default-icon-expected.html
LayoutTests/fast/attachment/attachment-default-icon.html
LayoutTests/fast/attachment/attachment-dom.html
LayoutTests/fast/attachment/attachment-folder-icon-expected.html
LayoutTests/fast/attachment/attachment-folder-icon.html
LayoutTests/fast/attachment/attachment-icon-from-file-extension-expected.html
LayoutTests/fast/attachment/attachment-icon-from-file-extension.html
LayoutTests/fast/attachment/attachment-label-highlight.html
LayoutTests/fast/attachment/attachment-progress.html
LayoutTests/fast/attachment/attachment-rendering.html
LayoutTests/fast/attachment/attachment-respects-css-size.html
LayoutTests/fast/attachment/attachment-select-on-click-inside-user-select-all.html
LayoutTests/fast/attachment/attachment-select-on-click.html
LayoutTests/fast/attachment/attachment-subtitle-resize.html
LayoutTests/fast/attachment/attachment-subtitle.html
LayoutTests/fast/attachment/attachment-title.html
LayoutTests/fast/attachment/attachment-type-attribute-expected.html
LayoutTests/fast/attachment/attachment-type-attribute.html
LayoutTests/fast/attachment/attachment-uti-expected.html
LayoutTests/fast/attachment/attachment-uti.html
LayoutTests/fast/attachment/attachment-wrapping-action-expected-mismatch.html
LayoutTests/fast/attachment/attachment-wrapping-action.html
LayoutTests/platform/gtk/TestExpectations
LayoutTests/platform/ios/fast/attachment/attachment-select-on-click-expected.txt
LayoutTests/platform/win/TestExpectations
LayoutTests/platform/wk2/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/WebCoreBuiltinNames.h
Source/WebCore/dom/make_event_factory.pl
Source/WebCore/dom/make_names.pl
Source/WebCore/editing/mac/EditorMac.mm
Source/WebCore/html/HTMLAttachmentElement.idl
Source/WebCore/html/HTMLTagNames.in
Source/WebCore/page/RuntimeEnabledFeatures.h
Source/WebCore/page/Settings.in
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/C/WKPreferences.cpp
Source/WebKit/UIProcess/API/C/WKPreferencesRefPrivate.h
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/WebView/WebView.mm
Tools/ChangeLog
Tools/DumpRenderTree/TestOptions.h
Tools/DumpRenderTree/TestOptions.mm
Tools/DumpRenderTree/mac/DumpRenderTree.mm
Tools/WebKitTestRunner/TestController.cpp
Tools/WebKitTestRunner/TestOptions.h
Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm

index 33dca88..dd7ae2e 100644 (file)
@@ -1,3 +1,55 @@
+2017-09-12  Ryosuke Niwa  <rniwa@webkit.org>
+
+        Dragging & dropping a file creates an attachment element even when it's disabled
+        https://bugs.webkit.org/show_bug.cgi?id=176769
+
+        Reviewed by Tim Horton.
+
+        Updated the existing attachment element tests to use the newly added webkitt-test-runner flag,
+        and added a new test (drag-files-to-editable-element-as-URLs.html) to make sure we don't create
+        an attachment element when dropping a file. 
+
+        * editing/pasteboard/copy-paste-attachment-expected.txt:
+        * editing/pasteboard/copy-paste-attachment.html:
+        * editing/pasteboard/drag-files-to-editable-element-as-URLs-expected.txt: Added.
+        * editing/pasteboard/drag-files-to-editable-element-as-URLs.html: Copied from
+        drag-files-to-editable-element.html.
+        * editing/pasteboard/drag-files-to-editable-element-as-attachment-expected.txt: Renamed from
+        drag-files-to-editable-element-expected.txt.
+        * editing/pasteboard/drag-files-to-editable-element-as-attachment.html: Renamed from
+        drag-files-to-editable-element.html.
+        * editing/pasteboard/drag-files-to-editable-element-expected.txt: Removed.
+        * editing/pasteboard/drag-files-to-editable-element.html: Removed.
+        * fast/attachment/attachment-action-expected.html:
+        * fast/attachment/attachment-action.html:
+        * fast/attachment/attachment-borderless-expected-mismatch.html:
+        * fast/attachment/attachment-borderless.html:
+        * fast/attachment/attachment-default-icon-expected.html:
+        * fast/attachment/attachment-default-icon.html:
+        * fast/attachment/attachment-dom.html:
+        * fast/attachment/attachment-folder-icon-expected.html:
+        * fast/attachment/attachment-folder-icon.html:
+        * fast/attachment/attachment-icon-from-file-extension-expected.html:
+        * fast/attachment/attachment-icon-from-file-extension.html:
+        * fast/attachment/attachment-label-highlight.html:
+        * fast/attachment/attachment-progress.html:
+        * fast/attachment/attachment-rendering.html:
+        * fast/attachment/attachment-respects-css-size.html:
+        * fast/attachment/attachment-select-on-click-inside-user-select-all.html:
+        * fast/attachment/attachment-select-on-click.html:
+        * fast/attachment/attachment-subtitle-resize.html:
+        * fast/attachment/attachment-subtitle.html:
+        * fast/attachment/attachment-title.html:
+        * fast/attachment/attachment-type-attribute-expected.html:
+        * fast/attachment/attachment-type-attribute.html:
+        * fast/attachment/attachment-uti-expected.html:
+        * fast/attachment/attachment-uti.html:
+        * fast/attachment/attachment-wrapping-action-expected-mismatch.html:
+        * fast/attachment/attachment-wrapping-action.html:
+        * platform/gtk/TestExpectations:
+        * platform/win/TestExpectations:
+        * platform/wk2/TestExpectations:
+
 2017-09-12  Michael Catanzaro  <mcatanzaro@igalia.com>
 
         [GTK] Unreviewed, update crash expectations after r221925
index 0a883f2..b399848 100644 (file)
@@ -1,13 +1,5 @@
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<!DOCTYPE html><!-- webkit-test-runner [ enableAttachmentElement=true ] -->
 <html>
-<head>
-<meta charset="utf-8">
-<script src="../resources/js-test-pre.js"></script>
-<script>
-    if (window.internals)
-        window.internals.settings.setAttachmentElementEnabled(true)
-</script>
-</head>
 <body id="body">
 
 <attachment id="attachment" title="title" subtitle="subtitle" action="action" progress="0.5"></attachment>
@@ -15,6 +7,7 @@
 <p id="description"></p>
 <div id="console"></div>
 
+<script src="../resources/js-test-pre.js"></script>
 <script>
 
     description("This tests that attachment elements are accessible.");
index 98cbe35..821e5b1 100644 (file)
@@ -1,15 +1,5 @@
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<!DOCTYPE html><!-- webkit-test-runner [ enableAttachmentElement=true ] -->
 <html>
-<head>
-<script>
-var successfullyParsed = false;
-</script>
-<script>
-    if (window.internals)
-        window.internals.settings.setAttachmentElementEnabled(true)
-</script>
-<script src="../../resources/js-test-pre.js"></script>
-</head>
 <body id="body">
 
 <div id="content">
@@ -23,7 +13,7 @@ world
 
 <p id="description"></p>
 <div id="console"></div>
-
+<script src="../../resources/js-test-pre.js"></script>
 <script>
 
     description("This test ensures that attributed string for range works");
index 124df48..6d91128 100644 (file)
@@ -1,13 +1,5 @@
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<!DOCTYPE html><!-- webkit-test-runner [ enableAttachmentElement=true ] -->
 <html>
-<head>
-<meta charset="utf-8">
-<script src="../../resources/js-test-pre.js"></script>
-<script>
-    if (window.internals)
-        window.internals.settings.setAttachmentElementEnabled(true)
-</script>
-</head>
 <body id="body">
 
 some
@@ -17,6 +9,7 @@ test
 <p id="description"></p>
 <div id="console"></div>
 
+<script src="../../resources/js-test-pre.js"></script>
 <script>
 
     description("This tests that attachment element replacements are present in strings.");
index 53c02f3..8906de5 100644 (file)
@@ -12,3 +12,4 @@ PASS successfullyParsed is true
 
 TEST COMPLETE
 This is a paragraph with an attachment¬†¬†and some other text.
+
index 9b1e763..0ab6650 100644 (file)
@@ -1,17 +1,12 @@
+<!DOCTYPE html><!-- webkit-test-runner [ enableAttachmentElement=true ] -->
 <html>
-<head>
-<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
-<script>
-    if (window.internals)
-        window.internals.settings.setAttachmentElementEnabled(true)
-</script>
-<script src="../../resources/js-test-pre.js"></script>
-</head>
 <body>
 <div contenteditable="true" id="test1">This is a paragraph with an attachment
     <attachment id='attachment'></attachment> and some other text.
 </div>
+<script src="../../resources/js-test-pre.js"></script>
 <script>
+
 var file;
 if (window.internals) {
     var file = window.internals.createFile("../resources/abe.png");
index c1f3f71..178803b 100644 (file)
@@ -1,10 +1,6 @@
-<!DOCTYPE html>
+<!DOCTYPE html><!-- webkit-test-runner [ enableAttachmentElement=true ] -->
 <html>
 <head>
-<script>
-    if (window.internals)
-        window.internals.settings.setAttachmentElementEnabled(true)
-</script>
 <script src="../../resources/js-test.js"></script>
 <style>
 #target {
diff --git a/LayoutTests/editing/pasteboard/drag-files-to-editable-element-as-URLs-expected.txt b/LayoutTests/editing/pasteboard/drag-files-to-editable-element-as-URLs-expected.txt
new file mode 100644 (file)
index 0000000..75824c1
--- /dev/null
@@ -0,0 +1,12 @@
+If we drag files onto an editable area, then attachments should be inserted into the editable area.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS window.HTMLAttachmentElement is undefined.
+PASS document.createElement("attachment") instanceof HTMLUnknownElement is true
+PASS editable.querySelector("attachment") is null
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/editing/pasteboard/drag-files-to-editable-element-as-URLs.html b/LayoutTests/editing/pasteboard/drag-files-to-editable-element-as-URLs.html
new file mode 100644 (file)
index 0000000..b5d08e8
--- /dev/null
@@ -0,0 +1,38 @@
+<!DOCTYPE html><!-- webkit-test-runner [ enableAttachmentElement=false ] -->
+<html>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<div id="editable" contentEditable=true style="width:200px; height:200px"></div>
+<script src="../../resources/js-test-pre.js"></script>
+<script>
+description('If we drag files onto an editable area, then attachments should be inserted into the editable area.');
+
+var editable = document.getElementById("editable");
+if (window.eventSender) {
+    dragFilesOntoEditable(['foo', 'bar', 'baz']);
+    shouldBeUndefined('window.HTMLAttachmentElement');
+    shouldBeTrue('document.createElement("attachment") instanceof HTMLUnknownElement');
+    shouldBe('editable.querySelector("attachment")', 'null');
+    editable.innerHTML = '';
+}
+
+function moveMouseToCenterOfElement(element)
+{
+    var centerX = element.offsetLeft + element.offsetWidth / 2;
+    var centerY = element.offsetTop + element.offsetHeight / 2;
+    eventSender.mouseMoveTo(centerX, centerY);
+}
+
+function dragFilesOntoEditable(files)
+{
+    eventSender.beginDragWithFiles(files);
+    moveMouseToCenterOfElement(editable);
+    eventSender.mouseUp();
+}
+
+var successfullyParsed = true;
+</script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
@@ -1,11 +1,10 @@
+<!DOCTYPE html><!-- webkit-test-runner [ enableAttachmentElement=true ] -->
 <html>
-<head>
-<script src="../../resources/js-test-pre.js"></script>
-</head>
 <body>
 <p id="description"></p>
 <div id="console"></div>
 <div id="editable" contentEditable=true style="width:200px; height:200px"></div>
+<script src="../../resources/js-test-pre.js"></script>
 <script>
 description('If we drag files onto an editable area, then attachments should be inserted into the editable area.');
 
index adaeb21..d2747e1 100644 (file)
@@ -1,9 +1,5 @@
-<!DOCTYPE html>
+<!DOCTYPE html><!-- webkit-test-runner [ enableAttachmentElement=true ] -->
 <html>
-<script>
-if (window.internals)
-    window.internals.settings.setAttachmentElementEnabled(true);
-</script>
 <style>
 div {
     width: 300px;
index 9646b2b..0439d59 100644 (file)
@@ -1,9 +1,5 @@
-<!DOCTYPE html>
+<!DOCTYPE html><!-- webkit-test-runner [ enableAttachmentElement=true ] -->
 <html>
-<script>
-if (window.internals)
-    window.internals.settings.setAttachmentElementEnabled(true);
-</script>
 <style>
 div {
     width: 300px;
index 2e9a12f..1057389 100644 (file)
@@ -1,9 +1,5 @@
-<!DOCTYPE html>
+<!DOCTYPE html><!-- webkit-test-runner [ enableAttachmentElement=true ] -->
 <html>
-<script>
-    if (window.internals)
-        window.internals.settings.setAttachmentElementEnabled(true)
-</script>
 <body>
 <attachment id="attachment" title="overridden title" subtitle="1024 bytes"></attachment>
 </body>
index c4dcd87..1c81d78 100644 (file)
@@ -1,9 +1,5 @@
-<!DOCTYPE html>
+<!DOCTYPE html><!-- webkit-test-runner [ enableAttachmentElement=true ] -->
 <html>
-<script>
-    if (window.internals)
-        window.internals.settings.setAttachmentElementEnabled(true)
-</script>
 <body>
 <attachment id="attachment" title="overridden title" subtitle="1024 bytes" style="-webkit-appearance: borderless-attachment;"></attachment>
 </body>
index d1514aa..93eb477 100644 (file)
@@ -1,10 +1,6 @@
-<!DOCTYPE html>
+<!DOCTYPE html><!-- webkit-test-runner [ enableAttachmentElement=true ] -->
 <html>
 <body>
-<script>
-    if (window.internals)
-        window.internals.settings.setAttachmentElementEnabled(true)
-</script>
 <attachment id="attachment" title="  "></attachment>
 <script>
 var file;
index 7e8bed6..bd48efa 100644 (file)
@@ -1,10 +1,6 @@
-<!DOCTYPE html>
+<!DOCTYPE html><!-- webkit-test-runner [ enableAttachmentElement=true ] -->
 <html>
 <body>
-<script>
-    if (window.internals)
-        window.internals.settings.setAttachmentElementEnabled(true)
-</script>
 <attachment title="   "></attachment>
 </body>
 </html>
index b0c8677..154d9a2 100644 (file)
@@ -1,11 +1,7 @@
-<!DOCTYPE html>
+<!DOCTYPE html><!-- webkit-test-runner [ enableAttachmentElement=true ] -->
 <html>
 <head>
 <meta charset="utf-8">
-<script>
-    if (window.internals)
-        window.internals.settings.setAttachmentElementEnabled(true)
-</script>
 <script src="../../resources/js-test-pre.js"></script>
 </head>
 <body>
index cab19c0..a3aa478 100644 (file)
@@ -1,9 +1,5 @@
-<!DOCTYPE html>
+<!DOCTYPE html><!-- webkit-test-runner [ enableAttachmentElement=true ] -->
 <html>
-<script>
-    if (window.internals)
-        window.internals.settings.setAttachmentElementEnabled(true)
-</script>
 <body>
 <attachment title=" "></attachment>
 <attachment title=" "></attachment>
index 1858ca6..ac7c36c 100644 (file)
@@ -1,9 +1,5 @@
-<!DOCTYPE html>
+<!DOCTYPE html><!-- webkit-test-runner [ enableAttachmentElement=true ] -->
 <html>
-<script>
-    if (window.internals)
-        window.internals.settings.setAttachmentElementEnabled(true)
-</script>
 <body>
 <attachment title=" " type="multipart/x-folder"></attachment>
 <attachment title=" " type="application/vnd.apple.folder"></attachment>
index d071d53..3428ad7 100644 (file)
@@ -1,9 +1,5 @@
-<!DOCTYPE html>
+<!DOCTYPE html><!-- webkit-test-runner [ enableAttachmentElement=true ] -->
 <html>
-<script>
-    if (window.internals)
-        window.internals.settings.setAttachmentElementEnabled(true)
-</script>
 <body>
 <attachment></attachment>
 <script>
index c41131d..036fca3 100644 (file)
@@ -1,9 +1,5 @@
-<!DOCTYPE html>
+<!DOCTYPE html><!-- webkit-test-runner [ enableAttachmentElement=true ] -->
 <html>
-<script>
-    if (window.internals)
-        window.internals.settings.setAttachmentElementEnabled(true)
-</script>
 <body>
 <attachment title="test-file.txt"></attachment>
 </body>
index 6987448..7f0684c 100644 (file)
@@ -1,9 +1,7 @@
-<!DOCTYPE html>
+<!DOCTYPE html><!-- webkit-test-runner [ enableAttachmentElement=true ] -->
 <html>
 <body>
 <script>
-if (window.internals)
-    window.internals.settings.setAttachmentElementEnabled(true)
 
 var attachmentShortLabel = document.createElement("attachment");
 var attachmentLongOnTopLabel = document.createElement("attachment");
index 981f34b..78e97de 100644 (file)
@@ -1,9 +1,5 @@
-<!DOCTYPE html>
+<!DOCTYPE html><!-- webkit-test-runner [ enableAttachmentElement=true ] -->
 <html>
-<script>
-    if (window.internals)
-        window.internals.settings.setAttachmentElementEnabled(true)
-</script>
 <body>
 <attachment progress="-1.5"></attachment>
 <attachment progress="0"></attachment>
index b41edda..c85932a 100644 (file)
@@ -1,9 +1,5 @@
-<html>
+<html><!-- webkit-test-runner [ enableAttachmentElement=true ] -->
 <head>
-<script>
-    if (window.internals)
-        window.internals.settings.setAttachmentElementEnabled(true)
-</script>
 </head>
 <body>
     <p>This tests that attachments have a custom renderer.</p>
index 176f349..e615a91 100644 (file)
@@ -1,9 +1,5 @@
-<!DOCTYPE html>
+<!DOCTYPE html><!-- webkit-test-runner [ enableAttachmentElement=true ] -->
 <html>
-<script>
-    if (window.internals)
-        window.internals.settings.setAttachmentElementEnabled(true)
-</script>
 <body>
 <attachment id="attachment" title="overridden title" subtitle="1024 bytes" style="width: 500px; height: 500px;"></attachment>
 </body>
index ff16bfb..9291807 100644 (file)
@@ -1,9 +1,5 @@
-<!DOCTYPE html>
+<!DOCTYPE html><!-- webkit-test-runner [ enableAttachmentElement=true ] -->
 <html>
-<script>
-    if (window.internals)
-        window.internals.settings.setAttachmentElementEnabled(true)
-</script>
 <body onload="runTest()">
 <div style="-webkit-user-select: all;">text before <attachment id="attachment"></attachment> text after</div>
 <script>
index 0705b90..258e3d2 100644 (file)
@@ -1,9 +1,5 @@
-<!DOCTYPE html>
+<!DOCTYPE html><!-- webkit-test-runner [ enableAttachmentElement=true ] -->
 <html>
-<script>
-    if (window.internals)
-        window.internals.settings.setAttachmentElementEnabled(true)
-</script>
 <body onload="runTest()">
 <div>text before <attachment id="attachment"></attachment> text after</div>
 <div id="result"></div>
index 019da4b..c9c4e0b 100644 (file)
@@ -1,10 +1,6 @@
-<!DOCTYPE html>
+<!DOCTYPE html><!-- webkit-test-runner [ enableAttachmentElement=true ] -->
 <html>
 <script src="../../resources/js-test-pre.js"></script>
-<script>
-    if (window.internals)
-        window.internals.settings.setAttachmentElementEnabled(true)
-</script>
 <body>
 <attachment id="wideAttachment" subtitle="VERY LONG SUBTITLE THAT WILL MAKE THE ATTACHMENT VERY WIDE"></attachment>
 <attachment id="skinnyAttachment" subtitle="skinny but wider than icon"></attachment>
index ed052cb..85a9ea5 100644 (file)
@@ -1,9 +1,5 @@
-<!DOCTYPE html>
+<!DOCTYPE html><!-- webkit-test-runner [ enableAttachmentElement=true ] -->
 <html>
-<script>
-    if (window.internals)
-        window.internals.settings.setAttachmentElementEnabled(true)
-</script>
 <body>
 <attachment id="attachment" subtitle="1024 bytes"></attachment>
 <script>
index a28462a..79b2bcf 100644 (file)
@@ -1,9 +1,5 @@
-<!DOCTYPE html>
+<!DOCTYPE html><!-- webkit-test-runner [ enableAttachmentElement=true ] -->
 <html>
-<script>
-    if (window.internals)
-        window.internals.settings.setAttachmentElementEnabled(true)
-</script>
 <body>
 <attachment id="attachment" title="overridden title" subtitle="1024 bytes"></attachment>
 <script>
index be936bf..d339b12 100644 (file)
@@ -1,9 +1,5 @@
-<!DOCTYPE html>
+<!DOCTYPE html><!-- webkit-test-runner [ enableAttachmentElement=true ] -->
 <html>
-<script>
-    if (window.internals)
-        window.internals.settings.setAttachmentElementEnabled(true)
-</script>
 <body>
 <attachment id="attachment" title="  "></attachment>
 <script>
index 86eb348..cd9a7cd 100644 (file)
@@ -1,9 +1,5 @@
-<!DOCTYPE html>
+<!DOCTYPE html><!-- webkit-test-runner [ enableAttachmentElement=true ] -->
 <html>
-<script>
-    if (window.internals)
-        window.internals.settings.setAttachmentElementEnabled(true)
-</script>
 <body>
 <attachment type="text/plain" title="  "></attachment>
 </body>
index a55ac80..cc76d06 100644 (file)
@@ -1,9 +1,5 @@
-<!DOCTYPE html>
+<!DOCTYPE html><!-- webkit-test-runner [ enableAttachmentElement=true ] -->
 <html>
-<script>
-    if (window.internals)
-        window.internals.settings.setAttachmentElementEnabled(true)
-</script>
 <body>
 <attachment title=" " type="image/jpeg"></attachment>
 <attachment title=" " type="text/plain"></attachment>
index 7697664..573f9cc 100644 (file)
@@ -1,9 +1,5 @@
-<!DOCTYPE html>
+<!DOCTYPE html><!-- webkit-test-runner [ enableAttachmentElement=true ] -->
 <html>
-<script>
-    if (window.internals)
-        window.internals.settings.setAttachmentElementEnabled(true)
-</script>
 <body>
 <attachment title=" " type="public.jpeg"></attachment>
 <attachment title=" " type="public.plain-text"></attachment>
index 1d86a9c..979d369 100644 (file)
@@ -1,9 +1,5 @@
-<!DOCTYPE html>
+<!DOCTYPE html><!-- webkit-test-runner [ enableAttachmentElement=true ] -->
 <html>
-<script>
-    if (window.internals)
-        window.internals.settings.setAttachmentElementEnabled(true)
-</script>
 <body>
 <attachment action=" " title="title"></attachment>
 </body>
index d63dbe3..e237b61 100644 (file)
@@ -1,9 +1,5 @@
-<!DOCTYPE html>
+<!DOCTYPE html><!-- webkit-test-runner [ enableAttachmentElement=true ] -->
 <html>
-<script>
-    if (window.internals)
-        window.internals.settings.setAttachmentElementEnabled(true)
-</script>
 <body>
 <attachment action="&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; " title="title"></attachment>
 </body>
index ef05f08..6350cae 100644 (file)
@@ -2803,7 +2803,8 @@ webkit.org/b/122511 webkit.org/b/120401 fast/regions/selection/selecting-text-in
 webkit.org/b/122511 webkit.org/b/120401 fast/regions/selection/selecting-text-in-2-regions-vert-lr.html [ ImageOnlyFailure ]
 
 # PasteBoard::plainText() does not support file names.
-webkit.org/b/99070 editing/pasteboard/drag-files-to-editable-element.html [ Failure ]
+webkit.org/b/99070 editing/pasteboard/drag-files-to-editable-element-as-attachment.html [ Skip ]
+webkit.org/b/99070 editing/pasteboard/drag-files-to-editable-element-as-URLs.html [ Skip ]
 http/tests/images/hidpi-srcset-copy.html [ Skip ]
 
 # Opera-submitted tests to W3C for <track>, a lot of failures still.
index 03d8523..dce597a 100644 (file)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 24: IndexSizeError: The index is not in the allowed range.
+CONSOLE MESSAGE: line 20: IndexSizeError: The index is not in the allowed range.
 layer at (0,0) size 800x600
   RenderView at (0,0) size 800x600
 layer at (0,0) size 800x150
index 264f943..f637486 100644 (file)
@@ -1159,7 +1159,8 @@ editing/pasteboard/drop-file-svg.html [ Skip ]
 editing/pasteboard/file-drag-to-editable.html [ Skip ]
 editing/pasteboard/get-data-text-plain-drop.html [ Skip ]
 # TODO PasteBoard::plainText() does not support file names.
-editing/pasteboard/drag-files-to-editable-element.html [ Skip ]
+editing/pasteboard/drag-files-to-editable-element-as-attachment.html [ Skip ]
+editing/pasteboard/drag-files-to-editable-element-as-URLs.html [ Skip ]
 # TODO FileInputType::receiveDroppedFiles receive relative path
 webkit.org/b/90426 editing/pasteboard/file-input-files-access.html [ Failure ]
 webkit.org/b/90425 [ Release ] editing/pasteboard/dataTransfer-setData-getData.html [ Failure ]
index 85bed31..7aa5806 100644 (file)
@@ -135,7 +135,8 @@ plugins/open-and-close-window-with-plugin.html
 editing/undo/undo-iframe-location-change.html
 
 # PasteBoard::plainText() does not support file names.
-editing/pasteboard/drag-files-to-editable-element.html
+editing/pasteboard/drag-files-to-editable-element-as-attachment.html [ Skip ]
+editing/pasteboard/drag-files-to-editable-element-as-URLs.html [ Skip ]
 
 # Times out
 # https://bugs.webkit.org/show_bug.cgi?id=63806
index cc94f47..5010cca 100644 (file)
@@ -1,3 +1,42 @@
+2017-09-12  Ryosuke Niwa  <rniwa@webkit.org>
+
+        Dragging & dropping a file creates an attachment element even when it's disabled
+        https://bugs.webkit.org/show_bug.cgi?id=176769
+
+        Reviewed by Tim Horton.
+
+        The bug that dropping a file always created an attachment element even when it's disabled by settings
+        was caused by WebContentReader::readFilenames always creating an attachment element. Fixed this by
+        checking the runtime flag. The fix is tested by drag-files-to-editable-element-as-URLs.html
+
+        To fix the bug that HTMLAttachmentElement is always exposed on the global object even when it's disabled
+        by settings, replaced the setting to enable attachment element by an equivalent runtime enabled flag,
+        and hid both the interface as well as the element behind it. Fixed various bugs in our code generator
+        to make this work.
+
+        Tests: editing/pasteboard/drag-files-to-editable-element-as-URLs.html
+               editing/pasteboard/drag-files-to-editable-element-as-attachment.html
+
+        * bindings/js/WebCoreBuiltinNames.h: Added symbols used in the generated code.
+        * dom/make_event_factory.pl:
+        (defaultItemFactory): Replaced "runtimeConditonal" option by "runtimeEnabled".
+        (generateImplementation):
+        * dom/make_names.pl:
+        (defaultTagPropertyHash):
+        (printConstructorInterior): Return a HTMLUnknownElement if the element is disabled by a runtime flag.
+        (printTypeHelpers): Make is<HTMLAttachmentElement>(~) returns false when the feature is disabled by
+        checking whether the given element is an instance of HTMLUnknownElement.
+        (printWrapperFunctions): Simplified this code by matching the code for settingsConditional.
+        * editing/mac/EditorMac.mm:
+        (WebCore::Editor::WebContentReader::readFilenames): Fixed the bug that this code was always creating
+        an attachment element even when the feature is disabled.
+        * html/HTMLAttachmentElement.idl: Hide this behind a runtime flag.
+        * html/HTMLTagNames.in: 
+        * page/RuntimeEnabledFeatures.h:
+        (WebCore::RuntimeEnabledFeatures::setAttachmentElementEnabled): Added.
+        (WebCore::RuntimeEnabledFeatures::attachmentElementEnabled const): Added.
+        * page/Settings.in: Removed attachmentElementEnabled.
+
 2017-09-12  Youenn Fablet  <youenn@apple.com>
 
         Introduce a RecordData for Cache to efficiently check whether it matches a corresponding request or not
index 374ab7a..c5dea39 100644 (file)
@@ -35,6 +35,7 @@ namespace WebCore {
     macro(AnimationEffectReadOnly) \
     macro(AnimationTimeline) \
     macro(ApplePaySession) \
+    macro(AttachmentElement) \
     macro(Audio) \
     macro(Cache) \
     macro(CacheStorage) \
@@ -53,6 +54,7 @@ namespace WebCore {
     macro(Gamepad) \
     macro(GamepadButton) \
     macro(GamepadEvent) \
+    macro(HTMLAttachmentElement) \
     macro(HTMLAudioElement) \
     macro(HTMLSlotElement) \
     macro(Headers) \
index 705f2df..4f07922 100644 (file)
@@ -45,7 +45,7 @@ sub defaultItemFactory
     return (
         'interfaceName' => 0,
         'conditional' => 0,
-        'runtimeConditional' => 0
+        'runtimeEnabled' => 0
     );
 }
 
@@ -95,7 +95,7 @@ sub generateImplementation()
 
     for my $eventName (sort keys %parsedEvents) {
         my $conditional = $parsedEvents{$eventName}{"conditional"};
-        my $runtimeConditional = $parsedEvents{$eventName}{"runtimeConditional"};
+        my $runtimeEnabled = $parsedEvents{$eventName}{"runtimeEnabled"};
         my $interfaceName = $InCompiler->interfaceForItem($eventName);
 
         # FIXME: This should pay attention to $runtimeConditional so it can support RuntimeEnabledFeatures.
index 0c78718..886b03e 100755 (executable)
@@ -200,7 +200,7 @@ sub defaultTagPropertyHash
         'wrapperOnlyIfMediaIsAvailable' => 0,
         'settingsConditional' => 0,
         'conditional' => 0,
-        'runtimeConditional' => 0,
+        'runtimeEnabled' => 0,
         'customTypeHelper' => 0,
     );
 }
@@ -420,19 +420,18 @@ END
 ;
     }
 
-    my $runtimeConditional = $enabledTags{$tagName}{runtimeConditional};
-    if ($runtimeConditional) {
-        print F <<END
-    if (!RuntimeEnabledFeatures::sharedFeatures().${runtimeConditional}Enabled())
-        return 0;
-END
-;
-    }
-
+    my $runtimeCondition;
     my $settingsConditional = $enabledTags{$tagName}{settingsConditional};
+    my $runtimeEnabled = $enabledTags{$tagName}{runtimeEnabled};
     if ($settingsConditional) {
+        $runtimeCondition = "document.settings().${settingsConditional}()";
+    } elsif ($runtimeEnabled) {
+        $runtimeCondition = "RuntimeEnabledFeatures::sharedFeatures().${runtimeEnabled}Enabled()";
+    }
+
+    if ($runtimeCondition) {
         print F <<END
-    if (!document.settings().${settingsConditional}())
+    if (!$runtimeCondition)
         return $parameters{fallbackInterfaceName}::create($constructorTagName, document);
 END
 ;
@@ -669,7 +668,7 @@ public:
 private:
 END
        ;
-       if ($parameters{namespace} eq "HTML" && ($parsedTags{$name}{wrapperOnlyIfMediaIsAvailable} || $parsedTags{$name}{settingsConditional})) {
+       if ($parameters{namespace} eq "HTML" && ($parsedTags{$name}{wrapperOnlyIfMediaIsAvailable} || $parsedTags{$name}{settingsConditional} || $parsedTags{$name}{runtimeEnabled})) {
            print F <<END
     static bool checkTagName(const WebCore::HTMLElement& element) { return !element.isHTMLUnknownElement() && element.hasTagName(WebCore::$parameters{namespace}Names::${name}Tag); }
     static bool checkTagName(const WebCore::Node& node) { return is<WebCore::HTMLElement>(node) && checkTagName(downcast<WebCore::HTMLElement>(node)); }
@@ -1187,16 +1186,13 @@ static JSDOMObject* create$enabledTags{$tagName}{interfaceName}Wrapper(JSDOMGlob
 
 END
             ;
-        } elsif ($enabledTags{$tagName}{runtimeConditional}) {
-            my $runtimeConditional = $enabledTags{$tagName}{runtimeConditional};
+        } elsif ($enabledTags{$tagName}{runtimeEnabled}) {
+            my $runtimeEnabled = $enabledTags{$tagName}{runtimeEnabled};
             print F <<END
 static JSDOMObject* create${JSInterfaceName}Wrapper(JSDOMGlobalObject* globalObject, Ref<$parameters{namespace}Element>&& element)
 {
-    if (!RuntimeEnabledFeatures::sharedFeatures().${runtimeConditional}Enabled()) {
-        ASSERT(element->is$parameters{fallbackInterfaceName}());
+    if (element->is$parameters{fallbackInterfaceName}())
         return createWrapper<$parameters{fallbackJSInterfaceName}>(globalObject, WTFMove(element));
-    }
-
     return createWrapper<${JSInterfaceName}>(globalObject, WTFMove(element));
 }
 END
index 4a26300..e99fb8a 100644 (file)
@@ -59,6 +59,7 @@
 #import "RenderBlock.h"
 #import "RenderImage.h"
 #import "RuntimeApplicationChecks.h"
+#import "RuntimeEnabledFeatures.h"
 #import "Settings.h"
 #import "StyleProperties.h"
 #import "Text.h"
@@ -378,14 +379,16 @@ bool Editor::WebContentReader::readFilenames(const Vector<String>& paths)
 
     for (auto& text : paths) {
 #if ENABLE(ATTACHMENT_ELEMENT)
-        auto attachment = HTMLAttachmentElement::create(attachmentTag, document);
-        attachment->setFile(File::create([[NSURL fileURLWithPath:text] path]).ptr());
-        fragment->appendChild(attachment);
-#else
+        if (RuntimeEnabledFeatures::sharedFeatures().attachmentElementEnabled()) {
+            auto attachment = HTMLAttachmentElement::create(attachmentTag, document);
+            attachment->setFile(File::create([[NSURL fileURLWithPath:text] path]).ptr());
+            fragment->appendChild(attachment);
+            continue;
+        }
+#endif
         auto paragraph = createDefaultParagraphElement(document);
         paragraph->appendChild(document.createTextNode(frame.editor().client()->userVisibleString([NSURL fileURLWithPath:text])));
         fragment->appendChild(paragraph);
-#endif
     }
 
     return true;
index d69a157..4178b4b 100644 (file)
@@ -24,7 +24,8 @@
  */
 
 [
-    Conditional=ATTACHMENT_ELEMENT
+    Conditional=ATTACHMENT_ELEMENT,
+    EnabledAtRuntime=AttachmentElement,
 ] interface HTMLAttachmentElement : HTMLElement {
     attribute File? file;
 };
index d56685f..5c7c8d7 100644 (file)
@@ -12,7 +12,7 @@ applet
 area
 article interfaceName=HTMLElement
 aside interfaceName=HTMLElement
-attachment conditional=ATTACHMENT_ELEMENT, settingsConditional=attachmentElementEnabled
+attachment conditional=ATTACHMENT_ELEMENT, runtimeEnabled=attachmentElement
 audio wrapperOnlyIfMediaIsAvailable, conditional=VIDEO, constructorNeedsCreatedByParser, customTypeHelper
 b interfaceName=HTMLElement
 base
index e17e574..5fa4d29 100644 (file)
@@ -79,6 +79,11 @@ public:
     void setDataTransferItemsEnabled(bool areEnabled) { m_areDataTransferItemsEnabled = areEnabled; }
     bool dataTransferItemsEnabled() const { return m_areDataTransferItemsEnabled; }
 
+#if ENABLE(ATTACHMENT_ELEMENT)
+    void setAttachmentElementEnabled(bool areEnabled) { m_isAttachmentElementEnabled = areEnabled; }
+    bool attachmentElementEnabled() const { return m_isAttachmentElementEnabled; }
+#endif
+
     void setModernMediaControlsEnabled(bool areEnabled) { m_areModernMediaControlsEnabled = areEnabled; }
     bool modernMediaControlsEnabled() const { return m_areModernMediaControlsEnabled; }
 
@@ -238,6 +243,10 @@ private:
     bool m_areDataTransferItemsEnabled { false };
     bool m_inputEventsEnabled { true };
 
+#if ENABLE(ATTACHMENT_ELEMENT)
+    bool m_isAttachmentElementEnabled { false };
+#endif
+
 #if ENABLE(INDEXED_DATABASE_IN_WORKERS)
     bool m_isIndexedDBWorkersEnabled { true };
 #endif
index a8cfa9f..efe88ed 100644 (file)
@@ -242,8 +242,6 @@ serviceControlsEnabled initial=false, conditional=SERVICE_CONTROLS
 
 appleMailPaginationQuirkEnabled initial=false
 
-attachmentElementEnabled initial=true, conditional=ATTACHMENT_ELEMENT
-
 deferredCSSParserEnabled initial=false
 
 repaintOutsideLayoutEnabled initial=false
index 7793f14..2030d5b 100644 (file)
@@ -1,3 +1,17 @@
+2017-09-12  Ryosuke Niwa  <rniwa@webkit.org>
+
+        Dragging & dropping a file creates an attachment element even when it's disabled
+        https://bugs.webkit.org/show_bug.cgi?id=176769
+
+        Reviewed by Tim Horton.
+
+        * UIProcess/API/C/WKPreferences.cpp:
+        (WKPreferencesSetAttachmentElementEnabled):
+        (WKPreferencesGetAttachmentElementEnabled):
+        * UIProcess/API/C/WKPreferencesRefPrivate.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::updatePreferences):
+
 2017-09-12  Youenn Fablet  <youenn@apple.com>
 
         Introduce a RecordData for Cache to efficiently check whether it matches a corresponding request or not
index 8aba41e..22d13e8 100644 (file)
@@ -910,6 +910,16 @@ bool WKPreferencesGetMockScrollbarsEnabled(WKPreferencesRef preferencesRef)
     return toImpl(preferencesRef)->mockScrollbarsEnabled();
 }
 
+void WKPreferencesSetAttachmentElementEnabled(WKPreferencesRef preferencesRef, bool flag)
+{
+    toImpl(preferencesRef)->setAttachmentElementEnabled(flag);
+}
+
+bool WKPreferencesGetAttachmentElementEnabled(WKPreferencesRef preferencesRef)
+{
+    return toImpl(preferencesRef)->attachmentElementEnabled();
+}
+
 void WKPreferencesSetWebAudioEnabled(WKPreferencesRef preferencesRef, bool enabled)
 {
     toImpl(preferencesRef)->setWebAudioEnabled(enabled);
index 13f0fa4..4746ad3 100644 (file)
@@ -457,6 +457,10 @@ WK_EXPORT bool WKPreferencesGetSelectionPaintingWithoutSelectionGapsEnabled(WKPr
 WK_EXPORT void WKPreferencesSetAllowsPictureInPictureMediaPlayback(WKPreferencesRef, bool flag);
 WK_EXPORT bool WKPreferencesGetAllowsPictureInPictureMediaPlayback(WKPreferencesRef);
 
+// Defaults to false.
+WK_EXPORT void WKPreferencesSetAttachmentElementEnabled(WKPreferencesRef preferencesRef, bool flag);
+WK_EXPORT bool WKPreferencesGetAttachmentElementEnabled(WKPreferencesRef preferencesRef);
+
 // Defaults to false
 WK_EXPORT void WKPreferencesSetIntersectionObserverEnabled(WKPreferencesRef, bool flag);
 WK_EXPORT bool WKPreferencesGetIntersectionObserverEnabled(WKPreferencesRef);
index f196fa9..3fc3425 100644 (file)
@@ -3132,9 +3132,6 @@ void WebPage::updatePreferences(const WebPreferencesStore& store)
     settings.setInlineMediaPlaybackRequiresPlaysInlineAttribute(store.getBoolValueForKey(WebPreferencesKey::inlineMediaPlaybackRequiresPlaysInlineAttributeKey()));
     settings.setInvisibleAutoplayNotPermitted(store.getBoolValueForKey(WebPreferencesKey::invisibleAutoplayNotPermittedKey()));
     settings.setMediaDataLoadsAutomatically(store.getBoolValueForKey(WebPreferencesKey::mediaDataLoadsAutomaticallyKey()));
-#if ENABLE(ATTACHMENT_ELEMENT)
-    settings.setAttachmentElementEnabled(store.getBoolValueForKey(WebPreferencesKey::attachmentElementEnabledKey()));
-#endif
     settings.setAllowsPictureInPictureMediaPlayback(store.getBoolValueForKey(WebPreferencesKey::allowsPictureInPictureMediaPlaybackKey()));
     settings.setMediaControlsScaleWithPageZoom(store.getBoolValueForKey(WebPreferencesKey::mediaControlsScaleWithPageZoomKey()));
     settings.setMockScrollbarsEnabled(store.getBoolValueForKey(WebPreferencesKey::mockScrollbarsEnabledKey()));
@@ -3330,6 +3327,10 @@ void WebPage::updatePreferences(const WebPreferencesStore& store)
 
     RuntimeEnabledFeatures::sharedFeatures().setDataTransferItemsEnabled(store.getBoolValueForKey(WebPreferencesKey::dataTransferItemsEnabledKey()));
 
+#if ENABLE(ATTACHMENT_ELEMENT)
+    RuntimeEnabledFeatures::sharedFeatures().setAttachmentElementEnabled(store.getBoolValueForKey(WebPreferencesKey::attachmentElementEnabledKey()));
+#endif
+
 #if ENABLE(WEBGL2)
     RuntimeEnabledFeatures::sharedFeatures().setWebGL2Enabled(store.getBoolValueForKey(WebPreferencesKey::webGL2EnabledKey()));
 #endif
index dcab446..e806632 100644 (file)
@@ -1,3 +1,13 @@
+2017-09-12  Ryosuke Niwa  <rniwa@webkit.org>
+
+        Dragging & dropping a file creates an attachment element even when it's disabled
+        https://bugs.webkit.org/show_bug.cgi?id=176769
+
+        Reviewed by Tim Horton.
+
+        * WebView/WebView.mm:
+        (-[WebView _preferencesChanged:]):
+
 2017-09-11  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         [iOS DnD] Support DataTransfer.setDragImage when starting a drag on iOS
index fb760a2..8c82ee7 100644 (file)
@@ -2995,6 +2995,10 @@ static bool needsSelfRetainWhileLoadingQuirk()
     RuntimeEnabledFeatures::sharedFeatures().setCustomElementsEnabled([preferences customElementsEnabled]);
     RuntimeEnabledFeatures::sharedFeatures().setDataTransferItemsEnabled([preferences dataTransferItemsEnabled]);
 
+#if ENABLE(ATTACHMENT_ELEMENT)
+    RuntimeEnabledFeatures::sharedFeatures().setAttachmentElementEnabled([preferences attachmentElementEnabled]);
+#endif
+
     RuntimeEnabledFeatures::sharedFeatures().setInteractiveFormValidationEnabled([self interactiveFormValidationEnabled]);
     RuntimeEnabledFeatures::sharedFeatures().setModernMediaControlsEnabled([preferences modernMediaControlsEnabled]);
 
@@ -3069,10 +3073,6 @@ static bool needsSelfRetainWhileLoadingQuirk()
 
     settings.setMediaDataLoadsAutomatically([preferences mediaDataLoadsAutomatically]);
 
-#if ENABLE(ATTACHMENT_ELEMENT)
-    settings.setAttachmentElementEnabled([preferences attachmentElementEnabled]);
-#endif
-
     settings.setAllowContentSecurityPolicySourceStarToMatchAnyProtocol(shouldAllowContentSecurityPolicySourceStarToMatchAnyProtocol());
 
     settings.setShouldConvertInvalidURLsToBlank(shouldConvertInvalidURLsToBlank());
index 589e9ca..283a1d6 100644 (file)
@@ -1,3 +1,27 @@
+2017-09-12  Ryosuke Niwa  <rniwa@webkit.org>
+
+        Dragging & dropping a file creates an attachment element even when it's disabled
+        https://bugs.webkit.org/show_bug.cgi?id=176769
+
+        Reviewed by Tim Horton.
+
+        Added a webkit-test-runner flag to enable attachment element via runtime flag since this feature is now hidden
+        behind a runtime-enabled flag which needs to be set at the time of global object initialization.
+
+        * DumpRenderTree/TestOptions.h:
+        (TestOptions): Added.
+        * DumpRenderTree/TestOptions.mm:
+        (TestOptions::TestOptions):
+        * DumpRenderTree/mac/DumpRenderTree.mm:
+        (setWebPreferencesForTestOptions):
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::resetPreferencesToConsistentValues):
+        (WTR::updateTestOptionsFromTestHeader):
+        * WebKitTestRunner/TestOptions.h:
+        (WTR::TestOptions::hasSameInitializationOptions const):
+        * WebKitTestRunner/cocoa/TestControllerCocoa.mm:
+        (WTR::TestController::platformCreateWebView):
+
 2017-09-11  Filip Pizlo  <fpizlo@apple.com>
 
         WSL should allow you to say "protocol Foo : Bar { ... }"
index 4646eeb..0f67d19 100644 (file)
@@ -29,6 +29,7 @@
 @class NSURL;
 
 struct TestOptions {
+    bool enableAttachmentElement { false };
     bool enableIntersectionObserver { false };
     bool enableModernMediaControls { true };
     bool enablePointerLock { false };
index 0c7a7c7..3c4f26f 100644 (file)
@@ -78,7 +78,9 @@ TestOptions::TestOptions(NSURL *testURL, const TestCommand& command)
         }
         auto key = pairString.substr(pairStart, equalsLocation - pairStart);
         auto value = pairString.substr(equalsLocation + 1, pairEnd - (equalsLocation + 1));
-        if (key == "enableIntersectionObserver")
+        if (key == "enableAttachmentElement")
+            this->enableAttachmentElement = parseBooleanTestHeaderValue(value);
+        else if (key == "enableIntersectionObserver")
             this->enableIntersectionObserver = parseBooleanTestHeaderValue(value);
         else if (key == "enableModernMediaControls")
             this->enableModernMediaControls = parseBooleanTestHeaderValue(value);
index db4c929..989aa46 100644 (file)
@@ -980,6 +980,7 @@ static void setWebPreferencesForTestOptions(const TestOptions& options)
 {
     WebPreferences *preferences = [WebPreferences standardPreferences];
 
+    preferences.attachmentElementEnabled = options.enableAttachmentElement;
     preferences.intersectionObserverEnabled = options.enableIntersectionObserver;
     preferences.modernMediaControlsEnabled = options.enableModernMediaControls;
     preferences.credentialManagementEnabled = options.enableCredentialManagement;
index c7464e7..8739939 100644 (file)
@@ -684,6 +684,7 @@ void TestController::resetPreferencesToConsistentValues(const TestOptions& optio
 
     WKPreferencesSetMockScrollbarsEnabled(preferences, options.useMockScrollbars);
     WKPreferencesSetNeedsSiteSpecificQuirks(preferences, options.needsSiteSpecificQuirks);
+    WKPreferencesSetAttachmentElementEnabled(preferences, options.enableAttachmentElement);
     WKPreferencesSetIntersectionObserverEnabled(preferences, options.enableIntersectionObserver);
     WKPreferencesSetModernMediaControlsEnabled(preferences, options.enableModernMediaControls);
     WKPreferencesSetCredentialManagementEnabled(preferences, options.enableCredentialManagement);
@@ -1024,6 +1025,8 @@ static void updateTestOptionsFromTestHeader(TestOptions& testOptions, const std:
             testOptions.ignoresViewportScaleLimits = parseBooleanTestHeaderValue(value);
         if (key == "useCharacterSelectionGranularity")
             testOptions.useCharacterSelectionGranularity = parseBooleanTestHeaderValue(value);
+        if (key == "enableAttachmentElement")
+            testOptions.enableAttachmentElement = parseBooleanTestHeaderValue(value);
         if (key == "enableIntersectionObserver")
             testOptions.enableIntersectionObserver = parseBooleanTestHeaderValue(value);
         if (key == "enableModernMediaControls")
index 99ea15e..d491af4 100644 (file)
@@ -43,6 +43,7 @@ struct TestOptions {
     bool needsSiteSpecificQuirks { false };
     bool ignoresViewportScaleLimits { false };
     bool useCharacterSelectionGranularity { false };
+    bool enableAttachmentElement { false };
     bool enableIntersectionObserver { false };
     bool enableModernMediaControls { true };
     bool enablePointerLock { false };
@@ -66,6 +67,7 @@ struct TestOptions {
             || useMockScrollbars != options.useMockScrollbars
             || needsSiteSpecificQuirks != options.needsSiteSpecificQuirks
             || useCharacterSelectionGranularity != options.useCharacterSelectionGranularity
+            || enableAttachmentElement != options.enableAttachmentElement
             || enableIntersectionObserver != options.enableIntersectionObserver
             || enableModernMediaControls != options.enableModernMediaControls
             || enablePointerLock != options.enablePointerLock
index ebc336d..d68df32 100644 (file)
@@ -138,8 +138,13 @@ void TestController::platformCreateWebView(WKPageConfigurationRef, const TestOpt
         [copiedConfiguration setIgnoresViewportScaleLimits:YES];
     if (options.useCharacterSelectionGranularity)
         [copiedConfiguration setSelectionGranularity:WKSelectionGranularityCharacter];
+    if (options.useCharacterSelectionGranularity)
+        [copiedConfiguration setSelectionGranularity:WKSelectionGranularityCharacter];
 #endif
 
+    if (options.enableAttachmentElement)
+        [copiedConfiguration _setAttachmentElementEnabled: YES];
+
     m_mainWebView = std::make_unique<PlatformWebView>(copiedConfiguration.get(), options);
 #else
     m_mainWebView = std::make_unique<PlatformWebView>(globalWebViewConfiguration, options);