fune/browser/extensions/webcompat/shims/private-browsing-web-api-fixes.js
Rob Wu ce4599d3d4 Bug 1742344 - Unbreak imgur.io on Android in PBM r=webcompat-reviewers,twisniewski
In private browsing mode, `caches.keys()` rejects. imgur.io does not
expect that. As a work-around, `window.caches` can be deleted. This shim
is already defined in the source, but did not work because the URL
pattern changed.

An example of a current URL is https://imgur.io/js/vendor.1ae05f3622fe27342a53.js

This patch fixes up the URL.

The problem only occurs on imgur.io, not imgur.com. A visit on either
domain may result in a redirect to the other domain depending on whether
the user agent is mobile.

Test case:

1. Visit about:config and set `general.useragent.override` to
   `Mozilla/5.0 (Android 14.0; Mobile; rv:120.0) Gecko/120.0 Firefox/120.0`
2. Open a private browsing window and visit imgur.io

Before this patch, imgur was broken.
With this patch, imgur works again.

Besides fixing the imgur issue, this also removes the `indexedDB` hider,
because `indexedDB` has been supported in private browsing mode since
Firefox 115, by https://bugzilla.mozilla.org/show_bug.cgi?id=1831058

Differential Revision: https://phabricator.services.mozilla.com/D193391
2023-11-13 00:56:25 +00:00

19 lines
739 B
JavaScript

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
/**
* Bug 1714354 - Fix for site issues with web APIs in private browsing
*
* Some sites expect specific DOM APIs to work in specific ways, which
* is not always true, such as in private browsing mode. We work around
* related breakage by undefining those APIs entirely in private
* browsing mode for those sites.
*/
// caches.keys() rejects in private browsing mode:
// https://bugzilla.mozilla.org/show_bug.cgi?id=1742344#c4
// Can be removed once bug 1714354 is fixed.
delete window.wrappedJSObject.caches;