Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New C-S-S webcompat intervention: modifyLocalStorage #1026

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
20 changes: 20 additions & 0 deletions src/features/web-compat.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ContentFeature from '../content-feature.js'

Check failure on line 1 in src/features/web-compat.js

View workflow job for this annotation

GitHub Actions / unit (ubuntu-20.04)

Property 'modifyLocalStorage' does not exist on type 'WebCompatSettings'.
import { URL } from '../captured-globals.js'

/**
Expand Down Expand Up @@ -117,6 +117,10 @@
if (this.getFeatureSettingEnabled('screenLock')) {
this.screenLockFix()
}

if (this.getFeatureSettingEnabled('modifyLocalStorage')) {
this.modifyLocalStorage()
}
}

/** Shim Web Share API in Android WebView */
Expand Down Expand Up @@ -531,6 +535,22 @@
}
}

/**
* Support for modifying localStorage entries
*/
modifyLocalStorage () {
/** @type {import('../types//webcompat-settings').WebCompatSettings['modifyLocalStorage']} */
dharb marked this conversation as resolved.
Show resolved Hide resolved
const settings = this.getFeatureSetting('modifyLocalStorage')

if (!settings || !settings.changes) return

settings.changes.forEach((change) => {
if (change.action === 'delete') {
localStorage.removeItem(change.key)
}
})
}

/**
* Support for proxying `window.webkit.messageHandlers`
*/
Expand Down
Loading