Title: [295564] trunk/LayoutTests
Revision
295564
Author
akeer...@apple.com
Date
2022-06-15 10:06:12 -0700 (Wed, 15 Jun 2022)

Log Message

REGRESSION: [ Mac wk2 ] fast/forms/datetimelocal/datetimelocal-editable-components/datetimelocal-choose-value-from-picker.html is a flaky failure
https://bugs.webkit.org/show_bug.cgi?id=239257
rdar://91653542

Reviewed by Wenson Hsieh.

245100@main changed the value parsing and sanitization algorithm for
<input type="datetime-local"> to better match the spec. Following this change,
the output of HTMLInputElement.value uses the shortest possible string,
omitting seconds or milliseconds when 0.

The flaky test tests that choosing a value using the date/time picker does not
unexpectedly add or remove second and millisecond fields. This behavior was
being verified by checking whether the input's value contained seconds or
milliseconds after using the picker. However, following 245100@main, the value
can appear without seconds/milliseconds, even though the editable fields do.

The non-determinism comes from the fact that the current system time is used
to populate the seconds and milliseconds field when using the picker on an
empty input. Consequently, the test will fail when the current time has a 0
second value.

To fix, verify that using the picker does not unexpectedly add or remove second
and millisecond fields by checking the width of the element before and after
date selection. This approach ensures determinism, while fulfilling the goal of
the test.

As an aside, the current behavior to populate the seconds and milliseconds for
empty inputs could be improved. http://webkit.org/b/241620 has been filed, with
the intent of setting the seconds and milliseconds fields to 0 when they are
initially empty.

* LayoutTests/fast/forms/datetimelocal/datetimelocal-editable-components/datetimelocal-choose-value-from-picker-expected.txt:
* LayoutTests/fast/forms/datetimelocal/datetimelocal-editable-components/datetimelocal-choose-value-from-picker.html:
* LayoutTests/platform/mac-wk2/TestExpectations:

Canonical link: https://commits.webkit.org/251569@main

Modified Paths

Diff

Modified: trunk/LayoutTests/fast/forms/datetimelocal/datetimelocal-editable-components/datetimelocal-choose-value-from-picker-expected.txt (295563 => 295564)


--- trunk/LayoutTests/fast/forms/datetimelocal/datetimelocal-editable-components/datetimelocal-choose-value-from-picker-expected.txt	2022-06-15 16:59:25 UTC (rev 295563)
+++ trunk/LayoutTests/fast/forms/datetimelocal/datetimelocal-editable-components/datetimelocal-choose-value-from-picker-expected.txt	2022-06-15 17:06:12 UTC (rev 295564)
@@ -4,24 +4,19 @@
 
 
 Testing empty input with no step value.
-PASS valueHasSeconds is false
-PASS valueHasMillseconds is false
+PASS emptyInput.offsetWidth === emptyInputOriginalWidth is true
 
 Testing empty input with step attribute precise to seconds.
-PASS valueHasSeconds is true
-PASS valueHasMillseconds is false
+PASS emptyInputWithSecondStep.offsetWidth === emptyInputWithSecondStepOriginalWidth is true
 
 Testing empty input with step attribute precise to milliseconds.
-PASS valueHasSeconds is true
-PASS valueHasMillseconds is true
+PASS emptyInputWithMillisecondStep.offsetWidth === emptyInputWithMillisecondStepOriginalWidth is true
 
 Testing input with a value that contains seconds.
-PASS valueHasSeconds is true
-PASS valueHasMillseconds is false
+PASS inputWithSecondsValue.offsetWidth === inputWithSecondsValueOriginalWidth is true
 
 Testing input with a value that contains milliseconds.
-PASS valueHasSeconds is true
-PASS valueHasMillseconds is true
+PASS inputWithMillisecondsValue.offsetWidth === inputWithMillisecondsValueOriginalWidth is true
 
 PASS successfullyParsed is true
 

Modified: trunk/LayoutTests/fast/forms/datetimelocal/datetimelocal-editable-components/datetimelocal-choose-value-from-picker.html (295563 => 295564)


--- trunk/LayoutTests/fast/forms/datetimelocal/datetimelocal-editable-components/datetimelocal-choose-value-from-picker.html	2022-06-15 16:59:25 UTC (rev 295563)
+++ trunk/LayoutTests/fast/forms/datetimelocal/datetimelocal-editable-components/datetimelocal-choose-value-from-picker.html	2022-06-15 17:06:12 UTC (rev 295564)
@@ -1,7 +1,7 @@
 <!DOCTYPE html>
 <html>
 <head>
-<script src=""
+<script src=""
 <script src=""
 </head>
 <body>
@@ -16,16 +16,6 @@
 
 jsTestIsAsync = true;
 
-function hasSeconds(value) {
-    time = value.slice(value.lastIndexOf('T') + 1);
-    return time.length > 5;
-}
-
-function hasMilliseconds(value) {
-    time = value.slice(value.lastIndexOf('T') + 1);
-    return time.length > 8;
-}
-
 async function activateElementAndChooseDateUsingPicker(input) {
     await UIHelper.activateElementAndWaitForInputSession(input);
     await UIHelper.isShowingDateTimePicker();
@@ -32,61 +22,45 @@
     await UIHelper.chooseDateTimePickerValue();
 }
 
-function expectNoSecondsOrMilliseconds(value) {
-    valueHasSeconds = hasSeconds(value);
-    shouldBeFalse("valueHasSeconds");
-    valueHasMillseconds = hasMilliseconds(value);
-    shouldBeFalse("valueHasMillseconds");
-}
-
-function expectSeconds(value) {
-    valueHasSeconds = hasSeconds(value);
-    shouldBeTrue("valueHasSeconds");
-    valueHasMillseconds = hasMilliseconds(value);
-    shouldBeFalse("valueHasMillseconds");
-}
-
-function expectMilliseconds(value) {
-    valueHasSeconds = hasSeconds(value);
-    shouldBeTrue("valueHasSeconds");
-    valueHasMillseconds = hasMilliseconds(value);
-    shouldBeTrue("valueHasMillseconds");
-}
-
 addEventListener("load", async () => {
     description("Tests that choosing a value using the date/time picker does not unexpectedly add or remove second and millisecond fields.");
 
     debug("Testing empty input with no step value.");
+    emptyInputOriginalWidth = emptyInput.offsetWidth;
     await activateElementAndChooseDateUsingPicker(emptyInput);
-    expectNoSecondsOrMilliseconds(emptyInput.value);
+    shouldBeTrue("emptyInput.offsetWidth === emptyInputOriginalWidth");
     await UIHelper.deactivateFormControl(emptyInput);
     await UIHelper.ensurePresentationUpdate();
 
     debug("");
     debug("Testing empty input with step attribute precise to seconds.");
+    emptyInputWithSecondStepOriginalWidth = emptyInputWithSecondStep.offsetWidth;
     await activateElementAndChooseDateUsingPicker(emptyInputWithSecondStep);
-    expectSeconds(emptyInputWithSecondStep.value);
+    shouldBeTrue("emptyInputWithSecondStep.offsetWidth === emptyInputWithSecondStepOriginalWidth");
     await UIHelper.deactivateFormControl(emptyInputWithSecondStep);
     await UIHelper.ensurePresentationUpdate();
 
     debug("");
     debug("Testing empty input with step attribute precise to milliseconds.");
+    emptyInputWithMillisecondStepOriginalWidth = emptyInputWithMillisecondStep.offsetWidth;
     await activateElementAndChooseDateUsingPicker(emptyInputWithMillisecondStep);
-    expectMilliseconds(emptyInputWithMillisecondStep.value);
+    shouldBeTrue("emptyInputWithMillisecondStep.offsetWidth === emptyInputWithMillisecondStepOriginalWidth");
     await UIHelper.deactivateFormControl(emptyInputWithMillisecondStep);
     await UIHelper.ensurePresentationUpdate();
 
     debug("");
     debug("Testing input with a value that contains seconds.");
+    inputWithSecondsValueOriginalWidth = inputWithSecondsValue.offsetWidth;
     await activateElementAndChooseDateUsingPicker(inputWithSecondsValue);
-    expectSeconds(inputWithSecondsValue.value);
+    shouldBeTrue("inputWithSecondsValue.offsetWidth === inputWithSecondsValueOriginalWidth");
     await UIHelper.deactivateFormControl(inputWithSecondsValue);
     await UIHelper.ensurePresentationUpdate();
 
     debug("");
     debug("Testing input with a value that contains milliseconds.");
+    inputWithMillisecondsValueOriginalWidth = inputWithMillisecondsValue.offsetWidth;
     await activateElementAndChooseDateUsingPicker(inputWithMillisecondsValue);
-    expectMilliseconds(inputWithMillisecondsValue.value);
+    shouldBeTrue("inputWithMillisecondsValue.offsetWidth === inputWithMillisecondsValueOriginalWidth");
     await UIHelper.deactivateFormControl(inputWithMillisecondsValue);
     await UIHelper.ensurePresentationUpdate();
 
@@ -94,7 +68,5 @@
     finishJSTest();
 });
 </script>
-
-<script src=""
 </body>
 </html>

Modified: trunk/LayoutTests/platform/mac-wk2/TestExpectations (295563 => 295564)


--- trunk/LayoutTests/platform/mac-wk2/TestExpectations	2022-06-15 16:59:25 UTC (rev 295563)
+++ trunk/LayoutTests/platform/mac-wk2/TestExpectations	2022-06-15 17:06:12 UTC (rev 295564)
@@ -1630,8 +1630,6 @@
 
 webkit.org/b/239308 media/media-source/media-source-webm-vorbis-partial.html [ Failure ]
 
-webkit.org/b/239257 fast/forms/datetimelocal/datetimelocal-editable-components/datetimelocal-choose-value-from-picker.html [ Pass Failure ]
-
 webkit.org/b/239304 http/tests/cache-storage/cache-origins.https.html [ Pass Failure ]
 
 # [ Monterey wk2 debug ] WebGL conformance tests are a flaky time out
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to