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

[Bug] The battery's isSupported is broken. #3688

Open
7 tasks done
Jesse205 opened this issue Jan 2, 2024 · 5 comments
Open
7 tasks done

[Bug] The battery's isSupported is broken. #3688

Jesse205 opened this issue Jan 2, 2024 · 5 comments

Comments

@Jesse205
Copy link

Jesse205 commented Jan 2, 2024

Describe the bug

Using only xxx in xxx to determine support can be problematic.

image

I am using a new version of Microsoft Edge and my computer is a battery free computer.

To fix this, just add typeof navigator.getBattery === 'function'

Reproduction

https://stackblitz.com/edit/vitejs-vite-tuyecr?file=src%2FApp.vue

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (4) x64 Intel(R) Core(TM) i3-4170 CPU @ 3.70GHz
    Memory: 407.99 MB / 11.87 GB
  Binaries:
    Node: 21.2.0 - D:\Program Files\nodejs\node.EXE
    Yarn: 1.22.21 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 10.2.3 - D:\Program Files\nodejs\npm.CMD
    pnpm: 8.11.0 - ~\AppData\Roaming\npm\pnpm.CMD
  Browsers:
    Edge: Chromium (120.0.2210.77)
    Internet Explorer: 11.0.19041.3636

Used Package Manager

yarn

Validations

@Jesse205
Copy link
Author

Jesse205 commented Jan 2, 2024

Already exists pr #3634

@Jesse205
Copy link
Author

Jesse205 commented Jan 2, 2024

I looked at other functions and it didn't added typeof either. Perhaps other functions also have this kind of bug?

@Doctor-wu
Copy link
Member

Already exists pr #3634

Hi @Jesse205 , That PR appears to be not active, welcome to commit a new one :)

@Doctor-wu
Copy link
Member

Already exists pr #3634

Hi @Jesse205 , That PR appears to be not active, welcome to commit a new one :)

That author just replied, ignore this🥹

@Jesse205
Copy link
Author

Jesse205 commented Jan 3, 2024

I found that delete navigator.getBattery can resets the getBattery function. And the problem is not reproduced in other browsers. I think it might be some extension I installed that makes navigator.getBattery undefined or only http://xxx cannot use navigator.getBattery.

Browers:

  • Chrome: v120.0.6099.130, no extensions
  • Cent Browser: v5.0.1002.354 (official release) (32-bit) (Chromium 102.0.5005.167), only Tampermonkey, no scripts
  • Edge: v120.0.2210.91 (official version) (64-bit), very many extensions

Chrome(https://cn.bing.com/chrome/newtab):
image

Chrome(http://192.168.56.1:5173/):
image

Cent Browser(https://hao.centbrowser.cn/):
image

Cent Browser(http://192.168.56.1:5173/):
image

Edge(http://192.168.56.1:5173/):
image
image

Edge(https://www.hao123.com/):
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants