rust-lang / cargo

The Rust package manager
https://doc.rust-lang.org/cargo
Apache License 2.0
12.62k stars 2.4k forks source link

Cargo book occasionally resets theme when using Pale Moon browser #10400

Closed quixoticaxis closed 2 years ago

quixoticaxis commented 2 years ago

Problem

When reading the Cargo book, bundled with the installation and accessible by calling rustup docs --cargo, navigating between partitions via ToC occasionally resets the theme to the default light one.

Steps

  1. Install Pale Moon browser.
  2. Download rustup.
  3. Install the default toolchain (maybe it can be skipped).
  4. Use rustup docs --cargo to open the book in the browser.
  5. Navigate to 1.1.
  6. Switch the theme to "Rust".
  7. Navigate to other partition, for example, to 4.2.7. — the theme resets to the default one.
  8. Navigate back to the original partition — the theme is back to "Rust".

Possible Solution(s)

As a workaround, the other browser can be used, I cannot reproduce the issue using Microsoft Edge.

Idk, but, based on the behavior, it looks like the theme is somehow attached to the partition.

Notes

The bundled Unstable book, Edition guide, Rustc book, and Embedded book exhibit the same behavior.

The bundled Rust book, Rustonomicon, Rustdoc book, and Rust by Example do not suffer from this issue.

Version

cargo 1.58.0 (f01b232bc 2022-01-19)
release: 1.58.0
commit-hash: f01b232bc7f4d94f0c4603930a5a96277715eb8c
commit-date: 2022-01-19
host: x86_64-pc-windows-msvc
libgit2: 1.3.0 (sys:0.13.23 vendored)
libcurl: 7.80.0-DEV (sys:0.4.51+curl-7.80.0 vendored ssl:Schannel)
os: Windows 10.0.22000 (Windows 10 Pro) [64-bit]

Pale Moon Version: 29.4.4
weihanglo commented 2 years ago

I feel like this issue should go to rust-lang/mdBook. Apart from that, if my memory still fresh, Pale Moon is (was?) a Firefox fork. What does Firefox behave on your machine?

For the code itself, the theme in mdbook is a simple item stored in localStorage. Each time when the page is loaded, a script tries to get the item mdbook-theme from localStorage and set the style accordingly.

Refs:

quixoticaxis commented 2 years ago

@weihanglo, I decided to open the issue here because the behavior differs between the offline books on Pale Moon.

I installed Firefox and it seems to behave in the third way: it keeps the theme in all of the online books (like all three browsers I tried), but it resets the theme in all of the offline books.

So, to sum up: Edge works both online and offline. Pale Moon works online, and works offline for some of the books included with the Rust installation. Firefox works online and does not work with offline books.

I suppose, I'd open an issue at mdBook, but keep this issue opened for now.

quixoticaxis commented 2 years ago

I found out, thanks to @weihanglo, that the issue seems to be rooted in the fact that local storage access for file:/// is implementation defined and covered by non normative section of the spec.