Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Side by Side Diff: test/mjsunit/es6/promises.js

Issue 1370583002: Don’t smash globals used by the test helper itself. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « AUTHORS ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 var poisoned = {caller: 0, callee: 0, arguments: 0} 55 var poisoned = {caller: 0, callee: 0, arguments: 0}
56 try { 56 try {
57 var x = o[name] 57 var x = o[name]
58 o[name] = undefined 58 o[name] = undefined
59 clear(x) 59 clear(x)
60 } catch(e) {} // assertTrue(name in poisoned) } 60 } catch(e) {} // assertTrue(name in poisoned) }
61 } 61 }
62 62
63 // Find intrinsics and null them out. 63 // Find intrinsics and null them out.
64 var globals = Object.getOwnPropertyNames(this) 64 var globals = Object.getOwnPropertyNames(this)
65 var whitelist = {Promise: true, TypeError: true} 65 var whitelist = {
66 Promise: true,
67 TypeError: true,
68 String: true,
69 JSON: true,
70 Error: true,
71 MjsUnitAssertionError: true
72 };
73
66 for (var i in globals) { 74 for (var i in globals) {
67 var name = globals[i] 75 var name = globals[i]
68 if (name in whitelist || name[0] === name[0].toLowerCase()) delete globals[i] 76 if (name in whitelist || name[0] === name[0].toLowerCase()) delete globals[i]
69 } 77 }
70 for (var i in globals) { 78 for (var i in globals) {
71 if (globals[i]) clearProp(this, globals[i]) 79 if (globals[i]) clearProp(this, globals[i])
72 } 80 }
73 81
74 82
75 var asyncAssertsExpected = 0; 83 var asyncAssertsExpected = 0;
(...skipping 14 matching lines...) Expand all
90 %EnqueueMicrotask(function() { 98 %EnqueueMicrotask(function() {
91 if (asyncAssertsExpected === 0) 99 if (asyncAssertsExpected === 0)
92 assertAsync(true, "all") 100 assertAsync(true, "all")
93 else if (iteration > 10) // Shouldn't take more. 101 else if (iteration > 10) // Shouldn't take more.
94 assertAsync(false, "all") 102 assertAsync(false, "all")
95 else 103 else
96 assertAsyncDone(iteration + 1) 104 assertAsyncDone(iteration + 1)
97 }); 105 });
98 } 106 }
99 107
100
101 (function() { 108 (function() {
102 assertThrows(function() { Promise(function() {}) }, TypeError) 109 assertThrows(function() { Promise(function() {}) }, TypeError)
103 })(); 110 })();
104 111
105 (function() { 112 (function() {
106 assertTrue(new Promise(function() {}) instanceof Promise) 113 assertTrue(new Promise(function() {}) instanceof Promise)
107 })(); 114 })();
108 115
109 (function() { 116 (function() {
110 assertThrows(function() { new Promise(5) }, TypeError) 117 assertThrows(function() { new Promise(5) }, TypeError)
(...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after
1023 Promise.all([11, Promise.accept(12), 13, MyPromise.accept(14), 15, 16]) 1030 Promise.all([11, Promise.accept(12), 13, MyPromise.accept(14), 15, 16])
1024 assertTrue(log === "nx14n", "subclass/all/arg") 1031 assertTrue(log === "nx14n", "subclass/all/arg")
1025 1032
1026 log = "" 1033 log = ""
1027 MyPromise.all([21, Promise.accept(22), 23, MyPromise.accept(24), 25, 26]) 1034 MyPromise.all([21, Promise.accept(22), 23, MyPromise.accept(24), 25, 26])
1028 assertTrue(log === "nx24nnx21nnx23nnnx25nnx26n", "subclass/all/self") 1035 assertTrue(log === "nx24nnx21nnx23nnnx25nnx26n", "subclass/all/self")
1029 })(); 1036 })();
1030 1037
1031 1038
1032 assertAsyncDone() 1039 assertAsyncDone()
OLDNEW
« no previous file with comments | « AUTHORS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698