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
+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
-<!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>
<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.");
-<!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">
<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");
-<!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
<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.");
TEST COMPLETE
This is a paragraph with an attachment  and some other text.
+
+<!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");
-<!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 {
--- /dev/null
+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
+
--- /dev/null
+<!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>
+<!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.');
-<!DOCTYPE html>
+<!DOCTYPE html><!-- webkit-test-runner [ enableAttachmentElement=true ] -->
<html>
-<script>
-if (window.internals)
- window.internals.settings.setAttachmentElementEnabled(true);
-</script>
<style>
div {
width: 300px;
-<!DOCTYPE html>
+<!DOCTYPE html><!-- webkit-test-runner [ enableAttachmentElement=true ] -->
<html>
-<script>
-if (window.internals)
- window.internals.settings.setAttachmentElementEnabled(true);
-</script>
<style>
div {
width: 300px;
-<!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>
-<!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>
-<!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;
-<!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>
-<!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>
-<!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>
-<!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>
-<!DOCTYPE html>
+<!DOCTYPE html><!-- webkit-test-runner [ enableAttachmentElement=true ] -->
<html>
-<script>
- if (window.internals)
- window.internals.settings.setAttachmentElementEnabled(true)
-</script>
<body>
<attachment></attachment>
<script>
-<!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>
-<!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");
-<!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>
-<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>
-<!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>
-<!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>
-<!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>
-<!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>
-<!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>
-<!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>
-<!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>
-<!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>
-<!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>
-<!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>
-<!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>
-<!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>
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.
-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
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 ]
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
+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
macro(AnimationEffectReadOnly) \
macro(AnimationTimeline) \
macro(ApplePaySession) \
+ macro(AttachmentElement) \
macro(Audio) \
macro(Cache) \
macro(CacheStorage) \
macro(Gamepad) \
macro(GamepadButton) \
macro(GamepadEvent) \
+ macro(HTMLAttachmentElement) \
macro(HTMLAudioElement) \
macro(HTMLSlotElement) \
macro(Headers) \
return (
'interfaceName' => 0,
'conditional' => 0,
- 'runtimeConditional' => 0
+ 'runtimeEnabled' => 0
);
}
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.
'wrapperOnlyIfMediaIsAvailable' => 0,
'settingsConditional' => 0,
'conditional' => 0,
- 'runtimeConditional' => 0,
+ 'runtimeEnabled' => 0,
'customTypeHelper' => 0,
);
}
;
}
- 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
;
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)); }
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
#import "RenderBlock.h"
#import "RenderImage.h"
#import "RuntimeApplicationChecks.h"
+#import "RuntimeEnabledFeatures.h"
#import "Settings.h"
#import "StyleProperties.h"
#import "Text.h"
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;
*/
[
- Conditional=ATTACHMENT_ELEMENT
+ Conditional=ATTACHMENT_ELEMENT,
+ EnabledAtRuntime=AttachmentElement,
] interface HTMLAttachmentElement : HTMLElement {
attribute File? file;
};
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
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; }
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
appleMailPaginationQuirkEnabled initial=false
-attachmentElementEnabled initial=true, conditional=ATTACHMENT_ELEMENT
-
deferredCSSParserEnabled initial=false
repaintOutsideLayoutEnabled initial=false
+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
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);
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);
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()));
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
+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
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]);
settings.setMediaDataLoadsAutomatically([preferences mediaDataLoadsAutomatically]);
-#if ENABLE(ATTACHMENT_ELEMENT)
- settings.setAttachmentElementEnabled([preferences attachmentElementEnabled]);
-#endif
-
settings.setAllowContentSecurityPolicySourceStarToMatchAnyProtocol(shouldAllowContentSecurityPolicySourceStarToMatchAnyProtocol());
settings.setShouldConvertInvalidURLsToBlank(shouldConvertInvalidURLsToBlank());
+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 { ... }"
@class NSURL;
struct TestOptions {
+ bool enableAttachmentElement { false };
bool enableIntersectionObserver { false };
bool enableModernMediaControls { true };
bool enablePointerLock { false };
}
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);
{
WebPreferences *preferences = [WebPreferences standardPreferences];
+ preferences.attachmentElementEnabled = options.enableAttachmentElement;
preferences.intersectionObserverEnabled = options.enableIntersectionObserver;
preferences.modernMediaControlsEnabled = options.enableModernMediaControls;
preferences.credentialManagementEnabled = options.enableCredentialManagement;
WKPreferencesSetMockScrollbarsEnabled(preferences, options.useMockScrollbars);
WKPreferencesSetNeedsSiteSpecificQuirks(preferences, options.needsSiteSpecificQuirks);
+ WKPreferencesSetAttachmentElementEnabled(preferences, options.enableAttachmentElement);
WKPreferencesSetIntersectionObserverEnabled(preferences, options.enableIntersectionObserver);
WKPreferencesSetModernMediaControlsEnabled(preferences, options.enableModernMediaControls);
WKPreferencesSetCredentialManagementEnabled(preferences, options.enableCredentialManagement);
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")
bool needsSiteSpecificQuirks { false };
bool ignoresViewportScaleLimits { false };
bool useCharacterSelectionGranularity { false };
+ bool enableAttachmentElement { false };
bool enableIntersectionObserver { false };
bool enableModernMediaControls { true };
bool enablePointerLock { false };
|| useMockScrollbars != options.useMockScrollbars
|| needsSiteSpecificQuirks != options.needsSiteSpecificQuirks
|| useCharacterSelectionGranularity != options.useCharacterSelectionGranularity
+ || enableAttachmentElement != options.enableAttachmentElement
|| enableIntersectionObserver != options.enableIntersectionObserver
|| enableModernMediaControls != options.enableModernMediaControls
|| enablePointerLock != options.enablePointerLock
[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);