| Index: LayoutTests/fast/forms/reportValidity-handler-updates-dom.html
|
| diff --git a/LayoutTests/fast/forms/checkValidity-handler-updates-dom.html b/LayoutTests/fast/forms/reportValidity-handler-updates-dom.html
|
| similarity index 65%
|
| copy from LayoutTests/fast/forms/checkValidity-handler-updates-dom.html
|
| copy to LayoutTests/fast/forms/reportValidity-handler-updates-dom.html
|
| index 5d495e492eac886fcc42c39fa1aae49bd7bb0a6c..486460e96b01845aa8aaace05ed584e1b6c145bc 100644
|
| --- a/LayoutTests/fast/forms/checkValidity-handler-updates-dom.html
|
| +++ b/LayoutTests/fast/forms/reportValidity-handler-updates-dom.html
|
| @@ -2,12 +2,22 @@
|
| <html>
|
| <head>
|
| <script src="../../resources/js-test.js"></script>
|
| +<style>
|
| +:focus { background: rgb(0, 255, 0); }
|
| +:not(:focus) { background: rgb(255, 0, 0); }
|
| +</style>
|
| </head>
|
| <body>
|
| <p id="description"></p>
|
| <div id="console"></div>
|
| <script>
|
| -description('HTMLFormElement::checkValidity() with cases that event handlers called by checkValidity() updates DOM structure.')
|
| +function backgroundOf(id) {
|
| + return document.defaultView.getComputedStyle(document.getElementById(id), null).getPropertyValue('background-color');
|
| +}
|
| +var unfocusedColor = 'rgb(255, 0, 0)';
|
| +var focusedColor = 'rgb(0, 255, 0)';
|
| +
|
| +description('HTMLFormElement::reportValidity() with cases that event handlers called by reportValidity() updates DOM structure.')
|
|
|
| var parent = document.createElement('div');
|
| document.body.appendChild(parent);
|
| @@ -21,7 +31,7 @@ var handler = function(event) {
|
| document.getElementById('i').addEventListener('invalid', handler, false);
|
| // The specificiation doesn't define the behavior in this case.
|
| // It's ok if WebKit doesn't crash.
|
| -shouldBeFalse('document.getElementById("f1").checkValidity()');
|
| +shouldBeFalse('document.getElementById("f1").reportValidity()');
|
|
|
| // ----------------------------------------------------------------
|
| debug('');
|
| @@ -36,10 +46,28 @@ var handler2 = function(event) {
|
| handler2Called = true;
|
| };
|
| document.getElementById('i2').addEventListener('invalid', handler2, false);
|
| -shouldBeFalse('document.getElementById("f1").checkValidity()');
|
| +shouldBeFalse('document.getElementById("f1").reportValidity()');
|
| // If the node was removed from the form, i2.checkValidity() is called, but an
|
| // invalid event is not fired because it is not in any documents.
|
| shouldBeFalse('handler2Called');
|
| +shouldBe('backgroundOf("i1")', 'focusedColor');
|
| +
|
| +// ----------------------------------------------------------------
|
| +debug('');
|
| +debug('A control that was checked was removed.');
|
| +parent.innerHTML = '<form id=f1><input name=i1 id=i1 required><input name=i2 id=i2 required></form>';
|
| +var handler1 = function(event) {
|
| + document.getElementById('f1').removeChild(document.getElementById('i1'));
|
| +};
|
| +document.getElementById('i1').addEventListener('invalid', handler1, false);
|
| +var handler2Called = false;
|
| +var handler2 = function(event) {
|
| + handler2Called = true;
|
| +};
|
| +document.getElementById('i2').addEventListener('invalid', handler2, false);
|
| +shouldBeFalse('document.getElementById("f1").reportValidity()');
|
| +shouldBeTrue('handler2Called');
|
| +shouldBe('backgroundOf("i2")', 'focusedColor');
|
|
|
| // ----------------------------------------------------------------
|
| debug('');
|
| @@ -57,9 +85,10 @@ handler1 = function(event) {
|
| document.getElementById('f1').appendChild(input);
|
| };
|
| document.getElementById('i1').addEventListener('invalid', handler1, false);
|
| -shouldBeFalse('document.getElementById("f1").checkValidity()');
|
| -// If a new node is added to the form, checkValidity() doesn't handle it.
|
| +shouldBeFalse('document.getElementById("f1").reportValidity()');
|
| +// If a new node is added to the form, reportValidity() doesn't handle it.
|
| shouldBeFalse('handler2Called');
|
| +shouldBe('backgroundOf("i1")', 'focusedColor');
|
|
|
| // ----------------------------------------------------------------
|
| debug('');
|
| @@ -75,9 +104,10 @@ handler2 = function(event) {
|
| handler2Called = true;
|
| };
|
| document.getElementById('i2').addEventListener('invalid', handler2, false);
|
| -shouldBeFalse('document.getElementById("f1").checkValidity()');
|
| +shouldBeFalse('document.getElementById("f1").reportValidity()');
|
| // The moved control is not checked.
|
| shouldBeFalse('handler2Called');
|
| +shouldBe('backgroundOf("i1")', 'focusedColor');
|
|
|
| // ----------------------------------------------------------------
|
| debug('');
|
| @@ -90,7 +120,7 @@ handler1 = function(event) {
|
| document.getElementById('i1').addEventListener('invalid', handler1, false);
|
| // i1 is not listed in 'unhandled invalid controls' because it was moved to
|
| // another document.
|
| -shouldBeTrue('document.getElementById("f1").checkValidity()');
|
| +shouldBeTrue('document.getElementById("f1").reportValidity()');
|
|
|
| parent.innerHTML = '';
|
| </script>
|
|
|