| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 var global = this.global || {}; | 28 var global = this.global || {}; |
| 29 var setTimeout; | 29 var setTimeout; |
| 30 var clearTimeout; | 30 var clearTimeout; |
| 31 | 31 |
| 32 (function() { | 32 (function() { |
| 33 var timers = {}; | 33 var timers = {}; |
| 34 var currentId = 0; | 34 var currentId = 0; |
| 35 | 35 |
| 36 function PostMicrotask(fn) { | 36 function PostMicrotask(fn) { |
| 37 var o = {}; | 37 Promise.resolve().then(fn); |
| 38 Object.observe(o, function() { | |
| 39 fn(); | |
| 40 }); | |
| 41 // Change something to enqueue a microtask. | |
| 42 o.x = 'hello'; | |
| 43 } | 38 } |
| 44 | 39 |
| 45 setInterval = function(fn, delay) { | 40 setInterval = function(fn, delay) { |
| 46 var i = 0; | 41 var i = 0; |
| 47 var id = currentId++; | 42 var id = currentId++; |
| 48 function loop() { | 43 function loop() { |
| 49 if (!timers[id]) { | 44 if (!timers[id]) { |
| 50 return; | 45 return; |
| 51 } | 46 } |
| 52 if (i++ >= delay) { | 47 if (i++ >= delay) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 67 | 62 |
| 68 setTimeout = function(fn, delay) { | 63 setTimeout = function(fn, delay) { |
| 69 var id = setInterval(function() { | 64 var id = setInterval(function() { |
| 70 fn(); | 65 fn(); |
| 71 clearInterval(id); | 66 clearInterval(id); |
| 72 }, delay); | 67 }, delay); |
| 73 return id; | 68 return id; |
| 74 } | 69 } |
| 75 | 70 |
| 76 }()); | 71 }()); |
| OLD | NEW |