Hide navigator.requestWakeLock and MozWakeLock from the web except on Firefox OS

RESOLVED FIXED in mozilla30

Status

()

defect
RESOLVED FIXED
6 years ago
3 months ago

People

(Reporter: Ehsan, Assigned: kanru)

Tracking

(Blocks 1 bug, {dev-doc-complete})

Trunk
mozilla30
Points:
---
Dependency tree / graph
Bug Flags:
in-testsuite +

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(4 attachments, 1 obsolete attachment)

Reporter

Description

6 years ago
navigator.requestWakeLock and MozWakeLock only do something useful in Firefox OS, but they are currently exposed to all platforms unconditionally.  The WebIDL has a [Func="Navigator::HasWakeLockSupport"] attribute which may trick people into believing that these names are not exposed in some places but that function only makes sure that it can instantiate the nsIPowerManagerService service, which is available everywhere.

Kan-ru, is there any reason why we should not do this?  If not, are you interested in taking this bug?

Thanks!
Flags: needinfo?(kchen)
Reporter

Updated

6 years ago
Keywords: dev-doc-needed
Assignee

Updated

6 years ago
Assignee: nobody → kchen
Flags: needinfo?(kchen)
We'll want this soonish, to prevent web pages from having the ability to prevent the screen saver from turning on in non-B2G builds.
Blocks: 517870, 968603
Assignee

Comment 2

5 years ago
mochitest-browser test can't use SpecialPowers.pushPermissions without this fix.

TEST-UNEXPECTED-FAIL | chrome://mochitests/content/browser/dom/power/test/browser_wakelocks.js | leaked window property: lastPermission
Attachment #8373145 - Flags: review?(jmaher)
Assignee

Comment 4

5 years ago
Was disabled entirely in bug 843893. I think we should at least run a subset of these tests.
Attachment #8373147 - Flags: review?(jgriffin)
An update to test_interfaces.html (and a review from a DOM peer) would be needed.
Assignee

Comment 6

5 years ago
Attachment #8373200 - Flags: review?(bzbarsky)
Comment on attachment 8373145 [details] [diff] [review]
Fix leaked lastPermission var

Review of attachment 8373145 [details] [diff] [review]:
-----------------------------------------------------------------

thanks!
Attachment #8373145 - Flags: review?(jmaher) → review+
Comment on attachment 8373147 [details] [diff] [review]
Re-enable basic power & wakelock tests for desktop

Review of attachment 8373147 [details] [diff] [review]:
-----------------------------------------------------------------

thanks for cleaning up the moz.build rules and making the mochitest.ini more complete!
Attachment #8373147 - Flags: review?(jgriffin) → review+
Reporter

Comment 10

5 years ago
Comment on attachment 8373146 [details] [diff] [review]
Hide navigator.requestWakeLock behind pref dom.wakelock.enabled

Review of attachment 8373146 [details] [diff] [review]:
-----------------------------------------------------------------

Thanks for fixing this!  r=me with the below addressed.

::: dom/base/Navigator.cpp
@@ +1685,5 @@
>  Navigator::HasWakeLockSupport(JSContext* /* unused*/, JSObject* /*unused */)
>  {
> +  // First of all, the general pref has to be turned on.
> +  bool enabled = false;
> +  Preferences::GetBool("dom.wakelock.enabled", &enabled);

Please use a [Pref] attribute in the webidl instead.
Attachment #8373146 - Flags: review?(ehsan) → review+
Reporter

Comment 11

5 years ago
Also, can you please add a test which makes sure that navigator.requestWakeLock is unavailable in non-gonk platforms?
Comment on attachment 8373200 [details] [diff] [review]
Update test_interfaces.html

r=me
Attachment #8373200 - Flags: review?(bzbarsky) → review+
Blocks: 971761
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.