-
Notifications
You must be signed in to change notification settings - Fork 46.4k
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
Issue/#19545 #19584
Issue/#19545 #19584
Conversation
Hi @pfongkye! Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 93543e0:
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
2 similar comments
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
typeof data.name === 'function' || !data.name | ||
? 'function' | ||
: data.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.
The javascript Proxy wraps the name attribute. I think instead of using data.name
you can replace it by data.prototype.constructor.name
. It is the same thing but the difference is the constructor.name is not wrapped by the proxy.
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.
The javascript Proxy wraps the name attribute.
Oh that's very interesting! Nice find.
I think instead of using
data.name
you can replace it bydata.prototype.constructor.name
. It is the same thing but the difference is the constructor.name is not wrapped by the proxy.
I'm wary of using data.prototype.constructor.name
because not all objects have a prototype (e.g. Object.create(null)
Yes. Sounds worth doing. |
@bvaughn I had some tests failing before the modifications. I fixed some. There are two remaining. I wanted to check with you if these are the new expected behaviors before fixing them: |
@@ -403,13 +403,13 @@ describe('InspectedElementContext', () => { | |||
|
|||
expect(targetRenderCount).toBe(1); | |||
expect(errorSpy).toHaveBeenCalledTimes(1); | |||
expect(errorSpy).toHaveBeenCalledWith('error'); | |||
expect(errorSpy).toHaveBeenCalledWith('Warning: error'); |
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.
Umm.. does Warning: error
look okay? The only tests failing in CircleCI belong to this specific commit (args prefixed with "Warning: ").
@pfongkye I'm not sure I understand what you're asking about those two tests. How do they fail? Hard for me to say if the failure would be expected or not without having more context. The second one in particular though (expected 3 but got 1) does not seem expected, I think. |
@@ -43,7 +43,7 @@ describe('Bridge', () => { | |||
jest.runAllTimers(); | |||
expect(wall.send).not.toHaveBeenCalled(); | |||
expect(console.warn).toHaveBeenCalledWith( | |||
'Cannot send message "should not send" through a Bridge that has been shutdown.', | |||
'Warning: Cannot send message "should not send" through a Bridge that has been shutdown.', |
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.
Why are you adding "Warning:" prefixes to these tests?
Sorry. So I don't know why but I was having those two tests failing on my computer (OS is Windows 10 Professional): But after running I'm going to revert commit pfongkye@6b36d98#diff-ab5ee5655b2aac3260e1f836546a13c9 and hopefully find out why the tests are failing. |
This reverts commit 6b36d98.
FWIW, I checked out your branch and reverted that commit locally– and when I ran DevTools tests, they all passed. |
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.
This looks like a nice improvement to me. Let's see if CI is happy 😄
Any other changes you looking to include? (I see the PR is still in "Draft" status)
Nope. It was because of the tests :) |
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.
Looks good to me, thank you!
Thanks a lot! |
Summary
Fixes #19545
The data.name in a given payload should not be a function since window.postMessage would throw an error.
If I'm on the right path, should we modify
formatDataForPreview
to take into consideration the fact that data.name can be an anonymous function?Test Plan