Open Bug 1213792 Opened 9 years ago Updated 1 year ago

Interface objects have an own "toString" property.


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

40 Branch





(Reporter: crimsteam, Unassigned)



(Keywords: dev-doc-needed)

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0
Build ID: 20150929144111

Steps to reproduce:

Per actual DOM spec toString() method is defined through IDL:
where we see:
"If the stringifier is unforgeable on the interface or if the interface was declared with the [Global] or [PrimaryGlobal] extended attribute, then the property exists on every object that implements the interface. Otherwise, the property exists on the interface prototype object."

Small test:


And results:
Firefox and Chrome: false, true, true (wrong)
IE, Opera (Presto): false, false, true (correct)
This is not specific to Range; updated the summary to match.
Summary: Expose Range.toString() only on interface prototype object → Interface objects have an own "toString" property.
Interface objects have a toString because Function.prototype.toString throws for interface objects, so we have to shadow it for stringification of interface objects to work at all.

One Function.prototype.toString is fixed to not suck, we can remove this toString bit.

I guess I'll mark this dependent on bug 1039986, just in case the patches there don't remove the toString hackery on interface objects.
Depends on: 1039986
Looks like after closing this bug is no longer valid, I check stringifier for Range and DOMTokenList and all worsk fine. Maybe can be close?
Component: DOM → DOM: Core & HTML
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.