Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Side by Side Diff: LayoutTests/battery-status/multiple-promises.html

Issue 976373002: Return same promise consistently when using navigator.getBattery() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase, make compile, fix comment Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | LayoutTests/battery-status/multiple-promises-after-resolve.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <body> 3 <body>
4 <script src="../resources/js-test.js"></script> 4 <script src="../resources/js-test.js"></script>
5 <script> 5 <script>
6 description("Test multiple promise resolution."); 6 description("Test multiple promise resolution.");
7 7
8 if (!window.testRunner) 8 if (!window.testRunner)
9 debug('This test cannot be run without the TestRunner'); 9 debug('This test cannot be run without the TestRunner');
10 10
(...skipping 30 matching lines...) Expand all
41 } 41 }
42 42
43 var promise1Count = 0; 43 var promise1Count = 0;
44 var promise2Count = 0; 44 var promise2Count = 0;
45 45
46 function finishIfReady() { 46 function finishIfReady() {
47 if (promise1Count == 1 && promise2Count == 1) 47 if (promise1Count == 1 && promise2Count == 1)
48 setTimeout(finishJSTest, 0); 48 setTimeout(finishJSTest, 0);
49 } 49 }
50 50
51 promise1 = navigator.getBattery().then( 51 promise1 = navigator.getBattery();
52 promise1.then(
52 function(battery) { 53 function(battery) {
53 debug('first resolution'); 54 debug('first resolution');
54 checkBatteryInfo(battery); 55 checkBatteryInfo(battery);
55 promise1Count++; 56 promise1Count++;
56 finishIfReady(); 57 finishIfReady();
57 }, batteryStatusFailure); 58 }, batteryStatusFailure);
58 59
59 promise2 = navigator.getBattery().then( 60 promise2 = navigator.getBattery();
61 promise2.then(
60 function(battery) { 62 function(battery) {
61 debug('second resolution'); 63 debug('second resolution');
62 checkBatteryInfo(battery); 64 checkBatteryInfo(battery);
63 promise2Count++; 65 promise2Count++;
64 finishIfReady(); 66 finishIfReady();
65 }, batteryStatusFailure); 67 }, batteryStatusFailure);
66 68
67 shouldBeFalse('promise1 === promise2'); 69 shouldBeTrue('promise1 === promise2');
68 setAndFireMockBatteryInfo(false, 10, 20, 0.5); 70 setAndFireMockBatteryInfo(false, 10, 20, 0.5);
69 </script> 71 </script>
70 </body> 72 </body>
71 </html> 73 </html>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/battery-status/multiple-promises-after-resolve.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698