Closed Bug 963366 Opened 7 years ago Closed 7 years ago

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

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla30

People

(Reporter: ehsan, Assigned: kanru)

References

(Blocks 1 open bug)

Details

(Keywords: dev-doc-complete)

Attachments

(4 files, 1 obsolete file)

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)
Keywords: dev-doc-needed
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
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)
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.
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+
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+
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.