]> git.lizzy.rs Git - rust.git/commitdiff
Disable browser history API on file:/ URLs
authorJan-Erik Rediger <janerik@fnordig.de>
Mon, 14 Sep 2015 11:52:32 +0000 (13:52 +0200)
committerJan-Erik Rediger <janerik@fnordig.de>
Mon, 14 Sep 2015 20:48:34 +0000 (22:48 +0200)
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

index 9d84d4ea3c1a995d42a44bb95f57f6a4c937f4ed..5b0b19b95af197da09c7e058b070db216635bf9e 100644 (file)
@@ -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) {