DevTools: Network - Request response doesn't render contents with no mimeType

If a network request is blocked or cancelled, the mimeType field remains
'undefined' because the 'responseReceived' event is never raised. If a
user then clicks on this blocked/cancelled network request in the network
tool, any attempt to view the Response will result in a white window,
instead of 'Failed to load response data'.  This occurs because the
RequestResponseView assumes that a mimeType is present, and consequently
throws a JS exception:

  Cannot read property 'startsWith' of undefined
  shell.js:720:43           Function.fromMimeType
  network_module.js:785:114 Function._hasTextContent
  network_module.js:792:97  Function.sourceViewForRequest
  network_module.js:798:91  async Network.RequestResponseView.createPreview
  network_module.js:797:40  async Network.RequestResponseView.showPreview

The fix here is to update _hasTextContent, so that the call into
fromMimeType always has a valid string. I've also updated the JSDoc
comment to indicate that a string is required and not nullable.

Change-Id: Ib6e89ef6f7cc45387cb25a7c10e01432f8855199
Auto-Submit: Mike Jackson <>
Reviewed-by: Joel Einbinder <>
Reviewed-by: Dmitry Gozman <>
Commit-Queue: Mike Jackson <>
Commit-Queue: Dmitry Gozman <>
Cr-Commit-Position: refs/heads/master@{#642980}
4 files changed