Solved: Google Chrome Hides The URL Of Error Pages

Posted at

If you've fiddle with networking testing and you've done something wrong,
you'll happen to need the URL of the last error page, accessed through JavaScript,
It is shown to be immensely difficult,

There are, naturally, several reasons.

- Google Chrome uses an internal-page, replacing the what should have been your page,
showing a, more friendly, error message.

For the following example I've blocked through my HOSTS file, just for fun,
Followed by accessing chrome://net-internals/#dns and clearing up the DNS-cache, I've then hard-refreshed the page to render the following DNS-error page:


Say you are currently working on designing a new version of core to Google's DNS-algorithm, but you STILL want to view the page. How would you extract the URL? for example extracting the URL and doing a little top.location.replace("'s-url.."), and using my (for example) php-proxy (which you can download for free from:

Imagine that awesome JavaScript-bookmark... :)

Surprisingly - top.location.href, the "what you've thought was the solution", will show you something weird... :)


You are in-fact, in the most protected domains under chrome, and internal web-site named data:text/html,chromewebdata, which will show you that, friendly error.

The page's content will generated dynamically, its DOM is injected with pre-existing data (similar to server-side populating the raw data into an HTML page).

* those pages are NOT accessible by chrome-extensions (unless you'll give it specific permissions through some internal flags.. but don't do it.. hazards extensions might get access to your raw data through malicious script-injections..)

Anyway... a bookmarklet should be sufficient,
getting the data through some data in the DOM.


Solution: ;)

   "" + encodeURIComponent(url)
, "" === top.location.hostname && -1 !== top.location.pathname.indexOf("chromewebdata") ? top.loadTimeData.data_.summary.failedUrl : top.location.href


naturally implement your proxy somewhere, and some sort of AUTH protection might be helpful as well,
set everything right, and you'll got yourself a nice little developer-toolkit to help you while you'll be working on network-engineering.

Happy codding :]

another variation (for a bookmarklet)

(function(window, document, location, PROXY_BASE_URL, tmp){
  tmp = -1 === location.href.toLowerCase().indexOf("chromewebdata") 
                            ? location.href
                            : loadTimeData.data_.summary.failedUrl
                                      .replace("\\u0202a","").replace("\\u202b","").replace("\\u202c","")   /* remove Unicode be-directional hints (l-t-r, r-t-l and end hint). */
  tmp = encodeURIComponent(tmp);
  tmp = tmp.replace("%E2%80%AA","");
  tmp = PROXY_BASE_URL + tmp;
, top.document
, top.location
, ""