Closed Bug 355260 Opened 18 years ago Closed 17 years ago

XML and XMLList methods require "this" to be XML and XMLList correspondingly.

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED WONTFIX

People

(Reporter: igor, Unassigned)

References

Details

This is a spin-off of bug 355233 comment 5. 

Currently SM allows to apply methods extracted from XML.prototype to XMLList objects and vice versa while according to E4X such calls should throw TypeError:

Standard ECMA-357 2nd Edition / December 2005
http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-357.pdf

13.4.4 Properties of the XML Prototype Object (Built-in Methods)
| None of the built-in functions defined on XML.prototype are generic.
| They throw a TypeError exception if the this value is not an XML object.
| Therefore, they cannot be transferred to other kinds of objects for use
| as a method.

13.5.4 Properties of the XMLList Prototype Object (Built-in Methods)
| None of the built-in functions defined on XMLList.prototype are generic.
| They throw a TypeError exception if the this value is not an XMLList object.
| Therefore, they cannot be transferred to other kinds of objects for use
| as a method.


The following test case demonstrates the problem:

~/m/trunk/mozilla/js/src> cat ~/m/files/y.js

try {
  XML.prototype.function::length.call(<><a/><b/></>);
  throw "XML.prototype.length applied to XMLList does not throw an exception";
} catch (e if e instanceof TypeError) {}

try {
  XMLList.prototype.function::length.call(<a/>);
  throw "XMLList.prototype.length applied to XML does not throw an exception";
} catch (e if e instanceof TypeError) {}

print("OK");

~/m/trunk/mozilla/js/src> ./Linux_All_DBG.OBJ/js ~/m/files/y.js
uncaught exception: XML.prototype.length applied to XMLList does not throw an exception
See bug 373020 comment 1
Status: NEW → RESOLVED
Closed: 17 years ago
Depends on: 373020
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.