Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / battery-status / multiple-promises.html
blob5b3c8500b67fa7f8ed5b6eee4116b2d99ce48135
1 <!DOCTYPE html>
2 <html>
3 <body>
4 <script src="../resources/js-test.js"></script>
5 <script>
6 description("Test multiple promise resolution.");
8 if (!window.testRunner)
9 debug('This test cannot be run without the TestRunner');
11 // Clean-up any unused battery manager objects from previous tests.
12 gc();
13 jsTestIsAsync = true;
14 testRunner.waitUntilDone();
15 testRunner.setCanOpenWindows();
16 testRunner.setCloseRemainingWindowsWhenComplete(true);
18 var mockBatteryInfo;
19 function setAndFireMockBatteryInfo(charging, chargingTime, dischargingTime, level) {
20 mockBatteryInfo = { charging: charging,
21 chargingTime: chargingTime,
22 dischargingTime: dischargingTime,
23 level: level };
24 testRunner.didChangeBatteryStatus(charging, chargingTime, dischargingTime, level);
27 // compare obtained battery values with the mock values
28 function checkBatteryInfo(batteryManager) {
29 batteryInfo = batteryManager;
30 shouldBeDefined("batteryInfo");
31 shouldBeDefined("mockBatteryInfo");
32 shouldBe('batteryInfo.charging', 'mockBatteryInfo.charging');
33 shouldBe('batteryInfo.chargingTime', 'mockBatteryInfo.chargingTime');
34 shouldBe('batteryInfo.dischargingTime', 'mockBatteryInfo.dischargingTime');
35 shouldBe('batteryInfo.level', 'mockBatteryInfo.level');
38 function batteryStatusFailure() {
39 testFailed('failed to successfully resolve the promise');
40 setTimeout(finishJSTest, 0);
43 var promise1Count = 0;
44 var promise2Count = 0;
46 function finishIfReady() {
47 if (promise1Count == 1 && promise2Count == 1)
48 setTimeout(finishJSTest, 0);
51 promise1 = navigator.getBattery();
52 promise1.then(
53 function(battery) {
54 debug('first resolution');
55 checkBatteryInfo(battery);
56 promise1Count++;
57 finishIfReady();
58 }, batteryStatusFailure);
60 promise2 = navigator.getBattery();
61 promise2.then(
62 function(battery) {
63 debug('second resolution');
64 checkBatteryInfo(battery);
65 promise2Count++;
66 finishIfReady();
67 }, batteryStatusFailure);
69 shouldBeTrue('promise1 === promise2');
70 setAndFireMockBatteryInfo(false, 10, 20, 0.5);
71 </script>
72 </body>
73 </html>