Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/editing/spelling/spelling-attribute-change.html |
| diff --git a/third_party/WebKit/LayoutTests/editing/spelling/spelling-attribute-change.html b/third_party/WebKit/LayoutTests/editing/spelling/spelling-attribute-change.html |
| index 68dcb8e37e28886b66dc62677f65c48a4774a9e2..5376913f2c842cfac46b40b97b99c8e75d5c418a 100644 |
| --- a/third_party/WebKit/LayoutTests/editing/spelling/spelling-attribute-change.html |
| +++ b/third_party/WebKit/LayoutTests/editing/spelling/spelling-attribute-change.html |
| @@ -1,11 +1,48 @@ |
| -<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
| -<html> |
| -<head> |
| -<script src="../../resources/js-test.js"></script> |
| -</head> |
| -<body> |
| -<p id="description"></p> |
| -<div id="console"></div> |
| -<script src="script-tests/spelling-attribute-change.js"></script> |
| -</body> |
| -</html> |
| +<!doctype html> |
| +<script src="../../resources/testharness.js"></script> |
| +<script src="../../resources/testharnessreport.js"></script> |
| +<script src="../assert_selection.js"></script> |
| +<script src="spellcheck_test.js"></script> |
| + |
| +<script> |
| +const testElementTypes = ['span', 'input', 'textarea']; |
| +const initialValues = [undefined, true, false]; |
| +const finalValues = [true, false]; |
| + |
| +function generateInputText(type, value) { |
| + var text = `<${type} ${type === 'span' ? 'contenteditable ' : ''}id="target"`; |
| + if (value !== undefined) |
| + text += ` spellcheck="${value}"`; |
| + text += '>'; |
| + if (type !== 'input') |
| + text += `</${type}>`; |
| + return text; |
| +} |
| + |
| +function generateExpectedText(type, value) { |
| + const misspelling = value ? '#zz#' : 'zz'; |
| + var text = `<${type} ${type === 'span' ? 'contenteditable ' : ''}id="target" spellcheck="${value}"`; |
| + if (type === 'input') { |
| + text += ` value="Hello,${misspelling}.">`; |
| + } else { |
| + text += `>Hello,${misspelling}.</${type}>`; |
| + } |
| + return text; |
| +} |
| + |
| +testElementTypes.forEach(type => { |
|
yosin_UTC9
2016/10/28 08:43:52
Please don't use control-flow to generate sample i
Xiaocheng
2016/10/28 09:21:01
Done.
|
| + initialValues.forEach(initialValue => { |
| + finalValues.forEach(finalValue => spellcheck_test( |
| + generateInputText(type, initialValue), |
| + document => { |
| + const target = document.getElementById('target'); |
| + target.spellcheck = finalValue; |
| + target.focus(); |
| + document.execCommand('insertText', false, 'Hello,'); |
| + document.execCommand('insertText', false, 'zz.'); |
| + }, |
| + generateExpectedText(type, finalValue), |
| + `Change "spellcheck" of <${type}> from ${initialValue} to ${finalValue}`)); |
| + }); |
| +}); |
| +</script> |