Bug 16704 - input with type="hidden" matches :enabled/:disabled (Acid3 bug)
Summary: input with type="hidden" matches :enabled/:disabled (Acid3 bug)
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac OS X 10.4
: P2 Normal
Assignee: Beth Dakin
URL:
Keywords: NeedsReduction
Depends on:
Blocks:
 
Reported: 2008-01-01 22:17 PST by Eric Seidel (no email)
Modified: 2008-01-04 22:42 PST (History)
1 user (show)

See Also:


Attachments
Patch: Prevent :enabled and :disabled from applying to input type="hidden" (6.96 KB, patch)
2008-01-04 20:56 PST, Beth Dakin
oliver: 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-01 22:17:31 PST
input with type="hidden" matches :enabled/:disabled (Acid3 bug)

    function () {
      // test 42: :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");
      });
      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 11");
        input.disabled = true;
        expect(input, disabled, "failure 12");
        input.removeAttribute("disabled");
        expect(input, enabled, "failure 13");
        input.setAttribute("type", "hidden");
        expect(input, neither, "an input with type=hidden is matching one of :enabled or :disabled");
      });
      return 3;
    },

We'll need to make a nicer stand-alone test case.
Comment 1 Beth Dakin 2008-01-04 20:56:09 PST
Created attachment 18282 [details]
Patch: Prevent :enabled and :disabled from applying to input type="hidden"

I verified that this fixes the test in Acid3.
Comment 2 Oliver Hunt 2008-01-04 21:00:17 PST
Comment on attachment 18282 [details]
Patch: Prevent :enabled and :disabled from applying to input type="hidden"

r=me, my only requirement is that you do layoutController.dumpAsText() (or whatever the controller is called)

There's n o need for this to be a render tree comparison
Comment 3 Oliver Hunt 2008-01-04 21:19:22 PST
Fixed with r29191.
Comment 4 Adele Peterson 2008-01-04 22:40:36 PST
would it be better to check that a renderer exists instead of special casing the hidden input?
Comment 5 Adele Peterson 2008-01-04 22:42:06 PST
that would cause enabled controls that have display:none set to no longer match those rules...which might not be desirable.