Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / js / resources / Promise-resolve-state-in-workers.js
blob45d74068b20a944b13882b864204fa4e8b16c14e
1 importScripts('../../../resources/js-test.js');
3 description('Test Promise.');
5 jsTestIsAsync = true;
7 var resolve;
8 var promise = new Promise(function(r) { resolve = 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 resolve('hello');
23 shouldBeEqualToString('promiseState', 'pending');
25 promise.then(function() {
26 shouldBeEqualToString('promiseState', 'fulfilled');
27 shouldBeEqualToString('promiseResult', 'hello');
28 finishJSTest();
29 }, function() {
30 testFailed('promise is rejected.');
31 finishJSTest();
32 });