simulating support for missing web apis?

Is there a way to simulate the lack of support for web apis in Firefox or Chrome? Like for example, deactivating the push api so I can test if my fallback properly triggers. I was hoping for a setting in about:config or something similar. For example, I have this line of code:
export const isSupported = ('pushManager' in registration) && ('getSubscription' in registration.pushManager);
export const isSupported = ('pushManager' in registration) && ('getSubscription' in registration.pushManager);
In my browser, isSupported is always true because my browser supports the push api. But I want to test if this variable is actually really false when support is missing.
7 Replies
ἔρως
ἔρως9mo ago
the easiest option is to test on a browser that doesnt support it and the easiest is to just install windows 10, on some older version or using one of those many websites that let you run your site on different browsers
Wonderbear
Wonderbear9mo ago
That sounds very inflexible and too complex for this simple problem Do you mean I should install win10 in a vm? That sounds even more complex 😅
ἔρως
ἔρως9mo ago
well, you can try to nuke the value from window like window.thingy = null or undefined windows 10 is pretty simple to install
Wonderbear
Wonderbear9mo ago
I tried that. Doesnt really work. Most of these javascript global objects are getter only And when it works then javascript still counts them as existent on the parent object Therefore the clause 'xyz' in obj doesnt work as intended anymore delete obj is straight up ignored
ἔρως
ἔρως9mo ago
then create a plain old js object add the keys you want to it pretend that thats the window object test if the missing key is there this way, you can toggle features on/off for testing or just manually invert the logic
Jochem
Jochem9mo ago
Misspell the strings So just check for something that doesn't exist Easier to make logical errors inverting logic
ἔρως
ἔρως9mo ago
that works too
Want results from more Discord servers?
Add your server