react/packages/react-devtools-shell
Ruslan Lesiutin b14f8da155
refactor[devtools]: forbid editing class instances in props (#26522)
## Summary
Fixes https://github.com/facebook/react/issues/24781

Restricting from editing props, which are class instances, because their
internals should be opaque.

Proposed changes:
1. Adding new data type `class_instance`: based on prototype chain of an
object we will check if its plain or not. If not, then will be marked as
`class_instance`. This should not affect `arrays`, ..., because we do
this in the end of an `object` case in `getDataType` function.

Important detail: this approach won't work for objects created with
`Object.create`, because of the custom prototype. This can also be
bypassed by manually deleting a prototype ¯\\\_(ツ)_/¯
I am not sure if there might be a better solution (which will cover all
cases) to detect if object is a class instance. Initially I was trying
to use `Object.getPrototypeOf(object) === Object.prototype`, but this
won't work for cases when we are dealing with `iframe`.


2. Objects with a type `class_instance` will be marked as unserializable
and read-only.

## Demo
`person` is a class instance, `object` is a plain object


https://user-images.githubusercontent.com/28902667/228914791-ebdc8ab0-eb5c-426d-8163-66d56b5e8790.mov
2023-04-03 11:32:17 +01:00
..
src refactor[devtools]: forbid editing class instances in props (#26522) 2023-04-03 11:32:17 +01:00
e2e-regression.html DevTools] e2e Regression Testing App (#24619) 2022-05-26 11:36:00 -04:00
e2e.html Refactored DevTools test shell for e2e (#22968) 2021-12-15 11:42:59 -05:00
index.html [DevTools] add perf regression test page in shell (#25078) 2023-01-04 17:31:13 -05:00
multi.html DevTools: Support mulitple DevTools instances per page (#22949) 2021-12-14 12:16:16 -05:00
package.json DevTools] e2e Regression Testing App (#24619) 2022-05-26 11:36:00 -04:00
perf-regression.html [DevTools] add perf regression test page in shell (#25078) 2023-01-04 17:31:13 -05:00
README.md Add details in READMEs for react-devtools local developement (#24148) 2022-03-24 10:04:12 -04:00
webpack.config.js [DevTools] add perf regression test page in shell (#25078) 2023-01-04 17:31:13 -05:00

Harness for testing local changes to the react-devtools-inline and react-devtools-shared packages.

Development

This target should be run in parallel with the react-devtools-inline package. The first step then is to run that target following the instructions in the react-devtools-inline README's local development section.

The test harness can then be run as follows:

cd packages/react-devtools-shell

yarn start

Once you set both up, you can view the test harness with inlined devtools in browser at http://localhost:8080/