Property access never fails even if the property exists

RESOLVED INVALID

Status

()

RESOLVED INVALID
8 years ago
8 years ago

People

(Reporter: sdwilsh, Assigned: mrbkap)

Tracking

Trunk
x86
Windows 7
Points:
---

Firefox Tracking Flags

(blocking2.0 -)

Details

(Reporter)

Description

8 years ago
I ran into this today while working on bug 606966.  I have an interface, mozIPlaceInfo, that has a series of attributes defined on it.  I pass this into a method, and try to get a property off the object:

PRInt64 placeId = -1;
bool hasPlaceId = NS_SUCCEEDED(info->GetPlaceId(&placeId));

At this point, placeId = 0, and hasPlaceId = true.  The JS object that I pass in looks like this:
{
  url: NetUtil.newURI("http://mozilla.org/test_no_id_throws"),
}

This used to return an error, but it doesn't anymore.
(Reporter)

Updated

8 years ago
blocking2.0: --- → ?
Shawn, any chance you could write up a testcase for this?
(Reporter)

Comment 2

8 years ago
yes, but unless this turns into a blocker, I don't see myself having time for it any time soon.
Hmm, the more I think about this the more it worries me. I'd like to at least understand what's causing this change. Blake, can you have a look once you're done with your current set of blockers?
Assignee: nobody → mrbkap
blocking2.0: ? → final+

Updated

8 years ago
Whiteboard: [softblocker]
Shawn, mrbkap says this doesn't return an error in 3.6, so I'm unblocking on this. When did this return an error?
blocking2.0: final+ → -
Whiteboard: [softblocker]
(Reporter)

Comment 5

8 years ago
(In reply to comment #4)
> Shawn, mrbkap says this doesn't return an error in 3.6, so I'm unblocking on
> this. When did this return an error?
Huh, maybe it was older than 3.6?  Conversations with timeless on irc indicated that we had done an error in the past (I recall writing code that used this in the past too).

I also never saw any console spew that looks like this:
************************************************************
* Call to xpconnect wrapped JSObject produced this error:  *
[Exception... "'JavaScript component does not have a method named: "handleCompletion"' when calling method: [mozIStorageStatementCallback::handleCompletion]"  nsresult: "0x80570030 (NS_ERROR_XPC_JSOBJECT_HAS_NO_FUNCTION_NAMED)"  location: "<unknown>"  data: no]
************************************************************

But maybe we only do that for methods, and that is where the confusion is coming from?  (It also errors for methods).
I'm marking this INVALID based on the previous discussion. Shawn, did you want to morph this bug into an enhancement asking XPConnect to warn in this case?
Status: NEW → RESOLVED
Last Resolved: 8 years ago
Resolution: --- → INVALID
(Reporter)

Comment 7

8 years ago
(In reply to comment #6)
> I'm marking this INVALID based on the previous discussion. Shawn, did you want
> to morph this bug into an enhancement asking XPConnect to warn in this case?
It would be handy if it did, but I'm just as inclined to use the js api instead for all future things.

Comment 8

8 years ago
oh yeah, properties are treated as undefined (which coerces to 0), i was probably confused and thought we were talking about methods. sorry. in theory the return value could be NS_SUCCEEDED() but not NS_OK, we have things like LOSS_OF_INSIGNIFICANT_DATA.
You need to log in before you can comment on or make changes to this bug.