Closed Bug 618827 Opened 14 years ago Closed 13 years ago

JS: instanceof fails when object's constructor is initialized from an iframe

Categories

(Core :: XPConnect, defect)

x86
Windows 7
defect
Not set
normal

Tracking

()

RESOLVED FIXED
Tracking Status
blocking2.0 --- betaN+

People

(Reporter: bkon, Assigned: gal)

Details

(Keywords: regression)

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.10 (KHTML, like Gecko) Chrome/8.0.552.215 Safari/534.10
Build Identifier: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0b7) Gecko/20100101 Firefox/4.0b7

When an object constructor is initialized from an iframe, instanceof incorrectly returns false when applied to an recently created object.

Reproducible: Always

Steps to Reproduce:
1. Create a sample html file with contents displayed below:

<body>

<script type="text/javascript">
var iframe = document.createElement("iframe");
iframe.style.display = "none";
document.body.appendChild(iframe);

// write a script into the <iframe> and steal its Array object
frames[frames.length - 1].document.write(
  "<script>parent.XXX = Array;<\/script>"
);

var newItem = new XXX();
console.log(newItem instanceof XXX);
</script>
</body>

2. Open FF Beta
3. Open web console
4. Load the sample file (doesn't matter if it's loaded via file:// or via http://
5. Note the output displayed in the web console (by the last line inside the script)
Actual Results:  
"false" displayed in the web console.

Expected Results:  
"true" displayed in the web console.
Summary: JS: instanceof fails when object's constructor is initialized from an inframe → JS: instanceof fails when object's constructor is initialized from an iframe
Component: General → DOM
Product: Firefox → Core
QA Contact: general → general
Hmm.  That's odd, but doesn't seem like a DOM issue; more likely a problem with wrappers.
Status: UNCONFIRMED → NEW
blocking2.0: --- → ?
Component: DOM → XPConnect
Ever confirmed: true
Keywords: regression
QA Contact: general → xpconnect
Assignee: nobody → mrbkap
blocking2.0: ? → betaN+
mrbkap says this is a dupe of bug 597872.
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → DUPLICATE
Still reproducible in Firefox 4 Beta 10 (which already contains fix for the bug 620486)
Status: RESOLVED → REOPENED
Resolution: DUPLICATE → ---
Assignee: mrbkap → gal
Looking at this.
Attached file test case
Ok, this is false for us, false for safari, and true for chrome. I couldn't get opera to display anything.
What about IE?  And presumably this was true in Gecko 1.9.x?
I am not saying I won't fix this. I just noted the weird behavior for now.
Blocks: 631135
No longer blocks: 631135
An independent bug causes that instanceof to still fail, filed as 631135 with the same testcase.
Status: REOPENED → RESOLVED
Closed: 14 years ago13 years ago
Resolution: --- → FIXED
It's true in Firefox 3.6.13, IE8, IE8 in "IE7 compatibility mode", replacing console.log() with alert() in the original source makes Opera display "true" as well.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: