Closed Bug 1352799 Opened 3 years ago Closed 3 years ago

dynamic maxlength in input form didn't work


(Core :: DOM: Editor, defect, P3)

52 Branch



Tracking Status
firefox52 - ---
firefox55 --- fixed


(Reporter: h_enzi, Assigned: m_kato)




(Keywords: dev-doc-complete, testcase)


(2 files)

User Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0
Build ID: 20170323105023

Steps to reproduce:

i changed the value of input's maxlength dynamically using javascript

Actual results:

the value of maxlength did changed, for example from maxlength='2' to maxlength='4'
(i checked it via inspect element)

Expected results:

i can't type more than 2 character when the maxlength value is changed to 4
forgot to mention, it works when i changed the value of maxlength to 0, then change it again using setTimeout
Could you attach a minimal testcase, please.
Flags: needinfo?(h_enzi)
Keywords: testcase-wanted
[Tracking Requested - why for this release]:
Need more info with atleast minimum test case to reproduce futher
Need more information from the user to reproduce it further
Component: Untriaged → Editor
Product: Firefox → Core
Too late for 52, and it doesn't sound like this is in a state where it can be tracked for future releases.
I can confirm this one, please see:

steps to reproduce:

- click b1
- input: "12" into the textbox
- click b2
- click b3
- input something into the textbox, it should be 4 char max but we can't input more than 2

sorry the URL should be:
sorry the URL should be:
Old FF33 has the bug too.
Flags: needinfo?(h_enzi)
nsTextControlFrame sets SetMaxTextLLength to editor, but due to display = none, RestyleManager doesn't call nsTextControlFrame::AttributeChanged.  So we should move calling SetMaxTextLength to HTMLInputElement or nsTextEditorState
Assignee: nobody → m_kato
Priority: -- → P3
Ever confirmed: true
Comment on attachment 8860841 [details]
Bug 1352799 - Part 2. Add test for changing maxlength dynamically.

::: editor/libeditor/tests/test_bug1352799.html:60
(Diff revision 1)
> +    window.setTimeout(() => {
> +      input.removeAttribute('maxlength');
> + = 'block';
> +
> +      input.focus();
> +
> +      synthesizeKey('1', {});
> +      synthesizeKey('2', {});
> +      synthesizeKey('3', {});
> +      synthesizeKey('4', {});
> +      synthesizeKey('5', {});
> +      synthesizeKey('6', {});
> +      synthesizeKey('7', {});
> +      synthesizeKey('8', {});
> +
> +      is(input.value, '12345678', 'value should be 12345678 without maxlength');
> +
> +      SimpleTest.finish();

Could you add a test which sets smaller number to maxlength. Then, I guess that the value should be truncated. If you'd need to change the behavior for compatibility with other browsers, it'd be okay to use todo_is().
Attachment #8860841 - Flags: review?(masayuki) → review+
Comment on attachment 8860840 [details]
Bug 1352799 - Always set maxlength on initializing editor.
Attachment #8860840 - Flags: review?(masayuki) → review+
Pushed by
Always set maxlength on initializing editor. r=masayuki
Part 2. Add test for changing maxlength dynamically. r=masayuki
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla55
*Might* be better to be in "Firefox 55 for Developers", but up to writers.
Keywords: dev-doc-needed
OS: Unspecified → All
Hardware: Unspecified → All
I've added a note to the Fx55 release notes to cover this; see the bottom of:

Let me know if you think the wording is OK. Thanks!
(In reply to Chris Mills (Mozilla, MDN editor) [:cmills] from comment #21)
> I've added a note to the Fx55 release notes to cover this; see the bottom of:
> Let me know if you think the wording is OK. Thanks!

Thanks, looks fine to me.
Duplicate of this bug: 743169
Duplicate of this bug: 818270
You need to log in before you can comment on or make changes to this bug.