code: function () {
      // Get the array of gamepads, the first method (getGamepads)
      // is the most modern one and is supported by Firefox 28+ and
      // Chrome 35+. The second one (webkitGetGamepads) is a deprecated method
      // used by older Chrome builds.
      var rawGamepads =
          (navigator.getGamepads && navigator.getGamepads()) ||
          (navigator.webkitGetGamepads && navigator.webkitGetGamepads());
  
      if (rawGamepads) {
        // We don't want to use rawGamepads coming straight from the browser,
        // since it can have "holes" (e.g. if you plug two gamepads, and then
        // unplug the first one, the remaining one will be at index [1]).
        gamepadSupport.gamepads = [];
  
        // We only refresh the display when we detect some gamepads are new
        // or removed; we do it by comparing raw gamepad table entries to
        // `undefined`.
        var gamepadsChanged = false;
  
        for (var i = 0; i < rawGamepads.length; i++) {
          if (typeof rawGamepads[i] !== gamepadSupport.prevRawGamepadTypes[i]) {
            gamepadsChanged = true;
            gamepadSupport.prevRawGamepadTypes[i] = typeof rawGamepads[i];
          }
  
          if (rawGamepads[i]) {
            gamepadSupport.gamepads.push(rawGamepads[i]);
          }
        }
  
        // Ask the tester to refresh the visual representations of gamepads
        // on the screen.
        if (gamepadsChanged) {
          window.tester.updateGamepads(gamepadSupport.gamepads);
        }
      }
    }
docs: This function is called only on Chrome, which does not yet support connection/disconnection events but requires you to monitor an array for changes.