writingsuggestions.html (49431B)
1 <!DOCTYPE html> 2 <title>Tests for the writingsuggestions attribute</title> 3 <link rel='author' title='Sanket Joshi' href='mailto:sajos@microsoft.com'> 4 <link rel="help" href="https://html.spec.whatwg.org/multipage/interaction.html#writingsuggestions"> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <script> 8 'use strict'; 9 10 customElements.define('test-custom-element', class extends HTMLElement {}); 11 12 test(function() { 13 assert_true('writingSuggestions' in document.createElement('input')); 14 }, 'Test that the writingsuggestions attribute is available on HTMLInputElement.'); 15 16 test(function() { 17 assert_true('writingSuggestions' in document.createElement('textarea')); 18 }, 'Test that the writingsuggestions attribute is available on HTMLTextAreaElement.'); 19 20 test(function() { 21 assert_true('writingSuggestions' in document.createElement('div')); 22 }, 'Test that the writingsuggestions attribute is available on HTMLDivElement.'); 23 24 test(function() { 25 assert_true('writingSuggestions' in document.createElement('span')); 26 }, 'Test that the writingsuggestions attribute is available on HTMLSpanElement.'); 27 28 test(function() { 29 assert_true('writingSuggestions' in document.createElement('test-custom-element')); 30 }, 'Test that the writingsuggestions attribute is available on custom elements.'); 31 32 test(function() { 33 let input = document.createElement('input'); 34 input.type = 'color'; 35 assert_true('writingSuggestions' in input); 36 }, 'Test that the writingsuggestions attribute is available on an input type which the attribute doesn\'t apply. The User Agent is responsible that writing suggestions are not applied to the element.'); 37 38 test(function() { 39 let textarea = document.createElement('textarea'); 40 textarea.disabled = true; 41 assert_true('writingSuggestions' in textarea); 42 }, 'Test that the writingsuggestions attribute is available on a disabled element. The User Agent is responsible that writing suggestions are not applied to the element.'); 43 44 function testSetAttributeDirectly(IDLValue, contentValue, expectedIDLValue, expectedContentValue, testDescription) { 45 test(function() { 46 let input_color = document.createElement('input'); 47 input_color.type = 'color'; 48 49 let disabled_textarea = document.createElement('textarea'); 50 disabled_textarea.disabled = true; 51 52 const elements = [document.createElement('input'), 53 document.createElement('textarea'), 54 document.createElement('div'), 55 document.createElement('span'), 56 document.createElement('test-custom-element'), 57 disabled_textarea, 58 input_color ]; 59 60 elements.forEach(function(element) { 61 if (IDLValue != undefined) { 62 element.writingSuggestions = IDLValue; 63 } 64 if (contentValue != undefined) { 65 element.setAttribute('writingsuggestions', contentValue); 66 } 67 assert_equals(element.writingSuggestions, expectedIDLValue); 68 assert_equals(element.getAttribute('writingsuggestions'), expectedContentValue); 69 }); 70 }, testDescription); 71 } 72 73 // Test setting either the `writingsuggestions` IDL or content attribute to some variation of 'true' directly on the target element. 74 testSetAttributeDirectly('true', undefined, 'true', 'true', 'Test setting the `writingsuggestions` IDL attribute to `true` directly on the target element.'); 75 testSetAttributeDirectly(undefined, 'true', 'true', 'true', 'Test setting the `writingsuggestions` content attribute to `true` directly on the target element.'); 76 testSetAttributeDirectly(true, undefined, 'true', 'true', 'Test setting the `writingsuggestions` IDL attribute to boolean `true` directly on the target element.'); 77 testSetAttributeDirectly(undefined, true, 'true', 'true', 'Test setting the `writingsuggestions` content attribute to boolean `true` directly on the target element.'); 78 testSetAttributeDirectly('TrUe', undefined, 'true', 'TrUe', 'Test setting the `writingsuggestions` IDL attribute to `TrUe` directly on the target element.'); 79 testSetAttributeDirectly(undefined, 'TrUe', 'true', 'TrUe', 'Test setting the `writingsuggestions` content attribute to `TrUe` directly on the target element.'); 80 81 // Test setting either the `writingsuggestions` IDL or content attribute to some variation of 'false' directly on the target element. 82 testSetAttributeDirectly('false', undefined, 'false', 'false', 'Test setting the `writingsuggestions` IDL attribute to `false` directly on the target element.'); 83 testSetAttributeDirectly(undefined, 'false', 'false', 'false', 'Test setting the `writingsuggestions` content attribute to `false` directly on the target element.'); 84 testSetAttributeDirectly(false, undefined, 'false', 'false', 'Test setting the `writingsuggestions` IDL attribute to boolean `false` directly on the target element.'); 85 testSetAttributeDirectly(undefined, false, 'false', 'false', 'Test setting the `writingsuggestions` content attribute to boolean `false` directly on the target element.'); 86 testSetAttributeDirectly('FaLsE', undefined, 'false', 'FaLsE', 'Test setting the `writingsuggestions` IDL attribute to `FaLsE` directly on the target element.'); 87 testSetAttributeDirectly(undefined, 'FaLsE', 'false', 'FaLsE', 'Test setting the `writingsuggestions` content attribute to `FaLsE` directly on the target element.'); 88 89 // Test setting either the `writingsuggestions` IDL or content attribute to the empty string directly on the target element. 90 testSetAttributeDirectly('', undefined, 'true', '', 'Test setting the `writingsuggestions` IDL attribute to the empty string directly on the target element.'); 91 testSetAttributeDirectly(undefined, '', 'true', '', 'Test setting the `writingsuggestions` content attribute to the empty string directly on the target element.'); 92 93 // Test setting either the `writingsuggestions` IDL or content attribute to an invalid value directly on the target element. 94 testSetAttributeDirectly('foo', undefined, 'true', 'foo', 'Test setting the `writingsuggestions` IDL attribute to an invalid value directly on the target element.'); 95 testSetAttributeDirectly(undefined, 'foo', 'true', 'foo', 'Test setting the `writingsuggestions` content attribute to an invalid value directly on the target element.'); 96 97 // Test setting neither the `writingsuggestions` IDL nor content attribute directly on the target element. 98 testSetAttributeDirectly(undefined, undefined, 'true', null, 'Test the writing suggestions state when the `writingsuggestions` attribute is missing.'); 99 100 // Test setting the content attribute after the IDL attribute and making sure the IDL and content attributes are properly reflected. 101 testSetAttributeDirectly('true', 'false', 'false', 'false', 'Test setting the `writingsuggestions` content attribute to `false` after the IDL attribute was set to `true`.'); 102 testSetAttributeDirectly('true', '', 'true', '', 'Test setting the `writingsuggestions` content attribute to the empty string after the IDL attribute was set to `true`.'); 103 testSetAttributeDirectly('true', 'foo', 'true', 'foo', 'Test setting the `writingsuggestions` content attribute to an invalid value after the IDL attribute was set to `true`.'); 104 testSetAttributeDirectly('true', 'TrUe', 'true', 'TrUe', 'Test setting the `writingsuggestions` content attribute to `TrUe` after the IDL attribute was set to `true`.'); 105 testSetAttributeDirectly('true', 'FaLsE', 'false', 'FaLsE', 'Test setting the `writingsuggestions` content attribute to `FaLsE` after the IDL attribute was set to `true`.'); 106 testSetAttributeDirectly('true', true, 'true', 'true', 'Test setting the `writingsuggestions` content attribute to boolean `true` after the IDL attribute was set to `true`.'); 107 testSetAttributeDirectly('true', false, 'false', 'false', 'Test setting the `writingsuggestions` content attribute to boolean `false` after the IDL attribute was set to `true`.'); 108 109 testSetAttributeDirectly('false', 'true', 'true', 'true', 'Test setting the `writingsuggestions` content attribute to `true` after the IDL attribute was set to `false`.'); 110 testSetAttributeDirectly('false', '', 'true', '', 'Test setting the `writingsuggestions` content attribute to the empty string after the IDL attribute was set to `false`.'); 111 testSetAttributeDirectly('false', 'foo', 'true', 'foo', 'Test setting the `writingsuggestions` content attribute to an invalid value after the IDL attribute was set to `false`.'); 112 testSetAttributeDirectly('false', 'TrUe', 'true', 'TrUe', 'Test setting the `writingsuggestions` content attribute to `TrUe` after the IDL attribute was set to `false`.'); 113 testSetAttributeDirectly('false', 'FaLsE', 'false', 'FaLsE', 'Test setting the `writingsuggestions` content attribute to `FaLsE` after the IDL attribute was set to `false`.'); 114 testSetAttributeDirectly('false', true, 'true', 'true', 'Test setting the `writingsuggestions` content attribute to boolean `true` after the IDL attribute was set to `false`.'); 115 testSetAttributeDirectly('false', false, 'false', 'false', 'Test setting the `writingsuggestions` content attribute to boolean `false` after the IDL attribute was set to `false`.'); 116 117 test(function() { 118 const elements = [ new DOMParser().parseFromString('<input writingsuggestions />', 'text/html').body.firstElementChild, 119 new DOMParser().parseFromString('<textarea writingsuggestions></textarea>', 'text/html').body.firstElementChild, 120 new DOMParser().parseFromString('<div writingsuggestions></div>', 'text/html').body.firstElementChild, 121 new DOMParser().parseFromString('<span writingsuggestions></span>', 'text/html').body.firstElementChild, 122 new DOMParser().parseFromString('<input type="color" writingsuggestions />', 'text/html').body.firstElementChild, 123 new DOMParser().parseFromString('<textarea disabled writingsuggestions></textarea>', 'text/html').body.firstElementChild ]; 124 125 elements.forEach(function(element) { 126 assert_equals(element.writingSuggestions, 'true'); 127 assert_equals(element.getAttribute('writingsuggestions'), ''); 128 }); 129 }, 'Test setting the `writingsuggestions` attribute with a missing value directly on the target element.'); 130 131 test(function() { 132 const elements = [ new DOMParser().parseFromString('<html><body writingsuggestions="true"><input /></body></html>', 'text/html').body.firstElementChild, 133 new DOMParser().parseFromString('<html><body writingsuggestions="true"><textarea></textarea></body></html>', 'text/html').body.firstElementChild, 134 new DOMParser().parseFromString('<html><body writingsuggestions="true"><div></div></body></html>', 'text/html').body.firstElementChild, 135 new DOMParser().parseFromString('<html><body writingsuggestions="true"><span></span></body></html>', 'text/html').body.firstElementChild, 136 new DOMParser().parseFromString('<html><body writingsuggestions="true"><input type="color"/></body></html>', 'text/html').body.firstElementChild, 137 new DOMParser().parseFromString('<html><body writingsuggestions="true"><textarea disabled></textarea></body></html>', 'text/html').body.firstElementChild ]; 138 139 elements.forEach(function(element) { 140 assert_equals(element.parentElement.writingSuggestions, 'true'); 141 assert_equals(element.parentElement.getAttribute('writingsuggestions'), 'true'); 142 assert_equals(element.writingSuggestions, 'true'); 143 assert_equals(element.getAttribute('writingsuggestions'), null); 144 }); 145 }, 'Test setting the `writingsuggestions` attribute to "true" on a parent element.'); 146 147 test(function() { 148 const elements = [ new DOMParser().parseFromString('<html><body writingsuggestions=""><input /></body></html>', 'text/html').body.firstElementChild, 149 new DOMParser().parseFromString('<html><body writingsuggestions=""><textarea></textarea></body></html>', 'text/html').body.firstElementChild, 150 new DOMParser().parseFromString('<html><body writingsuggestions=""><div></div></body></html>', 'text/html').body.firstElementChild, 151 new DOMParser().parseFromString('<html><body writingsuggestions=""><span></span></body></html>', 'text/html').body.firstElementChild, 152 new DOMParser().parseFromString('<html><body writingsuggestions=""><input type="color"/></body></html>', 'text/html').body.firstElementChild, 153 new DOMParser().parseFromString('<html><body writingsuggestions=""><textarea disabled></textarea></body></html>', 'text/html').body.firstElementChild ]; 154 155 elements.forEach(function(element) { 156 assert_equals(element.parentElement.writingSuggestions, 'true'); 157 assert_equals(element.parentElement.getAttribute('writingsuggestions'), ''); 158 assert_equals(element.writingSuggestions, 'true'); 159 assert_equals(element.getAttribute('writingsuggestions'), null); 160 }); 161 }, 'Test setting the `writingsuggestions` attribute to an empty string on a parent element.'); 162 163 test(function() { 164 const elements = [ new DOMParser().parseFromString('<html><body writingsuggestions="false"><input /></body></html>', 'text/html').body.firstElementChild, 165 new DOMParser().parseFromString('<html><body writingsuggestions="false"><textarea></textarea></body></html>', 'text/html').body.firstElementChild, 166 new DOMParser().parseFromString('<html><body writingsuggestions="false"><div></div></body></html>', 'text/html').body.firstElementChild, 167 new DOMParser().parseFromString('<html><body writingsuggestions="false"><span></span></body></html>', 'text/html').body.firstElementChild, 168 new DOMParser().parseFromString('<html><body writingsuggestions="false"><input type="color"/></body></html>', 'text/html').body.firstElementChild, 169 new DOMParser().parseFromString('<html><body writingsuggestions="false"><textarea disabled></textarea></body></html>', 'text/html').body.firstElementChild ]; 170 171 elements.forEach(function(element) { 172 assert_equals(element.parentElement.writingSuggestions, 'false'); 173 assert_equals(element.parentElement.getAttribute('writingsuggestions'), 'false'); 174 assert_equals(element.writingSuggestions, 'false'); 175 assert_equals(element.getAttribute('writingsuggestions'), null); 176 }); 177 }, 'Test setting the `writingsuggestions` attribute to "false" on a parent element.'); 178 179 test(function() { 180 const elements = [ new DOMParser().parseFromString('<html><body writingsuggestions="foo"><input /></body></html>', 'text/html').body.firstElementChild, 181 new DOMParser().parseFromString('<html><body writingsuggestions="foo"><textarea></textarea></body></html>', 'text/html').body.firstElementChild, 182 new DOMParser().parseFromString('<html><body writingsuggestions="foo"><div></div></body></html>', 'text/html').body.firstElementChild, 183 new DOMParser().parseFromString('<html><body writingsuggestions="foo"><span></span></body></html>', 'text/html').body.firstElementChild, 184 new DOMParser().parseFromString('<html><body writingsuggestions="foo"><input type="color"/></body></html>', 'text/html').body.firstElementChild, 185 new DOMParser().parseFromString('<html><body writingsuggestions="foo"><textarea disabled></textarea></body></html>', 'text/html').body.firstElementChild ]; 186 187 elements.forEach(function(element) { 188 assert_equals(element.parentElement.writingSuggestions, 'true'); 189 assert_equals(element.parentElement.getAttribute('writingsuggestions'), 'foo'); 190 assert_equals(element.writingSuggestions, 'true'); 191 assert_equals(element.getAttribute('writingsuggestions'), null); 192 }); 193 }, 'Test setting the `writingsuggestions` attribute to an invalid value on a parent element.'); 194 195 test(function() { 196 const elements = [ new DOMParser().parseFromString('<html><body writingsuggestions="true"><input writingsuggestions="false"/></body></html>', 'text/html').body.firstElementChild, 197 new DOMParser().parseFromString('<html><body writingsuggestions="true"><textarea writingsuggestions="false"></textarea></body></html>', 'text/html').body.firstElementChild, 198 new DOMParser().parseFromString('<html><body writingsuggestions="true"><div writingsuggestions="false"></div></body></html>', 'text/html').body.firstElementChild, 199 new DOMParser().parseFromString('<html><body writingsuggestions="true"><span writingsuggestions="false"></span></body></html>', 'text/html').body.firstElementChild, 200 new DOMParser().parseFromString('<html><body writingsuggestions="true"><input type="color" writingsuggestions="false"/></body></html>', 'text/html').body.firstElementChild, 201 new DOMParser().parseFromString('<html><body writingsuggestions="true"><textarea disabled writingsuggestions="false"></textarea></body></html>', 'text/html').body.firstElementChild ]; 202 203 elements.forEach(function(element) { 204 assert_equals(element.parentElement.writingSuggestions, 'true'); 205 assert_equals(element.parentElement.getAttribute('writingsuggestions'), 'true'); 206 assert_equals(element.writingSuggestions, 'false'); 207 assert_equals(element.getAttribute('writingsuggestions'), 'false'); 208 }); 209 }, 'Test overriding the parent element\'s `writingsuggestions` attribute from "true" to "false".'); 210 211 test(function() { 212 const elements = [ new DOMParser().parseFromString('<html><body writingsuggestions=""><input writingsuggestions="false"/></body></html>', 'text/html').body.firstElementChild, 213 new DOMParser().parseFromString('<html><body writingsuggestions=""><textarea writingsuggestions="false"></textarea></body></html>', 'text/html').body.firstElementChild, 214 new DOMParser().parseFromString('<html><body writingsuggestions=""><div writingsuggestions="false"></div></body></html>', 'text/html').body.firstElementChild, 215 new DOMParser().parseFromString('<html><body writingsuggestions=""><span writingsuggestions="false"></span></body></html>', 'text/html').body.firstElementChild, 216 new DOMParser().parseFromString('<html><body writingsuggestions=""><input type="color" writingsuggestions="false"/></body></html>', 'text/html').body.firstElementChild, 217 new DOMParser().parseFromString('<html><body writingsuggestions=""><textarea disabled writingsuggestions="false"></textarea></body></html>', 'text/html').body.firstElementChild ]; 218 219 elements.forEach(function(element) { 220 assert_equals(element.parentElement.writingSuggestions, 'true'); 221 assert_equals(element.parentElement.getAttribute('writingsuggestions'), ''); 222 assert_equals(element.writingSuggestions, 'false'); 223 assert_equals(element.getAttribute('writingsuggestions'), 'false'); 224 }); 225 }, 'Test overriding the parent element\'s `writingsuggestions` attribute from the empty string to "false".'); 226 227 test(function() { 228 const elements = [ new DOMParser().parseFromString('<html><body writingsuggestions="false"><input writingsuggestions="true" /></body></html>', 'text/html').body.firstElementChild, 229 new DOMParser().parseFromString('<html><body writingsuggestions="false"><textarea writingsuggestions="true"></textarea></body></html>', 'text/html').body.firstElementChild, 230 new DOMParser().parseFromString('<html><body writingsuggestions="false"><div writingsuggestions="true"></div></body></html>', 'text/html').body.firstElementChild, 231 new DOMParser().parseFromString('<html><body writingsuggestions="false"><span writingsuggestions="true"></span></body></html>', 'text/html').body.firstElementChild, 232 new DOMParser().parseFromString('<html><body writingsuggestions="false"><input type="color" writingsuggestions="true"/></body></html>', 'text/html').body.firstElementChild, 233 new DOMParser().parseFromString('<html><body writingsuggestions="false"><textarea disabled writingsuggestions="true"></textarea></body></html>', 'text/html').body.firstElementChild, ]; 234 235 elements.forEach(function(element) { 236 assert_equals(element.parentElement.writingSuggestions, 'false'); 237 assert_equals(element.parentElement.getAttribute('writingsuggestions'), 'false'); 238 assert_equals(element.writingSuggestions, 'true'); 239 assert_equals(element.getAttribute('writingsuggestions'), 'true'); 240 }); 241 }, 'Test overriding the parent element\'s `writingsuggestions` attribute from "false" to "true".'); 242 243 test(function() { 244 const elements = [ new DOMParser().parseFromString('<html><body writingsuggestions="false"><input writingsuggestions="foo" /></body></html>', 'text/html').body.firstElementChild, 245 new DOMParser().parseFromString('<html><body writingsuggestions="false"><textarea writingsuggestions="foo"></textarea></body></html>', 'text/html').body.firstElementChild, 246 new DOMParser().parseFromString('<html><body writingsuggestions="false"><div writingsuggestions="foo"></div></body></html>', 'text/html').body.firstElementChild, 247 new DOMParser().parseFromString('<html><body writingsuggestions="false"><span writingsuggestions="foo"></span></body></html>', 'text/html').body.firstElementChild, 248 new DOMParser().parseFromString('<html><body writingsuggestions="false"><input type="color" writingsuggestions="foo"/></body></html>', 'text/html').body.firstElementChild, 249 new DOMParser().parseFromString('<html><body writingsuggestions="false"><textarea disabled writingsuggestions="foo"></textarea></body></html>', 'text/html').body.firstElementChild ]; 250 251 elements.forEach(function(element) { 252 assert_equals(element.parentElement.writingSuggestions, 'false'); 253 assert_equals(element.parentElement.getAttribute('writingsuggestions'), 'false'); 254 assert_equals(element.writingSuggestions, 'true'); 255 assert_equals(element.getAttribute('writingsuggestions'), 'foo'); 256 }); 257 }, 'Test overriding the parent element\'s `writingsuggestions` attribute from "false" to an invalid value.'); 258 259 test(function() { 260 const elements = [ new DOMParser().parseFromString('<html><body writingsuggestions="false"><input writingsuggestions="" /></body></html>', 'text/html').body.firstElementChild, 261 new DOMParser().parseFromString('<html><body writingsuggestions="false"><textarea writingsuggestions=""></textarea></body></html>', 'text/html').body.firstElementChild, 262 new DOMParser().parseFromString('<html><body writingsuggestions="false"><div writingsuggestions=""></div></body></html>', 'text/html').body.firstElementChild, 263 new DOMParser().parseFromString('<html><body writingsuggestions="false"><span writingsuggestions=""></span></body></html>', 'text/html').body.firstElementChild, 264 new DOMParser().parseFromString('<html><body writingsuggestions="false"><input type="color" writingsuggestions=""/></body></html>', 'text/html').body.firstElementChild, 265 new DOMParser().parseFromString('<html><body writingsuggestions="false"><textarea disabled writingsuggestions=""></textarea></body></html>', 'text/html').body.firstElementChild ]; 266 267 elements.forEach(function(element) { 268 assert_equals(element.parentElement.writingSuggestions, 'false'); 269 assert_equals(element.parentElement.getAttribute('writingsuggestions'), 'false'); 270 assert_equals(element.writingSuggestions, 'true'); 271 assert_equals(element.getAttribute('writingsuggestions'), ''); 272 }); 273 }, 'Test overriding the parent element\'s `writingsuggestions` attribute from "false" to the empty string.'); 274 275 test(function() { 276 const doc = new DOMParser().parseFromString('<html writingsuggestions="false"><body><input /><textarea></textarea><div></div><span></span><input type="color"/><textarea disabled></textarea></body></html>', 'text/html'); 277 assert_equals(doc.documentElement.writingSuggestions, 'false'); 278 assert_equals(doc.body.writingSuggestions, 'false'); 279 assert_equals(doc.querySelectorAll('input')[0].writingSuggestions, 'false'); 280 assert_equals(doc.querySelectorAll('textarea')[0].writingSuggestions, 'false'); 281 assert_equals(doc.querySelector('div').writingSuggestions, 'false'); 282 assert_equals(doc.querySelector('span').writingSuggestions, 'false'); 283 assert_equals(doc.querySelectorAll('input')[1].writingSuggestions, 'false'); 284 assert_equals(doc.querySelectorAll('textarea')[1].writingSuggestions, 'false'); 285 }, 'Test turning off writing suggestions for an entire document.'); 286 287 test(function() { 288 const doc = new DOMParser().parseFromString('<html writingsuggestions="false"><body><input writingsuggestions="true" /><textarea></textarea><div></div><span></span></body></html>', 'text/html'); 289 assert_equals(doc.documentElement.writingSuggestions, 'false'); 290 assert_equals(doc.body.writingSuggestions, 'false'); 291 assert_equals(doc.querySelector('input').writingSuggestions, 'true'); 292 assert_equals(doc.querySelector('textarea').writingSuggestions, 'false'); 293 assert_equals(doc.querySelector('div').writingSuggestions, 'false'); 294 assert_equals(doc.querySelector('span').writingSuggestions, 'false'); 295 }, 'Test overriding a non-parent ancestor element\'s `writingsuggestions` attribute on an input element from "false" to "true".'); 296 297 test(function() { 298 const doc = new DOMParser().parseFromString('<html writingsuggestions="false"><body><input /><textarea writingsuggestions="true"></textarea><div></div><span></span></body></html>', 'text/html'); 299 assert_equals(doc.documentElement.writingSuggestions, 'false'); 300 assert_equals(doc.body.writingSuggestions, 'false'); 301 assert_equals(doc.querySelector('input').writingSuggestions, 'false'); 302 assert_equals(doc.querySelector('textarea').writingSuggestions, 'true'); 303 assert_equals(doc.querySelector('div').writingSuggestions, 'false'); 304 assert_equals(doc.querySelector('span').writingSuggestions, 'false'); 305 }, 'Test overriding a non-parent ancestor element\'s `writingsuggestions` attribute on a textarea element from "false" to "true".'); 306 307 test(function() { 308 const doc = new DOMParser().parseFromString('<html writingsuggestions="false"><body><input /><textarea></textarea><div writingsuggestions="true"></div><span></span></body></html>', 'text/html'); 309 assert_equals(doc.documentElement.writingSuggestions, 'false'); 310 assert_equals(doc.body.writingSuggestions, 'false'); 311 assert_equals(doc.querySelector('input').writingSuggestions, 'false'); 312 assert_equals(doc.querySelector('textarea').writingSuggestions, 'false'); 313 assert_equals(doc.querySelector('div').writingSuggestions, 'true'); 314 assert_equals(doc.querySelector('span').writingSuggestions, 'false'); 315 }, 'Test overriding a non-parent ancestor element\'s `writingsuggestions` attribute on a div element from "false" to "true".'); 316 317 test(function() { 318 const doc = new DOMParser().parseFromString('<html writingsuggestions="false"><body><input /><textarea></textarea><div></div><span writingsuggestions="true"></span></body></html>', 'text/html'); 319 assert_equals(doc.documentElement.writingSuggestions, 'false'); 320 assert_equals(doc.body.writingSuggestions, 'false'); 321 assert_equals(doc.querySelector('input').writingSuggestions, 'false'); 322 assert_equals(doc.querySelector('textarea').writingSuggestions, 'false'); 323 assert_equals(doc.querySelector('div').writingSuggestions, 'false'); 324 assert_equals(doc.querySelector('span').writingSuggestions, 'true'); 325 }, 'Test overriding a non-parent ancestor element\'s `writingsuggestions` attribute on a span element from "false" to "true".'); 326 327 test(function() { 328 const doc = new DOMParser().parseFromString('<html writingsuggestions="false"><body><input type="color" writingsuggestions="true"><textarea></textarea><div></div><span></span></body></html>', 'text/html'); 329 assert_equals(doc.documentElement.writingSuggestions, 'false'); 330 assert_equals(doc.body.writingSuggestions, 'false'); 331 assert_equals(doc.querySelector('input').writingSuggestions, 'true'); 332 assert_equals(doc.querySelector('textarea').writingSuggestions, 'false'); 333 assert_equals(doc.querySelector('div').writingSuggestions, 'false'); 334 assert_equals(doc.querySelector('span').writingSuggestions, 'false'); 335 }, 'Test overriding a non-parent ancestor element\'s `writingsuggestions` attribute on an input type which the attribute doesn\'t apply from "false" to "true". The User Agent is responsible that writing suggestions are not applied to the element'); 336 337 test(function() { 338 const doc = new DOMParser().parseFromString('<html writingsuggestions="false"><body><input><textarea disabled writingsuggestions="true"></textarea><div></div><span></span></body></html>', 'text/html'); 339 assert_equals(doc.documentElement.writingSuggestions, 'false'); 340 assert_equals(doc.body.writingSuggestions, 'false'); 341 assert_equals(doc.querySelector('input').writingSuggestions, 'false'); 342 assert_equals(doc.querySelector('textarea').writingSuggestions, 'true'); 343 assert_equals(doc.querySelector('div').writingSuggestions, 'false'); 344 assert_equals(doc.querySelector('span').writingSuggestions, 'false'); 345 }, 'Test overriding a non-parent ancestor element\'s `writingsuggestions` attribute on a disabled textarea element from "false" to "true". The User Agent is responsible that writing suggestions are not applied to the element'); 346 347 test(function() { 348 const doc = new DOMParser().parseFromString('<html writingsuggestions="false"><body><input writingsuggestions=""><textarea></textarea><div></div><span></span></body></html>', 'text/html'); 349 assert_equals(doc.documentElement.writingSuggestions, 'false'); 350 assert_equals(doc.body.writingSuggestions, 'false'); 351 assert_equals(doc.querySelector('input').writingSuggestions, 'true'); 352 assert_equals(doc.querySelector('textarea').writingSuggestions, 'false'); 353 assert_equals(doc.querySelector('div').writingSuggestions, 'false'); 354 assert_equals(doc.querySelector('span').writingSuggestions, 'false'); 355 }, 'Test overriding a non-parent ancestor element\'s `writingsuggestions` attribute on an input element from "false" to the empty string.'); 356 357 test(function() { 358 const doc = new DOMParser().parseFromString('<html writingsuggestions="false"><body><input><textarea writingsuggestions=""></textarea><div></div><span></span></body></html>', 'text/html'); 359 assert_equals(doc.documentElement.writingSuggestions, 'false'); 360 assert_equals(doc.body.writingSuggestions, 'false'); 361 assert_equals(doc.querySelector('input').writingSuggestions, 'false'); 362 assert_equals(doc.querySelector('textarea').writingSuggestions, 'true'); 363 assert_equals(doc.querySelector('div').writingSuggestions, 'false'); 364 assert_equals(doc.querySelector('span').writingSuggestions, 'false'); 365 }, 'Test overriding a non-parent ancestor element\'s `writingsuggestions` attribute on a textarea element from "false" to the empty string.'); 366 367 test(function() { 368 const doc = new DOMParser().parseFromString('<html writingsuggestions="false"><body><input><textarea></textarea><div writingsuggestions=""></div><span></span></body></html>', 'text/html'); 369 assert_equals(doc.documentElement.writingSuggestions, 'false'); 370 assert_equals(doc.body.writingSuggestions, 'false'); 371 assert_equals(doc.querySelector('input').writingSuggestions, 'false'); 372 assert_equals(doc.querySelector('textarea').writingSuggestions, 'false'); 373 assert_equals(doc.querySelector('div').writingSuggestions, 'true'); 374 assert_equals(doc.querySelector('span').writingSuggestions, 'false'); 375 }, 'Test overriding a non-parent ancestor element\'s `writingsuggestions` attribute on a div element from "false" to the empty string.'); 376 377 test(function() { 378 const doc = new DOMParser().parseFromString('<html writingsuggestions="false"><body><input><textarea></textarea><div></div><span writingsuggestions=""></span></body></html>', 'text/html'); 379 assert_equals(doc.documentElement.writingSuggestions, 'false'); 380 assert_equals(doc.body.writingSuggestions, 'false'); 381 assert_equals(doc.querySelector('input').writingSuggestions, 'false'); 382 assert_equals(doc.querySelector('textarea').writingSuggestions, 'false'); 383 assert_equals(doc.querySelector('div').writingSuggestions, 'false'); 384 assert_equals(doc.querySelector('span').writingSuggestions, 'true'); 385 }, 'Test overriding a non-parent ancestor element\'s `writingsuggestions` attribute on a span element from "false" to the empty string.'); 386 387 test(function() { 388 const doc = new DOMParser().parseFromString('<html writingsuggestions="false"><body><input type="color" writingsuggestions=""><textarea></textarea><div></div><span></span></body></html>', 'text/html'); 389 assert_equals(doc.documentElement.writingSuggestions, 'false'); 390 assert_equals(doc.body.writingSuggestions, 'false'); 391 assert_equals(doc.querySelector('input').writingSuggestions, 'true'); 392 assert_equals(doc.querySelector('textarea').writingSuggestions, 'false'); 393 assert_equals(doc.querySelector('div').writingSuggestions, 'false'); 394 assert_equals(doc.querySelector('span').writingSuggestions, 'false'); 395 }, 'Test overriding a non-parent ancestor element\'s `writingsuggestions` attribute on an input type which the attribute doesn\'t apply from "false" to the empty string. The User Agent is responsible that writing suggestions are not applied to the element.'); 396 397 test(function() { 398 const doc = new DOMParser().parseFromString('<html writingsuggestions="false"><body><input><textarea disabled writingsuggestions=""></textarea><div></div><span></span></body></html>', 'text/html'); 399 assert_equals(doc.documentElement.writingSuggestions, 'false'); 400 assert_equals(doc.body.writingSuggestions, 'false'); 401 assert_equals(doc.querySelector('input').writingSuggestions, 'false'); 402 assert_equals(doc.querySelector('textarea').writingSuggestions, 'true'); 403 assert_equals(doc.querySelector('div').writingSuggestions, 'false'); 404 assert_equals(doc.querySelector('span').writingSuggestions, 'false'); 405 }, 'Test overriding a non-parent ancestor element\'s `writingsuggestions` attribute on a disabled textarea element from "false" to the empty string. The User Agent is responsible that writing suggestions are not applied to the element.'); 406 407 test(function() { 408 const doc = new DOMParser().parseFromString('<html writingsuggestions="false"><body><input writingsuggestions="foo"><textarea></textarea><div></div><span></span></body></html>', 'text/html'); 409 assert_equals(doc.documentElement.writingSuggestions, 'false'); 410 assert_equals(doc.body.writingSuggestions, 'false'); 411 assert_equals(doc.querySelector('input').writingSuggestions, 'true'); 412 assert_equals(doc.querySelector('textarea').writingSuggestions, 'false'); 413 assert_equals(doc.querySelector('div').writingSuggestions, 'false'); 414 assert_equals(doc.querySelector('span').writingSuggestions, 'false'); 415 }, 'Test overriding a non-parent ancestor element\'s `writingsuggestions` attribute on an input element from "false" to an invalid value.'); 416 417 test(function() { 418 const doc = new DOMParser().parseFromString('<html writingsuggestions="false"><body><input><textarea writingsuggestions="foo"></textarea><div></div><span></span></body></html>', 'text/html'); 419 assert_equals(doc.documentElement.writingSuggestions, 'false'); 420 assert_equals(doc.body.writingSuggestions, 'false'); 421 assert_equals(doc.querySelector('input').writingSuggestions, 'false'); 422 assert_equals(doc.querySelector('textarea').writingSuggestions, 'true'); 423 assert_equals(doc.querySelector('div').writingSuggestions, 'false'); 424 assert_equals(doc.querySelector('span').writingSuggestions, 'false'); 425 }, 'Test overriding a non-parent ancestor element\'s `writingsuggestions` attribute on a textarea element from "false" to an invalid value.'); 426 427 test(function() { 428 const doc = new DOMParser().parseFromString('<html writingsuggestions="false"><body><input><textarea></textarea><div writingsuggestions="foo"></div><span></span></body></html>', 'text/html'); 429 assert_equals(doc.documentElement.writingSuggestions, 'false'); 430 assert_equals(doc.body.writingSuggestions, 'false'); 431 assert_equals(doc.querySelector('input').writingSuggestions, 'false'); 432 assert_equals(doc.querySelector('textarea').writingSuggestions, 'false'); 433 assert_equals(doc.querySelector('div').writingSuggestions, 'true'); 434 assert_equals(doc.querySelector('span').writingSuggestions, 'false'); 435 }, 'Test overriding a non-parent ancestor element\'s `writingsuggestions` attribute on a div element from "false" to an invalid value.'); 436 437 test(function() { 438 const doc = new DOMParser().parseFromString('<html writingsuggestions="false"><body><input><textarea></textarea><div></div><span writingsuggestions="foo"></span></body></html>', 'text/html'); 439 assert_equals(doc.documentElement.writingSuggestions, 'false'); 440 assert_equals(doc.body.writingSuggestions, 'false'); 441 assert_equals(doc.querySelector('input').writingSuggestions, 'false'); 442 assert_equals(doc.querySelector('textarea').writingSuggestions, 'false'); 443 assert_equals(doc.querySelector('div').writingSuggestions, 'false'); 444 assert_equals(doc.querySelector('span').writingSuggestions, 'true'); 445 }, 'Test overriding a non-parent ancestor element\'s `writingsuggestions` attribute on a span element from "false" to an invalid value.'); 446 447 test(function() { 448 const doc = new DOMParser().parseFromString('<html writingsuggestions="false"><body><input type="color" writingsuggestions="foo"><textarea></textarea><div></div><span></span></body></html>', 'text/html'); 449 assert_equals(doc.documentElement.writingSuggestions, 'false'); 450 assert_equals(doc.body.writingSuggestions, 'false'); 451 assert_equals(doc.querySelector('input').writingSuggestions, 'true'); 452 assert_equals(doc.querySelector('textarea').writingSuggestions, 'false'); 453 assert_equals(doc.querySelector('div').writingSuggestions, 'false'); 454 assert_equals(doc.querySelector('span').writingSuggestions, 'false'); 455 }, 'Test overriding a non-parent ancestor element\'s `writingsuggestions` attribute on an input type which the attribute doesn\'t apply from "false" to an invalid value. The User Agent is responsible that writing suggestions are not applied to the element.'); 456 457 test(function() { 458 const doc = new DOMParser().parseFromString('<html writingsuggestions="false"><body><input><textarea disabled writingsuggestions="foo"></textarea><div></div><span></span></body></html>', 'text/html'); 459 assert_equals(doc.documentElement.writingSuggestions, 'false'); 460 assert_equals(doc.body.writingSuggestions, 'false'); 461 assert_equals(doc.querySelector('input').writingSuggestions, 'false'); 462 assert_equals(doc.querySelector('textarea').writingSuggestions, 'true'); 463 assert_equals(doc.querySelector('div').writingSuggestions, 'false'); 464 assert_equals(doc.querySelector('span').writingSuggestions, 'false'); 465 }, 'Test overriding a non-parent ancestor element\'s `writingsuggestions` attribute on a disabled textarea element from "false" to an invalid value. The User Agent is responsible that writing suggestions are not applied to the element.'); 466 467 test(function() { 468 const doc = new DOMParser().parseFromString('<html writingsuggestions="true"><body><input writingsuggestions="false"><textarea></textarea><div></div><span></span></body></html>', 'text/html'); 469 assert_equals(doc.documentElement.writingSuggestions, 'true'); 470 assert_equals(doc.body.writingSuggestions, 'true'); 471 assert_equals(doc.querySelector('input').writingSuggestions, 'false'); 472 assert_equals(doc.querySelector('textarea').writingSuggestions, 'true'); 473 assert_equals(doc.querySelector('div').writingSuggestions, 'true'); 474 assert_equals(doc.querySelector('span').writingSuggestions, 'true'); 475 }, 'Test overriding a non-parent ancestor element\'s `writingsuggestions` attribute on an input element from "true" to "false".'); 476 477 test(function() { 478 const doc = new DOMParser().parseFromString('<html writingsuggestions="true"><body><input><textarea writingsuggestions="false"></textarea><div></div><span></span></body></html>', 'text/html'); 479 assert_equals(doc.documentElement.writingSuggestions, 'true'); 480 assert_equals(doc.body.writingSuggestions, 'true'); 481 assert_equals(doc.querySelector('input').writingSuggestions, 'true'); 482 assert_equals(doc.querySelector('textarea').writingSuggestions, 'false'); 483 assert_equals(doc.querySelector('div').writingSuggestions, 'true'); 484 assert_equals(doc.querySelector('span').writingSuggestions, 'true'); 485 }, 'Test overriding a non-parent ancestor element\'s `writingsuggestions` attribute on a textarea element from "true" to "false".'); 486 487 test(function() { 488 const doc = new DOMParser().parseFromString('<html writingsuggestions="true"><body><input><textarea></textarea><div writingsuggestions="false"></div><span></span></body></html>', 'text/html'); 489 assert_equals(doc.documentElement.writingSuggestions, 'true'); 490 assert_equals(doc.body.writingSuggestions, 'true'); 491 assert_equals(doc.querySelector('input').writingSuggestions, 'true'); 492 assert_equals(doc.querySelector('textarea').writingSuggestions, 'true'); 493 assert_equals(doc.querySelector('div').writingSuggestions, 'false'); 494 assert_equals(doc.querySelector('span').writingSuggestions, 'true'); 495 }, 'Test overriding a non-parent ancestor element\'s `writingsuggestions` attribute on a div element from "true" to "false".'); 496 497 test(function() { 498 const doc = new DOMParser().parseFromString('<html writingsuggestions="true"><body><input><textarea></textarea><div></div><span writingsuggestions="false"></span></body></html>', 'text/html'); 499 assert_equals(doc.documentElement.writingSuggestions, 'true'); 500 assert_equals(doc.body.writingSuggestions, 'true'); 501 assert_equals(doc.querySelector('input').writingSuggestions, 'true'); 502 assert_equals(doc.querySelector('textarea').writingSuggestions, 'true'); 503 assert_equals(doc.querySelector('div').writingSuggestions, 'true'); 504 assert_equals(doc.querySelector('span').writingSuggestions, 'false'); 505 }, 'Test overriding a non-parent ancestor element\'s `writingsuggestions` attribute on a span element from "true" to "false".'); 506 507 test(function() { 508 const doc = new DOMParser().parseFromString('<html writingsuggestions="true"><body><input type="color" writingsuggestions="false"><textarea></textarea><div></div><span></span></body></html>', 'text/html'); 509 assert_equals(doc.documentElement.writingSuggestions, 'true'); 510 assert_equals(doc.body.writingSuggestions, 'true'); 511 assert_equals(doc.querySelector('input').writingSuggestions, 'false'); 512 assert_equals(doc.querySelector('textarea').writingSuggestions, 'true'); 513 assert_equals(doc.querySelector('div').writingSuggestions, 'true'); 514 assert_equals(doc.querySelector('span').writingSuggestions, 'true'); 515 }, 'Test overriding a non-parent ancestor element\'s `writingsuggestions` attribute on an input type which the attribute doesn\'t apply from "true" to "false". The User Agent is responsible that writing suggestions are not applied to the element.'); 516 517 test(function() { 518 const doc = new DOMParser().parseFromString('<html writingsuggestions="true"><body><input><textarea disabled writingsuggestions="false"></textarea><div></div><span></span></body></html>', 'text/html'); 519 assert_equals(doc.documentElement.writingSuggestions, 'true'); 520 assert_equals(doc.body.writingSuggestions, 'true'); 521 assert_equals(doc.querySelector('input').writingSuggestions, 'true'); 522 assert_equals(doc.querySelector('textarea').writingSuggestions, 'false'); 523 assert_equals(doc.querySelector('div').writingSuggestions, 'true'); 524 assert_equals(doc.querySelector('span').writingSuggestions, 'true'); 525 }, 'Test overriding a non-parent ancestor element\'s `writingsuggestions` attribute on a disabled textarea element from "true" to "false". The User Agent is responsible that writing suggestions are not applied to the element.'); 526 527 test(function() { 528 const doc = new DOMParser().parseFromString('<html writingsuggestions=""><body><input writingsuggestions="false"><textarea></textarea><div></div><span></span></body></html>', 'text/html'); 529 assert_equals(doc.documentElement.writingSuggestions, 'true'); 530 assert_equals(doc.body.writingSuggestions, 'true'); 531 assert_equals(doc.querySelector('input').writingSuggestions, 'false'); 532 assert_equals(doc.querySelector('textarea').writingSuggestions, 'true'); 533 assert_equals(doc.querySelector('div').writingSuggestions, 'true'); 534 assert_equals(doc.querySelector('span').writingSuggestions, 'true'); 535 }, 'Test overriding a non-parent ancestor element\'s `writingsuggestions` attribute on an input element from the empty string to "false".'); 536 537 test(function() { 538 const doc = new DOMParser().parseFromString('<html writingsuggestions=""><body><input><textarea writingsuggestions="false"></textarea><div></div><span></span></body></html>', 'text/html'); 539 assert_equals(doc.documentElement.writingSuggestions, 'true'); 540 assert_equals(doc.body.writingSuggestions, 'true'); 541 assert_equals(doc.querySelector('input').writingSuggestions, 'true'); 542 assert_equals(doc.querySelector('textarea').writingSuggestions, 'false'); 543 assert_equals(doc.querySelector('div').writingSuggestions, 'true'); 544 assert_equals(doc.querySelector('span').writingSuggestions, 'true'); 545 }, 'Test overriding a non-parent ancestor element\'s `writingsuggestions` attribute on a textarea element from the empty string to "false".'); 546 547 test(function() { 548 const doc = new DOMParser().parseFromString('<html writingsuggestions=""><body><input><textarea></textarea><div writingsuggestions="false"></div><span></span></body></html>', 'text/html'); 549 assert_equals(doc.documentElement.writingSuggestions, 'true'); 550 assert_equals(doc.body.writingSuggestions, 'true'); 551 assert_equals(doc.querySelector('input').writingSuggestions, 'true'); 552 assert_equals(doc.querySelector('textarea').writingSuggestions, 'true'); 553 assert_equals(doc.querySelector('div').writingSuggestions, 'false'); 554 assert_equals(doc.querySelector('span').writingSuggestions, 'true'); 555 }, 'Test overriding a non-parent ancestor element\'s `writingsuggestions` attribute on a div element from the empty string to "false".'); 556 557 test(function() { 558 const doc = new DOMParser().parseFromString('<html writingsuggestions=""><body><input><textarea></textarea><div></div><span writingsuggestions="false"></span></body></html>', 'text/html'); 559 assert_equals(doc.documentElement.writingSuggestions, 'true'); 560 assert_equals(doc.body.writingSuggestions, 'true'); 561 assert_equals(doc.querySelector('input').writingSuggestions, 'true'); 562 assert_equals(doc.querySelector('textarea').writingSuggestions, 'true'); 563 assert_equals(doc.querySelector('div').writingSuggestions, 'true'); 564 assert_equals(doc.querySelector('span').writingSuggestions, 'false'); 565 }, 'Test overriding a non-parent ancestor element\'s `writingsuggestions` attribute on a span element from the empty string to "false".'); 566 567 test(function() { 568 const doc = new DOMParser().parseFromString('<html writingsuggestions=""><body><input type="color" writingsuggestions="false"><textarea></textarea><div></div><span></span></body></html>', 'text/html'); 569 assert_equals(doc.documentElement.writingSuggestions, 'true'); 570 assert_equals(doc.body.writingSuggestions, 'true'); 571 assert_equals(doc.querySelector('input').writingSuggestions, 'false'); 572 assert_equals(doc.querySelector('textarea').writingSuggestions, 'true'); 573 assert_equals(doc.querySelector('div').writingSuggestions, 'true'); 574 assert_equals(doc.querySelector('span').writingSuggestions, 'true'); 575 }, 'Test overriding a non-parent ancestor element\'s `writingsuggestions` attribute on an input type which the attribute doesn\'t apply from the empty string to "false". The User Agent is responsible that writing suggestions are not applied to the element.'); 576 577 test(function() { 578 const doc = new DOMParser().parseFromString('<html writingsuggestions=""><body><input><textarea disabled writingsuggestions="false"></textarea><div></div><span></span></body></html>', 'text/html'); 579 assert_equals(doc.documentElement.writingSuggestions, 'true'); 580 assert_equals(doc.body.writingSuggestions, 'true'); 581 assert_equals(doc.querySelector('input').writingSuggestions, 'true'); 582 assert_equals(doc.querySelector('textarea').writingSuggestions, 'false'); 583 assert_equals(doc.querySelector('div').writingSuggestions, 'true'); 584 assert_equals(doc.querySelector('span').writingSuggestions, 'true'); 585 }, 'Test overriding a non-parent ancestor element\'s `writingsuggestions` attribute on a disabled textarea element from the empty string to "false". The User Agent is responsible that writing suggestions are not applied to the element.'); 586 587 test(function() { 588 const doc = new DOMParser().parseFromString('<html writingsuggestions="true"><body><div contenteditable="true"><span>Writing suggestions allowed.</span> <span writingsuggestions="false">Writing suggestions not allowed.</span></div></body></html>', 'text/html'); 589 const div = doc.querySelector('div'); 590 const span1 = doc.querySelector('span'); 591 const span2 = doc.querySelector('span:last-child'); 592 assert_equals(div.writingSuggestions, 'true'); 593 assert_equals(span1.writingSuggestions, 'true'); 594 assert_equals(span2.writingSuggestions, 'false'); 595 }, 'Test that for continuous text on the screen, writing suggestions may be allowed in one part but not another.'); 596 597 </script> 598 </body> 599 </html>