Bug 8131 - Some properties and methods of window and document objects cannot be converted to a string
Summary: Some properties and methods of window and document objects cannot be converte...
Status: CLOSED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 416.x
Hardware: Mac OS X 10.4
: P2 Normal
Assignee: Nobody
URL: http://www.gtalbot.org/DHTMLSection/L...
Keywords:
: 7936 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-04-01 18:45 PST by Gérard Talbot
Modified: 2008-03-21 11:31 PDT (History)
2 users (show)

See Also:


Attachments
fix window.debug and test all properties (2.90 KB, patch)
2006-06-17 07:29 PDT, Alexey Proskuryakov
ggaren: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Gérard Talbot 2006-04-01 18:45:48 PST
Steps to reproduce:
1- Load provided URL
2- click the button to list the properties and methods of window | document | event object

Actual results in Safari 2.02 (416.13): nothing happens

Expected results: properties and methods should be listed.

Right now, Mozilla browsers, MSIE 6, Opera 7+ lists the properties and methods of these objects (albeit some browsers may have a few bugs too).

Fixing this bug would help DHTML and/or js+DOM scripters figuring out what they can use in a DHTML application and establish the level/degree of support/implementation of this or that property/method in Safari.

I searched for duplicate and couldn't find any.
Comment 1 Alexey Proskuryakov 2006-04-02 01:08:37 PST
Some of the properties here cannot be explicitly converted to a string:
alert(window['CSSRule']); // OK, [object CSSRuleConstructor]
alert(window['CSSRule']+""); // exception, "TypeError: No default value". OK in Firefox.

Interestingly, these problematic properties are just not listed in Firefox - not sure why.

Event object is dumped correctly in current WebKit builds, available at <http://nightly.webkit.org>. The troublesome property was event.view.
Comment 2 Eric Seidel (no email) 2006-04-02 01:30:54 PST
I feel like I fixed a very similar bug last fall which was caused by some of our java script binding objects not having proper prototypes (thus not having a toString() method).
Comment 3 Gérard Talbot 2006-04-02 12:22:58 PDT
> Some of the properties here cannot be explicitly converted to a string:
> alert(window['CSSRule']); // OK, [object CSSRuleConstructor]

I've never seen such "window['CSSRule']" code but I know one can access css rules in Firefox with

if(document.styleSheets && "cssRules" in document.styleSheets[0]) 
// DOM 2 CSS interface compliant
{
... code ...
};

http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/css.html#CSS-CSSStyleSheet-cssRules

At this precise url
<http://www.quirksmode.org/dom/w3c_css.html#access>
Peter-Paul Koch claims that Safari 1.3 supports cssRules[] collection. He gives a testpage:
<http://www.quirksmode.org/dom/tests/stylesheets.html>

> Event object is dumped correctly in current WebKit builds, available at
> <http://nightly.webkit.org>.

<...Argh...sigh> unfortunately, I can only test my website with a Mac in an Internet Cafe.
Comment 4 Alexey Proskuryakov 2006-04-02 14:12:41 PDT
> I've never seen such "window['CSSRule']" code 

Oh, this is actually just a reduction of what fails in the test case:

TotalString += PropertyIterator + 1 + ". " + arrWindowProperties[PropertyIterator] + " = " + window[arrWindowProperties[PropertyIterator]] + "<br>";

arrWindowProperties[0] happens to be CSSRule in Safari. Several other window properties (e.g. window.XMLHttpRequest) have the same problem. To partially work around this WebKit bug, you can use a try/catch block:

try {
 TotalString += PropertyIterator + 1 + ". " + arrWindowProperties[PropertyIterator] + " = " + window[arrWindowProperties[PropertyIterator]] + "<br>";
} catch (ex) {
 TotalString += PropertyIterator + 1 + ". " + arrWindowProperties[PropertyIterator] + " - " + ex + "<br>";
}

> <...Argh...sigh> unfortunately, I can only test my website with a Mac in an
> Internet Cafe.

No problem, checking with nightly builds is not a requirement for filing WebKit bugs, it's just an extra favor :)
Comment 5 Alexey Proskuryakov 2006-04-15 02:30:24 PDT
*** Bug 7936 has been marked as a duplicate of this bug. ***
Comment 6 Alexey Proskuryakov 2006-06-05 22:06:53 PDT
Most of the missing prototypes have been added in bug 9310. There is a strange problem with window.debug - it is only present when the document is loaded for the first time (not after a reload), and it still causes a "No default value" exception.
Comment 7 Alexey Proskuryakov 2006-06-17 07:29:01 PDT
Created attachment 8884 [details]
fix window.debug and test all properties

I have added a prototype to window.debug, now all the properties of window and document objects can be converted to string.

The strange behavior of window.debug is caused by it being added in KJSProxy::initScriptIfNeeded(), which isn't called when reloading. I am not sure where it should be (Interpreter::initGlobalObject? kjs_window.cpp? removed completely?)
Comment 8 Geoffrey Garen 2006-06-17 20:51:55 PDT
Comment on attachment 8884 [details]
fix window.debug and test all properties

Good fix.

Given the goofiness of this property, and the existence of alternatives like window.console.log, I think we should probably remove it entirely.

If KDE folks are listening, do you get any mileage out of window.debug?
Comment 9 Alexey Proskuryakov 2006-06-17 23:59:18 PDT
Landed r14903. Opened bug 9492 for window.debug.
Comment 10 Gérard Talbot 2008-03-21 09:07:10 PDT
Marking as VERIFIED