Closed Bug 398109 Opened 17 years ago Closed 17 years ago

toString() on XOW is very odd

Categories

(Core :: XPConnect, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: bzbarsky, Assigned: mrbkap)

References

Details

Attachments

(1 file)

STEPS TO REPRODUCE:

1)  javascript:alert(window)
2)  javascript:alert(window + "")
3)  Write a mochitest in which you have a test like:

   is(null, window, "Should be null, for some reason")

EXPECTED RESULTS:  All three give the same string for the window

ACTUAL RESULTS:
1)  Gives "[object XPCCrossOriginWrapper [object Window]]"
2)  Gives "[object Window]"
3)  Gives "[]"

This last particularly bothers me, since I can't tell why that's happening.
Flags: blocking1.9?
#3 happens due to a bug in MochiKit's repr (specifically, its isArrayLike function returns true for window objects, which is incorrect). I'll file that in a second. I have a patch for cases 1 and 2.
Attached patch FixSplinter Review
If only hg allowed me to give more context to the diff...

The only tricky bit here is that this code is shared by both XPCNativeWrapper whose toString I wanted to leave alone.

With this patch, to verify that you have a XOW from JS, you must do Object.prototype.toString.call(obj).
Assignee: nobody → mrbkap
Status: NEW → ASSIGNED
Attachment #282965 - Flags: superreview?(bzbarsky)
Attachment #282965 - Flags: review?(jst)
Comment on attachment 282965 [details] [diff] [review]
Fix

sr=bzbarsky
Attachment #282965 - Flags: superreview?(bzbarsky) → superreview+
I filed bug 398118 on the MochiKit issue.
Attachment #282965 - Flags: review?(jst) → review+
Comment on attachment 282965 [details] [diff] [review]
Fix

This fixes a XOW inconsistency and makes alert(window) and alert(window + '') do the same thing.
Attachment #282965 - Flags: approval1.9?
Not a blocker maybe, but since there's a patch, it'd be great to get it in.
Flags: blocking1.9? → blocking1.9-
Whiteboard: [wanted-1.9]
Comment on attachment 282965 [details] [diff] [review]
Fix

This will help ease confusion about XOWs and will make us consistent again.
Attachment #282965 - Flags: approvalM9?
Comment on attachment 282965 [details] [diff] [review]
Fix

a=endgame drivers for after M9 freeze
Attachment #282965 - Flags: approvalM9?
Attachment #282965 - Flags: approvalM9-
Attachment #282965 - Flags: approval1.9?
Attachment #282965 - Flags: approval1.9+
Fix checked in.
Status: ASSIGNED → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
Flags: in-testsuite?
Flags: wanted1.9+
Whiteboard: [wanted-1.9]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: