Closed
Bug 1014965
Opened 12 years ago
Closed 12 years ago
NativeJSObject.optString does the wrong thing on "key":null
Categories
(Firefox for Android Graveyard :: General, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
Firefox 32
People
(Reporter: nalexander, Assigned: capella)
Details
Attachments
(1 file, 3 obsolete files)
|
3.45 KB,
patch
|
jchen
:
review+
|
Details | Diff | Splinter Review |
Per http://stackoverflow.com/a/23377941, JSONObject.optString on "key":null returns "null". NativeJSObject.optString throws an IllegalArgumentException (which is caught and *ignored* in the event handling, which is awful but not this bug). Like Android, we need to be bug-compatible, even though it sucks.
| Reporter | ||
Comment 1•12 years ago
|
||
While we're at it, NativeJSObject doesn't implement isNull, making it impossible to work-around.
| Assignee | ||
Comment 2•12 years ago
|
||
Implement isNull() for NativeJSObject, add tests ...
Attachment #8428724 -
Flags: review?(nalexander)
| Reporter | ||
Comment 3•12 years ago
|
||
Comment on attachment 8428724 [details] [diff] [review]
bug1014965.diff Implement isNull()
Review of attachment 8428724 [details] [diff] [review]:
-----------------------------------------------------------------
This looks good to me, but I'm going to redirect to jchen.
::: mobile/android/base/tests/testEventDispatcher.java
@@ +294,5 @@
> null, object.optStringArray("stringArray", null));
> fAssertSame("optStringArray returns fallback value if nonexistent",
> null, object.optStringArray("nonexistent_stringArray", null));
> +
> + fAssertEquals("Native (undefined) is null", true, object.isNull("isNullTest0"));
Can we include a" has" test for these first two (or all four) to make it really clear how the first two act?
Attachment #8428724 -
Flags: review?(nchen)
Attachment #8428724 -
Flags: review?(nalexander)
Attachment #8428724 -
Flags: feedback+
| Assignee | ||
Updated•12 years ago
|
Attachment #8428724 -
Flags: review?(nchen)
| Reporter | ||
Updated•12 years ago
|
Attachment #8428724 -
Attachment is obsolete: true
| Assignee | ||
Updated•12 years ago
|
Assignee: nobody → markcapella
Status: NEW → ASSIGNED
Comment 5•12 years ago
|
||
Comment on attachment 8428761 [details] [diff] [review]
bug1014965.diff Implement isNull()
Review of attachment 8428761 [details] [diff] [review]:
-----------------------------------------------------------------
Instead of adding isNull, can we treat null as undefined in GetProperty? See https://mail.mozilla.org/pipermail/mobile-firefox-dev/2014-May/000683.html
Attachment #8428761 -
Flags: review?(nchen)
| Assignee | ||
Comment 6•12 years ago
|
||
mmmm .... that seems to make sense :-)
Attachment #8428761 -
Attachment is obsolete: true
Attachment #8429371 -
Flags: review?(nchen)
Comment 7•12 years ago
|
||
Comment on attachment 8429371 [details] [diff] [review]
bug1014965.diff
Review of attachment 8429371 [details] [diff] [review]:
-----------------------------------------------------------------
LGTM. Thanks!
::: mobile/android/base/tests/testEventDispatcher.java
@@ +311,5 @@
> +
> + fAssertEquals("Native optDouble returns fallback value if undefined",
> + -3.1415926535, object.optDouble("undefined", -3.1415926535));
> + fAssertEquals("Native optDouble returns fallback value if null",
> + -3.1415926535, object.optDouble("null", -3.1415926535));
I tend to use numbers that have exact floating point representation (e.g. 0.5, 1.75, etc.) to avoid possible subtle bugs, but it's not a big deal.
@@ +318,5 @@
> + "chromodynamics", object.optString("undefined", "chromodynamics"));
> + fAssertEquals("Native optString returns fallback value if null",
> + "chromodynamics", object.optString("null", "chromodynamics"));
> + fAssertNotSame("Native optString does not return fallback value if emptyString",
> + "chromodynamics", object.optString("emptyString", "chromodynamics"));
fAssertNotEquals. And let's stick with "foo" and "bar" :)
Attachment #8429371 -
Flags: review?(nchen) → review+
| Assignee | ||
Comment 8•12 years ago
|
||
| Assignee | ||
Comment 9•12 years ago
|
||
Re-requesting review ... I had to remove the test for the "undefined" var as the push-to-try failed, pointing out that it won't pass the |message.toBundle();| portion of the test.
Attachment #8429371 -
Attachment is obsolete: true
Attachment #8430198 -
Flags: review?(nchen)
| Assignee | ||
Comment 10•12 years ago
|
||
re-push to try passed ok
https://tbpl.mozilla.org/?tree=Try&rev=fcbab0b69168
Comment 11•12 years ago
|
||
Comment on attachment 8430198 [details] [diff] [review]
bug1014965.diff
Review of attachment 8430198 [details] [diff] [review]:
-----------------------------------------------------------------
LGTM!
Attachment #8430198 -
Flags: review?(nchen) → review+
| Assignee | ||
Comment 12•12 years ago
|
||
Comment 13•12 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 32
Updated•5 years ago
|
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•