Closed Bug 808807 Opened 12 years ago Closed 6 years ago

mochitest converts Array to Object

Categories

(Testing :: Mochitest, defect)

defect
Not set
normal

Tracking

(blocking-kilimanjaro:?)

RESOLVED WONTFIX
blocking-kilimanjaro ?

People

(Reporter: dchanm+bugzilla, Unassigned)

Details

Attachments

(1 file, 1 obsolete file)

Attached file test array returned by function (obsolete) —
See attached test case. You will need the patch from bug 808734

PermissionsInstaller.expandPermissions always returns an Array. [1] However something is happening and the Array turns into an Array like object

Expected
["contacts", "contacts-read", "contacts-create", "contacts-write"]

Result
{"0": "contacts", "1": "contacts-read", "2": "contacts-create", "3": "contacts-write"}

Gaia
commit 4f5aecb0a75cf89a45848b349d977eaeb008e858

Gecko
commit 618d9a9a2b30325b19e514a1b2de6989ad8d5bc3


[1] - http://mxr.mozilla.org/mozilla-central/source/dom/apps/src/PermissionsInstaller.jsm#263
Comment on attachment 678491 [details]
test array returned by function

You're sure it's not returning an Array from that module's global?  The instanceof operator is arguably broken about this, but that's life.  If you want to check if a value is an Array, from any global, use Array.isArray(perm).  If you're seeing this other-global array look like an object in, say, the console or whatever, that might arguably be a console bug.  (Or not; they might want to only show things as arrays if they're from the current window, although I kind of doubt it.)
I was using the wrong mochitest construct is() instead of ok(). I've changed it to ok() as well as using Array.isArray() as suggested by :Waldo

The test is still failing
Attachment #678491 - Attachment is obsolete: true
Mass closing mochitest bugs that haven't had activity in the past 5 years. Please re-open or file a new bug with modern context if this is still relevant.
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: