Skip to content
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

Open
wants to merge 33 commits into
base: main
Choose a base branch
from
Open

APIs for shimming standard APIs #956

wants to merge 33 commits into from

Conversation

muodov
Copy link
Member

@muodov muodov commented Apr 24, 2024

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.


setPositionState () {}
}

this.shimInterface('MediaSession', MyMediaSession, {
Copy link
Collaborator

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?

Copy link
Member Author

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.

}

// mark the class as a shimmed class
objectDefineProperty(ImplClass, ddgShimMark, {
Copy link
Collaborator

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 :)

Copy link
Member Author

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?

@muodov muodov changed the title WIP: APIs for shimming standard APIs APIs for shimming standard APIs May 1, 2024
@muodov muodov marked this pull request as ready for review May 1, 2024 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants