Can't open browsing history using JS

Here’s the jist of what I’m trying to do:

  url = 'chrome://history/?q=' + query;

  // open url
  if (keysDown.shift) {
    window.open(url, '_blank');
  } else {
    window.location.href = url;
  }
}

And here’s the error I’m getting:
Screenshot_2

The error appears both when I’m trying to open it in current tab and new window. I’d appreciate any help, thanks!