Closed Bug 225547 Opened 21 years ago Closed 18 years ago

javascript:this.netscape or javascript:eval("this.netscape") alerts "The url is not valid and cannot be loaded." OK

Categories

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

defect
Not set
major

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: timeless, Unassigned)

References

()

Details

Notes:
n4.79:
1. javascript:this.netscape returns:
[JavaPackage netscape]
2. I've never seen an alert like that for any javascript: url.

mozilla
1. This seems restricted to 
javascript:netscape, javascript:this.netscape, javascript:eval("this.netscape"),
javascript:eval("nets"+"cape").
I can't find any other object which does this.
2. I don't care about this bug, but it just seemed odd
3. This reminds me of view-source:foo:bar, but i don't think it relates.

Steps:
1. enable javascript [:-)]
2. click the url link

Expected Results:
No dialog alerts

Actual Results:
Alert
/!\ The url is not valid and cannot be loaded.
                 [     O K     ]

Acceptable results:
4xp [JavaPackage netscape] 
ie5 nothing (undefined coerced to null?)
js console says "Error: can't convert Object to string"
More fun:
in JS console, type netscape and click Evaluate
in Chatzilla, type /eval netscape
in Venkman, type netscape
This last one crashed for me, so upping severity.
Severity: trivial → major
Status: UNCONFIRMED → NEW
Ever confirmed: true
I typed netscape in Venkman 0.9.81 and didn't crash.
I typed typeof this.netscape in Venkman and got "undefined"; in the evaluate
input of the js console, I got no error.
 Syntax
Packages.netscape

Use the netscape property to access any class in the netscape package from
within JavaScript. Note that the top-level object netscape is a synonym for
Packages.netscape.
http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/packages.html#1194854


"The netscape object is a top-level, predefined JavaScript object. You can
automatically access it without using a constructor or calling a method.

The netscape object is a convenience synonym for the property Packages.netscape."
http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/netscape.html#1193137
Venkman binds |this| differently, perhaps.

The JS console shows "Error: can't convert Object to string".  Sounds like a
buggy implementation of toString for the object referenced by this.netscape in
DOM level 0 LiveConnect-compatible window objects.  Indeed, that object has no
toString method, and its __proto__ is undefined.

However, javascript:Packages.netscape works fine.  And javascript:sun and
javascript:java work fine.

Oddly, javascript:sun==Packages.sun and javascript:java==Packages.java evaluate
to false.  As does javascript:netscape==Packages.netscape.

I'm not sure why netscape does not have a prototype or a toString method, but
the failure to equate references such as java and Packages.java is a 4xp bug. 
Reassigning to liveconnect.

/be

Assignee: general → kyle.yuan
Component: DOM: Level 0 → Java: Live Connect
Flags: blocking1.7.1?
OS: Windows 2000 → All
Hardware: PC → All
the code path does not go through JavaPackage_resolve when executing
javascript:netscape, but javascript:sun does. "netscape" must be defined
somewhere else before it gets defined as a java package.
"netscape" is defined in nsSecurityNameSet::InitializeNameSet
http://lxr.mozilla.org/seamonkey/source/caps/src/nsSecurityManagerFactory.cpp#288

And this method gets called before liveconnect initialized.
http://lxr.mozilla.org/seamonkey/source/dom/src/base/nsJSEnvironment.cpp#1822
So, two bugs:

- One in liveconnect, for not making "java" and "Packages.java" refer to the
same object (ditto for sun and netscape).

- Another in CAPS or the DOM for preempting "netscape".

This bug could be used for either, but the second is what caused timeless to
file it, so I've filed bug 248409 for the first problem, assigned to Kyle. 
Relocating this bug to DOM for now.

/be
Assignee: kyle.yuan → general
Component: Java: Live Connect → DOM: Level 0
Keywords: 4xp
Doesn't CAPS have to pre-empt "netscape" so that we can support the
privilegeManager calls in the absence of Java?  (Or, I guess, even in the
presence of Java, since we're not forwarding the enablePrivilege stuff through
OJI regardless.)
Flags: blocking1.7.5? → blocking1.7.5-
No alert in 1.5.0.7; I get a page saying "[object Object]".
I typed in the JavaScript console of Firefox 1.5.0.7 build 20060909 (and then pressed evaluate button):
javascript:this.netscape
then
javascript:eval("this.netscape")
also
javascript:eval("nets"+"cape")
and also
javascript:netscape
and got [object Object] for all 4.
I then typed typeof this.netscape which returned object.

I typed in the Error console of Seamonkey 1.5a rv 1.9a1 build 2006092509 (and then pressed evaluate button):
javascript:this.netscape
then
javascript:eval("this.netscape")
also
javascript:eval("nets"+"cape")
and also
javascript:netscape
and got [object Object] for all 4.
I then typed typeof this.netscape which returned object

With Venkman 0.9.87:
0001: typeof netscape
object
0002: netscape
[object Object]
0003: eval("netscape")
[object Object]
0004: eval("nets" + "cape")
[object Object]
0005: netscape.toString()
[object Object]

So this bug seems to have been fixed

Resolving as WORKSFORME
Status: NEW → RESOLVED
Closed: 18 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.