Bug 1441976 - Expose BatteryManager only to Chrome scripts r=baku
authorJonathan Kingston <jkt@mozilla.com>
Mon, 18 Nov 2019 10:17:29 +0000
changeset 502396 84919209f983e0c7d71f12a5a5cd4f4edc57675e
parent 502395 66f5e8dbbb864408d9b4e2177ae964c4457fe68c
child 502397 e127df386eaf5caf0db224afac2052d906f2b8d8
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1441976
milestone72.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1441976 - Expose BatteryManager only to Chrome scripts r=baku Differential Revision: https://phabricator.services.mozilla.com/D47081
dom/battery/test/test_battery_unprivileged.html
dom/tests/mochitest/general/test_interfaces.js
dom/webidl/BatteryManager.webidl
testing/web-platform/meta/battery-status/battery-interface-idlharness.https.window.js.ini
--- a/dom/battery/test/test_battery_unprivileged.html
+++ b/dom/battery/test/test_battery_unprivileged.html
@@ -12,13 +12,14 @@
 <pre id="test">
 <script type="application/javascript">
 
 "use strict";
 
 /** Test for Battery API **/
 ok(!("getBattery" in navigator), "navigator.getBattery should not exist for unprivileged web content");
 ok(!("battery" in navigator), "navigator.battery should not exist");
+ok(!("BatteryManager" in window), "BatteryManager should not exist");
 
 </script>
 </pre>
 </body>
 </html>
--- a/dom/tests/mochitest/general/test_interfaces.js
+++ b/dom/tests/mochitest/general/test_interfaces.js
@@ -175,18 +175,16 @@ var interfaceNamesInGlobalScope = [
   { name: "AuthenticatorAttestationResponse" },
   // IMPORTANT: Do not change this list without review from a DOM peer!
   { name: "AuthenticatorResponse" },
   // IMPORTANT: Do not change this list without review from a DOM peer!
   { name: "BarProp", insecureContext: true },
   // IMPORTANT: Do not change this list without review from a DOM peer!
   { name: "BaseAudioContext", insecureContext: true },
   // IMPORTANT: Do not change this list without review from a DOM peer!
-  { name: "BatteryManager", insecureContext: true },
-  // IMPORTANT: Do not change this list without review from a DOM peer!
   { name: "BeforeUnloadEvent", insecureContext: true },
   // IMPORTANT: Do not change this list without review from a DOM peer!
   { name: "BiquadFilterNode", insecureContext: true },
   // IMPORTANT: Do not change this list without review from a DOM peer!
   { name: "Blob", insecureContext: true },
   // IMPORTANT: Do not change this list without review from a DOM peer!
   { name: "BlobEvent", insecureContext: true },
   // IMPORTANT: Do not change this list without review from a DOM peer!
--- a/dom/webidl/BatteryManager.webidl
+++ b/dom/webidl/BatteryManager.webidl
@@ -5,17 +5,17 @@
  *
  * The origin of this IDL file is
  * http://www.w3.org/TR/battery-status/
  *
  * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
  * liability, trademark and document use rules apply.
  */
 
-[Exposed=Window]
+[ChromeOnly, Exposed=Window]
 interface BatteryManager : EventTarget {
     readonly attribute boolean             charging;
     readonly attribute unrestricted double chargingTime;
     readonly attribute unrestricted double dischargingTime;
     readonly attribute double              level;
 
              attribute EventHandler        onchargingchange;
              attribute EventHandler        onchargingtimechange;
--- a/testing/web-platform/meta/battery-status/battery-interface-idlharness.https.window.js.ini
+++ b/testing/web-platform/meta/battery-status/battery-interface-idlharness.https.window.js.ini
@@ -1,40 +1,82 @@
 [battery-interface-idlharness.https.window.html]
-  [idl_test setup]
+  [Navigator interface: operation getBattery()]
+    expected: FAIL
+
+  [BatteryManager interface: manager must inherit property "chargingTime" with the proper type]
+    expected: FAIL
+
+  [BatteryManager interface: manager must inherit property "level" with the proper type]
     expected: FAIL
 
   [BatteryManager interface: manager must inherit property "onlevelchange" with the proper type]
     expected: FAIL
 
-  [BatteryManager interface: manager must inherit property "chargingTime" with the proper type]
+  [BatteryManager interface: attribute chargingTime]
+    expected: FAIL
+
+  [BatteryManager interface: existence and properties of interface prototype object's "constructor" property]
+    expected: FAIL
+
+  [BatteryManager interface: attribute ondischargingtimechange]
+    expected: FAIL
+
+  [BatteryManager interface: attribute dischargingTime]
+    expected: FAIL
+
+  [BatteryManager interface object name]
     expected: FAIL
 
   [BatteryManager must be primary interface of manager]
     expected: FAIL
 
   [Stringification of manager]
     expected: FAIL
 
   [BatteryManager interface: manager must inherit property "dischargingTime" with the proper type]
     expected: FAIL
 
+  [BatteryManager interface: existence and properties of interface object]
+    expected: FAIL
+
+  [BatteryManager interface: attribute onlevelchange]
+    expected: FAIL
+
   [Navigator interface: navigator must inherit property "getBattery()" with the proper type]
     expected: FAIL
 
+  [BatteryManager interface: attribute level]
+    expected: FAIL
+
+  [BatteryManager interface: existence and properties of interface prototype object]
+    expected: FAIL
+
+  [BatteryManager interface: existence and properties of interface prototype object's @@unscopables property]
+    expected: FAIL
+
   [BatteryManager interface: manager must inherit property "ondischargingtimechange" with the proper type]
     expected: FAIL
 
   [BatteryManager interface: manager must inherit property "onchargingchange" with the proper type]
     expected: FAIL
 
-  [BatteryManager interface: manager must inherit property "level" with the proper type]
+  [BatteryManager interface object length]
     expected: FAIL
 
-  [Navigator interface: operation getBattery()]
+  [BatteryManager interface: attribute onchargingtimechange]
+    expected: FAIL
+
+  [idl_test setup]
     expected: FAIL
 
   [BatteryManager interface: manager must inherit property "onchargingtimechange" with the proper type]
     expected: FAIL
 
   [BatteryManager interface: manager must inherit property "charging" with the proper type]
     expected: FAIL
 
+  [BatteryManager interface: attribute charging]
+    expected: FAIL
+
+  [BatteryManager interface: attribute onchargingchange]
+    expected: FAIL
+