Add integration tests for interacting with promises from native code.

This commit is contained in:
Josh Matthews 2016-08-12 12:46:26 -04:00
parent ab168204ed
commit f89355b85d
5 changed files with 98 additions and 5 deletions

View file

@ -7176,6 +7176,12 @@
"url": "/_mozilla/mozilla/preserve_wrapper_callback.html"
}
],
"mozilla/promise.html": [
{
"path": "mozilla/promise.html",
"url": "/_mozilla/mozilla/promise.html"
}
],
"mozilla/prototypes.html": [
{
"path": "mozilla/prototypes.html",

View file

@ -0,0 +1,3 @@
[promise.html]
type: testharness
prefs: [dom.testbinding.enabled:true]

View file

@ -0,0 +1,40 @@
<!doctype html>
<meta charset=utf-8>
<title></title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script>
promise_test(function() {
var t = new TestBinding;
return t.returnResolvedPromise('success')
.then(function(s) {
assert_equals(s, 'success');
});
}, 'Resolve callback gets argument');
promise_test(function(test) {
var t = new TestBinding;
return t.returnRejectedPromise('success')
.then(test.unreached_func())
.catch(function(s) {
assert_equals(s, 'success');
});
}, 'Reject callback gets argument');
promise_test(function(test) {
var t = new TestBinding;
var p = t.promiseNativeHandler(function(v) {
assert_equals(v, 'success');
}, null);
return Promise.resolve('success').then(p);
}, 'Native resolve callback gets argument');
promise_test(function(test) {
var t = new TestBinding;
var p = t.promiseNativeHandler(null, function(v) {
assert_equals(v, 'success');
});
p.then(test.unreached_func());
return Promise.resolve('success').then(p);
}, 'Native resolve callback gets argument');
</script>