Closed Bug 1272297 Opened 8 years ago Closed 8 years ago

Error message for invalid regular expression in 'pattern' attribute is output twice

Categories

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

defect
Not set
minor

Tracking

()

VERIFIED FIXED
mozilla51
Tracking Status
firefox51 --- fixed

People

(Reporter: sebo, Assigned: ben.tian)

References

Details

(Whiteboard: btpp-backlog [tw-dom])

Attachments

(1 file, 1 obsolete file)

Steps to reproduce:
1. Go to https://bugzilla.mozilla.org/attachment.cgi?id=786154
2. Open the Web Console

=> You'll see the following error message with a counter saying 2:
'Unable to check <input pattern='^.**$'> because the pattern is not a valid regexp: nothing to repeat'
Whiteboard: btpp-backlog [tw-dom]
Take this bug.

The error message is output twice with the following call stacks. One is triggered by |HTMLInputElement::AfterSetAttr| and the other is by |HTMLInputElement::DoneCreatingElement|.

=== 1st output ===
Breakpoint 1, nsContentUtils::IsPatternMatching (aValue=..., aPattern=..., aDocument=0x7f8a42aba000)
    at /home/bentian/WORKSPACE/projects/gecko/central/dom/base/nsContentUtils.cpp:6666
6666	    ReportPatternCompileFailure(aPattern, aDocument, cx);
(gdb) bt
#0  nsContentUtils::IsPatternMatching (aValue=..., aPattern=..., aDocument=0x7f8a42aba000)
    at /home/bentian/WORKSPACE/projects/gecko/central/dom/base/nsContentUtils.cpp:6666
#1  0x00007f8a5e25f7ed in mozilla::dom::HTMLInputElement::HasPatternMismatch (this=0x7f8a509ce180)
    at /home/bentian/WORKSPACE/projects/gecko/central/dom/html/HTMLInputElement.cpp:7031
#2  0x00007f8a5e2605fa in mozilla::dom::HTMLInputElement::UpdatePatternMismatchValidityState (this=0x7f8a509ce180)
    at /home/bentian/WORKSPACE/projects/gecko/central/dom/html/HTMLInputElement.cpp:7269
#3  0x00007f8a5e24ca88 in mozilla::dom::HTMLInputElement::AfterSetAttr (this=0x7f8a509ce180, aNameSpaceID=0, 
    aName=0x7f8a4b2a77f0, aValue=0x7fffbe8ff600, aNotify=false)
    at /home/bentian/WORKSPACE/projects/gecko/central/dom/html/HTMLInputElement.cpp:1470
#4  0x00007f8a5ce526be in mozilla::dom::Element::SetAttrAndNotify (this=0x7f8a509ce180, aNamespaceID=0, 
    aName=0x7f8a4b2a77f0, aPrefix=0x0, aOldValue=..., aParsedValue=..., aModType=2 '\002', aFireMutation=false, 
    aNotify=false, aCallAfterSetAttr=true)
    at /home/bentian/WORKSPACE/projects/gecko/central/dom/base/Element.cpp:2437
#5  0x00007f8a5ce51d1c in mozilla::dom::Element::SetAttr (this=0x7f8a509ce180, aNamespaceID=0, 
    aName=0x7f8a4b2a77f0, aPrefix=0x0, aValue=..., aNotify=false)
    at /home/bentian/WORKSPACE/projects/gecko/central/dom/base/Element.cpp:2315
#6  0x00007f8a5e2f957a in nsGenericHTMLElement::SetAttr (this=0x7f8a509ce180, aNameSpaceID=0, 
    aName=0x7f8a4b2a77f0, aPrefix=0x0, aValue=..., aNotify=false)
    at /home/bentian/WORKSPACE/projects/gecko/central/dom/html/nsGenericHTMLElement.cpp:855
#7  0x00007f8a5c821548 in nsHtml5TreeOperation::CreateElement (aNs=3, aName=0x7f8a4b2a8910, 
    aAttributes=0x7f8a41f578b0, aFromParser=mozilla::dom::FROM_PARSER_NETWORK, aNodeInfoManager=0x7f8a34737500, 
    aBuilder=0x7f8a35644800)
    at /home/bentian/WORKSPACE/projects/gecko/central/parser/html/nsHtml5TreeOperation.cpp:439
#8  0x00007f8a5c822825 in nsHtml5TreeOperation::Perform (this=0x7f8a3443b3f8, aBuilder=0x7f8a35644800, 
    aScriptElement=0x7fffbe9000d0)
    at /home/bentian/WORKSPACE/projects/gecko/central/parser/html/nsHtml5TreeOperation.cpp:701
#9  0x00007f8a5c8085ba in nsHtml5TreeOpExecutor::RunFlushLoop (this=0x7f8a35644800)
    at /home/bentian/WORKSPACE/projects/gecko/central/parser/html/nsHtml5TreeOpExecutor.cpp:448
#10 0x00007f8a5c80ca8f in nsHtml5ExecutorFlusher::Run (this=0x7f8a354da0c0)
    at /home/bentian/WORKSPACE/projects/gecko/central/parser/html/nsHtml5StreamParser.cpp:128

=== 2nd output ===
Breakpoint 1, nsContentUtils::IsPatternMatching (aValue=..., aPattern=..., aDocument=0x7f8a42aba000)
    at /home/bentian/WORKSPACE/projects/gecko/central/dom/base/nsContentUtils.cpp:6666
6666	    ReportPatternCompileFailure(aPattern, aDocument, cx);
(gdb) bt
#0  nsContentUtils::IsPatternMatching (aValue=..., aPattern=..., aDocument=0x7f8a42aba000)
    at /home/bentian/WORKSPACE/projects/gecko/central/dom/base/nsContentUtils.cpp:6666
#1  0x00007f8a5e25f7ed in mozilla::dom::HTMLInputElement::HasPatternMismatch (this=0x7f8a509ce180)
    at /home/bentian/WORKSPACE/projects/gecko/central/dom/html/HTMLInputElement.cpp:7031
#2  0x00007f8a5e2605fa in mozilla::dom::HTMLInputElement::UpdatePatternMismatchValidityState (this=0x7f8a509ce180)
    at /home/bentian/WORKSPACE/projects/gecko/central/dom/html/HTMLInputElement.cpp:7269
#3  0x00007f8a5e260754 in mozilla::dom::HTMLInputElement::UpdateAllValidityStates (this=0x7f8a509ce180, 
    aNotify=false) at /home/bentian/WORKSPACE/projects/gecko/central/dom/html/HTMLInputElement.cpp:7303
#4  0x00007f8a5e262021 in mozilla::dom::HTMLInputElement::OnValueChanged (this=0x7f8a509ce180, aNotify=false)
    at /home/bentian/WORKSPACE/projects/gecko/central/dom/html/HTMLInputElement.cpp:7740
#5  0x00007f8a5e31dbe2 in nsTextEditorState::SetValue (this=0x7f8a35abd420, aValue=..., aFlags=0)
    at /home/bentian/WORKSPACE/projects/gecko/central/dom/html/nsTextEditorState.cpp:2185
#6  0x00007f8a5e252f7f in mozilla::dom::HTMLInputElement::SetValueInternal (this=0x7f8a509ce180, aValue=..., 
    aFlags=0) at /home/bentian/WORKSPACE/projects/gecko/central/dom/html/HTMLInputElement.cpp:3047
#7  0x00007f8a5e25dae2 in mozilla::dom::HTMLInputElement::DoneCreatingElement (this=0x7f8a509ce180)
    at /home/bentian/WORKSPACE/projects/gecko/central/dom/html/HTMLInputElement.cpp:6299
#8  0x00007f8a5c82233f in nsHtml5TreeOperation::DoneCreatingElement (aNode=0x7f8a509ce180)
    at /home/bentian/WORKSPACE/projects/gecko/central/parser/html/nsHtml5TreeOperation.cpp:616
#9  0x00007f8a5c822d47 in nsHtml5TreeOperation::Perform (this=0x7f8a3443b458, aBuilder=0x7f8a35644800, 
    aScriptElement=0x7fffbe9000d0)
    at /home/bentian/WORKSPACE/projects/gecko/central/parser/html/nsHtml5TreeOperation.cpp:787
#10 0x00007f8a5c8085ba in nsHtml5TreeOpExecutor::RunFlushLoop (this=0x7f8a35644800)
    at /home/bentian/WORKSPACE/projects/gecko/central/parser/html/nsHtml5TreeOpExecutor.cpp:448
Assignee: nobody → btian
A quick fix. Will further verify.
Olli, can you review my patch that skips pattern validity check while parser is creating the input element (per comment 1 finding)?

Try result is in https://treeherder.mozilla.org/#/jobs?repo=try&revision=5ac5ddda61e2
Attachment #8778777 - Attachment is obsolete: true
Attachment #8779222 - Flags: review?(bugs)
Comment on attachment 8779222 [details] [diff] [review]
[final] Patch 1: Do not check pattern validity while parser is creating this input element, r=smaug

Makes sense.

I guess we don't have similar issue with UpdateTypeMismatchValidityState and others since in those cases we don't report anything to console.
Attachment #8779222 - Flags: review?(bugs) → review+
Attachment #8779222 - Attachment description: Patch 1 (v2): Do not check pattern validity while parser is creating this input element → [final] Patch 1: Do not check pattern validity while parser is creating this input element, r=smaug
Keywords: checkin-needed
Pushed by cbook@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/21806380a254
Do not check pattern validity while parser is creating this input element. r=smaug
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/21806380a254
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla51
Tested on Nightly 51.0a1 (2016-08-15) and works fine for me. Thank you!

Sebastian
Status: RESOLVED → VERIFIED
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: