ruffle
ruffle copied to clipboard
extension: Re-enable SWF takeover using declarativeNetRequest
~~This is a draft because I can't figure out how to feature detect it, so it only works on Chrome Canary or Chrome Dev when using google-chrome-unstable --enable-features=DeclarativeNetRequestResponseHeaderMatching. See https://github.com/w3c/webextensions/issues/638 for the issue about feature detection.~~
~~On Chrome stable, these rules mean literally every URL does a redirect to the internal player page, so this can't be merged without either feature detection or user agent sniffing.~~
This is based on https://github.com/w3c/webextensions/issues/460. I added feature detection. This should be tested on Chrome Canary or Chrome Dev. As of the latest available Chrome Dev on Fedora, this is supported without manually enabling the flag.
See screencast:
Can we at least wait until this is properly supported in Chrome so we don't have to do that annoying bug detection dance?
Can we at least wait until this is properly supported in Chrome so we don't have to do that annoying bug detection dance?
I don't disagree with waiting but we'll still need to decide what to do here. Supposedly Chromium does throw just like Firefox with a fully unsupported RuleCondition. The bug, as confirmed in https://issues.chromium.org/issues/347186592#comment9, is actually that features developed behind a flag are not fully hidden behind the flag in Chrome. Without this "annoying bug detection dance", with just a try and catch, we may end up in a situation where both older and newer versions of Chrome work properly with Ruffle but the versions that were implementing this feature behind a flag are broken. I'm not sure that's acceptable.
the versions that were implementing this feature behind a flag are broken. I'm not sure that's acceptable.
I didn't quite realize this could happen. I sort of assumed this problem would still be limited to Canary.
Do we want/need to have a setting for disabling this specific feature?
Having a setting for disabling this feature may be nice in general since some people did find it frustrating when trying to just download SWFs. I added showSWFDownload to the player page for that reason.
However, I'm not sure that's enough. Try checking out https://github.com/ruffle-rs/ruffle/pull/16694/commits/ca7fc87f428eb2ef64abfb61ba6687d9123b59a9 and using the extension in Chrome stable. https://google.com redirects to the player page. Needing to disable this feature to stop that is unintuitive.
Do we want/need to have a setting for disabling this specific feature?
Latest commit adds this.
Marking this PR as waiting on review. Whether we merge soon or wait until Chrome 128 reaches stable in August is an open question, but the code shouldn't actually be changing between now and then. Unfortunately, the feature detection method copied from https://github.com/w3c/webextensions/issues/638#issuecomment-2181124486 will be necessary to continue supporting Ruffle on Chrome 126 or 127, which were implementing this feature behind a flag, as noted in https://issues.chromium.org/issues/347186592#comment9.
Official docs: https://developer.chrome.com/docs/extensions/reference/api/declarativeNetRequest#type-HeaderInfo and https://developer.chrome.com/docs/extensions/reference/api/declarativeNetRequest#property-RuleCondition-excludedResponseHeaders and https://developer.chrome.com/docs/extensions/reference/api/declarativeNetRequest#property-RuleCondition-responseHeaders