Open Bug 1622329 Opened 5 years ago Updated 3 years ago

Should Promise::CreateFromExisting assert the passed object is PromiseObject ?

Categories

(Core :: DOM: Core & HTML, enhancement)

enhancement

Tracking

()

People

(Reporter: arai, Unassigned)

Details

DOMPromise's mPromiseObj comes from 2 places

The former is newly created one, so it's always PromiseObject.
The latter is from the caller, and it doesn't assert any about the type.

Some consumer of promiseObj() expects it to always be a PromiseObject
https://searchfox.org/mozilla-central/rev/f36cb2af46edd2659f446b7acdb2154e230ee445/xpcom/base/CycleCollectedJSContext.cpp#695-696
https://searchfox.org/mozilla-central/rev/f36cb2af46edd2659f446b7acdb2154e230ee445/xpcom/base/CycleCollectedJSContext.cpp#738-739

Some others calls JSAPI that accepts both PromiseObject and wrapper.
https://searchfox.org/mozilla-central/rev/f36cb2af46edd2659f446b7acdb2154e230ee445/dom/promise/Promise.cpp#304-305

If it should always be a PromiseObject, at least we should assert IsPromiseObject in Promise::CreateFromExisting.

Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.