SERVER-128125ClosedFixed
Align bsonObjToArray ownership semantics with bsonGetImmutable
bsonObjToArray and bsonGetImmutable are sibling functions in the MozJS BSON binding layer. bsonGetImmutable ensures the BSONObj it works with is owned before creating JS wrappers around it; bsonObjToArray does not apply the same treatment. This inconsistency can lead to incorrect behaviour when operating on sub-document wrappers. Bring bsonObjToArray in line with the established pattern used by bsonGetImmutable.