| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 // Flags: --allow-natives-syntax --harmony-tostring | 28 // Flags: --allow-natives-syntax --harmony-tostring |
| 29 | 29 |
| 30 // Make sure we don't rely on functions patchable by monkeys. | 30 // Make sure we don't rely on functions patchable by monkeys. |
| 31 var call = Function.prototype.call.call.bind(Function.prototype.call) | 31 var call = Function.prototype.call.call.bind(Function.prototype.call) |
| 32 var observe = Object.observe; | |
| 33 var getOwnPropertyNames = Object.getOwnPropertyNames; | 32 var getOwnPropertyNames = Object.getOwnPropertyNames; |
| 34 var defineProperty = Object.defineProperty; | 33 var defineProperty = Object.defineProperty; |
| 35 var numberPrototype = Number.prototype; | 34 var numberPrototype = Number.prototype; |
| 36 var symbolIterator = Symbol.iterator; | 35 var symbolIterator = Symbol.iterator; |
| 37 | 36 |
| 38 | 37 |
| 39 (function() { | 38 (function() { |
| 40 // Test before clearing global (fails otherwise) | 39 // Test before clearing global (fails otherwise) |
| 41 assertEquals("[object Promise]", | 40 assertEquals("[object Promise]", |
| 42 Object.prototype.toString.call(new Promise(function() {}))); | 41 Object.prototype.toString.call(new Promise(function() {}))); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 function assertAsync(b, s) { | 79 function assertAsync(b, s) { |
| 81 if (b) { | 80 if (b) { |
| 82 print(s, "succeeded") | 81 print(s, "succeeded") |
| 83 } else { | 82 } else { |
| 84 %AbortJS(s + " FAILED!") // Simply throwing here will have no effect. | 83 %AbortJS(s + " FAILED!") // Simply throwing here will have no effect. |
| 85 } | 84 } |
| 86 --asyncAssertsExpected | 85 --asyncAssertsExpected |
| 87 } | 86 } |
| 88 | 87 |
| 89 function assertAsyncDone(iteration) { | 88 function assertAsyncDone(iteration) { |
| 90 var iteration = iteration || 0 | 89 var iteration = iteration || 0; |
| 91 var dummy = {} | 90 %EnqueueMicrotask(function() { |
| 92 observe(dummy, | 91 if (asyncAssertsExpected === 0) |
| 93 function() { | 92 assertAsync(true, "all") |
| 94 if (asyncAssertsExpected === 0) | 93 else if (iteration > 10) // Shouldn't take more. |
| 95 assertAsync(true, "all") | 94 assertAsync(false, "all") |
| 96 else if (iteration > 10) // Shouldn't take more. | 95 else |
| 97 assertAsync(false, "all") | 96 assertAsyncDone(iteration + 1) |
| 98 else | 97 }); |
| 99 assertAsyncDone(iteration + 1) | |
| 100 } | |
| 101 ) | |
| 102 dummy.dummy = dummy | |
| 103 } | 98 } |
| 104 | 99 |
| 105 | 100 |
| 106 (function() { | 101 (function() { |
| 107 assertThrows(function() { Promise(function() {}) }, TypeError) | 102 assertThrows(function() { Promise(function() {}) }, TypeError) |
| 108 })(); | 103 })(); |
| 109 | 104 |
| 110 (function() { | 105 (function() { |
| 111 assertTrue(new Promise(function() {}) instanceof Promise) | 106 assertTrue(new Promise(function() {}) instanceof Promise) |
| 112 })(); | 107 })(); |
| (...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1028 Promise.all([11, Promise.accept(12), 13, MyPromise.accept(14), 15, 16]) | 1023 Promise.all([11, Promise.accept(12), 13, MyPromise.accept(14), 15, 16]) |
| 1029 assertTrue(log === "nx14n", "subclass/all/arg") | 1024 assertTrue(log === "nx14n", "subclass/all/arg") |
| 1030 | 1025 |
| 1031 log = "" | 1026 log = "" |
| 1032 MyPromise.all([21, Promise.accept(22), 23, MyPromise.accept(24), 25, 26]) | 1027 MyPromise.all([21, Promise.accept(22), 23, MyPromise.accept(24), 25, 26]) |
| 1033 assertTrue(log === "nx24nnx21nnx23nnnx25nnx26n", "subclass/all/self") | 1028 assertTrue(log === "nx24nnx21nnx23nnnx25nnx26n", "subclass/all/self") |
| 1034 })(); | 1029 })(); |
| 1035 | 1030 |
| 1036 | 1031 |
| 1037 assertAsyncDone() | 1032 assertAsyncDone() |
| OLD | NEW |