about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSteve Klabnik <steve@steveklabnik.com>2015-09-19 11:15:47 -0400
committerSteve Klabnik <steve@steveklabnik.com>2015-09-19 11:15:47 -0400
commit6872d13e967937e5b7e4204592d3d29ee85a692e (patch)
tree38ae828e794825163c51aa71b1158d3281da64ce
parent655b2ef45fb87925fcdd4ceb44eb36e0c62dad24 (diff)
parent7f5ec6c392c53225d85b160bcef3cedbc366ed72 (diff)
downloadrust-6872d13e967937e5b7e4204592d3d29ee85a692e.tar.gz
rust-6872d13e967937e5b7e4204592d3d29ee85a692e.zip
Rollup merge of #28400 - badboy:disable-browser-history-on-file, r=steveklabnik
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
-rw-r--r--src/librustdoc/html/static/main.js3
1 files changed, 2 insertions, 1 deletions
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) {