Diff
Modified: trunk/LayoutTests/ChangeLog (268275 => 268276)
--- trunk/LayoutTests/ChangeLog 2020-10-09 19:19:52 UTC (rev 268275)
+++ trunk/LayoutTests/ChangeLog 2020-10-09 19:33:25 UTC (rev 268276)
@@ -1,3 +1,20 @@
+2020-10-09 Aditya Keerthi <[email protected]>
+
+ [macOS] Add editability to input type=month
+ https://bugs.webkit.org/show_bug.cgi?id=217481
+ <rdar://problem/70097164>
+
+ Reviewed by Sam Weinig.
+
+ * TestExpectations:
+ * fast/forms/month/month-editable-components/month-editable-components-focus-and-blur-events-expected.txt: Added.
+ * fast/forms/month/month-editable-components/month-editable-components-focus-and-blur-events.html: Added.
+ * fast/forms/month/month-editable-components/month-editable-components-keyboard-events-expected.txt: Added.
+ * fast/forms/month/month-editable-components/month-editable-components-keyboard-events.html: Added.
+ * fast/forms/month/month-editable-components/month-editable-components-mouse-events-expected.txt: Added.
+ * fast/forms/month/month-editable-components/month-editable-components-mouse-events.html: Added.
+ * platform/mac-wk2/TestExpectations:
+
2020-10-09 Hector Lopez <[email protected]>
ASSERTION FAILED: REGRESSION(r268052?): WTF::CompletionHandler<void ()>::~CompletionHandler(): Completion handler should always be called !m_function
Modified: trunk/LayoutTests/TestExpectations (268275 => 268276)
--- trunk/LayoutTests/TestExpectations 2020-10-09 19:19:52 UTC (rev 268275)
+++ trunk/LayoutTests/TestExpectations 2020-10-09 19:33:25 UTC (rev 268276)
@@ -32,6 +32,7 @@
fast/css/watchos [ Skip ]
fast/forms/date/date-editable-components [ Skip ]
fast/forms/datetimelocal/datetimelocal-editable-components [ Skip ]
+fast/forms/month/month-editable-components [ Skip ]
fast/forms/time/time-editable-components [ Skip ]
fast/dom/Window/watchos [ Skip ]
fast/forms/select/mac-wk2 [ Skip ]
Added: trunk/LayoutTests/fast/forms/month/month-editable-components/month-editable-components-focus-and-blur-events-expected.txt (0 => 268276)
--- trunk/LayoutTests/fast/forms/month/month-editable-components/month-editable-components-focus-and-blur-events-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/forms/month/month-editable-components/month-editable-components-focus-and-blur-events-expected.txt 2020-10-09 19:33:25 UTC (rev 268276)
@@ -0,0 +1,55 @@
+Test for focus and blur events for <input type=month>
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Focus/blur using mouse
+
+PASS focusEventsFired is 1
+PASS blurEventsFired is 0
+PASS focusEventsFired is 1
+PASS blurEventsFired is 0
+PASS focusEventsFired is 1
+PASS blurEventsFired is 0
+PASS focusEventsFired is 1
+PASS blurEventsFired is 1
+
+Focus/blur using keyboard
+
+PASS focusEventsFired is 1
+PASS blurEventsFired is 0
+PASS focusEventsFired is 1
+PASS blurEventsFired is 0
+PASS focusEventsFired is 1
+PASS blurEventsFired is 1
+PASS focusEventsFired is 2
+PASS blurEventsFired is 1
+PASS focusEventsFired is 2
+PASS blurEventsFired is 1
+PASS focusEventsFired is 2
+PASS blurEventsFired is 2
+
+Focus/blur on disabled input
+
+PASS focusEventsFired is 0
+PASS blurEventsFired is 0
+PASS document.activeElement.id is "after"
+PASS focusEventsFired is 0
+PASS blurEventsFired is 0
+PASS document.activeElement.id is "before"
+PASS focusEventsFired is 0
+PASS blurEventsFired is 0
+
+Focus/blur on readonly input
+
+PASS focusEventsFired is 1
+PASS blurEventsFired is 0
+PASS document.activeElement.id is "after"
+PASS focusEventsFired is 1
+PASS blurEventsFired is 1
+PASS focusEventsFired is 1
+PASS blurEventsFired is 1
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/forms/month/month-editable-components/month-editable-components-focus-and-blur-events.html (0 => 268276)
--- trunk/LayoutTests/fast/forms/month/month-editable-components/month-editable-components-focus-and-blur-events.html (rev 0)
+++ trunk/LayoutTests/fast/forms/month/month-editable-components/month-editable-components-focus-and-blur-events.html 2020-10-09 19:33:25 UTC (rev 268276)
@@ -0,0 +1,141 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+<style>
+input {
+ width: 300px;
+ font-size: 30px;
+}
+</style>
+</head>
+<body>
+
+<input id="before" type="text">
+<input id="input" type="month" value="2020-08">
+<input id="after" type="text">
+
+<script>
+
+description("Test for focus and blur events for <input type=month>");
+
+blurEventsFired = 0;
+function onBlurEvent() {
+ blurEventsFired++;
+}
+
+focusEventsFired = 0;
+function onFocusEvent() {
+ focusEventsFired++;
+}
+
+function assertFocusAndBlurCount(numFocusEvents, numBlurEvents) {
+ shouldBe("focusEventsFired", numFocusEvents.toString());
+ shouldBe("blurEventsFired", numBlurEvents.toString());
+}
+
+function resetFocusAndBlurCount() {
+ blurEventsFired = 0;
+ focusEventsFired = 0;
+}
+
+function mouseClickOn(x, y) {
+ if (!window.eventSender)
+ return;
+ eventSender.mouseMoveTo(x + input.offsetLeft, y + input.offsetTop);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+}
+
+input.addEventListener("blur", onBlurEvent);
+input.addEventListener("focus", onFocusEvent);
+
+const center = input.offsetHeight / 2;
+
+debug("Focus/blur using mouse\n");
+
+// Click on month field.
+mouseClickOn(20, center);
+assertFocusAndBlurCount(1, 0);
+// Click on year field.
+mouseClickOn(60, center);
+assertFocusAndBlurCount(1, 0);
+// Click on control, but not a specific field.
+mouseClickOn(250, center);
+assertFocusAndBlurCount(1, 0);
+// Click outside control.
+mouseClickOn(input.offsetWidth + 5, input.offsetHeight + 5);
+assertFocusAndBlurCount(1, 1);
+resetFocusAndBlurCount();
+
+debug("\nFocus/blur using keyboard\n");
+
+UIHelper.activateElement(before);
+// Focus on month field.
+UIHelper.keyDown("\t");
+assertFocusAndBlurCount(1, 0);
+// Focus on year field.
+UIHelper.keyDown("\t");
+assertFocusAndBlurCount(1, 0);
+// Focus out.
+UIHelper.keyDown("\t");
+assertFocusAndBlurCount(1, 1);
+// Focus on year field.
+UIHelper.keyDown("\t", ["shiftKey"]);
+assertFocusAndBlurCount(2, 1);
+// Focus on month field.
+UIHelper.keyDown("\t", ["shiftKey"]);
+assertFocusAndBlurCount(2, 1);
+// Focus out.
+UIHelper.keyDown("\t", ["shiftKey"]);
+assertFocusAndBlurCount(2, 2);
+resetFocusAndBlurCount();
+
+debug("\nFocus/blur on disabled input\n")
+
+input.disabled = true;
+
+UIHelper.activateElement(before);
+// Tab to focus should skip disabled input.
+UIHelper.keyDown("\t");
+assertFocusAndBlurCount(0, 0);
+shouldBeEqualToString("document.activeElement.id", "after");
+// Shift+Tab should skip disabled input.
+UIHelper.keyDown("\t", ["shiftKey"]);
+assertFocusAndBlurCount(0, 0);
+shouldBeEqualToString("document.activeElement.id", "before");
+// Clicking on any part of the control should not focus/blur events.
+mouseClickOn(20, center);
+mouseClickOn(60, center);
+mouseClickOn(250, center);
+mouseClickOn(input.offsetWidth + 5, input.offsetHeight + 5);
+assertFocusAndBlurCount(0, 0);
+resetFocusAndBlurCount();
+
+debug("\nFocus/blur on readonly input\n")
+
+input.disabled = false;
+input.readOnly = true;
+
+UIHelper.activateElement(before);
+// Tab to focus should not skip readonly input.
+UIHelper.keyDown("\t");
+assertFocusAndBlurCount(1, 0);
+UIHelper.keyDown("\t");
+UIHelper.keyDown("\t");
+shouldBeEqualToString("document.activeElement.id", "after");
+assertFocusAndBlurCount(1, 1);
+// Clicking on any part of the control should fire the appropriate events.
+mouseClickOn(20, center);
+mouseClickOn(60, center);
+mouseClickOn(250, center);
+mouseClickOn(input.offsetWidth + 5, input.offsetHeight + 5);
+assertFocusAndBlurCount(1, 1);
+resetFocusAndBlurCount();
+
+</script>
+
+<script src=""
+</body>
+</html>
Added: trunk/LayoutTests/fast/forms/month/month-editable-components/month-editable-components-keyboard-events-expected.txt (0 => 268276)
--- trunk/LayoutTests/fast/forms/month/month-editable-components/month-editable-components-keyboard-events-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/forms/month/month-editable-components/month-editable-components-keyboard-events-expected.txt 2020-10-09 19:33:25 UTC (rev 268276)
@@ -0,0 +1,86 @@
+Test for keyboard operations for <input type=month>
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+
+Digit keys
+PASS input.value is "2012-09"
+PASS changeEventsFired is 4
+PASS inputEventsFired is 4
+
+Digit keys with leading zero
+PASS input.value is "0034-05"
+PASS changeEventsFired is 3
+PASS inputEventsFired is 3
+
+Digit keys and backspace key
+PASS input.value is "2020-02"
+PASS changeEventsFired is 6
+PASS inputEventsFired is 6
+
+Digit keys with timeout
+PASS input.value is "0001-02"
+PASS changeEventsFired is 2
+PASS inputEventsFired is 2
+
+Digit keys clamp value
+PASS input.value is "9999-12"
+PASS changeEventsFired is 4
+PASS inputEventsFired is 4
+
+Left/Right arrow keys
+PASS input.value is "0002-02"
+PASS input.value is "0002-03"
+PASS changeEventsFired is 2
+PASS inputEventsFired is 2
+
+Advance field keys
+PASS input.value is "0002-06"
+PASS input.value is "0003-06"
+PASS input.value is "0004-06"
+PASS input.value is "0005-06"
+PASS input.value is "0006-06"
+PASS input.value is "0007-06"
+PASS input.value is "0008-06"
+PASS changeEventsFired is 7
+PASS inputEventsFired is 7
+
+Up/Down arrow keys
+PASS input.value is "2020-01"
+PASS input.value is "2020-02"
+PASS input.value is "2020-01"
+PASS input.value is "2020-12"
+PASS changeEventsFired is 4
+PASS inputEventsFired is 4
+
+Tab key
+PASS input.value is "0002-02"
+PASS document.activeElement.id is "after"
+PASS input.value is "0002-03"
+PASS document.activeElement.id is "before"
+PASS changeEventsFired is 2
+PASS inputEventsFired is 2
+
+Backspace key
+PASS input.value is ""
+PASS input.value is "2020-07"
+PASS changeEventsFired is 2
+PASS inputEventsFired is 2
+
+Delete key
+PASS input.value is ""
+PASS changeEventsFired is 1
+PASS inputEventsFired is 1
+
+Disabled/readonly
+PASS input.value is "2020-09"
+PASS input.value is "2020-01"
+PASS input.value is "2020-01"
+PASS input.value is "0002-01"
+PASS changeEventsFired is 2
+PASS inputEventsFired is 2
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/forms/month/month-editable-components/month-editable-components-keyboard-events.html (0 => 268276)
--- trunk/LayoutTests/fast/forms/month/month-editable-components/month-editable-components-keyboard-events.html (rev 0)
+++ trunk/LayoutTests/fast/forms/month/month-editable-components/month-editable-components-keyboard-events.html 2020-10-09 19:33:25 UTC (rev 268276)
@@ -0,0 +1,213 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+
+<input id="before" type="text">
+<input id="input" type="month">
+<input id="after" type="text">
+
+<script>
+
+jsTestIsAsync = true;
+
+changeEventsFired = 0;
+function onChangeEvent() {
+ changeEventsFired++;
+}
+
+inputEventsFired = 0;
+function onInputEvent() {
+ inputEventsFired++;
+}
+
+function beginTest(title, value) {
+ debug("\n" + title);
+ input.value = value || "";
+ input.blur();
+ input.focus();
+
+ changeEventsFired = 0;
+ inputEventsFired = 0;
+}
+
+input.addEventListener("change", onChangeEvent);
+input.addEventListener("input", onInputEvent);
+
+addEventListener("load", async () => {
+ description("Test for keyboard operations for <input type=month>");
+
+ beginTest("Digit keys"); // [mm]/yyyy
+ UIHelper.keyDown("9"); // -> [09]/yyyy
+ UIHelper.keyDown("rightArrow"); // -> 09/[yyyy]
+ UIHelper.keyDown("2"); // -> 09/[0002]
+ UIHelper.keyDown("0"); // -> 09/[0020]
+ UIHelper.keyDown("1"); // -> 09/[0201]
+ UIHelper.keyDown("2"); // -> 09/[2012]
+ UIHelper.keyDown("A"); // Ignored.
+ shouldBeEqualToString("input.value", "2012-09");
+ shouldBe("changeEventsFired", "4");
+ shouldBe("inputEventsFired", "4");
+
+ beginTest("Digit keys with leading zero"); // [mm]/yyyy
+ UIHelper.keyDown("0"); // -> [00]/yyyy
+ UIHelper.keyDown("5"); // -> [05]/yyyy
+ UIHelper.keyDown("rightArrow"); // -> 05/[yyyy]
+ UIHelper.keyDown("0"); // -> 05/[0001]
+ UIHelper.keyDown("0"); // -> 05/[0001]
+ UIHelper.keyDown("3"); // -> 05/[0003]
+ UIHelper.keyDown("4"); // -> 05/[0034]
+ shouldBeEqualToString("input.value", "0034-05");
+ shouldBe("changeEventsFired", "3");
+ shouldBe("inputEventsFired", "3");
+
+ beginTest("Digit keys and backspace key"); // [mm]/yyyy
+ UIHelper.keyDown("1"); // -> [01]/yyyy
+ UIHelper.keyDown("\b"); // -> [mm]/yyyy
+ UIHelper.keyDown("2"); // -> [02]/yyyy
+ UIHelper.keyDown("rightArrow"); // -> 02/[yyyy]
+ UIHelper.keyDown("4"); // -> 02/[0004]
+ UIHelper.keyDown("\b"); // -> 02/[yyyy]
+ UIHelper.keyDown("2"); // -> 02/[0002]
+ UIHelper.keyDown("0"); // -> 02/[0020]
+ UIHelper.keyDown("2"); // -> 02/[0202]
+ UIHelper.keyDown("0"); // -> 02/[2020]
+ shouldBeEqualToString("input.value", "2020-02");
+ shouldBe("changeEventsFired", "6");
+ shouldBe("inputEventsFired", "6");
+
+ beginTest("Digit keys with timeout"); // [mm]/yyyy
+ UIHelper.keyDown("2"); // -> [02]/yyyy
+ UIHelper.keyDown("rightArrow"); // -> 02/[yyyy]
+ UIHelper.keyDown("4"); // -> 02[0004]
+ await UIHelper.delayFor(1500); // Wait.
+ UIHelper.keyDown("1"); // -> 02/[0001]
+ shouldBeEqualToString("input.value", "0001-02");
+ shouldBe("changeEventsFired", "2");
+ shouldBe("inputEventsFired", "2");
+
+ beginTest("Digit keys clamp value"); // [mm]/yyyy
+ UIHelper.keyDown("9"); // -> [09]/yyyy
+ UIHelper.keyDown("9"); // -> [12]/yyyy
+ UIHelper.keyDown("rightArrow"); // -> 12/[yyyy]
+ UIHelper.keyDown("9"); // -> 12/[0009]
+ UIHelper.keyDown("9"); // -> 12/[0099]
+ UIHelper.keyDown("9"); // -> 12/[0999]
+ UIHelper.keyDown("9"); // -> 12/[9999]
+ shouldBeEqualToString("input.value", "9999-12");
+ shouldBe("changeEventsFired", "4");
+ shouldBe("inputEventsFired", "4");
+
+ beginTest("Left/Right arrow keys"); // [mm]/yyyy
+ UIHelper.keyDown("2"); // -> [02]/yyyy
+ UIHelper.keyDown("rightArrow"); // -> 02/[yyyy]
+ UIHelper.keyDown("2"); // -> 02/[0002]
+ shouldBeEqualToString("input.value", "0002-02");
+ UIHelper.keyDown("leftArrow"); // -> [02]/0002
+ UIHelper.keyDown("3"); // -> [03]/0002
+ shouldBeEqualToString("input.value", "0002-03");
+ shouldBe("changeEventsFired", "2");
+ shouldBe("inputEventsFired", "2");
+
+ beginTest("Advance field keys", "2020-06"); // [06]/2020
+ UIHelper.keyDown(" "); // -> 06/[2020]
+ UIHelper.keyDown("2"); // -> 06/[0002]
+ shouldBeEqualToString("input.value", "0002-06");
+ UIHelper.keyDown("leftArrow"); // -> [06]/0002
+ UIHelper.keyDown("/"); // -> 06/[0002]
+ UIHelper.keyDown("3"); // -> 06/[0003]
+ shouldBeEqualToString("input.value", "0003-06");
+ UIHelper.keyDown("leftArrow"); // -> [06]/0003
+ UIHelper.keyDown("-"); // -> 06/[0003]
+ UIHelper.keyDown("4"); // -> 06/[0004]
+ shouldBeEqualToString("input.value", "0004-06");
+ UIHelper.keyDown("leftArrow"); // -> [06]/0004
+ UIHelper.keyDown("."); // -> 06/[0004]
+ UIHelper.keyDown("5"); // -> 06/[0005]
+ shouldBeEqualToString("input.value", "0005-06");
+ UIHelper.keyDown("leftArrow"); // -> [06]/0005
+ UIHelper.keyDown(":"); // -> 06/[0005]
+ UIHelper.keyDown("6"); // -> 06/[0006]
+ shouldBeEqualToString("input.value", "0006-06");
+ UIHelper.keyDown("leftArrow"); // -> [06]/0006
+ UIHelper.keyDown(";"); // -> 06/[0006]
+ UIHelper.keyDown("7"); // -> 06/[0007]
+ shouldBeEqualToString("input.value", "0007-06");
+ UIHelper.keyDown("leftArrow"); // -> [06]/0007
+ UIHelper.keyDown(","); // -> 06/[0007]
+ UIHelper.keyDown("8"); // -> 06/[0008]
+ shouldBeEqualToString("input.value", "0008-06");
+ shouldBe("changeEventsFired", "7");
+ shouldBe("inputEventsFired", "7");
+
+ beginTest("Up/Down arrow keys", "2020-12"); // [12]/2020
+ UIHelper.keyDown("upArrow"); // [01]/2020
+ shouldBeEqualToString("input.value", "2020-01");
+ UIHelper.keyDown("upArrow"); // [02]/2020
+ shouldBeEqualToString("input.value", "2020-02");
+ UIHelper.keyDown("downArrow"); // [01]/2020
+ shouldBeEqualToString("input.value", "2020-01");
+ UIHelper.keyDown("downArrow"); // [12]/2020
+ shouldBeEqualToString("input.value", "2020-12");
+ shouldBe("changeEventsFired", "4");
+ shouldBe("inputEventsFired", "4");
+
+ beginTest("Tab key");
+ UIHelper.keyDown("2"); // -> [02]/yyyy
+ UIHelper.keyDown("\t"); // -> 02/[yyyy]
+ UIHelper.keyDown("2"); // -> 02/[0002]
+ shouldBeEqualToString("input.value", "0002-02");
+ UIHelper.keyDown("\t"); // Focus out.
+ shouldBeEqualToString("document.activeElement.id", "after");
+ UIHelper.keyDown("\t", ["shiftKey"]); // -> 02/[0002]
+ UIHelper.keyDown("\t", ["shiftKey"]); // -> [02]/0002
+ UIHelper.keyDown("3"); // -> [03]/0002
+ shouldBeEqualToString("input.value", "0002-03");
+ UIHelper.keyDown("\t", ["shiftKey"]); // Focus out.
+ shouldBeEqualToString("document.activeElement.id", "before");
+ shouldBe("changeEventsFired", "2");
+ shouldBe("inputEventsFired", "2");
+
+ beginTest("Backspace key", "2020-08"); // [08]/2020
+ UIHelper.keyDown("\b"); // -> [mm]/2020
+ shouldBeEqualToString("input.value", "");
+ UIHelper.keyDown("7"); // -> [07]/2020
+ shouldBeEqualToString("input.value", "2020-07");
+ shouldBe("changeEventsFired", "2");
+ shouldBe("inputEventsFired", "2");
+
+ beginTest("Delete key", "2021-08"); // [08]/2021
+ UIHelper.keyDown("delete"); // -> [mm]/2021
+ shouldBeEqualToString("input.value", "");
+ shouldBe("changeEventsFired", "1");
+ shouldBe("inputEventsFired", "1");
+
+ beginTest("Disabled/readonly", "2020-09");
+ input.disabled = true;
+ UIHelper.keyDown("1");
+ shouldBeEqualToString("input.value", "2020-09");
+ input.disabled = false;
+ input.focus();
+ UIHelper.keyDown("1");
+ shouldBeEqualToString("input.value", "2020-01");
+ input.readOnly = true;
+ UIHelper.keyDown("rightArrow");
+ UIHelper.keyDown("2");
+ shouldBeEqualToString("input.value", "2020-01");
+ input.readOnly = false;
+ UIHelper.keyDown("2");
+ shouldBeEqualToString("input.value", "0002-01");
+ shouldBe("changeEventsFired", "2");
+ shouldBe("inputEventsFired", "2");
+
+ finishJSTest();
+});
+
+</script>
+
+<script src=""
+</body>
+</html>
Added: trunk/LayoutTests/fast/forms/month/month-editable-components/month-editable-components-mouse-events-expected.txt (0 => 268276)
--- trunk/LayoutTests/fast/forms/month/month-editable-components/month-editable-components-mouse-events-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/forms/month/month-editable-components/month-editable-components-mouse-events-expected.txt 2020-10-09 19:33:25 UTC (rev 268276)
@@ -0,0 +1,24 @@
+Test for mouse events for <input type=month>
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Enabled Input
+
+PASS input.value is "2020-09"
+PASS input.value is "0012-09"
+PASS input.value is "0012-05"
+PASS input.value is "0012-05"
+PASS clickEventsFired is 3
+
+Disabled Input
+
+PASS clickEventsFired is 0
+
+Readonly Input
+
+PASS clickEventsFired is 3
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/forms/month/month-editable-components/month-editable-components-mouse-events.html (0 => 268276)
--- trunk/LayoutTests/fast/forms/month/month-editable-components/month-editable-components-mouse-events.html (rev 0)
+++ trunk/LayoutTests/fast/forms/month/month-editable-components/month-editable-components-mouse-events.html 2020-10-09 19:33:25 UTC (rev 268276)
@@ -0,0 +1,98 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+<style>
+input {
+ width: 300px;
+ font-size: 30px;
+}
+</style>
+</head>
+<body>
+
+<input id="input" type="month" value="2020-10">
+
+<script>
+
+description("Test for mouse events for <input type=month>");
+
+clickEventsFired = 0;
+function onClickEvent() {
+ clickEventsFired++;
+}
+
+function mouseClickOn(x, y) {
+ if (!window.eventSender)
+ return;
+ eventSender.mouseMoveTo(x + input.offsetLeft, y + input.offsetTop);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+}
+
+input.addEventListener("click", onClickEvent);
+const center = input.offsetHeight / 2;
+
+debug("Enabled Input\n");
+
+// Click on month field.
+mouseClickOn(20, center);
+UIHelper.keyDown("9");
+shouldBeEqualToString("input.value", "2020-09");
+
+// Click on year field.
+mouseClickOn(60, center);
+UIHelper.keyDown("1");
+UIHelper.keyDown("2");
+shouldBeEqualToString("input.value", "0012-09");
+
+// Click on control, but not a specific field, defaults to first field.
+mouseClickOn(250, center);
+UIHelper.keyDown("5");
+shouldBeEqualToString("input.value", "0012-05");
+
+// Click outside control.
+mouseClickOn(input.offsetWidth + 5, input.offsetHeight + 5);
+UIHelper.keyDown("7");
+shouldBeEqualToString("input.value", "0012-05");
+
+shouldBe("clickEventsFired", "3");
+
+debug("\nDisabled Input\n");
+clickEventsFired = 0;
+input.disabled = true;
+input.readOnly = false;
+
+// Click on month field.
+mouseClickOn(20, center);
+// Click on year field.
+mouseClickOn(60, center);
+// Click on control, but not a specific field, defaults to first field.
+mouseClickOn(250, center);
+// Click outside control.
+mouseClickOn(input.offsetWidth + 5, input.offsetHeight + 5);
+
+shouldBe("clickEventsFired", "0");
+
+debug("\nReadonly Input\n");
+clickEventsFired = 0;
+input.disabled = false;
+input.readOnly = true;
+
+// Click on month field.
+mouseClickOn(20, center);
+// Click on year field.
+mouseClickOn(60, center);
+// Click on control, but not a specific field, defaults to first field.
+mouseClickOn(250, center);
+// Click outside control.
+mouseClickOn(input.offsetWidth + 5, input.offsetHeight + 5);
+
+shouldBe("clickEventsFired", "3");
+
+</script>
+
+<script src=""
+</body>
+</html>
Modified: trunk/LayoutTests/platform/mac-wk2/TestExpectations (268275 => 268276)
--- trunk/LayoutTests/platform/mac-wk2/TestExpectations 2020-10-09 19:19:52 UTC (rev 268275)
+++ trunk/LayoutTests/platform/mac-wk2/TestExpectations 2020-10-09 19:33:25 UTC (rev 268276)
@@ -14,6 +14,7 @@
fast/events/cursors [ Pass ]
fast/forms/date/date-editable-components [ Pass ]
fast/forms/datetimelocal/datetimelocal-editable-components [ Pass ]
+fast/forms/month/month-editable-components [ Pass ]
fast/forms/time/time-editable-components [ Pass ]
fast/forms/select/mac-wk2 [ Pass ]
fast/sandbox/mac [ Pass ]
Modified: trunk/Source/WebCore/ChangeLog (268275 => 268276)
--- trunk/Source/WebCore/ChangeLog 2020-10-09 19:19:52 UTC (rev 268275)
+++ trunk/Source/WebCore/ChangeLog 2020-10-09 19:33:25 UTC (rev 268276)
@@ -1,3 +1,26 @@
+2020-10-09 Aditya Keerthi <[email protected]>
+
+ [macOS] Add editability to input type=month
+ https://bugs.webkit.org/show_bug.cgi?id=217481
+ <rdar://problem/70097164>
+
+ Reviewed by Sam Weinig.
+
+ This patch adds editability to input type=month by leveraging existing
+ logic to add editable components to date/time inputs.
+
+ Tests: fast/forms/month/month-editable-components/month-editable-components-focus-and-blur-events.html
+ fast/forms/month/month-editable-components/month-editable-components-keyboard-events.html
+ fast/forms/month/month-editable-components/month-editable-components-mouse-events.html
+
+ * html/MonthInputType.cpp:
+ (WebCore::MonthInputType::formatDateTimeFieldsState const):
+ (WebCore::MonthInputType::setupLayoutParameters const):
+ * platform/text/cocoa/LocaleCocoa.mm:
+ (WebCore::LocaleCocoa::shortMonthFormat):
+
+ Update presented month format string to match AppKit.
+
2020-10-09 Keith Miller <[email protected]>
Finalizers shouldn't run if events can't fire
Modified: trunk/Source/WebCore/html/MonthInputType.cpp (268275 => 268276)
--- trunk/Source/WebCore/html/MonthInputType.cpp 2020-10-09 19:19:52 UTC (rev 268275)
+++ trunk/Source/WebCore/html/MonthInputType.cpp 2020-10-09 19:33:25 UTC (rev 268276)
@@ -33,10 +33,12 @@
#include "MonthInputType.h"
#include "DateComponents.h"
+#include "DateTimeFieldsState.h"
#include "Decimal.h"
#include "HTMLInputElement.h"
#include "HTMLNames.h"
#include "InputTypeNames.h"
+#include "PlatformLocale.h"
#include "StepRange.h"
#include <wtf/DateMath.h>
#include <wtf/MathExtras.h>
@@ -139,13 +141,18 @@
return results.containsAll({ DateTimeFormatValidationResults::HasYear, DateTimeFormatValidationResults::HasMonth });
}
-String MonthInputType::formatDateTimeFieldsState(const DateTimeFieldsState&) const
+String MonthInputType::formatDateTimeFieldsState(const DateTimeFieldsState& state) const
{
- return emptyString();
+ if (!state.year || !state.month)
+ return emptyString();
+
+ return makeString(pad('0', 4, *state.year), '-', pad('0', 2, *state.month));
}
-void MonthInputType::setupLayoutParameters(DateTimeEditElement::LayoutParameters&, const DateComponents&) const
+void MonthInputType::setupLayoutParameters(DateTimeEditElement::LayoutParameters& layoutParameters, const DateComponents&) const
{
+ layoutParameters.dateTimeFormat = layoutParameters.locale.shortMonthFormat();
+ layoutParameters.fallbackDateTimeFormat = "yyyy-MM"_s;
}
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/text/cocoa/LocaleCocoa.mm (268275 => 268276)
--- trunk/Source/WebCore/platform/text/cocoa/LocaleCocoa.mm 2020-10-09 19:19:52 UTC (rev 268275)
+++ trunk/Source/WebCore/platform/text/cocoa/LocaleCocoa.mm 2020-10-09 19:33:25 UTC (rev 268276)
@@ -160,7 +160,7 @@
{
if (!m_shortMonthFormat.isNull())
return m_shortMonthFormat;
- m_shortMonthFormat = [NSDateFormatter dateFormatFromTemplate:@"yyyyMMM" options:0 locale:m_locale.get()];
+ m_shortMonthFormat = [NSDateFormatter dateFormatFromTemplate:@"yM" options:0 locale:m_locale.get()];
return m_shortMonthFormat;
}