| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <script src="../../resources/js-test.js"></script> | 4 <script src="../../resources/js-test.js"></script> |
| 5 </head> | 5 </head> |
| 6 <body> | 6 <body> |
| 7 <div id="description"></div> | 7 <div id="description"></div> |
| 8 <div id="console"></div> | 8 <div id="console"></div> |
| 9 <script> | 9 <script> |
| 10 description('Test Promise native then.'); | 10 description('Test Promise native then.'); |
| 11 | 11 |
| 12 window.jsTestIsAsync = true; | 12 window.jsTestIsAsync = true; |
| 13 | 13 |
| 14 var resolve; | 14 var resolve; |
| 15 var promise = new Promise(function(r) { resolve = r; }); | 15 var promise = new Promise(function(r) { resolve = r; }); |
| 16 var newPromise = window.internals.addOneToPromise(promise); | 16 var newPromise = window.internals.addOneToPromise(promise); |
| 17 debug("Got a new promise: " + newPromise); | |
| 18 | 17 |
| 19 newPromise.then(function(result) { | 18 newPromise.then(function(result) { |
| 20 window.result = result; | 19 window.result = result; |
| 21 shouldBe('result', '11'); | 20 shouldBe('result', '11'); |
| 22 return window.internals.addOneToPromise(result); | 21 return window.internals.addOneToPromise(result); |
| 23 }).then(function(result) { | 22 }).then(function(result) { |
| 24 window.result = result; | 23 window.result = result; |
| 25 shouldBe('result', '12'); | 24 shouldBe('result', '12'); |
| 26 testPassed('DONE'); | 25 testPassed('DONE'); |
| 27 }, function() { | 26 }, function() { |
| 28 testFailed("rejected"); | 27 testFailed("rejected"); |
| 29 }).then(finishJSTest, finishJSTest); | 28 }).then(finishJSTest, finishJSTest); |
| 30 | 29 |
| 31 resolve(new Promise(function(resolve) { resolve(10); })); | 30 resolve(new Promise(function(resolve) { resolve(10); })); |
| 32 | 31 |
| 33 </script> | 32 </script> |
| 34 </body> | 33 </body> |
| 35 </html> | 34 </html> |
| OLD | NEW |