tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

react-dom-test-utils-dev.js (48448B)


      1 /** @license React v16.8.6
      2 * react-dom-test-utils.development.js
      3 *
      4 * Copyright (c) Facebook, Inc. and its affiliates.
      5 *
      6 * This source code is licensed under the MIT license found in the
      7 * LICENSE file in the root directory of this source tree.
      8 */
      9 
     10 'use strict';
     11 
     12 (function (global, factory) {
     13 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require("resource://devtools/client/shared/vendor/react.mjs"), require("resource://devtools/client/shared/vendor/react-dom.mjs")) :
     14 typeof define === 'function' && define.amd ? define(['resource://devtools/client/shared/vendor/react.js', 'resource://devtools/client/shared/vendor/react-dom.js'], factory) :
     15 (global.ReactTestUtils = factory(global.React,global.ReactDOM));
     16 }(this, (function (React,ReactDOM) { 'use strict';
     17 
     18 var ReactInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
     19 
     20 var _assign = ReactInternals.assign;
     21 
     22 /**
     23 * Use invariant() to assert state which your program assumes to be true.
     24 *
     25 * Provide sprintf-style format (only %s is supported) and arguments
     26 * to provide information about what broke and what you were
     27 * expecting.
     28 *
     29 * The invariant message will be stripped in production, but the invariant
     30 * will remain to ensure logic does not differ in production.
     31 */
     32 
     33 var validateFormat = function () {};
     34 
     35 {
     36  validateFormat = function (format) {
     37    if (format === undefined) {
     38      throw new Error('invariant requires an error message argument');
     39    }
     40  };
     41 }
     42 
     43 function invariant(condition, format, a, b, c, d, e, f) {
     44  validateFormat(format);
     45 
     46  if (!condition) {
     47    var error = void 0;
     48    if (format === undefined) {
     49      error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
     50    } else {
     51      var args = [a, b, c, d, e, f];
     52      var argIndex = 0;
     53      error = new Error(format.replace(/%s/g, function () {
     54        return args[argIndex++];
     55      }));
     56      error.name = 'Invariant Violation';
     57    }
     58 
     59    error.framesToPop = 1; // we don't care about invariant's own frame
     60    throw error;
     61  }
     62 }
     63 
     64 // Relying on the `invariant()` implementation lets us
     65 // preserve the format and params in the www builds.
     66 
     67 /**
     68 * Similar to invariant but only logs a warning if the condition is not met.
     69 * This can be used to log issues in development environments in critical
     70 * paths. Removing the logging code for production environments will keep the
     71 * same logic and follow the same code paths.
     72 */
     73 
     74 var warningWithoutStack = function () {};
     75 
     76 {
     77  warningWithoutStack = function (condition, format) {
     78    for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
     79      args[_key - 2] = arguments[_key];
     80    }
     81 
     82    if (format === undefined) {
     83      throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
     84    }
     85    if (args.length > 8) {
     86      // Check before the condition to catch violations early.
     87      throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
     88    }
     89    if (condition) {
     90      return;
     91    }
     92    if (typeof console !== 'undefined') {
     93      var argsWithFormat = args.map(function (item) {
     94        return '' + item;
     95      });
     96      argsWithFormat.unshift('Warning: ' + format);
     97 
     98      // We intentionally don't use spread (or .apply) directly because it
     99      // breaks IE9: https://github.com/facebook/react/issues/13610
    100      Function.prototype.apply.call(console.error, console, argsWithFormat);
    101    }
    102    try {
    103      // --- Welcome to debugging React ---
    104      // This error was thrown as a convenience so that you can use this stack
    105      // to find the callsite that caused this warning to fire.
    106      var argIndex = 0;
    107      var message = 'Warning: ' + format.replace(/%s/g, function () {
    108        return args[argIndex++];
    109      });
    110      throw new Error(message);
    111    } catch (x) {}
    112  };
    113 }
    114 
    115 var warningWithoutStack$1 = warningWithoutStack;
    116 
    117 /**
    118 * `ReactInstanceMap` maintains a mapping from a public facing stateful
    119 * instance (key) and the internal representation (value). This allows public
    120 * methods to accept the user facing instance as an argument and map them back
    121 * to internal methods.
    122 *
    123 * Note that this module is currently shared and assumed to be stateless.
    124 * If this becomes an actual Map, that will break.
    125 */
    126 
    127 /**
    128 * This API should be called `delete` but we'd have to make sure to always
    129 * transform these to strings for IE support. When this transform is fully
    130 * supported we can rename it.
    131 */
    132 
    133 
    134 function get(key) {
    135  return key._reactInternalFiber;
    136 }
    137 
    138 var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
    139 
    140 // Prevent newer renderers from RTE when used with older react package versions.
    141 // Current owner and dispatcher used to share the same ref,
    142 // but PR #14548 split them out to better support the react-debug-tools package.
    143 if (!ReactSharedInternals.hasOwnProperty('ReactCurrentDispatcher')) {
    144  ReactSharedInternals.ReactCurrentDispatcher = {
    145    current: null
    146  };
    147 }
    148 
    149 // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
    150 // nor polyfill, then a plain number is used for performance.
    151 
    152 var FunctionComponent = 0;
    153 var ClassComponent = 1;
    154 // Before we know whether it is function or class
    155 var HostRoot = 3; // Root of a host tree. Could be nested inside another node.
    156 // A subtree. Could be an entry point to a different renderer.
    157 var HostComponent = 5;
    158 var HostText = 6;
    159 
    160 // Don't change these two values. They're used by React Dev Tools.
    161 var NoEffect = /*              */0;
    162 
    163 
    164 // You can change the rest (and add more).
    165 var Placement = /*             */2;
    166 
    167 
    168 
    169 
    170 
    171 
    172 
    173 
    174 
    175 
    176 // Passive & Update & Callback & Ref & Snapshot
    177 
    178 
    179 // Union of all host effects
    180 
    181 var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
    182 
    183 var MOUNTING = 1;
    184 var MOUNTED = 2;
    185 var UNMOUNTED = 3;
    186 
    187 function isFiberMountedImpl(fiber) {
    188  var node = fiber;
    189  if (!fiber.alternate) {
    190    // If there is no alternate, this might be a new tree that isn't inserted
    191    // yet. If it is, then it will have a pending insertion effect on it.
    192    if ((node.effectTag & Placement) !== NoEffect) {
    193      return MOUNTING;
    194    }
    195    while (node.return) {
    196      node = node.return;
    197      if ((node.effectTag & Placement) !== NoEffect) {
    198        return MOUNTING;
    199      }
    200    }
    201  } else {
    202    while (node.return) {
    203      node = node.return;
    204    }
    205  }
    206  if (node.tag === HostRoot) {
    207    // TODO: Check if this was a nested HostRoot when used with
    208    // renderContainerIntoSubtree.
    209    return MOUNTED;
    210  }
    211  // If we didn't hit the root, that means that we're in an disconnected tree
    212  // that has been unmounted.
    213  return UNMOUNTED;
    214 }
    215 
    216 
    217 
    218 
    219 
    220 function assertIsMounted(fiber) {
    221  !(isFiberMountedImpl(fiber) === MOUNTED) ? invariant(false, 'Unable to find node on an unmounted component.') : void 0;
    222 }
    223 
    224 function findCurrentFiberUsingSlowPath(fiber) {
    225  var alternate = fiber.alternate;
    226  if (!alternate) {
    227    // If there is no alternate, then we only need to check if it is mounted.
    228    var state = isFiberMountedImpl(fiber);
    229    !(state !== UNMOUNTED) ? invariant(false, 'Unable to find node on an unmounted component.') : void 0;
    230    if (state === MOUNTING) {
    231      return null;
    232    }
    233    return fiber;
    234  }
    235  // If we have two possible branches, we'll walk backwards up to the root
    236  // to see what path the root points to. On the way we may hit one of the
    237  // special cases and we'll deal with them.
    238  var a = fiber;
    239  var b = alternate;
    240  while (true) {
    241    var parentA = a.return;
    242    var parentB = parentA ? parentA.alternate : null;
    243    if (!parentA || !parentB) {
    244      // We're at the root.
    245      break;
    246    }
    247 
    248    // If both copies of the parent fiber point to the same child, we can
    249    // assume that the child is current. This happens when we bailout on low
    250    // priority: the bailed out fiber's child reuses the current child.
    251    if (parentA.child === parentB.child) {
    252      var child = parentA.child;
    253      while (child) {
    254        if (child === a) {
    255          // We've determined that A is the current branch.
    256          assertIsMounted(parentA);
    257          return fiber;
    258        }
    259        if (child === b) {
    260          // We've determined that B is the current branch.
    261          assertIsMounted(parentA);
    262          return alternate;
    263        }
    264        child = child.sibling;
    265      }
    266      // We should never have an alternate for any mounting node. So the only
    267      // way this could possibly happen is if this was unmounted, if at all.
    268      invariant(false, 'Unable to find node on an unmounted component.');
    269    }
    270 
    271    if (a.return !== b.return) {
    272      // The return pointer of A and the return pointer of B point to different
    273      // fibers. We assume that return pointers never criss-cross, so A must
    274      // belong to the child set of A.return, and B must belong to the child
    275      // set of B.return.
    276      a = parentA;
    277      b = parentB;
    278    } else {
    279      // The return pointers point to the same fiber. We'll have to use the
    280      // default, slow path: scan the child sets of each parent alternate to see
    281      // which child belongs to which set.
    282      //
    283      // Search parent A's child set
    284      var didFindChild = false;
    285      var _child = parentA.child;
    286      while (_child) {
    287        if (_child === a) {
    288          didFindChild = true;
    289          a = parentA;
    290          b = parentB;
    291          break;
    292        }
    293        if (_child === b) {
    294          didFindChild = true;
    295          b = parentA;
    296          a = parentB;
    297          break;
    298        }
    299        _child = _child.sibling;
    300      }
    301      if (!didFindChild) {
    302        // Search parent B's child set
    303        _child = parentB.child;
    304        while (_child) {
    305          if (_child === a) {
    306            didFindChild = true;
    307            a = parentB;
    308            b = parentA;
    309            break;
    310          }
    311          if (_child === b) {
    312            didFindChild = true;
    313            b = parentB;
    314            a = parentA;
    315            break;
    316          }
    317          _child = _child.sibling;
    318        }
    319        !didFindChild ? invariant(false, 'Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue.') : void 0;
    320      }
    321    }
    322 
    323    !(a.alternate === b) ? invariant(false, 'Return fibers should always be each others\' alternates. This error is likely caused by a bug in React. Please file an issue.') : void 0;
    324  }
    325  // If the root is not a host container, we're in a disconnected tree. I.e.
    326  // unmounted.
    327  !(a.tag === HostRoot) ? invariant(false, 'Unable to find node on an unmounted component.') : void 0;
    328  if (a.stateNode.current === a) {
    329    // We've determined that A is the current branch.
    330    return fiber;
    331  }
    332  // Otherwise B has to be current branch.
    333  return alternate;
    334 }
    335 
    336 /* eslint valid-typeof: 0 */
    337 
    338 var EVENT_POOL_SIZE = 10;
    339 
    340 /**
    341 * @interface Event
    342 * @see http://www.w3.org/TR/DOM-Level-3-Events/
    343 */
    344 var EventInterface = {
    345  type: null,
    346  target: null,
    347  // currentTarget is set when dispatching; no use in copying it here
    348  currentTarget: function () {
    349    return null;
    350  },
    351  eventPhase: null,
    352  bubbles: null,
    353  cancelable: null,
    354  timeStamp: function (event) {
    355    return event.timeStamp || Date.now();
    356  },
    357  defaultPrevented: null,
    358  isTrusted: null
    359 };
    360 
    361 function functionThatReturnsTrue() {
    362  return true;
    363 }
    364 
    365 function functionThatReturnsFalse() {
    366  return false;
    367 }
    368 
    369 /**
    370 * Synthetic events are dispatched by event plugins, typically in response to a
    371 * top-level event delegation handler.
    372 *
    373 * These systems should generally use pooling to reduce the frequency of garbage
    374 * collection. The system should check `isPersistent` to determine whether the
    375 * event should be released into the pool after being dispatched. Users that
    376 * need a persisted event should invoke `persist`.
    377 *
    378 * Synthetic events (and subclasses) implement the DOM Level 3 Events API by
    379 * normalizing browser quirks. Subclasses do not necessarily have to implement a
    380 * DOM interface; custom application-specific events can also subclass this.
    381 *
    382 * @param {object} dispatchConfig Configuration used to dispatch this event.
    383 * @param {*} targetInst Marker identifying the event target.
    384 * @param {object} nativeEvent Native browser event.
    385 * @param {DOMEventTarget} nativeEventTarget Target node.
    386 */
    387 function SyntheticEvent(dispatchConfig, targetInst, nativeEvent, nativeEventTarget) {
    388  {
    389    // these have a getter/setter for warnings
    390    delete this.nativeEvent;
    391    delete this.preventDefault;
    392    delete this.stopPropagation;
    393    delete this.isDefaultPrevented;
    394    delete this.isPropagationStopped;
    395  }
    396 
    397  this.dispatchConfig = dispatchConfig;
    398  this._targetInst = targetInst;
    399  this.nativeEvent = nativeEvent;
    400 
    401  var Interface = this.constructor.Interface;
    402  for (var propName in Interface) {
    403    if (!Interface.hasOwnProperty(propName)) {
    404      continue;
    405    }
    406    {
    407      delete this[propName]; // this has a getter/setter for warnings
    408    }
    409    var normalize = Interface[propName];
    410    if (normalize) {
    411      this[propName] = normalize(nativeEvent);
    412    } else {
    413      if (propName === 'target') {
    414        this.target = nativeEventTarget;
    415      } else {
    416        this[propName] = nativeEvent[propName];
    417      }
    418    }
    419  }
    420 
    421  var defaultPrevented = nativeEvent.defaultPrevented != null ? nativeEvent.defaultPrevented : nativeEvent.returnValue === false;
    422  if (defaultPrevented) {
    423    this.isDefaultPrevented = functionThatReturnsTrue;
    424  } else {
    425    this.isDefaultPrevented = functionThatReturnsFalse;
    426  }
    427  this.isPropagationStopped = functionThatReturnsFalse;
    428  return this;
    429 }
    430 
    431 _assign(SyntheticEvent.prototype, {
    432  preventDefault: function () {
    433    this.defaultPrevented = true;
    434    var event = this.nativeEvent;
    435    if (!event) {
    436      return;
    437    }
    438 
    439    if (event.preventDefault) {
    440      event.preventDefault();
    441    } else if (typeof event.returnValue !== 'unknown') {
    442      event.returnValue = false;
    443    }
    444    this.isDefaultPrevented = functionThatReturnsTrue;
    445  },
    446 
    447  stopPropagation: function () {
    448    var event = this.nativeEvent;
    449    if (!event) {
    450      return;
    451    }
    452 
    453    if (event.stopPropagation) {
    454      event.stopPropagation();
    455    } else if (typeof event.cancelBubble !== 'unknown') {
    456      // The ChangeEventPlugin registers a "propertychange" event for
    457      // IE. This event does not support bubbling or cancelling, and
    458      // any references to cancelBubble throw "Member not found".  A
    459      // typeof check of "unknown" circumvents this issue (and is also
    460      // IE specific).
    461      event.cancelBubble = true;
    462    }
    463 
    464    this.isPropagationStopped = functionThatReturnsTrue;
    465  },
    466 
    467  /**
    468   * We release all dispatched `SyntheticEvent`s after each event loop, adding
    469   * them back into the pool. This allows a way to hold onto a reference that
    470   * won't be added back into the pool.
    471   */
    472  persist: function () {
    473    this.isPersistent = functionThatReturnsTrue;
    474  },
    475 
    476  /**
    477   * Checks if this event should be released back into the pool.
    478   *
    479   * @return {boolean} True if this should not be released, false otherwise.
    480   */
    481  isPersistent: functionThatReturnsFalse,
    482 
    483  /**
    484   * `PooledClass` looks for `destructor` on each instance it releases.
    485   */
    486  destructor: function () {
    487    var Interface = this.constructor.Interface;
    488    for (var propName in Interface) {
    489      {
    490        Object.defineProperty(this, propName, getPooledWarningPropertyDefinition(propName, Interface[propName]));
    491      }
    492    }
    493    this.dispatchConfig = null;
    494    this._targetInst = null;
    495    this.nativeEvent = null;
    496    this.isDefaultPrevented = functionThatReturnsFalse;
    497    this.isPropagationStopped = functionThatReturnsFalse;
    498    this._dispatchListeners = null;
    499    this._dispatchInstances = null;
    500    {
    501      Object.defineProperty(this, 'nativeEvent', getPooledWarningPropertyDefinition('nativeEvent', null));
    502      Object.defineProperty(this, 'isDefaultPrevented', getPooledWarningPropertyDefinition('isDefaultPrevented', functionThatReturnsFalse));
    503      Object.defineProperty(this, 'isPropagationStopped', getPooledWarningPropertyDefinition('isPropagationStopped', functionThatReturnsFalse));
    504      Object.defineProperty(this, 'preventDefault', getPooledWarningPropertyDefinition('preventDefault', function () {}));
    505      Object.defineProperty(this, 'stopPropagation', getPooledWarningPropertyDefinition('stopPropagation', function () {}));
    506    }
    507  }
    508 });
    509 
    510 SyntheticEvent.Interface = EventInterface;
    511 
    512 /**
    513 * Helper to reduce boilerplate when creating subclasses.
    514 */
    515 SyntheticEvent.extend = function (Interface) {
    516  var Super = this;
    517 
    518  var E = function () {};
    519  E.prototype = Super.prototype;
    520  var prototype = new E();
    521 
    522  function Class() {
    523    return Super.apply(this, arguments);
    524  }
    525  _assign(prototype, Class.prototype);
    526  Class.prototype = prototype;
    527  Class.prototype.constructor = Class;
    528 
    529  Class.Interface = _assign({}, Super.Interface, Interface);
    530  Class.extend = Super.extend;
    531  addEventPoolingTo(Class);
    532 
    533  return Class;
    534 };
    535 
    536 addEventPoolingTo(SyntheticEvent);
    537 
    538 /**
    539 * Helper to nullify syntheticEvent instance properties when destructing
    540 *
    541 * @param {String} propName
    542 * @param {?object} getVal
    543 * @return {object} defineProperty object
    544 */
    545 function getPooledWarningPropertyDefinition(propName, getVal) {
    546  var isFunction = typeof getVal === 'function';
    547  return {
    548    configurable: true,
    549    set: set,
    550    get: get
    551  };
    552 
    553  function set(val) {
    554    var action = isFunction ? 'setting the method' : 'setting the property';
    555    warn(action, 'This is effectively a no-op');
    556    return val;
    557  }
    558 
    559  function get() {
    560    var action = isFunction ? 'accessing the method' : 'accessing the property';
    561    var result = isFunction ? 'This is a no-op function' : 'This is set to null';
    562    warn(action, result);
    563    return getVal;
    564  }
    565 
    566  function warn(action, result) {
    567    var warningCondition = false;
    568    !warningCondition ? warningWithoutStack$1(false, "This synthetic event is reused for performance reasons. If you're seeing this, " + "you're %s `%s` on a released/nullified synthetic event. %s. " + 'If you must keep the original synthetic event around, use event.persist(). ' + 'See https://fb.me/react-event-pooling for more information.', action, propName, result) : void 0;
    569  }
    570 }
    571 
    572 function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) {
    573  var EventConstructor = this;
    574  if (EventConstructor.eventPool.length) {
    575    var instance = EventConstructor.eventPool.pop();
    576    EventConstructor.call(instance, dispatchConfig, targetInst, nativeEvent, nativeInst);
    577    return instance;
    578  }
    579  return new EventConstructor(dispatchConfig, targetInst, nativeEvent, nativeInst);
    580 }
    581 
    582 function releasePooledEvent(event) {
    583  var EventConstructor = this;
    584  !(event instanceof EventConstructor) ? invariant(false, 'Trying to release an event instance into a pool of a different type.') : void 0;
    585  event.destructor();
    586  if (EventConstructor.eventPool.length < EVENT_POOL_SIZE) {
    587    EventConstructor.eventPool.push(event);
    588  }
    589 }
    590 
    591 function addEventPoolingTo(EventConstructor) {
    592  EventConstructor.eventPool = [];
    593  EventConstructor.getPooled = getPooledEvent;
    594  EventConstructor.release = releasePooledEvent;
    595 }
    596 
    597 /**
    598 * Forked from fbjs/warning:
    599 * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
    600 *
    601 * Only change is we use console.warn instead of console.error,
    602 * and do nothing when 'console' is not supported.
    603 * This really simplifies the code.
    604 * ---
    605 * Similar to invariant but only logs a warning if the condition is not met.
    606 * This can be used to log issues in development environments in critical
    607 * paths. Removing the logging code for production environments will keep the
    608 * same logic and follow the same code paths.
    609 */
    610 
    611 var lowPriorityWarning = function () {};
    612 
    613 {
    614  var printWarning = function (format) {
    615    for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
    616      args[_key - 1] = arguments[_key];
    617    }
    618 
    619    var argIndex = 0;
    620    var message = 'Warning: ' + format.replace(/%s/g, function () {
    621      return args[argIndex++];
    622    });
    623    if (typeof console !== 'undefined') {
    624      console.warn(message);
    625    }
    626    try {
    627      // --- Welcome to debugging React ---
    628      // This error was thrown as a convenience so that you can use this stack
    629      // to find the callsite that caused this warning to fire.
    630      throw new Error(message);
    631    } catch (x) {}
    632  };
    633 
    634  lowPriorityWarning = function (condition, format) {
    635    if (format === undefined) {
    636      throw new Error('`lowPriorityWarning(condition, format, ...args)` requires a warning ' + 'message argument');
    637    }
    638    if (!condition) {
    639      for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
    640        args[_key2 - 2] = arguments[_key2];
    641      }
    642 
    643      printWarning.apply(undefined, [format].concat(args));
    644    }
    645  };
    646 }
    647 
    648 var lowPriorityWarning$1 = lowPriorityWarning;
    649 
    650 /**
    651 * HTML nodeType values that represent the type of the node
    652 */
    653 
    654 var ELEMENT_NODE = 1;
    655 
    656 // Do not uses the below two methods directly!
    657 // Instead use constants exported from DOMTopLevelEventTypes in ReactDOM.
    658 // (It is the only module that is allowed to access these methods.)
    659 
    660 function unsafeCastStringToDOMTopLevelType(topLevelType) {
    661  return topLevelType;
    662 }
    663 
    664 var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
    665 
    666 /**
    667 * Generate a mapping of standard vendor prefixes using the defined style property and event name.
    668 *
    669 * @param {string} styleProp
    670 * @param {string} eventName
    671 * @returns {object}
    672 */
    673 function makePrefixMap(styleProp, eventName) {
    674  var prefixes = {};
    675 
    676  prefixes[styleProp.toLowerCase()] = eventName.toLowerCase();
    677  prefixes['Webkit' + styleProp] = 'webkit' + eventName;
    678  prefixes['Moz' + styleProp] = 'moz' + eventName;
    679 
    680  return prefixes;
    681 }
    682 
    683 /**
    684 * A list of event names to a configurable list of vendor prefixes.
    685 */
    686 var vendorPrefixes = {
    687  animationend: makePrefixMap('Animation', 'AnimationEnd'),
    688  animationiteration: makePrefixMap('Animation', 'AnimationIteration'),
    689  animationstart: makePrefixMap('Animation', 'AnimationStart'),
    690  transitionend: makePrefixMap('Transition', 'TransitionEnd')
    691 };
    692 
    693 /**
    694 * Event names that have already been detected and prefixed (if applicable).
    695 */
    696 var prefixedEventNames = {};
    697 
    698 /**
    699 * Element to check for prefixes on.
    700 */
    701 var style = {};
    702 
    703 /**
    704 * Bootstrap if a DOM exists.
    705 */
    706 if (canUseDOM) {
    707  style = document.createElementNS('http://www.w3.org/1999/xhtml', 'div').style;
    708 
    709  // On some platforms, in particular some releases of Android 4.x,
    710  // the un-prefixed "animation" and "transition" properties are defined on the
    711  // style object but the events that fire will still be prefixed, so we need
    712  // to check if the un-prefixed events are usable, and if not remove them from the map.
    713  if (!('AnimationEvent' in window)) {
    714    delete vendorPrefixes.animationend.animation;
    715    delete vendorPrefixes.animationiteration.animation;
    716    delete vendorPrefixes.animationstart.animation;
    717  }
    718 
    719  // Same as above
    720  if (!('TransitionEvent' in window)) {
    721    delete vendorPrefixes.transitionend.transition;
    722  }
    723 }
    724 
    725 /**
    726 * Attempts to determine the correct vendor prefixed event name.
    727 *
    728 * @param {string} eventName
    729 * @returns {string}
    730 */
    731 function getVendorPrefixedEventName(eventName) {
    732  if (prefixedEventNames[eventName]) {
    733    return prefixedEventNames[eventName];
    734  } else if (!vendorPrefixes[eventName]) {
    735    return eventName;
    736  }
    737 
    738  var prefixMap = vendorPrefixes[eventName];
    739 
    740  for (var styleProp in prefixMap) {
    741    if (prefixMap.hasOwnProperty(styleProp) && styleProp in style) {
    742      return prefixedEventNames[eventName] = prefixMap[styleProp];
    743    }
    744  }
    745 
    746  return eventName;
    747 }
    748 
    749 /**
    750 * To identify top level events in ReactDOM, we use constants defined by this
    751 * module. This is the only module that uses the unsafe* methods to express
    752 * that the constants actually correspond to the browser event names. This lets
    753 * us save some bundle size by avoiding a top level type -> event name map.
    754 * The rest of ReactDOM code should import top level types from this file.
    755 */
    756 var TOP_ABORT = unsafeCastStringToDOMTopLevelType('abort');
    757 var TOP_ANIMATION_END = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationend'));
    758 var TOP_ANIMATION_ITERATION = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationiteration'));
    759 var TOP_ANIMATION_START = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationstart'));
    760 var TOP_BLUR = unsafeCastStringToDOMTopLevelType('blur');
    761 var TOP_CAN_PLAY = unsafeCastStringToDOMTopLevelType('canplay');
    762 var TOP_CAN_PLAY_THROUGH = unsafeCastStringToDOMTopLevelType('canplaythrough');
    763 var TOP_CANCEL = unsafeCastStringToDOMTopLevelType('cancel');
    764 var TOP_CHANGE = unsafeCastStringToDOMTopLevelType('change');
    765 var TOP_CLICK = unsafeCastStringToDOMTopLevelType('click');
    766 var TOP_CLOSE = unsafeCastStringToDOMTopLevelType('close');
    767 var TOP_COMPOSITION_END = unsafeCastStringToDOMTopLevelType('compositionend');
    768 var TOP_COMPOSITION_START = unsafeCastStringToDOMTopLevelType('compositionstart');
    769 var TOP_COMPOSITION_UPDATE = unsafeCastStringToDOMTopLevelType('compositionupdate');
    770 var TOP_CONTEXT_MENU = unsafeCastStringToDOMTopLevelType('contextmenu');
    771 var TOP_COPY = unsafeCastStringToDOMTopLevelType('copy');
    772 var TOP_CUT = unsafeCastStringToDOMTopLevelType('cut');
    773 var TOP_DOUBLE_CLICK = unsafeCastStringToDOMTopLevelType('dblclick');
    774 
    775 var TOP_DRAG = unsafeCastStringToDOMTopLevelType('drag');
    776 var TOP_DRAG_END = unsafeCastStringToDOMTopLevelType('dragend');
    777 var TOP_DRAG_ENTER = unsafeCastStringToDOMTopLevelType('dragenter');
    778 var TOP_DRAG_EXIT = unsafeCastStringToDOMTopLevelType('dragexit');
    779 var TOP_DRAG_LEAVE = unsafeCastStringToDOMTopLevelType('dragleave');
    780 var TOP_DRAG_OVER = unsafeCastStringToDOMTopLevelType('dragover');
    781 var TOP_DRAG_START = unsafeCastStringToDOMTopLevelType('dragstart');
    782 var TOP_DROP = unsafeCastStringToDOMTopLevelType('drop');
    783 var TOP_DURATION_CHANGE = unsafeCastStringToDOMTopLevelType('durationchange');
    784 var TOP_EMPTIED = unsafeCastStringToDOMTopLevelType('emptied');
    785 var TOP_ENCRYPTED = unsafeCastStringToDOMTopLevelType('encrypted');
    786 var TOP_ENDED = unsafeCastStringToDOMTopLevelType('ended');
    787 var TOP_ERROR = unsafeCastStringToDOMTopLevelType('error');
    788 var TOP_FOCUS = unsafeCastStringToDOMTopLevelType('focus');
    789 
    790 var TOP_INPUT = unsafeCastStringToDOMTopLevelType('input');
    791 
    792 var TOP_KEY_DOWN = unsafeCastStringToDOMTopLevelType('keydown');
    793 var TOP_KEY_PRESS = unsafeCastStringToDOMTopLevelType('keypress');
    794 var TOP_KEY_UP = unsafeCastStringToDOMTopLevelType('keyup');
    795 var TOP_LOAD = unsafeCastStringToDOMTopLevelType('load');
    796 var TOP_LOAD_START = unsafeCastStringToDOMTopLevelType('loadstart');
    797 var TOP_LOADED_DATA = unsafeCastStringToDOMTopLevelType('loadeddata');
    798 var TOP_LOADED_METADATA = unsafeCastStringToDOMTopLevelType('loadedmetadata');
    799 
    800 var TOP_MOUSE_DOWN = unsafeCastStringToDOMTopLevelType('mousedown');
    801 var TOP_MOUSE_MOVE = unsafeCastStringToDOMTopLevelType('mousemove');
    802 var TOP_MOUSE_OUT = unsafeCastStringToDOMTopLevelType('mouseout');
    803 var TOP_MOUSE_OVER = unsafeCastStringToDOMTopLevelType('mouseover');
    804 var TOP_MOUSE_UP = unsafeCastStringToDOMTopLevelType('mouseup');
    805 var TOP_PASTE = unsafeCastStringToDOMTopLevelType('paste');
    806 var TOP_PAUSE = unsafeCastStringToDOMTopLevelType('pause');
    807 var TOP_PLAY = unsafeCastStringToDOMTopLevelType('play');
    808 var TOP_PLAYING = unsafeCastStringToDOMTopLevelType('playing');
    809 
    810 
    811 
    812 
    813 
    814 
    815 
    816 
    817 var TOP_PROGRESS = unsafeCastStringToDOMTopLevelType('progress');
    818 var TOP_RATE_CHANGE = unsafeCastStringToDOMTopLevelType('ratechange');
    819 
    820 var TOP_SCROLL = unsafeCastStringToDOMTopLevelType('scroll');
    821 var TOP_SEEKED = unsafeCastStringToDOMTopLevelType('seeked');
    822 var TOP_SEEKING = unsafeCastStringToDOMTopLevelType('seeking');
    823 var TOP_SELECTION_CHANGE = unsafeCastStringToDOMTopLevelType('selectionchange');
    824 var TOP_STALLED = unsafeCastStringToDOMTopLevelType('stalled');
    825 
    826 var TOP_SUSPEND = unsafeCastStringToDOMTopLevelType('suspend');
    827 var TOP_TEXT_INPUT = unsafeCastStringToDOMTopLevelType('textInput');
    828 var TOP_TIME_UPDATE = unsafeCastStringToDOMTopLevelType('timeupdate');
    829 var TOP_TOGGLE = unsafeCastStringToDOMTopLevelType('toggle');
    830 var TOP_TOUCH_CANCEL = unsafeCastStringToDOMTopLevelType('touchcancel');
    831 var TOP_TOUCH_END = unsafeCastStringToDOMTopLevelType('touchend');
    832 var TOP_TOUCH_MOVE = unsafeCastStringToDOMTopLevelType('touchmove');
    833 var TOP_TOUCH_START = unsafeCastStringToDOMTopLevelType('touchstart');
    834 var TOP_TRANSITION_END = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('transitionend'));
    835 var TOP_VOLUME_CHANGE = unsafeCastStringToDOMTopLevelType('volumechange');
    836 var TOP_WAITING = unsafeCastStringToDOMTopLevelType('waiting');
    837 var TOP_WHEEL = unsafeCastStringToDOMTopLevelType('wheel');
    838 
    839 // List of events that need to be individually attached to media elements.
    840 // Note that events in this list will *not* be listened to at the top level
    841 // unless they're explicitly whitelisted in `ReactBrowserEventEmitter.listenTo`.
    842 
    843 // for .act's return value
    844 var findDOMNode = ReactDOM.findDOMNode;
    845 // Keep in sync with ReactDOMUnstableNativeDependencies.js
    846 // and ReactDOM.js:
    847 
    848 var _ReactDOM$__SECRET_IN = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Events;
    849 var getInstanceFromNode = _ReactDOM$__SECRET_IN[0];
    850 var getNodeFromInstance = _ReactDOM$__SECRET_IN[1];
    851 var getFiberCurrentPropsFromNode = _ReactDOM$__SECRET_IN[2];
    852 var injectEventPluginsByName = _ReactDOM$__SECRET_IN[3];
    853 var eventNameDispatchConfigs = _ReactDOM$__SECRET_IN[4];
    854 var accumulateTwoPhaseDispatches = _ReactDOM$__SECRET_IN[5];
    855 var accumulateDirectDispatches = _ReactDOM$__SECRET_IN[6];
    856 var enqueueStateRestore = _ReactDOM$__SECRET_IN[7];
    857 var restoreStateIfNeeded = _ReactDOM$__SECRET_IN[8];
    858 var dispatchEvent = _ReactDOM$__SECRET_IN[9];
    859 var runEventsInBatch = _ReactDOM$__SECRET_IN[10];
    860 
    861 
    862 function Event(suffix) {}
    863 
    864 var hasWarnedAboutDeprecatedMockComponent = false;
    865 
    866 /**
    867 * @class ReactTestUtils
    868 */
    869 
    870 /**
    871 * Simulates a top level event being dispatched from a raw event that occurred
    872 * on an `Element` node.
    873 * @param {number} topLevelType A number from `TopLevelEventTypes`
    874 * @param {!Element} node The dom to simulate an event occurring on.
    875 * @param {?Event} fakeNativeEvent Fake native event to use in SyntheticEvent.
    876 */
    877 function simulateNativeEventOnNode(topLevelType, node, fakeNativeEvent) {
    878  fakeNativeEvent.target = node;
    879  dispatchEvent(topLevelType, fakeNativeEvent);
    880 }
    881 
    882 /**
    883 * Simulates a top level event being dispatched from a raw event that occurred
    884 * on the `ReactDOMComponent` `comp`.
    885 * @param {Object} topLevelType A type from `BrowserEventConstants.topLevelTypes`.
    886 * @param {!ReactDOMComponent} comp
    887 * @param {?Event} fakeNativeEvent Fake native event to use in SyntheticEvent.
    888 */
    889 function simulateNativeEventOnDOMComponent(topLevelType, comp, fakeNativeEvent) {
    890  simulateNativeEventOnNode(topLevelType, findDOMNode(comp), fakeNativeEvent);
    891 }
    892 
    893 function findAllInRenderedFiberTreeInternal(fiber, test) {
    894  if (!fiber) {
    895    return [];
    896  }
    897  var currentParent = findCurrentFiberUsingSlowPath(fiber);
    898  if (!currentParent) {
    899    return [];
    900  }
    901  var node = currentParent;
    902  var ret = [];
    903  while (true) {
    904    if (node.tag === HostComponent || node.tag === HostText || node.tag === ClassComponent || node.tag === FunctionComponent) {
    905      var publicInst = node.stateNode;
    906      if (test(publicInst)) {
    907        ret.push(publicInst);
    908      }
    909    }
    910    if (node.child) {
    911      node.child.return = node;
    912      node = node.child;
    913      continue;
    914    }
    915    if (node === currentParent) {
    916      return ret;
    917    }
    918    while (!node.sibling) {
    919      if (!node.return || node.return === currentParent) {
    920        return ret;
    921      }
    922      node = node.return;
    923    }
    924    node.sibling.return = node.return;
    925    node = node.sibling;
    926  }
    927 }
    928 
    929 function validateClassInstance(inst, methodName) {
    930  if (!inst) {
    931    // This is probably too relaxed but it's existing behavior.
    932    return;
    933  }
    934  if (get(inst)) {
    935    // This is a public instance indeed.
    936    return;
    937  }
    938  var received = void 0;
    939  var stringified = '' + inst;
    940  if (Array.isArray(inst)) {
    941    received = 'an array';
    942  } else if (inst && inst.nodeType === ELEMENT_NODE && inst.tagName) {
    943    received = 'a DOM node';
    944  } else if (stringified === '[object Object]') {
    945    received = 'object with keys {' + Object.keys(inst).join(', ') + '}';
    946  } else {
    947    received = stringified;
    948  }
    949  invariant(false, '%s(...): the first argument must be a React class instance. Instead received: %s.', methodName, received);
    950 }
    951 
    952 // a stub element, lazily initialized, used by act() when flushing effects
    953 var actContainerElement = null;
    954 
    955 /**
    956 * Utilities for making it easy to test React components.
    957 *
    958 * See https://reactjs.org/docs/test-utils.html
    959 *
    960 * Todo: Support the entire DOM.scry query syntax. For now, these simple
    961 * utilities will suffice for testing purposes.
    962 * @lends ReactTestUtils
    963 */
    964 var ReactTestUtils = {
    965  renderIntoDocument: function (element) {
    966    var div = document.createElementNS('http://www.w3.org/1999/xhtml', 'div');
    967    // None of our tests actually require attaching the container to the
    968    // DOM, and doing so creates a mess that we rely on test isolation to
    969    // clean up, so we're going to stop honoring the name of this method
    970    // (and probably rename it eventually) if no problems arise.
    971    // document.documentElement.appendChild(div);
    972    return ReactDOM.render(element, div);
    973  },
    974 
    975  isElement: function (element) {
    976    return React.isValidElement(element);
    977  },
    978 
    979  isElementOfType: function (inst, convenienceConstructor) {
    980    return React.isValidElement(inst) && inst.type === convenienceConstructor;
    981  },
    982 
    983  isDOMComponent: function (inst) {
    984    return !!(inst && inst.nodeType === ELEMENT_NODE && inst.tagName);
    985  },
    986 
    987  isDOMComponentElement: function (inst) {
    988    return !!(inst && React.isValidElement(inst) && !!inst.tagName);
    989  },
    990 
    991  isCompositeComponent: function (inst) {
    992    if (ReactTestUtils.isDOMComponent(inst)) {
    993      // Accessing inst.setState warns; just return false as that'll be what
    994      // this returns when we have DOM nodes as refs directly
    995      return false;
    996    }
    997    return inst != null && typeof inst.render === 'function' && typeof inst.setState === 'function';
    998  },
    999 
   1000  isCompositeComponentWithType: function (inst, type) {
   1001    if (!ReactTestUtils.isCompositeComponent(inst)) {
   1002      return false;
   1003    }
   1004    var internalInstance = get(inst);
   1005    var constructor = internalInstance.type;
   1006    return constructor === type;
   1007  },
   1008 
   1009  findAllInRenderedTree: function (inst, test) {
   1010    validateClassInstance(inst, 'findAllInRenderedTree');
   1011    if (!inst) {
   1012      return [];
   1013    }
   1014    var internalInstance = get(inst);
   1015    return findAllInRenderedFiberTreeInternal(internalInstance, test);
   1016  },
   1017 
   1018  /**
   1019   * Finds all instance of components in the rendered tree that are DOM
   1020   * components with the class name matching `className`.
   1021   * @return {array} an array of all the matches.
   1022   */
   1023  scryRenderedDOMComponentsWithClass: function (root, classNames) {
   1024    validateClassInstance(root, 'scryRenderedDOMComponentsWithClass');
   1025    return ReactTestUtils.findAllInRenderedTree(root, function (inst) {
   1026      if (ReactTestUtils.isDOMComponent(inst)) {
   1027        var className = inst.className;
   1028        if (typeof className !== 'string') {
   1029          // SVG, probably.
   1030          className = inst.getAttribute('class') || '';
   1031        }
   1032        var classList = className.split(/\s+/);
   1033 
   1034        if (!Array.isArray(classNames)) {
   1035          !(classNames !== undefined) ? invariant(false, 'TestUtils.scryRenderedDOMComponentsWithClass expects a className as a second argument.') : void 0;
   1036          classNames = classNames.split(/\s+/);
   1037        }
   1038        return classNames.every(function (name) {
   1039          return classList.indexOf(name) !== -1;
   1040        });
   1041      }
   1042      return false;
   1043    });
   1044  },
   1045 
   1046  /**
   1047   * Like scryRenderedDOMComponentsWithClass but expects there to be one result,
   1048   * and returns that one result, or throws exception if there is any other
   1049   * number of matches besides one.
   1050   * @return {!ReactDOMComponent} The one match.
   1051   */
   1052  findRenderedDOMComponentWithClass: function (root, className) {
   1053    validateClassInstance(root, 'findRenderedDOMComponentWithClass');
   1054    var all = ReactTestUtils.scryRenderedDOMComponentsWithClass(root, className);
   1055    if (all.length !== 1) {
   1056      throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for class:' + className);
   1057    }
   1058    return all[0];
   1059  },
   1060 
   1061  /**
   1062   * Finds all instance of components in the rendered tree that are DOM
   1063   * components with the tag name matching `tagName`.
   1064   * @return {array} an array of all the matches.
   1065   */
   1066  scryRenderedDOMComponentsWithTag: function (root, tagName) {
   1067    validateClassInstance(root, 'scryRenderedDOMComponentsWithTag');
   1068    return ReactTestUtils.findAllInRenderedTree(root, function (inst) {
   1069      return ReactTestUtils.isDOMComponent(inst) && inst.tagName.toUpperCase() === tagName.toUpperCase();
   1070    });
   1071  },
   1072 
   1073  /**
   1074   * Like scryRenderedDOMComponentsWithTag but expects there to be one result,
   1075   * and returns that one result, or throws exception if there is any other
   1076   * number of matches besides one.
   1077   * @return {!ReactDOMComponent} The one match.
   1078   */
   1079  findRenderedDOMComponentWithTag: function (root, tagName) {
   1080    validateClassInstance(root, 'findRenderedDOMComponentWithTag');
   1081    var all = ReactTestUtils.scryRenderedDOMComponentsWithTag(root, tagName);
   1082    if (all.length !== 1) {
   1083      throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for tag:' + tagName);
   1084    }
   1085    return all[0];
   1086  },
   1087 
   1088  /**
   1089   * Finds all instances of components with type equal to `componentType`.
   1090   * @return {array} an array of all the matches.
   1091   */
   1092  scryRenderedComponentsWithType: function (root, componentType) {
   1093    validateClassInstance(root, 'scryRenderedComponentsWithType');
   1094    return ReactTestUtils.findAllInRenderedTree(root, function (inst) {
   1095      return ReactTestUtils.isCompositeComponentWithType(inst, componentType);
   1096    });
   1097  },
   1098 
   1099  /**
   1100   * Same as `scryRenderedComponentsWithType` but expects there to be one result
   1101   * and returns that one result, or throws exception if there is any other
   1102   * number of matches besides one.
   1103   * @return {!ReactComponent} The one match.
   1104   */
   1105  findRenderedComponentWithType: function (root, componentType) {
   1106    validateClassInstance(root, 'findRenderedComponentWithType');
   1107    var all = ReactTestUtils.scryRenderedComponentsWithType(root, componentType);
   1108    if (all.length !== 1) {
   1109      throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for componentType:' + componentType);
   1110    }
   1111    return all[0];
   1112  },
   1113 
   1114  /**
   1115   * Pass a mocked component module to this method to augment it with
   1116   * useful methods that allow it to be used as a dummy React component.
   1117   * Instead of rendering as usual, the component will become a simple
   1118   * <div> containing any provided children.
   1119   *
   1120   * @param {object} module the mock function object exported from a
   1121   *                        module that defines the component to be mocked
   1122   * @param {?string} mockTagName optional dummy root tag name to return
   1123   *                              from render method (overrides
   1124   *                              module.mockTagName if provided)
   1125   * @return {object} the ReactTestUtils object (for chaining)
   1126   */
   1127  mockComponent: function (module, mockTagName) {
   1128    if (!hasWarnedAboutDeprecatedMockComponent) {
   1129      hasWarnedAboutDeprecatedMockComponent = true;
   1130      lowPriorityWarning$1(false, 'ReactTestUtils.mockComponent() is deprecated. ' + 'Use shallow rendering or jest.mock() instead.\n\n' + 'See https://fb.me/test-utils-mock-component for more information.');
   1131    }
   1132 
   1133    mockTagName = mockTagName || module.mockTagName || 'div';
   1134 
   1135    module.prototype.render.mockImplementation(function () {
   1136      return React.createElement(mockTagName, null, this.props.children);
   1137    });
   1138 
   1139    return this;
   1140  },
   1141 
   1142  nativeTouchData: function (x, y) {
   1143    return {
   1144      touches: [{ pageX: x, pageY: y }]
   1145    };
   1146  },
   1147 
   1148  Simulate: null,
   1149  SimulateNative: {},
   1150 
   1151  act: function (callback) {
   1152    if (actContainerElement === null) {
   1153      // warn if we can't actually create the stub element
   1154      {
   1155        !(typeof document !== 'undefined' && document !== null && typeof document.createElement === 'function') ? warningWithoutStack$1(false, 'It looks like you called TestUtils.act(...) in a non-browser environment. ' + "If you're using TestRenderer for your tests, you should call " + 'TestRenderer.act(...) instead of TestUtils.act(...).') : void 0;
   1156      }
   1157      // then make it
   1158      actContainerElement = document.createElementNS('http://www.w3.org/1999/xhtml', 'div');
   1159    }
   1160 
   1161    var result = ReactDOM.unstable_batchedUpdates(callback);
   1162    // note: keep these warning messages in sync with
   1163    // createReactNoop.js and ReactTestRenderer.js
   1164    {
   1165      if (result !== undefined) {
   1166        var addendum = void 0;
   1167        if (result !== null && typeof result.then === 'function') {
   1168          addendum = '\n\nIt looks like you wrote ReactTestUtils.act(async () => ...), ' + 'or returned a Promise from the callback passed to it. ' + 'Putting asynchronous logic inside ReactTestUtils.act(...) is not supported.\n';
   1169        } else {
   1170          addendum = ' You returned: ' + result;
   1171        }
   1172        warningWithoutStack$1(false, 'The callback passed to ReactTestUtils.act(...) function must not return anything.%s', addendum);
   1173      }
   1174    }
   1175    ReactDOM.render(React.createElement('div', null), actContainerElement);
   1176    // we want the user to not expect a return,
   1177    // but we want to warn if they use it like they can await on it.
   1178    return {
   1179      then: function () {
   1180        {
   1181          warningWithoutStack$1(false, 'Do not await the result of calling ReactTestUtils.act(...), it is not a Promise.');
   1182        }
   1183      }
   1184    };
   1185  }
   1186 };
   1187 
   1188 /**
   1189 * Exports:
   1190 *
   1191 * - `ReactTestUtils.Simulate.click(Element)`
   1192 * - `ReactTestUtils.Simulate.mouseMove(Element)`
   1193 * - `ReactTestUtils.Simulate.change(Element)`
   1194 * - ... (All keys from event plugin `eventTypes` objects)
   1195 */
   1196 function makeSimulator(eventType) {
   1197  return function (domNode, eventData) {
   1198    !!React.isValidElement(domNode) ? invariant(false, 'TestUtils.Simulate expected a DOM node as the first argument but received a React element. Pass the DOM node you wish to simulate the event on instead. Note that TestUtils.Simulate will not work if you are using shallow rendering.') : void 0;
   1199    !!ReactTestUtils.isCompositeComponent(domNode) ? invariant(false, 'TestUtils.Simulate expected a DOM node as the first argument but received a component instance. Pass the DOM node you wish to simulate the event on instead.') : void 0;
   1200 
   1201    var dispatchConfig = eventNameDispatchConfigs[eventType];
   1202 
   1203    var fakeNativeEvent = new Event();
   1204    fakeNativeEvent.target = domNode;
   1205    fakeNativeEvent.type = eventType.toLowerCase();
   1206 
   1207    // We don't use SyntheticEvent.getPooled in order to not have to worry about
   1208    // properly destroying any properties assigned from `eventData` upon release
   1209    var targetInst = getInstanceFromNode(domNode);
   1210    var event = new SyntheticEvent(dispatchConfig, targetInst, fakeNativeEvent, domNode);
   1211 
   1212    // Since we aren't using pooling, always persist the event. This will make
   1213    // sure it's marked and won't warn when setting additional properties.
   1214    event.persist();
   1215    _assign(event, eventData);
   1216 
   1217    if (dispatchConfig.phasedRegistrationNames) {
   1218      accumulateTwoPhaseDispatches(event);
   1219    } else {
   1220      accumulateDirectDispatches(event);
   1221    }
   1222 
   1223    ReactDOM.unstable_batchedUpdates(function () {
   1224      // Normally extractEvent enqueues a state restore, but we'll just always
   1225      // do that since we're by-passing it here.
   1226      enqueueStateRestore(domNode);
   1227      runEventsInBatch(event);
   1228    });
   1229    restoreStateIfNeeded();
   1230  };
   1231 }
   1232 
   1233 function buildSimulators() {
   1234  ReactTestUtils.Simulate = {};
   1235 
   1236  var eventType = void 0;
   1237  for (eventType in eventNameDispatchConfigs) {
   1238    /**
   1239     * @param {!Element|ReactDOMComponent} domComponentOrNode
   1240     * @param {?object} eventData Fake event data to use in SyntheticEvent.
   1241     */
   1242    ReactTestUtils.Simulate[eventType] = makeSimulator(eventType);
   1243  }
   1244 }
   1245 
   1246 buildSimulators();
   1247 
   1248 /**
   1249 * Exports:
   1250 *
   1251 * - `ReactTestUtils.SimulateNative.click(Element/ReactDOMComponent)`
   1252 * - `ReactTestUtils.SimulateNative.mouseMove(Element/ReactDOMComponent)`
   1253 * - `ReactTestUtils.SimulateNative.mouseIn/ReactDOMComponent)`
   1254 * - `ReactTestUtils.SimulateNative.mouseOut(Element/ReactDOMComponent)`
   1255 * - ... (All keys from `BrowserEventConstants.topLevelTypes`)
   1256 *
   1257 * Note: Top level event types are a subset of the entire set of handler types
   1258 * (which include a broader set of "synthetic" events). For example, onDragDone
   1259 * is a synthetic event. Except when testing an event plugin or React's event
   1260 * handling code specifically, you probably want to use ReactTestUtils.Simulate
   1261 * to dispatch synthetic events.
   1262 */
   1263 
   1264 function makeNativeSimulator(eventType, topLevelType) {
   1265  return function (domComponentOrNode, nativeEventData) {
   1266    var fakeNativeEvent = new Event(eventType);
   1267    _assign(fakeNativeEvent, nativeEventData);
   1268    if (ReactTestUtils.isDOMComponent(domComponentOrNode)) {
   1269      simulateNativeEventOnDOMComponent(topLevelType, domComponentOrNode, fakeNativeEvent);
   1270    } else if (domComponentOrNode.tagName) {
   1271      // Will allow on actual dom nodes.
   1272      simulateNativeEventOnNode(topLevelType, domComponentOrNode, fakeNativeEvent);
   1273    }
   1274  };
   1275 }
   1276 
   1277 [[TOP_ABORT, 'abort'], [TOP_ANIMATION_END, 'animationEnd'], [TOP_ANIMATION_ITERATION, 'animationIteration'], [TOP_ANIMATION_START, 'animationStart'], [TOP_BLUR, 'blur'], [TOP_CAN_PLAY_THROUGH, 'canPlayThrough'], [TOP_CAN_PLAY, 'canPlay'], [TOP_CANCEL, 'cancel'], [TOP_CHANGE, 'change'], [TOP_CLICK, 'click'], [TOP_CLOSE, 'close'], [TOP_COMPOSITION_END, 'compositionEnd'], [TOP_COMPOSITION_START, 'compositionStart'], [TOP_COMPOSITION_UPDATE, 'compositionUpdate'], [TOP_CONTEXT_MENU, 'contextMenu'], [TOP_COPY, 'copy'], [TOP_CUT, 'cut'], [TOP_DOUBLE_CLICK, 'doubleClick'], [TOP_DRAG_END, 'dragEnd'], [TOP_DRAG_ENTER, 'dragEnter'], [TOP_DRAG_EXIT, 'dragExit'], [TOP_DRAG_LEAVE, 'dragLeave'], [TOP_DRAG_OVER, 'dragOver'], [TOP_DRAG_START, 'dragStart'], [TOP_DRAG, 'drag'], [TOP_DROP, 'drop'], [TOP_DURATION_CHANGE, 'durationChange'], [TOP_EMPTIED, 'emptied'], [TOP_ENCRYPTED, 'encrypted'], [TOP_ENDED, 'ended'], [TOP_ERROR, 'error'], [TOP_FOCUS, 'focus'], [TOP_INPUT, 'input'], [TOP_KEY_DOWN, 'keyDown'], [TOP_KEY_PRESS, 'keyPress'], [TOP_KEY_UP, 'keyUp'], [TOP_LOAD_START, 'loadStart'], [TOP_LOAD_START, 'loadStart'], [TOP_LOAD, 'load'], [TOP_LOADED_DATA, 'loadedData'], [TOP_LOADED_METADATA, 'loadedMetadata'], [TOP_MOUSE_DOWN, 'mouseDown'], [TOP_MOUSE_MOVE, 'mouseMove'], [TOP_MOUSE_OUT, 'mouseOut'], [TOP_MOUSE_OVER, 'mouseOver'], [TOP_MOUSE_UP, 'mouseUp'], [TOP_PASTE, 'paste'], [TOP_PAUSE, 'pause'], [TOP_PLAY, 'play'], [TOP_PLAYING, 'playing'], [TOP_PROGRESS, 'progress'], [TOP_RATE_CHANGE, 'rateChange'], [TOP_SCROLL, 'scroll'], [TOP_SEEKED, 'seeked'], [TOP_SEEKING, 'seeking'], [TOP_SELECTION_CHANGE, 'selectionChange'], [TOP_STALLED, 'stalled'], [TOP_SUSPEND, 'suspend'], [TOP_TEXT_INPUT, 'textInput'], [TOP_TIME_UPDATE, 'timeUpdate'], [TOP_TOGGLE, 'toggle'], [TOP_TOUCH_CANCEL, 'touchCancel'], [TOP_TOUCH_END, 'touchEnd'], [TOP_TOUCH_MOVE, 'touchMove'], [TOP_TOUCH_START, 'touchStart'], [TOP_TRANSITION_END, 'transitionEnd'], [TOP_VOLUME_CHANGE, 'volumeChange'], [TOP_WAITING, 'waiting'], [TOP_WHEEL, 'wheel']].forEach(function (_ref) {
   1278  var topLevelType = _ref[0],
   1279      eventType = _ref[1];
   1280 
   1281  /**
   1282   * @param {!Element|ReactDOMComponent} domComponentOrNode
   1283   * @param {?Event} nativeEventData Fake native event to use in SyntheticEvent.
   1284   */
   1285  ReactTestUtils.SimulateNative[eventType] = makeNativeSimulator(eventType, topLevelType);
   1286 });
   1287 
   1288 
   1289 
   1290 var ReactTestUtils$2 = ({
   1291 default: ReactTestUtils
   1292 });
   1293 
   1294 var ReactTestUtils$3 = ( ReactTestUtils$2 && ReactTestUtils ) || ReactTestUtils$2;
   1295 
   1296 // TODO: decide on the top-level export form.
   1297 // This is hacky but makes it work with both Rollup and Jest.
   1298 var testUtils = ReactTestUtils$3.default || ReactTestUtils$3;
   1299 
   1300 return testUtils;
   1301 
   1302 })));