chromium/third_party/blink/web_tests/netinfo/connection-types.html

<!DOCTYPE html>
<head>
<script src="../resources/js-test.js"></script>
<script src="resources/netinfo_common.js"></script>
</head>
<body>
<script>
description('Tests that all connection types of NetInfo are supported.');

if (!window.internals)
  log("This test requires window.internals");

var types = [
  ['cellular', 1.0],
  ['bluetooth', 2.0],
  ['ethernet', 3.0],
  ['wifi', 4.0],
  ['wimax', 5.0],
  ['other', 6.0],
  ['none', 7.0],
  ['unknown', 8.0],
  ['wimax', 8.0],
  ['wimax', 9.0]
];

// ontypechange is deprecated but this test is here to
// verify that it still works until it is removed.
connection.addEventListener('typechange', function(e) {
  shouldBe('connection.type', 'types[count][0]');
  shouldBe('connection.downlinkMax', 'types[count][1]');
});

var count = 0;
connection.addEventListener('change', function(e) {
  shouldBe('connection.type', 'types[count][0]');
  shouldBe('connection.downlinkMax', 'types[count][1]');

  if (++count === types.length)
    finishJSTest();
});

// Blink internally handles fine grained connection types on cellular network.
function convertType(type) {
  if (type == 'cellular')
    return 'cellular2g';
  return type;
}

for(var i = 0; i < types.length; i++)
  internals.setNetworkConnectionInfoOverride(isTypeOnline(types[i][0]), convertType(types[i][0]), initialEffectiveType, initialRtt, types[i][1]);

</script>
</body>
</html>