Closed Bug 47404 Opened 25 years ago Closed 24 years ago

NO_MODIFICATION_ALLOWED_ERR Exception not thrown when setting readonly properties in DOM Core Level 1

Categories

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

defect

Tracking

()

VERIFIED FIXED
Future

People

(Reporter: bc, Assigned: jst)

References

()

Details

(Keywords: dom1, helpwanted, Whiteboard: [XPCDOM])

From Bugzilla Helper: User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; m18) Gecko/20000730 BuildID: 200003020 None of the DOM Core Level 1/2 readonly properties throw a NO_MODIFICATION_ALLOWED_ERR Exception when being written to. The demonstration URL above gives examples for the readonly properties of the Document Object but http://www.mindspring.com/~bobclary/TestFrame_dom_core.html demonstrates that none of the DOM Core readonly properties throw this exception. Reproducible: Always Steps to Reproduce: 1.javascript:document.attributes = 0; Actual Results: no exception thrown but no modification made either Expected Results: thrown DOMException(NO_MODIFICATION_ALLOWED_ERR) Example: <a href="javascript:try { document.attributes = 0; alert('no exception thrown'); } catch(e) { alert( (e.code == 7 ? 'corrent' : 'wrong' ) + ' exception'); }">document.attributes = 0;</a>
QA Contact: gerardok → ckritzer
Confirmed on Linux 2000080108. Changing OS/Plat to all.
Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Windows NT → All
Hardware: PC → All
Attempting to set document.attributes should *not* throw a NO_MODIFICATION_ALLOWED_ERR exception, NO_MODIFICATION_ALLOWED_ERR is a DOM exception defined to be thrown when a method is called or when a read-write property is set on a node in a circumstance where the property can not be set per the definitions in the DOM spec, e.g. document.nodeValue='foo'. Since the 'attributes' property is defined to be readonly in the DOM spec the behaviour of an attempt to set that readonly property in a language where that is even possible (it's not possible in C++ since the compiler would catch that as an error, i.e. there's no SetAttributes() method in the Node interface), is outside of the scope of the DOM spec. The DOM is language neutral but this issue is specific to JS. I do agree that mozilla should throw a JS exception when attempting to set a readonly property, but NO_MODIFICATION_ALLOWED_ERR is not the correct exception. Brendan, any ideas here, how can we get mozilla to throw an exception in this case?
Oops, forgot to CC! Brendan, please see my last comment.
This bug has been marked "future" because the original netscape engineer working on this is over-burdened. If you feel this is an error, that you or another known resource will be working on this bug,or if it blocks your work in some way -- please attach your concern to the bug for reconsideration.
Status: NEW → ASSIGNED
Target Milestone: --- → Future
Anyone who wants to fix this, an idea: readonly in DOM IDL maps to JSPROP_READONLY, which per ECMA-262, results in a property that can be assigned to without exception, but without effect. Suppose there were another keyword like readonly that connoted "throws exception" -- I can't think of a great name, so call it xreadonly. For that attribute, DOM idlc could generate a read/write JS property with a tinyid, whose setter throws the desired exception. /be
Keywords: helpwanted
Mass update of qa contact
QA Contact: ckritzer → janc
Whiteboard: [XPCDOM]
Keywords: dom1
Component: DOM Level 1 → DOM Core
QA contact Update
QA Contact: janc → desale
XPConnect now throws an exception if a readonly property is being set, marking fixed.
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
Updating QA contact to Shivakiran Tummala.
QA Contact: desale → stummala
exception is raised but not the rite one ...checked with the testcase provided here ...also including testcase which demonstrated the problem <html> <BODY> <TABLE BORDER=1 id ="table"> <TR><TD>Dogbreath</TD><TD>Doghair</TD><TD>Dogspit</TD><TD>Dogtail</TD></TR> <TR><TD>Catbreath</TD><TD>Cathair</TD><TD>Catspit</TD><TD id=yuk>Searching for this cellIndex which should be 3</TD></TR> <TR><TD>Geckobreath</TD><TD>Gecko... hair</TD><TD>Geckospit</TD><TD>Geckotail</TD></TR> </TABLE> <SCRIPT TYPE="text/javascript"> try { //trying to set readonly length parameter of HTMLCollection object document.getElementById('table').rows.length=10; }catch (e) { if (e.code == 7) alert ("NO_MODIFICATION_ALLOWER_ERR"); else alert ("should be 7"); } </SCRIPT>
Severity: normal → critical
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
There is no spec that says what exception should be thrown when a property that is defined to be readonly in our IDL is being set in JS, the DOM spec has nothing to do with that, it's a language binding issue, not a DOM implementation issue. We throw a type error exception, and that's all we need to do. Marking FIXED again.
Status: REOPENED → RESOLVED
Closed: 25 years ago24 years ago
Resolution: --- → FIXED
this means as long as exception is thrown we are good
verified
Status: RESOLVED → VERIFIED
Component: DOM: Core → DOM: Core & HTML
QA Contact: stummala → general
You need to log in before you can comment on or make changes to this bug.