1 description("This test performs a check that :valid/:invalid CSS psudo selectors are lively applied.");
3 // Setup for static elements.
4 var form = document.createElement('form');
5 document.body.appendChild(form);
6 var nonForm = document.createElement('div');
7 document.body.appendChild(nonForm);
9 function makeInvalid() {
10 var i = document.createElement('input');
18 function backgroundOf(el) {
19 return document.defaultView.getComputedStyle(el, null).getPropertyValue('background-color');
22 var elBackground = 'backgroundOf(el)';
23 var invalidColor = 'rgb(255, 0, 0)';
24 var normalColor = 'rgb(255, 255, 255)';
25 var disabledColor = 'rgb(0, 0, 0)';
26 var readOnlyColor = 'rgb(0, 255, 0)';
27 var validColor = 'rgb(0, 0, 255)';
29 // --------------------------------
30 // willValidate change
31 // --------------------------------
32 var el = makeInvalid();
33 // Confirm this element is invalid.
34 debug('Chheck the initial state:');
35 shouldBe(elBackground, 'invalidColor');
37 debug('Change name:');
39 shouldBe(elBackground, 'invalidColor');
41 shouldBe(elBackground, 'invalidColor');
43 debug('Change disabled:');
46 shouldBe(elBackground, 'disabledColor');
48 shouldBe(elBackground, 'invalidColor');
50 debug('Change readOnly:');
53 shouldBe(elBackground, 'readOnlyColor');
55 shouldBe(elBackground, 'invalidColor');
57 debug('Inside/outside of a form:');
59 nonForm.appendChild(el);
60 shouldBe(elBackground, 'invalidColor');
62 shouldBe(elBackground, 'invalidColor');
64 // --------------------------------
66 // --------------------------------
67 debug('Change the value by DOM attribute:');
70 shouldBe(elBackground, 'validColor');
72 shouldBe(elBackground, 'invalidColor');
74 debug('Change the value by DOM attribute for a focused text field:');
78 shouldBe(elBackground, 'validColor');
80 debug('Change the value by key input:');
83 eventSender.keyDown('a');
84 shouldBe(elBackground, 'validColor');
85 eventSender.keyDown('backspace', []);
86 shouldBe(elBackground, 'invalidColor');
88 // --------------------------------
90 // --------------------------------
91 debug('Change required:');
94 shouldBe(elBackground, 'validColor');
96 shouldBe(elBackground, 'invalidColor');
98 debug('Change pattern:');
101 shouldBe(elBackground, 'validColor');
103 shouldBe(elBackground, 'invalidColor');
105 shouldBe(elBackground, 'validColor');
107 debug('Change step:');
111 shouldBe(elBackground, 'validColor');
113 shouldBe(elBackground, 'invalidColor');
115 shouldBe(elBackground, 'validColor');