forked from web-platform-tests/wpt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
battery-interface-idlharness.https.html
77 lines (72 loc) · 2.5 KB
/
battery-interface-idlharness.https.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<!DOCTYPE html>
<meta charset="utf-8">
<title>Battery test: IDL</title>
<link rel="author" title="Intel" href="http://www.intel.com">
<link rel="help" href="https://www.w3.org/TR/battery-status/">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/WebIDLParser.js"></script>
<script src="/resources/idlharness.js"></script>
<script type="text/plain" class="untested">
interface Navigator { };
interface EventTarget {
void addEventListener(DOMString type, EventListener? callback, optional boolean capture);
void removeEventListener(DOMString type, EventListener? callback, optional boolean capture);
boolean dispatchEvent(Event event);
};
[Callback]
interface EventListener {
void handleEvent(Event event);
};
[TreatNonObjectAsNull]
callback EventHandlerNonNull = any (Event event);
typedef EventHandlerNonNull? EventHandler;
</script>
<script type="text/plain">
partial interface Navigator {
Promise<BatteryManager> getBattery ();
};
[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;
attribute EventHandler ondischargingtimechange;
attribute EventHandler onlevelchange;
};
</script>
<script>
"use strict";
var t = async_test();
var idl_array = new IdlArray();
var idls;
var manager;
[].forEach.call(document.querySelectorAll('script[type=text\\/plain]'), function(node) {
idls = node.textContent;
idl_array[(node.className === 'untested') ? 'add_untested_idls' : 'add_idls'](idls);
});
t.step(function() {
assert_idl_attribute(navigator, 'getBattery', 'navigator must have getBattery attribute');
navigator.getBattery().then(function(bm) {
manager = bm;
idl_array.add_objects({Navigator: ['navigator'], BatteryManager: ['manager']});
idl_array.test();
t.done();
}).catch(function(err) {
t.assert_unreached("navigator.getBattery failed");
});
});
</script>
<h2>Description</h2>
<p>
This test validates the BatteryManager interface IDL.
</p>
<p>
This test uses <a href="/resources/idlharness.js">idlharness.js</a>, and
is complementary to the <a href="battery-interface.html">battery-interface.html</a>
test.
</p>
<div id="log"></div>