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

VERIFIED FIXED in Future

Status

()

Core
DOM: Core & HTML
P3
critical
VERIFIED FIXED
18 years ago
10 years ago

People

(Reporter: bc, Assigned: jst)

Tracking

({dom1, helpwanted})

Trunk
Future
dom1, helpwanted
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [XPCDOM], URL)

(Reporter)

Description

18 years ago
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>

Updated

18 years ago
QA Contact: gerardok → ckritzer

Comment 1

18 years ago
Confirmed on Linux 2000080108. Changing OS/Plat to all.
Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Windows NT → All
Hardware: PC → All
(Assignee)

Comment 2

18 years ago
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?
(Assignee)

Comment 3

18 years ago
Oops, forgot to CC! Brendan, please see my last comment.
(Assignee)

Comment 4

18 years ago
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

Comment 6

18 years ago
Mass update of qa contact
QA Contact: ckritzer → janc
(Assignee)

Updated

18 years ago
Whiteboard: [XPCDOM]
Keywords: dom1
Component: DOM Level 1 → DOM Core

Comment 7

18 years ago
QA contact Update
QA Contact: janc → desale
(Assignee)

Comment 8

17 years ago
XPConnect now throws an exception if a readonly property is being set, marking
fixed.
Status: ASSIGNED → RESOLVED
Last Resolved: 17 years ago
Resolution: --- → FIXED

Comment 9

17 years ago
Updating QA contact to Shivakiran Tummala.
QA Contact: desale → stummala

Comment 10

17 years ago
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 → ---
(Assignee)

Comment 11

17 years ago
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
Last Resolved: 17 years ago17 years ago
Resolution: --- → FIXED

Comment 12

17 years ago
this means as long as exception is thrown we are good 

Comment 13

17 years ago
verified
Status: RESOLVED → VERIFIED

Updated

10 years ago
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.