document toString in array throws an exception javascript




JavaScript Engine
11 years ago
11 years ago


(Reporter: Darren, Unassigned)


Windows XP

Firefox Tracking Flags

(Not tracked)




11 years ago
User-Agent:       Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; IEMB3; IEMB3)
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a8) Gecko/2007091216 GranParadiso/3.0a8

The following JS expression results in an exception being thrown:

var blah = "" + [ document ];

In Yahoo Mail, there is a case of this where the element in the array is
something other than the document element, and also causes an exception, but i
was not able to reduce this to a simple case.

Reproducible: Always

Steps to Reproduce:
1. create a function like function foo() { var blah = "" + [ document ]; }
2. put function in a browser document and call it, via foo()
Actual Results:  
an exception is thrown

Expected Results:  
the variable blah has the string "[Object ]" or something equivalent in it...

This bug prevents some Yahoo Mail features from working correctly.
This is some extra info that came in by mail:
I just have one question/issue (for now) :).  I just filed a bug for it at
The simple case i was able to reduce this to was
          var blah = ""  + [ document ];
... throws an exception. In the Y! Mail context, the expression is more complex.  Something more like...
         var elt = document.getElementById( 'someSpan' );
         var contextObj = [ elt, "tr", "br" ];
         YAHOO.logger.log ( "key=" + contextObj );
... it seems the invocation of the toString on the contextObj in this case, throws an exception.
Is this a known issue?  BTW, my workaround for this (for now), was to create a toString for the
problematic array... something like
       contextObj.toString  = function() { return "obj" + ... };

I tried to come up with a testcase based on this, but I don't get an exception.

Do you have a page or a site where we can see this exception occurring?
What is the actual message of the exception in question?
Assignee: nobody → general
Component: General → JavaScript Engine
Product: Firefox → Core
QA Contact: general → general
Version: unspecified → Trunk

Comment 2

11 years ago
cc'ing a few others to look.  i'm gonna dig around and see if there are other known issues like this out there.

please attach a reproducible testcase to this bug, along with the exception.

Comment 3

11 years ago
Here's a document to reproduce the issue.  Oddly, last week i was seeing a
completely different exception message in the error console.  Something with
the string notImplemented in it. Now I'm getting this exception message in the error console:

uncaught exception: Permission denied to call method History.item

   function doX() { 
      var blah = "" + [ document, "hi" ]; 

<body onload="doX()">
Hello FF 3

This sounds a lot like bug 390947, but that should be fixed.
Ah, right.
Darren, could you please retest in the latest nightly trunk build?

Comment 6

11 years ago
my test page, and Y! Mail seem to work fine WRT this bug when using the nightly trunk build.
Ok, thanks for testing, Darren.
I'm marking this bug worksforme (although I guess someone who could know could mark it duplicate of bug 390947).
Last Resolved: 11 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.