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

Unified Diff: ui/login/resource_loader.js

Issue 2028113002: Fix loadAssetsOnIdle not loading when document.readyState is 'interactive'. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/login/resource_loader.js
diff --git a/ui/login/resource_loader.js b/ui/login/resource_loader.js
index 4eb6cf302b040518ebc43c1569c072ed08f5bce3..56a68353cf9dbf8aefbcdcaf98813a207ca0817a 100644
--- a/ui/login/resource_loader.js
+++ b/ui/login/resource_loader.js
@@ -195,16 +195,18 @@ cr.define('cr.ui.login.ResourceLoader', function() {
function loadAssetsOnIdle(id, callback, opt_idleTimeoutMs) {
opt_idleTimeoutMs = opt_idleTimeoutMs || 250;
- let loadOnIdle = function() {
+ var loadOnIdle = function() {
window.requestIdleCallback(function() {
loadAssets(id, callback);
}, { timeout: opt_idleTimeoutMs });
};
- if (document.readyState == 'complete') {
- loadOnIdle();
- } else {
+ if (document.readyState == 'loading') {
window.addEventListener('DOMContentLoaded', loadOnIdle);
+ } else {
+ // DOMContentLoaded has already been called if document.readyState is
+ // 'interactive' or 'complete', so invoke the callback immediately.
+ loadOnIdle();
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698