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 29 matching lines...) Expand all Loading... | |
40 assertEquals("[object Promise]", | 40 assertEquals("[object Promise]", |
41 Object.prototype.toString.call(new Promise(function() {}))); | 41 Object.prototype.toString.call(new Promise(function() {}))); |
42 })(); | 42 })(); |
43 | 43 |
44 | 44 |
45 function clear(o) { | 45 function clear(o) { |
46 if (o === null || (typeof o !== 'object' && typeof o !== 'function')) return | 46 if (o === null || (typeof o !== 'object' && typeof o !== 'function')) return |
47 clear(o.__proto__) | 47 clear(o.__proto__) |
48 var properties = getOwnPropertyNames(o) | 48 var properties = getOwnPropertyNames(o) |
49 for (var i in properties) { | 49 for (var i in properties) { |
50 // Do not clobber Object.prototype.toString, which is used by tests. | |
51 if (properties[i] === "toString") continue; | |
50 clearProp(o, properties[i]) | 52 clearProp(o, properties[i]) |
51 } | 53 } |
52 } | 54 } |
53 | 55 |
54 function clearProp(o, name) { | 56 function clearProp(o, name) { |
55 var poisoned = {caller: 0, callee: 0, arguments: 0} | 57 var poisoned = {caller: 0, callee: 0, arguments: 0} |
56 try { | 58 try { |
57 var x = o[name] | 59 var x = o[name] |
58 o[name] = undefined | 60 o[name] = undefined |
59 clear(x) | 61 clear(x) |
(...skipping 988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1048 d6.resolve(6) | 1050 d6.resolve(6) |
1049 assertTrue(log === "dncncnx6", "subclass/chain") | 1051 assertTrue(log === "dncncnx6", "subclass/chain") |
1050 | 1052 |
1051 log = "" | 1053 log = "" |
1052 Promise.all([11, Promise.accept(12), 13, MyPromise.accept(14), 15, 16]) | 1054 Promise.all([11, Promise.accept(12), 13, MyPromise.accept(14), 15, 16]) |
1053 | 1055 |
1054 assertTrue(log === "nx14", "subclass/all/arg") | 1056 assertTrue(log === "nx14", "subclass/all/arg") |
1055 | 1057 |
1056 log = "" | 1058 log = "" |
1057 MyPromise.all([21, Promise.accept(22), 23, MyPromise.accept(24), 25, 26]) | 1059 MyPromise.all([21, Promise.accept(22), 23, MyPromise.accept(24), 25, 26]) |
1058 assertTrue(log === "nx24nnx21nnnnx23nnnx25nnx26n", "subclass/all/self") | 1060 assertTrue(log === "nx24nnx21nnx[object Promise]nnx23nnnx25nnx26n", |
caitp (gmail)
2015/12/22 17:34:06
This result matches the current behaviour of JavaS
| |
1061 "subclass/all/self") | |
1059 })(); | 1062 })(); |
1060 | 1063 |
1061 (function() { | 1064 (function() { |
1062 'use strict'; | 1065 'use strict'; |
1063 | 1066 |
1064 class Pact extends Promise { } | 1067 class Pact extends Promise { } |
1065 class Vow extends Pact { } | 1068 class Vow extends Pact { } |
1066 class Oath extends Vow { } | 1069 class Oath extends Vow { } |
1067 | 1070 |
1068 Oath.constructor = Vow; | 1071 Oath.constructor = Vow; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1110 var p = Promise.resolve(); | 1113 var p = Promise.resolve(); |
1111 var callCount = 0; | 1114 var callCount = 0; |
1112 defineProperty(p, "constructor", { | 1115 defineProperty(p, "constructor", { |
1113 get: function() { ++callCount; return Promise; } | 1116 get: function() { ++callCount; return Promise; } |
1114 }); | 1117 }); |
1115 p.then(); | 1118 p.then(); |
1116 assertEquals(1, callCount); | 1119 assertEquals(1, callCount); |
1117 })(); | 1120 })(); |
1118 | 1121 |
1119 assertAsyncDone() | 1122 assertAsyncDone() |
OLD | NEW |