Commit Graph
13147 Commits
Author SHA1 Message Date
71cfe02fbe Fix mistyped script arbitrary code execution vulnerability (#18660)
* add test to trustedTypes-test.internal.js

* fix mistyped script arbitrary code execution

* Removed redundant .toLowerCase() call

Co-authored-by: Brian Vaughn <[email protected]>
2020-04-21 12:10:25 -07:00
Brian VaughnandGitHub b1363b9211 Pin RNW to canary (#18692)
This unbreaks DevTools shell with the latest ReactDOM in master.
2020-04-21 11:46:29 -07:00
Brian VaughnandGitHub 40703bf187 DevTools: Improved "native" component stacks (#18656)
* DevTools console override handles new component stack format

DevTools does not attempt to mimic the default browser console format for its component stacks but it does properly detect the new format for Chrome, Firefox, and Safari.
2020-04-21 11:46:11 -07:00
Sebastian MarkbågeandGitHub 596af34e66 Avoid passing custom stacks to console.error (#18685)
* Detect double stacks in the new format in tests

* Remove unnecessary uses of getStackByFiberInDevAndProd

These all execute in the right execution context already.

* Set the debug fiber around the cases that don't have an execution context

* Remove stack detection in our console log overrides

We never pass custom stacks as part of the args anymore.

* Bonus: Don't append getStackAddendum to invariants

We print component stacks for every error anyway so this is just duplicate
information.
2020-04-21 09:22:46 -07:00
Dominic GannawayandGitHub 3e71688532 Remove ReactDOM.useEvent and associated types+tests (#18689) 2020-04-21 16:40:44 +01:00
Dominic GannawayandGitHub 261fbfda82 Revert "Pressable click fix (#18625)" (#18688)
This reverts commit adaef59079.
2020-04-21 11:08:30 +01:00
Dominic GannawayandGitHub 3e9dc98594 Remove null sibling (#18687) 2020-04-21 10:43:50 +01:00
Sebastian MarkbågeandGitHub 1cefdd246d Upgrade fbjs-scripts (#18684)
* Upgrade fbjs-scripts

This script takes into account the NODE_ENV as part of jest cache keys.
This avoids flaky tests since we depend on different transforms in prod
and dev.

* Upgrade Fresh test to Babel 7 transform
2020-04-20 18:20:03 -07:00
Naman GoelandGitHub adaef59079 Pressable click fix (#18625)
* Update press-legacy to use native click events

* update tests for pressable change

* fix formatting issue

* Address comments. Bring back some tests, remove others. Cleanup

* Fix flow and lint errors

* formatting fix missed by yarn lint
2020-04-20 23:13:17 +01:00
Dominic GannawayandGitHub 57541426a8 Modern event system: fix selectionchange bug (#18680) 2020-04-20 19:54:12 +01:00
Dominic GannawayandGitHub 7e2f380123 Refine the heuristics around beforeblur/afterblur (#18668)
* Refine the heuristics around beforeblur/afterblur
2020-04-20 19:32:22 +01:00
Sebastian SilbermannandGitHub d510e28b5a chore: Build react-dom/server in codesandbox CI (#18679) 2020-04-20 18:48:07 +01:00
Sebastian SilbermannandGitHub 0a20b01ec5 fix: skip dangerouslySetInnerHtml hydration warning if it's undefined (#18676)
* test: Add failing case for dangerouslySetInnerHtml=undefined

* fix: skip dangerouslySetInnerHtml warning if it's undefined

* test: add similar test that should trigger the warning

* chore: Remove redundant nullish check

* Poke yarn_test_www_variant which timed out

* test: Add smaller test for innerHTML=string to innerHTML=undefined
2020-04-20 18:46:55 +01:00
Dominic GannawayandGitHub 9782279def Revert "Revert focus event PRs (#18655)" (#18671)
This reverts commit 978e42f108.
2020-04-20 16:00:33 +01:00
Nicolas GallagherandGitHub 5b4be236e8 ReactDOM: remove unstable-native-dependencies bundle (#18483)
This is only used by react-native-web and will be replaced by a user-space
implementation. See: https://github.com/necolas/react-native-web/issues/1568
2020-04-18 15:40:13 -07:00
Brian VaughnandGitHub 4c42096079 Fix incorrect unmounted state update warning (#18617)
* Fix incorrect unmounted state update warning

We detach fibers (which nulls the  field) when we commit a deletion, so any state updates scheduled between that point and when we eventually flush passive effect destroys won't have a way to check if there is a pending passive unmount effect scheduled for its alternate unless we also explicitly track this for both the current and the alternate.

This commit adds a new DEV-only effect type, `PendingPassiveUnmountDev`, to handle this case.
2020-04-18 12:18:19 -07:00
Andrew ClarkandGitHub 540faf3141 Make Flow work with your editor (#18664)
We typecheck the reconciler against each one of our host configs.
`yarn flow dom` checks it against the DOM renderer, `yarn flow native`
checks it against the native renderer, and so on.

To do this, we generate separate flowconfig files.

Currently, there is no root-level host config, so running Flow
directly via `flow` CLI doesn't work. You have to use the `yarn flow`
command and pick a specific renderer.

A drawback of this design, though, is that our Flow setup doesn't work
with other tooling. Namely, editor integrations.

I think the intent of this was maybe so you don't run Flow against a
renderer than you intended, see it pass, and wrongly think you fixed
all the errors. However, since they all run in CI, I don't think this
is a big deal. In practice, I nearly always run Flow against the same
renderer (DOM), and I'm guessing that's the most common workflow for
others, too.

So what I've done in this commit is modify the `yarn flow` command to
copy the generated `.flowconfig` file into the root directory. The
editor integration will pick this up and show Flow information for
whatever was the last renderer you checked.

Everything else about the setup is the same, and all the renderers will
continue to be checked by CI.
2020-04-18 10:24:46 -07:00
Andrew ClarkandGitHub a1de1be595 Fix for #18657 (#18663)
* Failing test for #18657

* Remove incorrect priority check

I think this was just poor factoring on my part in #18411. Honestly it
doesn't make much sense to me, but my best guess is that I must have
thought that when `baseTime > currentChildExpirationTime`, the function
would fall through to the
`currentChildExpirationTime < renderExpirationTime` branch below.

Really I think just made an oopsie.

Regardless, this logic is galaxy brainéd. A goal of the Lanes refactor
I'm working on is to make these types of checks -- is there remaining
work in this tree? -- a lot easier to think about. Hopefully.
2020-04-17 16:32:55 -07:00
Dominic GannawayandGitHub d3cd3c9ce1 Revise isFiberInsideHiddenOrRemovedTree (#18662) 2020-04-17 23:58:40 +01:00
Andrew ClarkandGitHub 10e18861a5 Remove redundant expiration time comparisons (#18620)
I'm going through all the expiration times comparisons as part of my
refactor and I noticed this one has a redundancy.
2020-04-17 11:48:05 -07:00
Dominic GannawayandGitHub 978e42f108 Revert focus event PRs (#18655)
* Revert "Further cleanup to before/after blur (#18649)"

This reverts commit 3de3ed5195.

* Revert "Unify Flare FocusWithin responder with useFocusWithin (#18636)"

This reverts commit 8024c7d097.
2020-04-17 16:27:19 +01:00
Dominic GannawayandGitHub 3de3ed5195 Further cleanup to before/after blur (#18649) 2020-04-17 11:52:29 +01:00
Brian VaughnandGitHub 5c0962912a Fixed DevTools extension build:dev command (#18648) 2020-04-16 17:39:16 -07:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2a81bb3a69 Bump https-proxy-agent from 2.2.1 to 2.2.4 in /scripts/release (#18642)
Bumps [https-proxy-agent](https://github.com/TooTallNate/node-https-proxy-agent) from 2.2.1 to 2.2.4.
- [Release notes](https://github.com/TooTallNate/node-https-proxy-agent/releases)
- [Commits](https://github.com/TooTallNate/node-https-proxy-agent/compare/2.2.1...2.2.4)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-04-16 16:06:13 -07:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
d096a84068 Bump https-proxy-agent from 2.2.2 to 2.2.4 (#18643)
Bumps [https-proxy-agent](https://github.com/TooTallNate/node-https-proxy-agent) from 2.2.2 to 2.2.4.
- [Release notes](https://github.com/TooTallNate/node-https-proxy-agent/releases)
- [Commits](https://github.com/TooTallNate/node-https-proxy-agent/compare/2.2.2...2.2.4)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-04-16 16:06:06 -07:00
Dominic GannawayandGitHub aa8fee8215 Clean up modern plugins to remove dead code (#18639) 2020-04-16 20:10:23 +01:00
Dan AbramovandGitHub 58a2f21c5c Statically disable factory components for WWW (#18641) 2020-04-16 19:42:30 +01:00
Dominic GannawayandGitHub 8024c7d097 Unify Flare FocusWithin responder with useFocusWithin (#18636) 2020-04-16 19:35:41 +01:00
Dominic GannawayandGitHub 9b98d6187c Revert legacy plugin modules (#18638) 2020-04-16 18:46:24 +01:00
Dominic GannawayandGitHub e8f35ec4b8 Create copy of Legacy event plugins for Modern system (#18637) 2020-04-16 16:09:05 +01:00
Andrew ClarkandGitHub d989742c78 Run error replay test again new reconciler (#18628)
This is one of our few tests of an internal function. Need to import
the module that corresponds to the reconciler that's being tested.
2020-04-16 08:08:22 -07:00
Boris SerdiukandGitHub 9d904d7b40 Fix requiring timers module with non standard require (#18632)
fixes #18589
2020-04-16 12:36:09 +01:00
d1f1cd09b2 ADD: disableRemotePlayback attribute for HTML5 videos (#18619)
* Add support for disableremoteplayback

* Order attributes alphabetically

Co-authored-by: Tom Brown <[email protected]>
2020-04-16 10:23:48 +01:00
Brian VaughnandGitHub 6767ccd239 Fix CI (#18626) 2020-04-15 22:27:24 -07:00
Andrew ClarkandGitHub db7a334229 Fix wrong command in config.yml (#18624) 2020-04-15 21:44:38 -07:00
Brian VaughnandGitHub bb16e33939 Add experimental DebugTracing logger for internal use (#18531) 2020-04-15 19:10:15 -07:00
Andrew ClarkandGitHub 46b94dae25 Update nvmrc to the same one used in CI (#18623) 2020-04-15 16:03:02 -07:00
Andrew ClarkandGitHub c4986507d6 Delete mutableSourceFirstPendingUpdateTime (#18613) 2020-04-15 07:47:37 -07:00
Andrew Clark 0d35e8053e Fix typo in TestFlags
Copypasta when setting up `old` and `new` aliases. `old` should mean
that `enableNewReconciler` is off.
2020-04-14 23:32:53 -07:00
Dominic GannawayandGitHub 2a236c5fe0 ReactDOM.useEvent: add useEvent interaction hook (#18604) 2020-04-14 22:06:46 +01:00
Dominic GannawayandGitHub 04eb83d80d Move beforeblur phase to prepareForCommit (#18609) 2020-04-14 21:30:54 +01:00
Andrew ClarkandGitHub 6c36eccb80 Remove .internal from more test suites (#18597) 2020-04-14 07:43:00 -07:00
BetaSuandGitHub 379c7f9c55 remove unnecessary variable comparation (#18598)
Since it will continue when the props are equal in line 767, there is no need to compare whether they are not equal.
2020-04-14 14:53:47 +01:00
Andrew ClarkandGitHub 0a790cd0d2 Delete flushSuspenseFallbacksInTests flag (#18596)
* Move renderer `act` to work loop

* Delete `flushSuspenseFallbacksInTests`

This was meant to be a temporary hack to unblock the `act` work, but it
quickly spread throughout our tests.

What it's meant to do is force fallbacks to flush inside `act` even in
Concurrent Mode. It does this by wrapping the `setTimeout` call in a
check to see if it's in an `act` context. If so, it skips the delay and
immediately commits the fallback.

Really this is only meant for our internal React tests that need to
incrementally render. Nobody outside our team (and Relay) needs to do
that, yet. Even if/when we do support that, it may or may not be with
the same `flushAndYield` pattern we use internally.

However, even for our internal purposes, the behavior isn't right
because a really common reason we flush work incrementally is to make
assertions on the "suspended" state, before the fallback has committed.
There's no way to do that from inside `act` with the behavior of this
flag, because it causes the fallback to immediately commit. This has led
us to *not* use `act` in a lot of our tests, or to write code that
doesn't match what would actually happen in a real environment.

What we really want is for the fallbacks to be flushed at the *end` of
the `act` scope. Not within it.

This only affects the noop and test renderer versions of `act`, which
are implemented inside the reconciler. Whereas `ReactTestUtils.act` is
implemented in "userspace" for backwards compatibility. This is fine
because we didn't have any DOM Suspense tests that relied on this flag;
they all use test renderer or noop.

In the future, we'll probably want to move always use the reconciler
implementation of `act`. It will not affect the prod bundle, because we
currently only plan to support `act` in dev. Though we still haven't
completely figured that out. However, regardless of whether we support a
production `act` for users, we'll still need to write internal React
tests in production mode. For that use case, we'll likely add our own
internal version of `act` that assumes a mock Scheduler and might rely
on hacks that don't 100% align up with the public one.
2020-04-13 20:02:18 -07:00
Andrew ClarkandGitHub e5d924c6fc Fix www tests not running in prod (#18593)
I made a mistake when setting these up a while ago. Setting the NODE_ENV
in the CircleCI config doesn't work because it's also set in the node
script command.

The number of test commands is getting out of control. Might need to fix
it at some point. Not today for me.
2020-04-13 15:53:13 -07:00
Andrew ClarkandGitHub 5b8975dcdf Migrate conditional tests to gate pragma (#18585)
* Migrate conditional tests to gate pragma

I searched through the codebase for this pattern:

```js
describe('test suite', () => {
  if (!__EXPERIMENTAL__) { // or some other condition
    test("empty test so Jest doesn't complain", () => {});
    return;
  }

  // Unless we're in experimental mode, none of the tests in this block
  // will run.
})
```

and converted them to the `@gate` pragma instead.

The reason this pattern isn't preferred is because you end up disabling
more tests than you need to.

* Add flag for www release channels

Using a heuristic where I check a flag that is known to only be enabled
in www. I left a TODO to instead set the release channel explicitly in
each test config.
2020-04-13 14:45:52 -07:00
2e56265594 DevTools: Switch between "Rendered At" renders using keyboard arrow keys (#18586)
* Add keyboard navigation to fibre info sidebar

Co-authored-by: Brian Vaughn <[email protected]>
2020-04-13 13:00:13 -07:00
Andrew ClarkandGitHub 3ab15df1be Fix "missing flag" error for non-boolean types (#18592)
Not all test flags are booleans, e.g. the build type
2020-04-13 12:57:31 -07:00
Andrew ClarkandGitHub 8635170ab7 Codemod it.experimental to gate pragma (#18582)
* Codemod it.experimental to gate pragma

Find-and-replace followed by Prettier

* Delete it.experimental

Removes the API from our test setup script
2020-04-13 10:28:59 -07:00
Andrew ClarkandGitHub 42994038ce Add pragma for feature testing: @gate (#18581)
* Add pragma for feature testing: @gate

The `@gate` pragma declares under which conditions a test is expected to
pass.

If the gate condition passes, then the test runs normally (same as if
there were no pragma).

If the conditional fails, then the test runs and is *expected to fail*.

An alternative to `it.experimental` and similar proposals.

Examples
--------

Basic:

```js
// @gate enableBlocksAPI
test('passes only if Blocks API is available', () => {/*...*/})
```

Negation:

```js
// @gate !disableLegacyContext
test('depends on a deprecated feature', () => {/*...*/})
```

Multiple flags:

```js
// @gate enableNewReconciler
// @gate experimental
test('needs both useEvent and Blocks', () => {/*...*/})
```

Logical operators (yes, I'm sorry):

```js
// @gate experimental && (enableNewReconciler || disableSchedulerTimeoutBasedOnReactExpirationTime)
test('concurrent mode, doesn\'t work in old fork unless Scheduler timeout flag is disabled', () => {/*...*/})
```

Strings, and comparion operators

No use case yet but I figure eventually we'd use this to gate on
different release channels:

```js
// @gate channel ===  "experimental" || channel === "modern"
test('works in OSS experimental or www modern', () => {/*...*/})
```

How does it work?

I'm guessing those last two examples might be controversial. Supporting
those cases did require implementing a mini-parser.

The output of the transform is very straightforward, though.

Input:
```js
// @gate a && (b || c)
test('some test', () => {/*...*/})
```

Output:

```js
_test_gate(ctx => ctx.a && (ctx.b || ctx.c, 'some test'), () => {/*...*/});
```

It also works  with `it`, `it.only`, and `fit`. It leaves `it.skip` and
`xit` alone because those tests are disabled anyway.

`_test_gate` is a global method that I set up in our Jest config. It
works about the same as the existing `it.experimental` helper.

The context (`ctx`) argument is whatever we want it to be. I set it up
so that it throws if you try to access a flag that doesn't exist. I also
added some shortcuts for common gating conditions, like `old`
and `new`:

```js
// @gate experimental
test('experimental feature', () => {/*...*/})

// @gate new
test('only passes in new reconciler', () => {/*...*/})
```

Why implement this as a pragma instead of a runtime API?

- Doesn't require monkey patching built-in Jest methods. Instead it
  compiles to a runtime function that composes Jest's API.
- Will be easy to upgrade if Jest ever overhauls their API or we switch
  to a different testing framework (unlikely but who knows).
- It feels lightweight so hopefully people won't feel gross using it.
  For example, adding or removing a gate pragma will never affect the
  indentation of the test, unlike if you wrapped the test in a
  conditional block.

* Compatibility with console error/warning tracking

We patch console.error and console.warning to track unexpected calls
in our tests. If there's an unexpected call, we usually throw inside
an `afterEach` hook. However, that's too late for tests that we
expect to fail, because our `_test_gate` runtime can't capture the
error. So I also check for unexpected calls inside `_test_gate`.

* Move test flags to dedicated file

Added some instructions for how the flags are set up and how to
use them.

* Add dynamic version of gate API

Receives same flags as the pragma.

If we ever decide to revert the pragma, we can codemod them to use
this instead.
2020-04-13 10:14:34 -07:00