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
APIs for shimming standard APIs #956
base: main
Are you sure you want to change the base?
Conversation
setPositionState () {} | ||
} | ||
|
||
this.shimInterface('MediaSession', MyMediaSession, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be just:
this.shimInterface(MediaSession, {...})
And internally it use arg[0].name
for the typing?
Would this omit the need to then mock .name
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would require the class to always have the correct name, which we can't verify inside the method.
This file is not ready btw, the correct usages are in the test file.
src/content-feature.js
Outdated
} | ||
|
||
// mark the class as a shimmed class | ||
objectDefineProperty(ImplClass, ddgShimMark, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is still visible in getOwnPropertySymbols
, please validate :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, for sure. I thought it was an acceptable compromise so we can split shimProperty
from shimInterface
while still verifying the correct call order. Calling shimProperty
before shimInterface
would cause very tricky bugs.
We can also merge these two methods in one, what do you think?
Co-authored-by: Jonathan Kingston <jkingston@duckduckgo.com>
Project: https://app.asana.com/0/72649045549333/1207011810532429/f
This PR adds ContentFeature APIs to shim standard interfaces classes and global instances. These APIs are designed to be used in webcompat shims, when we write polyfills for APIs that are missing on specific platforms.