Closed Bug 1435922 Opened 6 years ago Closed 6 years ago

Discrepancy in behavior between Array.from and array spread

Categories

(Firefox :: Untriaged, defect)

58 Branch
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: iamchuckb+mozilla, Unassigned)

Details

Attachments

(1 file, 1 obsolete file)

1.87 KB, application/x-javascript
Details
Attached file safe.js (obsolete) —
User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:58.0) Gecko/20100101 Firefox/58.0
Build ID: 20180131005501

Steps to reproduce:

This may not actually be a security bug but it's inexplicable (to me) and only seems to occur when working with a somewhat large number of objects so I'm reporting it as such to be on the safe side.

0. I traverse the properties under `window` and index property names and property values in a Map (attached source is all that is necessary to recreate issue)
1. The indexer returns a map with ~6000 entries. I convert the iterator over entries into an array in two ways:
  a. `Array.from(map.entries())`
  b. `[...map.entries()]`
2. On many sites, these are the same. On some sites (the one brought to my attention and on which I can recreate is 511tactical.com), 1a and 1b yield arrays of different length.


Actual results:

let map = index()
map.size === 6165
Array.from(map.entries()).length === 0
[...map.entries()].length === 6165


Expected results:

let map = index()
map.size === 6165
Array.from(map.entries()).length === 6165
[...map.entries()].length === 6165
Attachment #8948585 - Attachment is obsolete: true
Investigated this further, it seems like the site in question is using a polyfill that unconditionally replaces the built-in implementation. Closing.
Status: UNCONFIRMED → RESOLVED
Closed: 6 years ago
Resolution: --- → INVALID
Group: firefox-core-security
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: