-
Notifications
You must be signed in to change notification settings - Fork 45
Proposal: Introduce InternalPromise to keep Promise integrity #80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
NOTE: Now, we introduced |
this is related to #78. instead of introducing |
How about this case? Promise.prototype.then = function () {
return new Promise(function (resolve, reject) { reject("Always reject"); });
}; I think this will break the loader pipeline. Because |
@Constellation I think we are covered at the algo level. E.g.: https://whatwg.github.io/loader/#request-fetch step 9, where we use the pass-thru of the promise returned by the hook. We can certainly improve https://whatwg.github.io/loader/#reacting-to-promises to protect us against this. Isn't that enough? Do you have any suggestion to protect against this? any precedent on this issue? /cc @domenic |
@caridy, @domenic |
correct, we want to guarantee that no matter how the promise gets resolved, the logic in 7.d.i and 7.d.2 gets executed. The same applies to I plan to add some notes (now that ecmarkup supports notes inside algos) to provide more details. |
@caridy: |
I think we can close this one, we have reduced the amount of tricks we are doing with promises, and we will continue doing so as part of #97 |
Now, the loader spec highly utilizes the Promise for its internal pipeline.
However, Promise itself is exposed to users freely. That means users can replace / modify
then
method to break the internal loader behavior.For example, in
RequestTranslate
step 7-c, https://whatwg.github.io/loader/#request-translateIt returns the promise inside the the other promise's fulfill handler. It finally invokes the
"then"
method in ECMA 262 6.0 section 25.4.1.3.2 step 8.http://ecma-international.org/ecma-262/6.0/#sec-promise-resolve-functions
Thus, by replacing the
Promise.prototype.then
, users can break the loader pipeline.So, we would like to propose
InternalPromise
. It is completely separated instances from thePromise
exposed to users. This meansInternalPromise !== Promise
andInternalPromise.prototype !== Promise.prototype
etc. ButInternalPromise
has the same functionality to thePromise
.The text was updated successfully, but these errors were encountered: