From 7f5ec6c392c53225d85b160bcef3cedbc366ed72 Mon Sep 17 00:00:00 2001 From: Jan-Erik Rediger Date: Mon, 14 Sep 2015 13:52:32 +0200 Subject: [PATCH] Disable browser history API on file:/ URLs history.pushState is defined, but not working whenever document.origin is "null" (literally that string, not just the null object). This is due to some security considerations and is unlikely to be ever working. For now just disable the usage of the history API when the documentation is accessed through a file:/ URL. See https://code.google.com/p/chromium/issues/detail?id=301210 for a Chrome-specific issue on the history API on file:/ URLs Closes #25953 --- src/librustdoc/html/static/main.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 9d84d4ea3c1..5b0b19b95af 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -54,7 +54,8 @@ } function browserSupportsHistoryApi() { - return window.history && typeof window.history.pushState === "function"; + return document.location.protocol != "file:" && + window.history && typeof window.history.pushState === "function"; } function highlightSourceLines(ev) {