Commit 2e7b7c8b authored by ziran.sun@samsung.com's avatar ziran.sun@samsung.com

Add Layout test to check <select> with -webkit-autofil style

R=tkent@chromium.org
BUG=58719

Review URL: https://codereview.chromium.org/214693004

git-svn-id: svn://svn.chromium.org/blink/trunk@170225 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 36d772ff
This tests that foreground and background colors properly change for autofilled inputs. It can only be run using the test harness. This tests that foreground and background colors properly change for autofilled inputs or select options. It can only be run using the test harness.
PASS successfullyParsed is true PASS successfullyParsed is true
TEST COMPLETE TEST COMPLETE
......
...@@ -13,9 +13,11 @@ ...@@ -13,9 +13,11 @@
var field = document.getElementById('field'); var field = document.getElementById('field');
var textarea = document.getElementById('textarea'); var textarea = document.getElementById('textarea');
var select = document.getElementById('select');
var computedStyleField = document.defaultView.getComputedStyle(field); var computedStyleField = document.defaultView.getComputedStyle(field);
var computedStyleTextarea = document.defaultView.getComputedStyle(textarea); var computedStyleTextarea = document.defaultView.getComputedStyle(textarea);
var computedStyleSelect = document.defaultView.getComputedStyle(select);
var originalForeground = computedStyleField.color; var originalForeground = computedStyleField.color;
var originalBackground = computedStyleField.backgroundColor; var originalBackground = computedStyleField.backgroundColor;
...@@ -31,11 +33,13 @@ ...@@ -31,11 +33,13 @@
if (window.internals) { if (window.internals) {
window.internals.setAutofilled(field, true); window.internals.setAutofilled(field, true);
window.internals.setAutofilled(textarea, true); window.internals.setAutofilled(textarea, true);
window.internals.setAutofilled(select, true);
} }
// Both the foreground and background colors should change. // Both the foreground and background colors should change.
computedStyleField = document.defaultView.getComputedStyle(field); computedStyleField = document.defaultView.getComputedStyle(field);
computedStyleTextarea = document.defaultView.getComputedStyle(textarea); computedStyleTextarea = document.defaultView.getComputedStyle(textarea);
computedStyleSelect = document.defaultView.getComputedStyle(select);
if (computedStyleField.color == originalForeground) { if (computedStyleField.color == originalForeground) {
testFailed('Foreground color for <input> element did not change when autofilled.'); testFailed('Foreground color for <input> element did not change when autofilled.');
return; return;
...@@ -52,15 +56,25 @@ ...@@ -52,15 +56,25 @@
testFailed('Background color for <textarea> element did not change when autofilled.'); testFailed('Background color for <textarea> element did not change when autofilled.');
return; return;
} }
if (computedStyleSelect.color == originalForeground) {
testFailed('Foreground color for <select> element did not change when autofilled.');
return;
}
if (computedStyleSelect.backgroundColor == originalBackground) {
testFailed('Background color for <select> element did not change when autofilled.');
return;
}
if (window.internals) { if (window.internals) {
window.internals.setAutofilled(field, false); window.internals.setAutofilled(field, false);
window.internals.setAutofilled(textarea, false); window.internals.setAutofilled(textarea, false);
window.internals.setAutofilled(select, false);
} }
// Colors should be restored. // Colors should be restored.
computedStyleField = document.defaultView.getComputedStyle(field); computedStyleField = document.defaultView.getComputedStyle(field);
computedStyleTextarea = document.defaultView.getComputedStyle(textarea); computedStyleTextarea = document.defaultView.getComputedStyle(textarea);
computedStyleSelect = document.defaultView.getComputedStyle(select);
if (computedStyleField.color != originalForeground) { if (computedStyleField.color != originalForeground) {
testFailed('Foreground color for <input> element did not revert when un-autofilled.'); testFailed('Foreground color for <input> element did not revert when un-autofilled.');
return; return;
...@@ -77,23 +91,32 @@ ...@@ -77,23 +91,32 @@
testFailed('Background color for <textarea> element did not revert when un-autofilled.'); testFailed('Background color for <textarea> element did not revert when un-autofilled.');
return; return;
} }
if (computedStyleSelect.color != originalForeground) {
testFailed('Foreground color for <select> element did not revert when un-autofilled.');
return;
}
if (computedStyleSelect.backgroundColor != originalBackground) {
testFailed('Background color for <select> element did not revert when un-autofilled.');
return;
}
testPassed(''); testPassed('');
} }
</script> </script>
<style> <style>
#field, #textarea { #field, #textarea, #select {
color: #FFFFFF; color: #FFFFFF;
background-color: #FFFFFF; background-color: #FFFFFF;
} }
</style> </style>
</head> </head>
<body onload="test()"> <body onload="test()">
This tests that foreground and background colors properly change for autofilled inputs. It can only be run using the test harness.<br> This tests that foreground and background colors properly change for autofilled inputs or select options. It can only be run using the test harness.<br>
<form name="fm"> <form name="fm">
<input type="text" id="field" value="Field value"> <input type="text" id="field" value="Field value">
<textarea id="textarea"></textarea> <textarea id="textarea"></textarea>
<select id="select"></select>
</form> </form>
<div id="console"></div> <div id="console"></div>
</body> </body>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment