resolve-element-function-property-order.js 860 B

123456789101112131415161718192021222324252627282930
  1. // Copyright (C) 2020 ExE Boss. All rights reserved.
  2. // This code is governed by the BSD license found in the LICENSE file.
  3. /*---
  4. esid: sec-createbuiltinfunction
  5. description: Promise.all resolve element function property order
  6. info: |
  7. Set order: "length", "name"
  8. ---*/
  9. var resolveElementFunction;
  10. var thenable = {
  11. then: function(fulfill) {
  12. resolveElementFunction = fulfill;
  13. }
  14. };
  15. function NotPromise(executor) {
  16. executor(function() {}, function() {});
  17. }
  18. NotPromise.resolve = function(v) {
  19. return v;
  20. };
  21. Promise.all.call(NotPromise, [thenable]);
  22. var propNames = Object.getOwnPropertyNames(resolveElementFunction);
  23. var lengthIndex = propNames.indexOf("length");
  24. var nameIndex = propNames.indexOf("name");
  25. assert(lengthIndex >= 0 && nameIndex === lengthIndex + 1,
  26. "The `length` property comes before the `name` property on built-in functions");