Closed Bug 565538 Opened 14 years ago Closed 14 years ago

Add tests for the mozIsTextField API

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.9.3a5

People

(Reporter: ehsan.akhgari, Assigned: mounir)

References

Details

Attachments

(1 file, 1 obsolete file)

Bug 557620 added the mozIsTextField API.  It didn't land any (good) tests alongside, though.  The only test landed is <http://mxr.mozilla.org/mozilla-central/source/content/html/content/test/test_bug557620.html?force=1#28> which only tests for the existence of the API, and it wasn't reviewed, according bug 557620 comment 37.

We need tests here to make sure that the API returns the correct value for all types of input controls.  The tests also need to cover the aExcludePassword parameter.
Assignee: nobody → mounir.lamouri
Status: NEW → ASSIGNED
OS: Mac OS X → All
Hardware: x86 → All
Attached patch Tests v1 (obsolete) — Splinter Review
Thank you for reporting this Ehsan.
Attachment #445088 - Flags: review?(ehsan)
Comment on attachment 445088 [details] [diff] [review]
Tests v1

>diff --git a/content/html/content/test/test_bug565538.html b/content/html/content/test/test_bug565538.html
>+/**
>+ * TODO: the next types are not yet in the tree.
>+ * The value is only a suggestion.
>+  ,['search',   true]
>+  ,['email',    true]
>+  ,['url',      true]
>+  ,['number',   false]
>+  ,['range',    false]
>+  ,['color',    false]
>+  ,['date',     false]
>+  ,['datetime', false]
>+  ,['month',    false]
>+  ,['week',     false]
>+  ,['time',     false]
>+  ,['datetime-local', false]
>+ */

Could you actually use todo_is for these tests, so that they appear as todo results in the test runs?  This way no one will forget to fix them when support for each of them is actually added.

To do this, you may check the type property after you set it, and if it's "text" (which means that the type is not supported), you can use todo_is instead of is.
Attachment #445088 - Flags: review?(ehsan)
Comment on attachment 445088 [details] [diff] [review]
Tests v1

>diff --git a/content/html/content/test/test_bug565538.html b/content/html/content/test/test_bug565538.html

>+var gElementTestData = [
>+   ['input',    true]
>+  ,['button',   false]
>+  ,['fieldset', false]
>+  ,['label',    false]
>+  ,['option',   false]
>+  ,['optgroup', false]
>+  ,['output',   false]
>+  ,['legend',   false]
>+  ,['select',   false]
>+  ,['textarea', false]
>+  ,['object',   false]
>+  ]
>+
>+var gInputTestData = [
>+   ['password', true]
>+  ,['tel',      true]
>+  ,['text',     true]
>+  ,['button',   false]
>+  ,['checkbox', false]
>+  ,['file',     false]
>+  ,['hidden',   false]
>+  ,['reset',    false]
>+  ,['image',    false]
>+  ,['radio',    false]
>+  ,['submit',   false]
>+/**
>+ * TODO: the next types are not yet in the tree.
>+ * The value is only a suggestion.
>+  ,['search',   true]
>+  ,['email',    true]
>+  ,['url',      true]
>+  ,['number',   false]
>+  ,['range',    false]
>+  ,['color',    false]
>+  ,['date',     false]
>+  ,['datetime', false]
>+  ,['month',    false]
>+  ,['week',     false]
>+  ,['time',     false]
>+  ,['datetime-local', false]
>+ */
>+  ]

1. JS arrays permit trailing commas with unchanged semantics:

var gInputTestData = [
   ['password', true],
  ];

is identical to

var gInputTestData = [
   ['password', true]
  ];

2. You're missing semicolons after the array declarations.
Attached patch Tests v2Splinter Review
Thank you Ehsan and Jeff for your feedbacks.

For the todo's, I wasn't able to use them for 'email', 'search' and 'url' because they are already returning the correct values. These states are now tested like already implemented ones so it will prevent regressions when implemented. I think that's better than a todo with the wrong value tested.
Attachment #445088 - Attachment is obsolete: true
Attachment #445205 - Flags: review?(ehsan)
Comment on attachment 445205 [details] [diff] [review]
Tests v2

Makes sense, thanks!
Attachment #445205 - Flags: review?(ehsan) → review+
Keywords: checkin-needed
http://hg.mozilla.org/mozilla-central/rev/4b9095d893f1
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9.3a5
Flags: in-testsuite+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: