Bug 16750 - text field element fails to match :checked (Acid3 bug)
Summary: text field element fails to match :checked (Acid3 bug)
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: Macintosh OS X 10.4
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-01-05 14:18 PST by Eric Seidel (no email)
Modified: 2008-01-06 00:14 PST (History)
0 users

See Also:


Attachments
Fix :checked matching type='text' and add test case (3.48 KB, patch)
2008-01-06 00:03 PST, Eric Seidel (no email)
sam: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Seidel (no email) 2008-01-05 14:18:55 PST
input element fails to match :checked (Acid3 bug)

      // test 43: :enabled, :disabled, :checked, etc
      selectorTest(function (doc, add, expect) {
        var input = doc.createElement('input');
        input.type = 'checkbox';
        doc.body.appendChild(input);
        var neither = 0;
        var both = add(":checked:enabled");
        var checked = add(":checked");
        var enabled = add(":enabled");
        expect(doc.body, neither, "control failure");
        expect(input, enabled, "input element didn't match :enabled");
        input.click();
        expect(input, both, "input element didn't match :checked");
        input.disabled = true;
        expect(input, checked, "failure 3");
        input.checked = false;
        expect(input, neither, "failure 4");
        expect(doc.body, neither, "failure 5");
      });
Comment 1 Eric Seidel (no email) 2008-01-05 14:20:21 PST
Test 43: FAIL (expected 0, got 1 - text field matched :checked)

The full test:
    function () {
      // test 43: :enabled, :disabled, :checked, etc
      selectorTest(function (doc, add, expect) {
        var input = doc.createElement('input');
        input.type = 'checkbox';
        doc.body.appendChild(input);
        var neither = 0;
        var both = add(":checked:enabled");
        var checked = add(":checked");
        var enabled = add(":enabled");
        expect(doc.body, neither, "control failure");
        expect(input, enabled, "input element didn't match :enabled");
        input.click();
        expect(input, both, "input element didn't match :checked");
        input.disabled = true;
        expect(input, checked, "failure 3");
        input.checked = false;
        expect(input, neither, "failure 4");
        expect(doc.body, neither, "failure 5");
      });
      selectorTest(function (doc, add, expect) {
        var input1 = doc.createElement('input');
        input1.type = 'radio';
        input1.name = 'radio';
        doc.body.appendChild(input1);
        var input2 = doc.createElement('input');
        input2.type = 'radio';
        input2.name = 'radio';
        doc.body.appendChild(input2);
        var checked = add(":checked");
        expect(input1, 0, "failure 6");
        expect(input2, 0, "failure 7");
        input2.checked = true;
        expect(input1, 0, "failure 6");
        expect(input2, checked, "failure 7");
        input1.checked = true;
        expect(input1, checked, "failure 8");
        expect(input2, 0, "failure 9");
        input2.setAttribute("checked", "checked"); // sets defaultChecked, doesn't change actual state
        expect(input1, checked, "failure 9");
        expect(input2, 0, "failure 10");
        input1.type = "text";
        expect(input1, 0, "text field matched :checked");
      });
      selectorTest(function (doc, add, expect) {
        var input = doc.createElement('input');
        input.type = 'button';
        doc.body.appendChild(input);
        var neither = 0;
        var enabled = add(":enabled");
        var disabled = add(":disabled");
        add(":enabled:disabled");
        expect(input, enabled, "failure 12");
        input.disabled = true;
        expect(input, disabled, "failure 13");
        input.removeAttribute("disabled");
        expect(input, enabled, "failure 14");
        expect(doc.body, neither, "failure 15");
      });
      return 3;
    },
Comment 2 Eric Seidel (no email) 2008-01-05 22:55:45 PST
Working on this.
Comment 3 Eric Seidel (no email) 2008-01-06 00:03:24 PST
Created attachment 18296 [details]
Fix :checked matching type='text' and add test case

 .../checked-pseudo-selector-expected.txt           |    6 ++++++
 .../HTMLInputElement/checked-pseudo-selector.html  |   13 +++++++++++++
 .../dom/HTMLInputElement/resources/TEMPLATE.html   |   13 +++++++++++++
 .../resources/checked-pseudo-selector.js           |   19 +++++++++++++++++++
 WebCore/html/HTMLInputElement.h                    |    3 ++-
 5 files changed, 53 insertions(+), 1 deletions(-)
Comment 4 Sam Weinig 2008-01-06 00:11:29 PST
Comment on attachment 18296 [details]
Fix :checked matching type='text' and add test case

This looks good.  I think the test might benefit from being a rendering test (or maybe have one in addition) but it's not a show-stopper.  ChangeLog needed as well.
Comment 5 Eric Seidel (no email) 2008-01-06 00:14:18 PST
I don't understand why/how this would be a rendering test...  I guess to display the fact that the styles matched?

committed as r29204.