Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / js / resources / Promise-reject-in-workers.js
blob95f08a67db494a1e0a3a891afa49cba1920b8049
1 importScripts('../../../resources/js-test.js');
3 description('Test Promise.');
5 jsTestIsAsync = true;
7 var reject;
8 var promise = new Promise(function(_, r) { reject = r; });
9 var promiseState = 'pending';
10 var promiseResult = undefined;
11 promise.then(function(result) {
12   promiseState = 'fulfilled';
13   promiseResult = result;
14 }, function(result) {
15   promiseState = 'rejected';
16   promiseResult = result;
17 });
19 shouldBeEqualToString('promiseState', 'pending');
21 reject('hello');
23 shouldBeEqualToString('promiseState', 'pending');
25 promise.then(function() {
26   testFailed('promise is fulfilled.');
27   finishJSTest();
28 }, function() {
29   shouldBeEqualToString('promiseState', 'rejected');
30   shouldBeEqualToString('promiseResult', 'hello');
31   finishJSTest();
32 });