Index: third_party/WebKit/Source/devtools/front_end/platform/utilities.js |
diff --git a/third_party/WebKit/Source/devtools/front_end/platform/utilities.js b/third_party/WebKit/Source/devtools/front_end/platform/utilities.js |
index 1edf9b970a48ff10343a6efb4712211a02eae093..73f1da98a56343803e2963659a181f2b22732206 100644 |
--- a/third_party/WebKit/Source/devtools/front_end/platform/utilities.js |
+++ b/third_party/WebKit/Source/devtools/front_end/platform/utilities.js |
@@ -1440,3 +1440,23 @@ Map.prototype.diff = function(other, isEqual) { |
} |
return {added: added, removed: removed, equal: equal}; |
}; |
+ |
+/** |
+ * TODO: move into its own module |
+ * @param {function()} callback |
+ * @suppressGlobalPropertiesCheck |
+ */ |
+function runOnWindowLoad(callback) { |
+ /** |
+ * @suppressGlobalPropertiesCheck |
+ */ |
+ function windowLoaded() { |
+ self.removeEventListener('DOMContentLoaded', windowLoaded, false); |
+ callback(); |
+ } |
+ |
+ if (document.readyState === 'complete' || document.readyState === 'interactive') |
+ callback(); |
+ else |
+ self.addEventListener('DOMContentLoaded', windowLoaded, false); |
+} |