| <!DOCTYPE html> |
| <html> |
| <head> |
| <script src="../../resources/js-test-pre.js"></script> |
| </head> |
| <body> |
| <div id="description"></div> |
| <div id="console"></div> |
| <script> |
| description('Test Promise.'); |
| |
| window.jsTestIsAsync = true; |
| |
| var firstPromise = new Promise(function(resolve) { |
| window.thisInInit = this; |
| resolve('hello'); |
| }); |
| |
| var secondPromise = firstPromise.then(function(result) { |
| throw 'foobar'; |
| }); |
| |
| var thirdPromise = secondPromise.then(function(result) { |
| fail('Unexpected invocation of fulfillCallback'); |
| }, function(result) { |
| window.thisInThenCallback = this; |
| shouldBeFalse('thisInThenCallback === thirdPromise'); |
| shouldBeTrue('thisInThenCallback === window'); |
| window.result = result; |
| shouldBeEqualToString('result', 'foobar'); |
| finishJSTest(); |
| }); |
| |
| </script> |
| <script src="../../resources/js-test-post.js"></script> |
| </body> |
| </html> |