Chromium Code Reviews| Index: third_party/WebKit/Source/devtools/front_end/Runtime.js |
| diff --git a/third_party/WebKit/Source/devtools/front_end/Runtime.js b/third_party/WebKit/Source/devtools/front_end/Runtime.js |
| index 2f0b1ee9713e90beb692924aa62af7a8b27d0b35..75ee3f325d4730888304a25432fff7b067de8eac 100644 |
| --- a/third_party/WebKit/Source/devtools/front_end/Runtime.js |
| +++ b/third_party/WebKit/Source/devtools/front_end/Runtime.js |
| @@ -116,6 +116,7 @@ function loadScriptsPromise(scriptNames, base) |
| var promises = []; |
| /** @type {!Array<string>} */ |
| var urls = []; |
| + var pauseSourceEvaluation = false; |
| var sources = new Array(scriptNames.length); |
| var scriptToEval = 0; |
| for (var i = 0; i < scriptNames.length; ++i) { |
| @@ -142,16 +143,32 @@ function loadScriptsPromise(scriptNames, base) |
| function scriptSourceLoaded(scriptNumber, scriptSource) |
| { |
| sources[scriptNumber] = scriptSource || ""; |
| + evaluateLoadedSources(); |
| + } |
| + |
| + function evaluateLoadedSources() |
| + { |
| // Eval scripts as fast as possible. |
|
pfeldman
2016/07/07 04:13:34
optional: We could sacrifice this optimization for
lushnikov
2016/07/07 21:26:22
Done.
|
| - while (typeof sources[scriptToEval] !== "undefined") { |
| - evaluateScript(urls[scriptToEval], sources[scriptToEval]); |
| + while (!pauseSourceEvaluation && typeof sources[scriptToEval] !== "undefined") { |
| + var asyncEvalPromise = evaluateScript(urls[scriptToEval], sources[scriptToEval]); |
| ++scriptToEval; |
| + if (asyncEvalPromise) { |
| + pauseSourceEvaluation = true; |
| + asyncEvalPromise.then(onAsyncEvalCompleted); |
| + } |
| } |
| } |
| + function onAsyncEvalCompleted() |
| + { |
| + pauseSourceEvaluation = false; |
| + evaluateLoadedSources(); |
| + } |
| + |
| /** |
| * @param {string} sourceURL |
| * @param {string=} scriptSource |
| + * @return {?Promise} |
| */ |
| function evaluateScript(sourceURL, scriptSource) |
| { |
| @@ -159,9 +176,11 @@ function loadScriptsPromise(scriptNames, base) |
| if (!scriptSource) { |
| // Do not reject, as this is normal in the hosted mode. |
| console.error("Empty response arrived for script '" + sourceURL + "'"); |
| - return; |
| + return null; |
| } |
| + self.runtime.onAsyncEvalCompletion = null; |
|
pfeldman
2016/07/07 04:13:34
nuke
lushnikov
2016/07/07 21:26:22
Done.
|
| self.eval(scriptSource + "\n//# sourceURL=" + sourceURL); |
|
pfeldman
2016/07/07 04:13:34
var promise = self.eval(scriptSource + "\n//# sour
lushnikov
2016/07/07 21:26:22
Done.
|
| + return self.runtime.onAsyncEvalCompletion; |
| } |
| } |