From 086c044dc34dfc0f74fbe41f4ecb402b2cd34884 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:13:33 +0200 Subject: Merging upstream version 125.0.1. Signed-off-by: Daniel Baumann --- .../writing-suggestions/writingsuggestions.html | 182 ++++++++++++++++++--- 1 file changed, 162 insertions(+), 20 deletions(-) (limited to 'testing/web-platform/tests/html/editing') diff --git a/testing/web-platform/tests/html/editing/editing-0/writing-suggestions/writingsuggestions.html b/testing/web-platform/tests/html/editing/editing-0/writing-suggestions/writingsuggestions.html index 49e75000d3..664659d90a 100644 --- a/testing/web-platform/tests/html/editing/editing-0/writing-suggestions/writingsuggestions.html +++ b/testing/web-platform/tests/html/editing/editing-0/writing-suggestions/writingsuggestions.html @@ -29,13 +29,33 @@ test(function() { assert_true('writingSuggestions' in document.createElement('test-custom-element')); }, 'Test that the writingsuggestions attribute is available on custom elements.'); +test(function() { + let input = document.createElement('input'); + input.type = 'color'; + assert_true('writingSuggestions' in input); +}, '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.'); + +test(function() { + let textarea = document.createElement('textarea'); + textarea.disabled = true; + assert_true('writingSuggestions' in textarea); +}, '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.'); + function testSetAttributeDirectly(IDLValue, contentValue, expectedIDLValue, expectedContentValue, testDescription) { test(function() { + let input_color = document.createElement('input'); + input_color.type = 'color'; + + let disabled_textarea = document.createElement('textarea'); + disabled_textarea.disabled = true; + const elements = [document.createElement('input'), document.createElement('textarea'), document.createElement('div'), document.createElement('span'), - document.createElement('test-custom-element') ]; + document.createElement('test-custom-element'), + disabled_textarea, + input_color ]; elements.forEach(function(element) { if (IDLValue != undefined) { @@ -55,7 +75,7 @@ testSetAttributeDirectly('true', undefined, 'true', 'true', 'Test setting the `w testSetAttributeDirectly(undefined, 'true', 'true', 'true', 'Test setting the `writingsuggestions` content attribute to `true` directly on the target element.'); testSetAttributeDirectly(true, undefined, 'true', 'true', 'Test setting the `writingsuggestions` IDL attribute to boolean `true` directly on the target element.'); testSetAttributeDirectly(undefined, true, 'true', 'true', 'Test setting the `writingsuggestions` content attribute to boolean `true` directly on the target element.'); -testSetAttributeDirectly('TrUe', undefined, 'true', 'true', 'Test setting the `writingsuggestions` IDL attribute to `TrUe` directly on the target element.'); +testSetAttributeDirectly('TrUe', undefined, 'true', 'TrUe', 'Test setting the `writingsuggestions` IDL attribute to `TrUe` directly on the target element.'); testSetAttributeDirectly(undefined, 'TrUe', 'true', 'TrUe', 'Test setting the `writingsuggestions` content attribute to `TrUe` directly on the target element.'); // Test setting either the `writingsuggestions` IDL or content attribute to some variation of 'false' directly on the target element. @@ -63,15 +83,15 @@ testSetAttributeDirectly('false', undefined, 'false', 'false', 'Test setting the testSetAttributeDirectly(undefined, 'false', 'false', 'false', 'Test setting the `writingsuggestions` content attribute to `false` directly on the target element.'); testSetAttributeDirectly(false, undefined, 'false', 'false', 'Test setting the `writingsuggestions` IDL attribute to boolean `false` directly on the target element.'); testSetAttributeDirectly(undefined, false, 'false', 'false', 'Test setting the `writingsuggestions` content attribute to boolean `false` directly on the target element.'); -testSetAttributeDirectly('FaLsE', undefined, 'false', 'false', 'Test setting the `writingsuggestions` IDL attribute to `FaLsE` directly on the target element.'); +testSetAttributeDirectly('FaLsE', undefined, 'false', 'FaLsE', 'Test setting the `writingsuggestions` IDL attribute to `FaLsE` directly on the target element.'); testSetAttributeDirectly(undefined, 'FaLsE', 'false', 'FaLsE', 'Test setting the `writingsuggestions` content attribute to `FaLsE` directly on the target element.'); // Test setting either the `writingsuggestions` IDL or content attribute to the empty string directly on the target element. -testSetAttributeDirectly('', undefined, 'true', 'true', 'Test setting the `writingsuggestions` IDL attribute to the empty string directly on the target element.'); +testSetAttributeDirectly('', undefined, 'true', '', 'Test setting the `writingsuggestions` IDL attribute to the empty string directly on the target element.'); testSetAttributeDirectly(undefined, '', 'true', '', 'Test setting the `writingsuggestions` content attribute to the empty string directly on the target element.'); // Test setting either the `writingsuggestions` IDL or content attribute to an invalid value directly on the target element. -testSetAttributeDirectly('foo', undefined, 'true', 'true', 'Test setting the `writingsuggestions` IDL attribute to an invalid value directly on the target element.'); +testSetAttributeDirectly('foo', undefined, 'true', 'foo', 'Test setting the `writingsuggestions` IDL attribute to an invalid value directly on the target element.'); testSetAttributeDirectly(undefined, 'foo', 'true', 'foo', 'Test setting the `writingsuggestions` content attribute to an invalid value directly on the target element.'); // Test setting neither the `writingsuggestions` IDL nor content attribute directly on the target element. @@ -98,7 +118,9 @@ test(function() { const elements = [ new DOMParser().parseFromString('', 'text/html').body.firstElementChild, new DOMParser().parseFromString('', 'text/html').body.firstElementChild, new DOMParser().parseFromString('
', 'text/html').body.firstElementChild, - new DOMParser().parseFromString('', 'text/html').body.firstElementChild ]; + new DOMParser().parseFromString('', 'text/html').body.firstElementChild, + new DOMParser().parseFromString('', 'text/html').body.firstElementChild, + new DOMParser().parseFromString('', 'text/html').body.firstElementChild ]; elements.forEach(function(element) { assert_equals(element.writingSuggestions, 'true'); @@ -110,7 +132,9 @@ test(function() { const elements = [ new DOMParser().parseFromString('', 'text/html').body.firstElementChild, new DOMParser().parseFromString('', 'text/html').body.firstElementChild, new DOMParser().parseFromString('
', 'text/html').body.firstElementChild, - new DOMParser().parseFromString('', 'text/html').body.firstElementChild ]; + new DOMParser().parseFromString('', 'text/html').body.firstElementChild, + new DOMParser().parseFromString('', 'text/html').body.firstElementChild, + new DOMParser().parseFromString('', 'text/html').body.firstElementChild ]; elements.forEach(function(element) { assert_equals(element.parentElement.writingSuggestions, 'true'); @@ -124,7 +148,9 @@ test(function() { const elements = [ new DOMParser().parseFromString('', 'text/html').body.firstElementChild, new DOMParser().parseFromString('', 'text/html').body.firstElementChild, new DOMParser().parseFromString('
', 'text/html').body.firstElementChild, - new DOMParser().parseFromString('', 'text/html').body.firstElementChild ]; + new DOMParser().parseFromString('', 'text/html').body.firstElementChild, + new DOMParser().parseFromString('', 'text/html').body.firstElementChild, + new DOMParser().parseFromString('', 'text/html').body.firstElementChild ]; elements.forEach(function(element) { assert_equals(element.parentElement.writingSuggestions, 'true'); @@ -138,7 +164,9 @@ test(function() { const elements = [ new DOMParser().parseFromString('', 'text/html').body.firstElementChild, new DOMParser().parseFromString('', 'text/html').body.firstElementChild, new DOMParser().parseFromString('
', 'text/html').body.firstElementChild, - new DOMParser().parseFromString('', 'text/html').body.firstElementChild ]; + new DOMParser().parseFromString('', 'text/html').body.firstElementChild, + new DOMParser().parseFromString('', 'text/html').body.firstElementChild, + new DOMParser().parseFromString('', 'text/html').body.firstElementChild ]; elements.forEach(function(element) { assert_equals(element.parentElement.writingSuggestions, 'false'); @@ -152,7 +180,9 @@ test(function() { const elements = [ new DOMParser().parseFromString('', 'text/html').body.firstElementChild, new DOMParser().parseFromString('', 'text/html').body.firstElementChild, new DOMParser().parseFromString('
', 'text/html').body.firstElementChild, - new DOMParser().parseFromString('', 'text/html').body.firstElementChild ]; + new DOMParser().parseFromString('', 'text/html').body.firstElementChild, + new DOMParser().parseFromString('', 'text/html').body.firstElementChild, + new DOMParser().parseFromString('', 'text/html').body.firstElementChild ]; elements.forEach(function(element) { assert_equals(element.parentElement.writingSuggestions, 'true'); @@ -163,10 +193,12 @@ test(function() { }, 'Test setting the `writingsuggestions` attribute to an invalid value on a parent element.'); test(function() { - const elements = [ new DOMParser().parseFromString('', 'text/html').body.firstElementChild, + const elements = [ new DOMParser().parseFromString('', 'text/html').body.firstElementChild, new DOMParser().parseFromString('', 'text/html').body.firstElementChild, new DOMParser().parseFromString('
', 'text/html').body.firstElementChild, - new DOMParser().parseFromString('', 'text/html').body.firstElementChild ]; + new DOMParser().parseFromString('', 'text/html').body.firstElementChild, + new DOMParser().parseFromString('', 'text/html').body.firstElementChild, + new DOMParser().parseFromString('', 'text/html').body.firstElementChild ]; elements.forEach(function(element) { assert_equals(element.parentElement.writingSuggestions, 'true'); @@ -177,10 +209,12 @@ test(function() { }, 'Test overriding the parent element\'s `writingsuggestions` attribute from "true" to "false".'); test(function() { - const elements = [ new DOMParser().parseFromString('', 'text/html').body.firstElementChild, + const elements = [ new DOMParser().parseFromString('', 'text/html').body.firstElementChild, new DOMParser().parseFromString('', 'text/html').body.firstElementChild, new DOMParser().parseFromString('
', 'text/html').body.firstElementChild, - new DOMParser().parseFromString('', 'text/html').body.firstElementChild ]; + new DOMParser().parseFromString('', 'text/html').body.firstElementChild, + new DOMParser().parseFromString('', 'text/html').body.firstElementChild, + new DOMParser().parseFromString('', 'text/html').body.firstElementChild ]; elements.forEach(function(element) { assert_equals(element.parentElement.writingSuggestions, 'true'); @@ -194,7 +228,9 @@ test(function() { const elements = [ new DOMParser().parseFromString('', 'text/html').body.firstElementChild, new DOMParser().parseFromString('', 'text/html').body.firstElementChild, new DOMParser().parseFromString('
', 'text/html').body.firstElementChild, - new DOMParser().parseFromString('', 'text/html').body.firstElementChild ]; + new DOMParser().parseFromString('', 'text/html').body.firstElementChild, + new DOMParser().parseFromString('', 'text/html').body.firstElementChild, + new DOMParser().parseFromString('', 'text/html').body.firstElementChild, ]; elements.forEach(function(element) { assert_equals(element.parentElement.writingSuggestions, 'false'); @@ -208,7 +244,9 @@ test(function() { const elements = [ new DOMParser().parseFromString('', 'text/html').body.firstElementChild, new DOMParser().parseFromString('', 'text/html').body.firstElementChild, new DOMParser().parseFromString('
', 'text/html').body.firstElementChild, - new DOMParser().parseFromString('', 'text/html').body.firstElementChild ]; + new DOMParser().parseFromString('', 'text/html').body.firstElementChild, + new DOMParser().parseFromString('', 'text/html').body.firstElementChild, + new DOMParser().parseFromString('', 'text/html').body.firstElementChild ]; elements.forEach(function(element) { assert_equals(element.parentElement.writingSuggestions, 'false'); @@ -222,7 +260,9 @@ test(function() { const elements = [ new DOMParser().parseFromString('', 'text/html').body.firstElementChild, new DOMParser().parseFromString('', 'text/html').body.firstElementChild, new DOMParser().parseFromString('
', 'text/html').body.firstElementChild, - new DOMParser().parseFromString('', 'text/html').body.firstElementChild ]; + new DOMParser().parseFromString('', 'text/html').body.firstElementChild, + new DOMParser().parseFromString('', 'text/html').body.firstElementChild, + new DOMParser().parseFromString('', 'text/html').body.firstElementChild ]; elements.forEach(function(element) { assert_equals(element.parentElement.writingSuggestions, 'false'); @@ -233,13 +273,15 @@ test(function() { }, 'Test overriding the parent element\'s `writingsuggestions` attribute from "false" to the empty string.'); test(function() { - const doc = new DOMParser().parseFromString('
', 'text/html'); + const doc = new DOMParser().parseFromString('
', 'text/html'); assert_equals(doc.documentElement.writingSuggestions, 'false'); assert_equals(doc.body.writingSuggestions, 'false'); - assert_equals(doc.querySelector('input').writingSuggestions, 'false'); - assert_equals(doc.querySelector('textarea').writingSuggestions, 'false'); + assert_equals(doc.querySelectorAll('input')[0].writingSuggestions, 'false'); + assert_equals(doc.querySelectorAll('textarea')[0].writingSuggestions, 'false'); assert_equals(doc.querySelector('div').writingSuggestions, 'false'); assert_equals(doc.querySelector('span').writingSuggestions, 'false'); + assert_equals(doc.querySelectorAll('input')[1].writingSuggestions, 'false'); + assert_equals(doc.querySelectorAll('textarea')[1].writingSuggestions, 'false'); }, 'Test turning off writing suggestions for an entire document.'); test(function() { @@ -282,6 +324,26 @@ test(function() { assert_equals(doc.querySelector('span').writingSuggestions, 'true'); }, 'Test overriding a non-parent ancestor element\'s `writingsuggestions` attribute on a span element from "false" to "true".'); +test(function() { + const doc = new DOMParser().parseFromString('
', 'text/html'); + assert_equals(doc.documentElement.writingSuggestions, 'false'); + assert_equals(doc.body.writingSuggestions, 'false'); + assert_equals(doc.querySelector('input').writingSuggestions, 'true'); + assert_equals(doc.querySelector('textarea').writingSuggestions, 'false'); + assert_equals(doc.querySelector('div').writingSuggestions, 'false'); + assert_equals(doc.querySelector('span').writingSuggestions, 'false'); +}, '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'); + +test(function() { + const doc = new DOMParser().parseFromString('
', 'text/html'); + assert_equals(doc.documentElement.writingSuggestions, 'false'); + assert_equals(doc.body.writingSuggestions, 'false'); + assert_equals(doc.querySelector('input').writingSuggestions, 'false'); + assert_equals(doc.querySelector('textarea').writingSuggestions, 'true'); + assert_equals(doc.querySelector('div').writingSuggestions, 'false'); + assert_equals(doc.querySelector('span').writingSuggestions, 'false'); +}, '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'); + test(function() { const doc = new DOMParser().parseFromString('
', 'text/html'); assert_equals(doc.documentElement.writingSuggestions, 'false'); @@ -322,6 +384,26 @@ test(function() { assert_equals(doc.querySelector('span').writingSuggestions, 'true'); }, 'Test overriding a non-parent ancestor element\'s `writingsuggestions` attribute on a span element from "false" to the empty string.'); +test(function() { + const doc = new DOMParser().parseFromString('
', 'text/html'); + assert_equals(doc.documentElement.writingSuggestions, 'false'); + assert_equals(doc.body.writingSuggestions, 'false'); + assert_equals(doc.querySelector('input').writingSuggestions, 'true'); + assert_equals(doc.querySelector('textarea').writingSuggestions, 'false'); + assert_equals(doc.querySelector('div').writingSuggestions, 'false'); + assert_equals(doc.querySelector('span').writingSuggestions, 'false'); +}, '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.'); + +test(function() { + const doc = new DOMParser().parseFromString('
', 'text/html'); + assert_equals(doc.documentElement.writingSuggestions, 'false'); + assert_equals(doc.body.writingSuggestions, 'false'); + assert_equals(doc.querySelector('input').writingSuggestions, 'false'); + assert_equals(doc.querySelector('textarea').writingSuggestions, 'true'); + assert_equals(doc.querySelector('div').writingSuggestions, 'false'); + assert_equals(doc.querySelector('span').writingSuggestions, 'false'); +}, '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.'); + test(function() { const doc = new DOMParser().parseFromString('
', 'text/html'); assert_equals(doc.documentElement.writingSuggestions, 'false'); @@ -362,6 +444,26 @@ test(function() { assert_equals(doc.querySelector('span').writingSuggestions, 'true'); }, 'Test overriding a non-parent ancestor element\'s `writingsuggestions` attribute on a span element from "false" to an invalid value.'); +test(function() { + const doc = new DOMParser().parseFromString('
', 'text/html'); + assert_equals(doc.documentElement.writingSuggestions, 'false'); + assert_equals(doc.body.writingSuggestions, 'false'); + assert_equals(doc.querySelector('input').writingSuggestions, 'true'); + assert_equals(doc.querySelector('textarea').writingSuggestions, 'false'); + assert_equals(doc.querySelector('div').writingSuggestions, 'false'); + assert_equals(doc.querySelector('span').writingSuggestions, 'false'); +}, '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.'); + +test(function() { + const doc = new DOMParser().parseFromString('
', 'text/html'); + assert_equals(doc.documentElement.writingSuggestions, 'false'); + assert_equals(doc.body.writingSuggestions, 'false'); + assert_equals(doc.querySelector('input').writingSuggestions, 'false'); + assert_equals(doc.querySelector('textarea').writingSuggestions, 'true'); + assert_equals(doc.querySelector('div').writingSuggestions, 'false'); + assert_equals(doc.querySelector('span').writingSuggestions, 'false'); +}, '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.'); + test(function() { const doc = new DOMParser().parseFromString('
', 'text/html'); assert_equals(doc.documentElement.writingSuggestions, 'true'); @@ -402,6 +504,26 @@ test(function() { assert_equals(doc.querySelector('span').writingSuggestions, 'false'); }, 'Test overriding a non-parent ancestor element\'s `writingsuggestions` attribute on a span element from "true" to "false".'); +test(function() { + const doc = new DOMParser().parseFromString('
', 'text/html'); + assert_equals(doc.documentElement.writingSuggestions, 'true'); + assert_equals(doc.body.writingSuggestions, 'true'); + assert_equals(doc.querySelector('input').writingSuggestions, 'false'); + assert_equals(doc.querySelector('textarea').writingSuggestions, 'true'); + assert_equals(doc.querySelector('div').writingSuggestions, 'true'); + assert_equals(doc.querySelector('span').writingSuggestions, 'true'); +}, '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.'); + +test(function() { + const doc = new DOMParser().parseFromString('
', 'text/html'); + assert_equals(doc.documentElement.writingSuggestions, 'true'); + assert_equals(doc.body.writingSuggestions, 'true'); + assert_equals(doc.querySelector('input').writingSuggestions, 'true'); + assert_equals(doc.querySelector('textarea').writingSuggestions, 'false'); + assert_equals(doc.querySelector('div').writingSuggestions, 'true'); + assert_equals(doc.querySelector('span').writingSuggestions, 'true'); +}, '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.'); + test(function() { const doc = new DOMParser().parseFromString('
', 'text/html'); assert_equals(doc.documentElement.writingSuggestions, 'true'); @@ -442,6 +564,26 @@ test(function() { assert_equals(doc.querySelector('span').writingSuggestions, 'false'); }, 'Test overriding a non-parent ancestor element\'s `writingsuggestions` attribute on a span element from the empty string to "false".'); +test(function() { + const doc = new DOMParser().parseFromString('
', 'text/html'); + assert_equals(doc.documentElement.writingSuggestions, 'true'); + assert_equals(doc.body.writingSuggestions, 'true'); + assert_equals(doc.querySelector('input').writingSuggestions, 'false'); + assert_equals(doc.querySelector('textarea').writingSuggestions, 'true'); + assert_equals(doc.querySelector('div').writingSuggestions, 'true'); + assert_equals(doc.querySelector('span').writingSuggestions, 'true'); +}, '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.'); + +test(function() { + const doc = new DOMParser().parseFromString('
', 'text/html'); + assert_equals(doc.documentElement.writingSuggestions, 'true'); + assert_equals(doc.body.writingSuggestions, 'true'); + assert_equals(doc.querySelector('input').writingSuggestions, 'true'); + assert_equals(doc.querySelector('textarea').writingSuggestions, 'false'); + assert_equals(doc.querySelector('div').writingSuggestions, 'true'); + assert_equals(doc.querySelector('span').writingSuggestions, 'true'); +}, '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.'); + test(function() { const doc = new DOMParser().parseFromString('
Writing suggestions allowed. Writing suggestions not allowed.
', 'text/html'); const div = doc.querySelector('div'); -- cgit v1.2.3