[Tests] We should have tests for preserving/resetting values of input type "time...
authoryosin@chromium.org <yosin@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Sep 2012 09:32:20 +0000 (09:32 +0000)
committeryosin@chromium.org <yosin@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Sep 2012 09:32:20 +0000 (09:32 +0000)
https://bugs.webkit.org/show_bug.cgi?id=96595

Reviewed by Kent Tamura.

This patch adds two tests for preserving/resetting values input type
"time" with multiple fields input UI after page reload, backward and
forward browser navigation.

This patch affects ports which enable both ENABLE_INPUT_TYPE_TIME and
ENABLE_INPUT_TYPE_TIME_MULTIPLE_FIELDS.

* fast/forms/time-multiple-fields/time-multiple-fields-preserve-value-after-history-back-expected.txt: Added.
* fast/forms/time-multiple-fields/time-multiple-fields-preserve-value-after-history-back.html: Added for checking value is preserved after history backward and forward navigation.
* fast/forms/time-multiple-fields/time-multiple-fields-reset-value-after-reload-expected.txt: Added.
* fast/forms/time-multiple-fields/time-multiple-fields-reset-preserve-value-after-reload.html: Added for checking values are resetted after page reload.

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

LayoutTests/ChangeLog
LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-preserve-value-after-history-back-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-preserve-value-after-history-back.html [new file with mode: 0644]
LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-reset-value-after-reload-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-reset-value-after-reload.html [new file with mode: 0644]

index 4251179..c5e3b38 100644 (file)
@@ -1,3 +1,22 @@
+2012-09-13  Yoshifumi Inoue  <yosin@chromium.org>
+
+        [Tests] We should have tests for preserving/resetting values of input type "time" after browser navigation
+        https://bugs.webkit.org/show_bug.cgi?id=96595
+
+        Reviewed by Kent Tamura.
+
+        This patch adds two tests for preserving/resetting values input type
+        "time" with multiple fields input UI after page reload, backward and
+        forward browser navigation.
+
+        This patch affects ports which enable both ENABLE_INPUT_TYPE_TIME and
+        ENABLE_INPUT_TYPE_TIME_MULTIPLE_FIELDS.
+
+        * fast/forms/time-multiple-fields/time-multiple-fields-preserve-value-after-history-back-expected.txt: Added.
+        * fast/forms/time-multiple-fields/time-multiple-fields-preserve-value-after-history-back.html: Added for checking value is preserved after history backward and forward navigation.
+        * fast/forms/time-multiple-fields/time-multiple-fields-reset-value-after-reload-expected.txt: Added.
+        * fast/forms/time-multiple-fields/time-multiple-fields-reset-preserve-value-after-reload.html: Added for checking values are resetted after page reload.
+
 2012-09-13  Ádám Kallai  <kadam@inf.u-szeged.hu>
 
         [Qt] Unreviewed gardening. Skip a failing test. Added platform specific expectations after r128375.
diff --git a/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-preserve-value-after-history-back-expected.txt b/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-preserve-value-after-history-back-expected.txt
new file mode 100644 (file)
index 0000000..f198660
--- /dev/null
@@ -0,0 +1,18 @@
+Checks input value is preserved after backward and forward
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Went back to a page. Checking a form control which had a full value:
+PASS "01:01" is "01:01"
+Went back to a page. Checking a form control which had a partial value:
+PASS "" is ""
+Went forward to a page. Checking a form control which had a full value:
+PASS "02:02" is "02:02"
+Went forward to a page. Checking a form control which had a partial value:
+PASS "" is ""
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-preserve-value-after-history-back.html b/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-preserve-value-after-history-back.html
new file mode 100644 (file)
index 0000000..2698fdc
--- /dev/null
@@ -0,0 +1,134 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<div id=container>
+<input type=time id=test1><br>
+<input type=time id=test2><br>
+<iframe id=iframe></iframe>
+</div>
+<script>
+description('Checks input value is preserved after backward and forward');
+if (!window.eventSender) {
+    debug('Please run within DumpRenderTree');
+}
+window.jsTestIsAsync = true;
+
+var iframe = document.getElementById('iframe');
+var testInput1 = document.getElementById('test1');
+var testInput2 = document.getElementById('test2');
+var state = 'direct';
+var pageName = location.search || '?page0';
+var testCases = [];
+
+function back(newState)
+{
+    parent.state = newState;
+    history.back();
+}
+
+function failed(message) {
+    testFailed(message + ' in ' + state);
+    finishJSTest();
+}
+
+function finishTest() {
+    runTestCases();
+    document.body.removeChild(document.getElementById('container'));
+    finishJSTest();
+}
+
+function forward(newState)
+{
+    parent.state = newState;
+    history.forward();
+}
+
+function keyDown(key, modifiers)
+{
+    if (!window.eventSender)
+        return;
+    eventSender.keyDown(key, modifiers);
+}
+
+function runTestCases() {
+    for (var index = 0; index < testCases.length; ++ index) {
+        var testCase = testCases[index];
+        debug(testCase['description'] + ':');
+        shouldBeEqualToString('"' + testCase['actual'] + '"', testCase['expected']);
+    }
+    debug('');
+}
+
+switch (pageName) {
+case '?page0':
+    iframe.src = location + '?page1';
+    break;
+case '?page1':
+    switch (parent.state) {
+    case 'direct': {
+        testInput1.value = '01:01';
+        testInput2.focus();
+        keyDown('upArrow');
+        var nextUri = location.toString().replace('?page1', '?page2');
+        setTimeout(function () { window.location.href = nextUri; }, 0);
+        break;
+    }
+    case 'backTo1':
+        parent.testCases.push(
+            {
+                'description' : 'Went back to a page. Checking a form control which had a full value',
+                'actual' : testInput1.value,
+                'expected' : '01:01' },
+            {
+                'description' : 'Went back to a page. Checking a form control which had a partial value',
+                'actual' : testInput2.value,
+                'expected' : ''
+            });
+        forward('forwardTo2');
+        break;
+    case 'backTo1Second':
+        parent.finishTest();
+        break;
+    default:
+        failed('Unsupported state(' + parent.state + ')');
+        break;
+    }
+    break;
+case '?page2':
+    switch (parent.state) {
+    case 'direct':
+        testInput1.value = '02:02';
+        testInput2.focus();
+        keyDown('upArrow');
+        back('backTo1');
+        break;
+    case 'forwardTo2':
+        parent.testCases.push(
+            {
+                'description' : 'Went forward to a page. Checking a form control which had a full value',
+                'actual' : testInput1.value,
+                'expected' : '02:02'
+            },
+            {
+                'description' : 'Went forward to a page. Checking a form control which had a partial value',
+                'actual' : testInput2.value,
+                'expected' : ''
+            });
+        back('backTo1Second');
+        break;
+    default:
+        failed('Unsupported state(' + parent.state + ')');
+        break;
+    }
+    break;
+default:
+    failed('Unsupported page(' + pageName + ')');
+    break;
+}
+</script>
+<script src="../../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-reset-value-after-reload-expected.txt b/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-reset-value-after-reload-expected.txt
new file mode 100644 (file)
index 0000000..7588e32
--- /dev/null
@@ -0,0 +1,11 @@
+Checks reloading page resets input values
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS testInput1.value is ""
+PASS testInput2.value is "02:02"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-reset-value-after-reload.html b/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-reset-value-after-reload.html
new file mode 100644 (file)
index 0000000..0e6ef34
--- /dev/null
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body onload="runBodyLoaded()">
+<iframe id=iframe srcdoc="<input type=time id=test1><input type=time id=test2 value=02:02>"></iframe>
+<script>
+description('Checks reloading page resets input values');
+window.jsTestIsAsync = true;
+
+var iframe = document.getElementById('iframe');
+var testInput1;
+var testInput2;
+
+function runBodyLoaded()
+{
+    iframe.contentDocument.getElementById('test1').value = '12:34';
+    iframe.contentDocument.getElementById('test2').value = '03:03';
+    iframe.addEventListener("load", function () { parent.runOnIFrameLoad(); });
+    iframe.contentWindow.location.reload();
+}
+
+function runOnIFrameLoad()
+{
+    testInput1 = iframe.contentDocument.getElementById('test1');
+    testInput2 = iframe.contentDocument.getElementById('test2');
+    shouldBeEqualToString('testInput1.value', '');
+    shouldBeEqualToString('testInput2.value', '02:02');
+    iframe.parentNode.removeChild(iframe);
+    finishJSTest();
+}
+</script>
+<script src="../../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>