From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- testing/web-platform/tests/battery-status/META.yml | 4 + .../tests/battery-status/api-defined.https.html | 30 +++++ ...olicy-attribute-redirect-on-load.https.sub.html | 28 +++++ ...-by-permissions-policy-attribute.https.sub.html | 27 +++++ ...ry-allowed-by-permissions-policy.https.sub.html | 28 +++++ ...ed-by-permissions-policy.https.sub.html.headers | 1 + ...attery-allowed-in-same-origin-iframe.https.html | 26 +++++ .../battery-charging-manual.https.html | 54 +++++++++ ...ttery-default-permissions-policy.https.sub.html | 28 +++++ ...y-disabled-by-permissions-policy.https.sub.html | 28 +++++ ...ed-by-permissions-policy.https.sub.html.headers | 1 + ...isallowed-in-cross-origin-iframe.https.sub.html | 27 +++++ .../battery-discharging-manual.https.html | 54 +++++++++ .../battery-status/battery-full-manual.https.html | 44 +++++++ .../battery-plugging-in-manual.https.html | 127 +++++++++++++++++++++ .../battery-promise-window.https.html | 30 +++++ .../battery-status/battery-promise.https.html | 20 ++++ .../battery-unplugging-manual.https.html | 112 ++++++++++++++++++ .../battery-status/idlharness.https.window.js | 20 ++++ .../multiple-promises-after-resolve.https.html | 23 ++++ .../battery-status/multiple-promises.https.html | 22 ++++ .../no-leak-on-detached-use.https.html | 48 ++++++++ .../battery-status/page-visibility.https.html | 38 ++++++ .../promise-with-eventlisteners.https.html | 36 ++++++ .../resources/battery-status-helpers.js | 34 ++++++ .../battery-status/resources/support-iframe.html | 5 + .../resources/support-window-open.html | 10 ++ .../resources/window-postmessage-open-close.html | 9 ++ .../restricted-level-precision.https.html | 22 ++++ 29 files changed, 936 insertions(+) create mode 100644 testing/web-platform/tests/battery-status/META.yml create mode 100644 testing/web-platform/tests/battery-status/api-defined.https.html create mode 100644 testing/web-platform/tests/battery-status/battery-allowed-by-permissions-policy-attribute-redirect-on-load.https.sub.html create mode 100644 testing/web-platform/tests/battery-status/battery-allowed-by-permissions-policy-attribute.https.sub.html create mode 100644 testing/web-platform/tests/battery-status/battery-allowed-by-permissions-policy.https.sub.html create mode 100644 testing/web-platform/tests/battery-status/battery-allowed-by-permissions-policy.https.sub.html.headers create mode 100644 testing/web-platform/tests/battery-status/battery-allowed-in-same-origin-iframe.https.html create mode 100644 testing/web-platform/tests/battery-status/battery-charging-manual.https.html create mode 100644 testing/web-platform/tests/battery-status/battery-default-permissions-policy.https.sub.html create mode 100644 testing/web-platform/tests/battery-status/battery-disabled-by-permissions-policy.https.sub.html create mode 100644 testing/web-platform/tests/battery-status/battery-disabled-by-permissions-policy.https.sub.html.headers create mode 100644 testing/web-platform/tests/battery-status/battery-disallowed-in-cross-origin-iframe.https.sub.html create mode 100644 testing/web-platform/tests/battery-status/battery-discharging-manual.https.html create mode 100644 testing/web-platform/tests/battery-status/battery-full-manual.https.html create mode 100644 testing/web-platform/tests/battery-status/battery-plugging-in-manual.https.html create mode 100644 testing/web-platform/tests/battery-status/battery-promise-window.https.html create mode 100644 testing/web-platform/tests/battery-status/battery-promise.https.html create mode 100644 testing/web-platform/tests/battery-status/battery-unplugging-manual.https.html create mode 100644 testing/web-platform/tests/battery-status/idlharness.https.window.js create mode 100644 testing/web-platform/tests/battery-status/multiple-promises-after-resolve.https.html create mode 100644 testing/web-platform/tests/battery-status/multiple-promises.https.html create mode 100644 testing/web-platform/tests/battery-status/no-leak-on-detached-use.https.html create mode 100644 testing/web-platform/tests/battery-status/page-visibility.https.html create mode 100644 testing/web-platform/tests/battery-status/promise-with-eventlisteners.https.html create mode 100644 testing/web-platform/tests/battery-status/resources/battery-status-helpers.js create mode 100644 testing/web-platform/tests/battery-status/resources/support-iframe.html create mode 100644 testing/web-platform/tests/battery-status/resources/support-window-open.html create mode 100644 testing/web-platform/tests/battery-status/resources/window-postmessage-open-close.html create mode 100644 testing/web-platform/tests/battery-status/restricted-level-precision.https.html (limited to 'testing/web-platform/tests/battery-status') diff --git a/testing/web-platform/tests/battery-status/META.yml b/testing/web-platform/tests/battery-status/META.yml new file mode 100644 index 0000000000..77d19a828d --- /dev/null +++ b/testing/web-platform/tests/battery-status/META.yml @@ -0,0 +1,4 @@ +spec: https://w3c.github.io/battery/ +suggested_reviewers: + - anssiko + - Honry diff --git a/testing/web-platform/tests/battery-status/api-defined.https.html b/testing/web-platform/tests/battery-status/api-defined.https.html new file mode 100644 index 0000000000..9fe41d4b49 --- /dev/null +++ b/testing/web-platform/tests/battery-status/api-defined.https.html @@ -0,0 +1,30 @@ + + + + + + + + + + + + diff --git a/testing/web-platform/tests/battery-status/battery-allowed-by-permissions-policy-attribute-redirect-on-load.https.sub.html b/testing/web-platform/tests/battery-status/battery-allowed-by-permissions-policy-attribute-redirect-on-load.https.sub.html new file mode 100644 index 0000000000..f65f3629df --- /dev/null +++ b/testing/web-platform/tests/battery-status/battery-allowed-by-permissions-policy-attribute-redirect-on-load.https.sub.html @@ -0,0 +1,28 @@ + + + + + + + diff --git a/testing/web-platform/tests/battery-status/battery-allowed-by-permissions-policy-attribute.https.sub.html b/testing/web-platform/tests/battery-status/battery-allowed-by-permissions-policy-attribute.https.sub.html new file mode 100644 index 0000000000..fc4a7bad81 --- /dev/null +++ b/testing/web-platform/tests/battery-status/battery-allowed-by-permissions-policy-attribute.https.sub.html @@ -0,0 +1,27 @@ + + + + + + + diff --git a/testing/web-platform/tests/battery-status/battery-allowed-by-permissions-policy.https.sub.html b/testing/web-platform/tests/battery-status/battery-allowed-by-permissions-policy.https.sub.html new file mode 100644 index 0000000000..8cbf39997b --- /dev/null +++ b/testing/web-platform/tests/battery-status/battery-allowed-by-permissions-policy.https.sub.html @@ -0,0 +1,28 @@ + + + + + + + diff --git a/testing/web-platform/tests/battery-status/battery-allowed-by-permissions-policy.https.sub.html.headers b/testing/web-platform/tests/battery-status/battery-allowed-by-permissions-policy.https.sub.html.headers new file mode 100644 index 0000000000..989fdc3df8 --- /dev/null +++ b/testing/web-platform/tests/battery-status/battery-allowed-by-permissions-policy.https.sub.html.headers @@ -0,0 +1 @@ +Permissions-Policy: battery=* diff --git a/testing/web-platform/tests/battery-status/battery-allowed-in-same-origin-iframe.https.html b/testing/web-platform/tests/battery-status/battery-allowed-in-same-origin-iframe.https.html new file mode 100644 index 0000000000..03475162df --- /dev/null +++ b/testing/web-platform/tests/battery-status/battery-allowed-in-same-origin-iframe.https.html @@ -0,0 +1,26 @@ + + +Battery Test: navigator.getBattery() is allowed in same origin iframe + + + + +
+ + diff --git a/testing/web-platform/tests/battery-status/battery-charging-manual.https.html b/testing/web-platform/tests/battery-status/battery-charging-manual.https.html new file mode 100644 index 0000000000..9ff7421638 --- /dev/null +++ b/testing/web-platform/tests/battery-status/battery-charging-manual.https.html @@ -0,0 +1,54 @@ + + +Battery Test: battery neither empty or full, charger plugged in + + + + + + +

Description

+

+ This test validates that all of the BatteryManager attributes exist and are set to their correct values when battery is charging. +

+ +

Preconditions

+
    +
  1. + The device is plugged in to the charger before this test is run. +
  2. +
  3. + The battery must neither be empty or full, nor reach empty or full capacity during the test. +
  4. +
  5. + Waiting for battery level change to fire levelchange event, maybe need a long time +
  6. +
+ + diff --git a/testing/web-platform/tests/battery-status/battery-default-permissions-policy.https.sub.html b/testing/web-platform/tests/battery-status/battery-default-permissions-policy.https.sub.html new file mode 100644 index 0000000000..7485250dae --- /dev/null +++ b/testing/web-platform/tests/battery-status/battery-default-permissions-policy.https.sub.html @@ -0,0 +1,28 @@ + + + + + + + diff --git a/testing/web-platform/tests/battery-status/battery-disabled-by-permissions-policy.https.sub.html b/testing/web-platform/tests/battery-status/battery-disabled-by-permissions-policy.https.sub.html new file mode 100644 index 0000000000..4afdee8a0c --- /dev/null +++ b/testing/web-platform/tests/battery-status/battery-disabled-by-permissions-policy.https.sub.html @@ -0,0 +1,28 @@ + + + + + + + diff --git a/testing/web-platform/tests/battery-status/battery-disabled-by-permissions-policy.https.sub.html.headers b/testing/web-platform/tests/battery-status/battery-disabled-by-permissions-policy.https.sub.html.headers new file mode 100644 index 0000000000..9ff0bc6190 --- /dev/null +++ b/testing/web-platform/tests/battery-status/battery-disabled-by-permissions-policy.https.sub.html.headers @@ -0,0 +1 @@ +Permissions-Policy: battery=() diff --git a/testing/web-platform/tests/battery-status/battery-disallowed-in-cross-origin-iframe.https.sub.html b/testing/web-platform/tests/battery-status/battery-disallowed-in-cross-origin-iframe.https.sub.html new file mode 100644 index 0000000000..c86e01f6ab --- /dev/null +++ b/testing/web-platform/tests/battery-status/battery-disallowed-in-cross-origin-iframe.https.sub.html @@ -0,0 +1,27 @@ + + +Battery Test: navigator.getBattery() is not allowed in cross origin iframe + + + + +
+ + diff --git a/testing/web-platform/tests/battery-status/battery-discharging-manual.https.html b/testing/web-platform/tests/battery-status/battery-discharging-manual.https.html new file mode 100644 index 0000000000..f321cf7548 --- /dev/null +++ b/testing/web-platform/tests/battery-status/battery-discharging-manual.https.html @@ -0,0 +1,54 @@ + + +Battery Test: battery neither empty or full, charger unplugged in + + + + + + +

Description

+

+ This test validates that all of the BatteryManager attributes exist and are set to their correct values when battery is discharging. +

+ +

Preconditions

+
    +
  1. + The device is unplugged from the charger before this test is run. +
  2. +
  3. + The battery must neither be empty or full, nor reach empty or full capacity during the test. +
  4. +
  5. + Waiting for battery level change to fire levelchange event, maybe need a long time +
  6. +
+ + diff --git a/testing/web-platform/tests/battery-status/battery-full-manual.https.html b/testing/web-platform/tests/battery-status/battery-full-manual.https.html new file mode 100644 index 0000000000..0680b7d933 --- /dev/null +++ b/testing/web-platform/tests/battery-status/battery-full-manual.https.html @@ -0,0 +1,44 @@ + + +Battery Test: battery full, charger plugged in + + + + + + +

Description

+

+ This test validates that all of the BatteryManager attributes exist and are set to their correct values when battery is full. +

+ +

Preconditions

+
    +
  1. + The device is plugged in to the charger before this test is run. +
  2. +
  3. + The battery is full. +
  4. +
+ + diff --git a/testing/web-platform/tests/battery-status/battery-plugging-in-manual.https.html b/testing/web-platform/tests/battery-status/battery-plugging-in-manual.https.html new file mode 100644 index 0000000000..1445bd7e26 --- /dev/null +++ b/testing/web-platform/tests/battery-status/battery-plugging-in-manual.https.html @@ -0,0 +1,127 @@ + + +Battery Test: battery not full, charger plugging in + + + + + + + +

Description

+

+ This test validates that all of the BatteryManager attributes exist and + are set to correct values, with corresponding events fired, + when the charger is plugged in. +

+ +

Preconditions

+
    +
  1. + The device is unplugged from the charger before this test is run. +
  2. +
  3. + The battery must not be full or reach full capacity before the time the test is run. +
  4. +
+ +
+
    +
  1. + Plug in the charger and wait for all the tests to complete. +
  2. +
  3. + The tests may take long time since the definition of how + often the chargingtimechange, dischargingtimechange, and levelchange + events are fired is left to the implementation. +
  4. +
+
+ +
+ + diff --git a/testing/web-platform/tests/battery-status/battery-promise-window.https.html b/testing/web-platform/tests/battery-status/battery-promise-window.https.html new file mode 100644 index 0000000000..362ef93667 --- /dev/null +++ b/testing/web-platform/tests/battery-status/battery-promise-window.https.html @@ -0,0 +1,30 @@ + + +Battery Test: window.open() makes a different Navigator object + + + + + +
+ Allow pop-up windows before running the tests. +
+
+ diff --git a/testing/web-platform/tests/battery-status/battery-promise.https.html b/testing/web-platform/tests/battery-status/battery-promise.https.html new file mode 100644 index 0000000000..ecf7318e1c --- /dev/null +++ b/testing/web-platform/tests/battery-status/battery-promise.https.html @@ -0,0 +1,20 @@ + + +Battery Test: navigator.getBattery() always return same battery promise + + + + +
+ diff --git a/testing/web-platform/tests/battery-status/battery-unplugging-manual.https.html b/testing/web-platform/tests/battery-status/battery-unplugging-manual.https.html new file mode 100644 index 0000000000..3b515786dc --- /dev/null +++ b/testing/web-platform/tests/battery-status/battery-unplugging-manual.https.html @@ -0,0 +1,112 @@ + + +Battery Test: charger unplugging + + + + + + + +

Description

+

+ This test validates that all of the BatteryManager attributes exist and + are set to correct values, with corresponding events fired, + when the charger is unplugged. +

+ +

Preconditions

+
    +
  1. + The device is plugged in to the charger before this test is run. +
  2. +
+ +
+ Unplug the charger and wait for all the tests to complete. +
+ +
+ + diff --git a/testing/web-platform/tests/battery-status/idlharness.https.window.js b/testing/web-platform/tests/battery-status/idlharness.https.window.js new file mode 100644 index 0000000000..8113d9e779 --- /dev/null +++ b/testing/web-platform/tests/battery-status/idlharness.https.window.js @@ -0,0 +1,20 @@ +// META: script=/resources/WebIDLParser.js +// META: script=/resources/idlharness.js +// META: timeout=long + +// https://w3c.github.io/battery/ + +'use strict'; + +idl_test( + ['battery-status'], + ['dom', 'html'], + async idl_array => { + idl_array.add_objects({ + Navigator: ['navigator'], + BatteryManager: ['manager'], + }) + + self.manager = await navigator.getBattery(); + } +); diff --git a/testing/web-platform/tests/battery-status/multiple-promises-after-resolve.https.html b/testing/web-platform/tests/battery-status/multiple-promises-after-resolve.https.html new file mode 100644 index 0000000000..2b43f124c0 --- /dev/null +++ b/testing/web-platform/tests/battery-status/multiple-promises-after-resolve.https.html @@ -0,0 +1,23 @@ + + + + + + + + + + + + diff --git a/testing/web-platform/tests/battery-status/multiple-promises.https.html b/testing/web-platform/tests/battery-status/multiple-promises.https.html new file mode 100644 index 0000000000..35015c80ba --- /dev/null +++ b/testing/web-platform/tests/battery-status/multiple-promises.https.html @@ -0,0 +1,22 @@ + + + + + + + + + + + + diff --git a/testing/web-platform/tests/battery-status/no-leak-on-detached-use.https.html b/testing/web-platform/tests/battery-status/no-leak-on-detached-use.https.html new file mode 100644 index 0000000000..8ea7ea303c --- /dev/null +++ b/testing/web-platform/tests/battery-status/no-leak-on-detached-use.https.html @@ -0,0 +1,48 @@ + + + + + + + + + + diff --git a/testing/web-platform/tests/battery-status/page-visibility.https.html b/testing/web-platform/tests/battery-status/page-visibility.https.html new file mode 100644 index 0000000000..27cc0208a8 --- /dev/null +++ b/testing/web-platform/tests/battery-status/page-visibility.https.html @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/battery-status/promise-with-eventlisteners.https.html b/testing/web-platform/tests/battery-status/promise-with-eventlisteners.https.html new file mode 100644 index 0000000000..6d7544b856 --- /dev/null +++ b/testing/web-platform/tests/battery-status/promise-with-eventlisteners.https.html @@ -0,0 +1,36 @@ + + + + + + + + + + + + diff --git a/testing/web-platform/tests/battery-status/resources/battery-status-helpers.js b/testing/web-platform/tests/battery-status/resources/battery-status-helpers.js new file mode 100644 index 0000000000..02acfe6c29 --- /dev/null +++ b/testing/web-platform/tests/battery-status/resources/battery-status-helpers.js @@ -0,0 +1,34 @@ +'use strict'; + +// These tests rely on the User Agent providing an implementation of +// platform battery status backends. +// +// In Chromium-based browsers this implementation is provided by a polyfill +// in order to reduce the amount of test-only code shipped to users. To enable +// these tests the browser must be run with these options: +// +// --enable-blink-features=MojoJS,MojoJSTest + +let mockBatteryMonitor = undefined; + +function battery_status_test(func, name, properties) { + promise_test(async t => { + if (mockBatteryMonitor === undefined) { + if (isChromiumBased) { + const mocks = + await import('/resources/chromium/mock-battery-monitor.js'); + mockBatteryMonitor = mocks.mockBatteryMonitor; + } + } + assert_implements( + mockBatteryMonitor, 'missing mockBatteryMonitor after initialization'); + + mockBatteryMonitor.start(); + + t.add_cleanup(() => { + mockBatteryMonitor.reset(); + return mockBatteryMonitor.stop(); + }); + return func(t, mockBatteryMonitor); + }, name, properties); +} diff --git a/testing/web-platform/tests/battery-status/resources/support-iframe.html b/testing/web-platform/tests/battery-status/resources/support-iframe.html new file mode 100644 index 0000000000..d4e5b31f13 --- /dev/null +++ b/testing/web-platform/tests/battery-status/resources/support-iframe.html @@ -0,0 +1,5 @@ + + +
+Hello! +
diff --git a/testing/web-platform/tests/battery-status/resources/support-window-open.html b/testing/web-platform/tests/battery-status/resources/support-window-open.html new file mode 100644 index 0000000000..afffc3af28 --- /dev/null +++ b/testing/web-platform/tests/battery-status/resources/support-window-open.html @@ -0,0 +1,10 @@ + + + diff --git a/testing/web-platform/tests/battery-status/resources/window-postmessage-open-close.html b/testing/web-platform/tests/battery-status/resources/window-postmessage-open-close.html new file mode 100644 index 0000000000..ae256c71ce --- /dev/null +++ b/testing/web-platform/tests/battery-status/resources/window-postmessage-open-close.html @@ -0,0 +1,9 @@ + + + + + + + diff --git a/testing/web-platform/tests/battery-status/restricted-level-precision.https.html b/testing/web-platform/tests/battery-status/restricted-level-precision.https.html new file mode 100644 index 0000000000..a66a22cecf --- /dev/null +++ b/testing/web-platform/tests/battery-status/restricted-level-precision.https.html @@ -0,0 +1,22 @@ + + + + + + + + + + + + -- cgit v1.2.3