OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007 Apple Inc. All rights reserved. |
3 * Copyright (C) 2012 Google Inc. All rights reserved. | 3 * Copyright (C) 2012 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * | 8 * |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 1417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1428 | 1428 |
1429 /** | 1429 /** |
1430 * @param {function()} callback | 1430 * @param {function()} callback |
1431 * @return {number} | 1431 * @return {number} |
1432 */ | 1432 */ |
1433 self.setImmediate = function(callback) | 1433 self.setImmediate = function(callback) |
1434 { | 1434 { |
1435 Promise.resolve().then(callback).done(); | 1435 Promise.resolve().then(callback).done(); |
1436 return 0; | 1436 return 0; |
1437 } | 1437 } |
| 1438 |
| 1439 /** |
| 1440 * @param {!function()} callback |
| 1441 * @suppressGlobalPropertiesCheck |
| 1442 */ |
| 1443 function runOnWindowLoad(callback) |
| 1444 { |
| 1445 /** |
| 1446 * @suppressGlobalPropertiesCheck |
| 1447 */ |
| 1448 function windowLoaded() |
| 1449 { |
| 1450 window.removeEventListener("DOMContentLoaded", windowLoaded, false); |
| 1451 callback(); |
| 1452 } |
| 1453 |
| 1454 if (document.readyState === "complete") |
| 1455 callback(); |
| 1456 else |
| 1457 window.addEventListener("DOMContentLoaded", windowLoaded, false); |
| 1458 } |
OLD | NEW |