Closed Bug 1296235 Opened 4 years ago Closed 1 year ago

Promise helper functions should be anonymous

Categories

(Core :: JavaScript: Standard Library, defect, P3)

defect

Tracking

()

RESOLVED FIXED
mozilla68
Tracking Status
firefox51 --- wontfix
firefox68 --- fixed

People

(Reporter: anba, Assigned: jorendorff)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

Test case 1:
---
var resolveElementFunction;
var thenable = {
  then: function(fulfill) {
    resolveElementFunction = fulfill;
  }
};
function NotPromise(e) { e(() => {}, () => {}) }
NotPromise.resolve = function(v) { return v; };
Promise.all.call(NotPromise, [thenable]);

assertEq(resolveElementFunction.hasOwnProperty("name"), false);
---


Test case 2:
---
var executorFunction;
function NotPromise(executor) {
  executorFunction = executor;
  executor(() => {}, () => {});
}
Promise.resolve.call(NotPromise);

assertEq(executorFunction.hasOwnProperty("name"), false);
---


Test case 3:
---
var rejectFunction;
new Promise(function(resolve, reject) {
  rejectFunction = reject;
});

assertEq(rejectFunction.hasOwnProperty("name"), false);
---


Test case 4:
---
var resolveFunction;
new Promise(function(resolve, reject) {
  resolveFunction = resolve;
});

assertEq(resolveFunction.hasOwnProperty("name"), false);
---


Expected: All tests pass
Actual: All tests fail

https://tc39.github.io/ecma262/#sec-promise.all-resolve-element-functions
https://tc39.github.io/ecma262/#sec-getcapabilitiesexecutor-functions
https://tc39.github.io/ecma262/#sec-promise-reject-functions
https://tc39.github.io/ecma262/#sec-promise-resolve-functions
Blocks: test262
Priority: -- → P3

The current standard requires some functions to have no own name property at
all; they instead inherit Function.prototype.name, which is "". However,
V8 and JSC both already do what we do, so we're working to change the standard
instead of changing our behavior. See
https://github.com/tc39/ecma262/issues/1049.

Assignee: nobody → jorendorff
Pushed by jorendorff@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/39a370883518
Adjust jstests.list to reflect that each function has an own `.name` property on purpose. r=jwalden
Status: NEW → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla68
You need to log in before you can comment on or make changes to this bug.