summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/js/Promise-simple.html
blob: dfd1f61280b4e4dcb52939c502d97da6584568ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
description('Test Promise.');

window.jsTestIsAsync = true;

var resolve;

var firstPromise = new Promise(function(newResolve) {
  window.thisInInit = this;
  resolve = newResolve;
});

var secondPromise = firstPromise.then(function(result) {
  window.thisInFulfillCallback = this;
  shouldBeFalse('thisInFulfillCallback === secondPromise');
  shouldBeTrue('thisInFulfillCallback === window');
  window.result = result;
  shouldBeEqualToString('result', 'hello');
  finishJSTest();
});

shouldBeFalse('thisInInit === firstPromise');
shouldBeTrue('thisInInit === window');

resolve('hello');

</script>
</body>
</html>