Commit dd2ed94f authored by Tatsuhisa Yamaguchi's avatar Tatsuhisa Yamaguchi Committed by Commit Bot

Avoid runtime error when window.reload is not available.

appWindow object doesn't have reload() method ready until the window is
loaded. This is a quick fix to avoid crashing the background script by
user operation.

Test: manually verified as noted in the bug
Bug: 789226
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: Ie2266792d8ca62bd0bae74ff2824b72221acbdb7
Reviewed-on: https://chromium-review.googlesource.com/800910Reviewed-by: default avatarYoshiki Iguchi <yoshiki@chromium.org>
Commit-Queue: Tatsuhisa Yamaguchi <yamaguchi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#522000}
parent 43a94cb5
...@@ -296,7 +296,15 @@ SingletonAppWindowWrapper.prototype.launch = ...@@ -296,7 +296,15 @@ SingletonAppWindowWrapper.prototype.launch =
this.queue.run(function(nextStep) { this.queue.run(function(nextStep) {
this.window_.contentWindow.appState = appState; this.window_.contentWindow.appState = appState;
this.window_.contentWindow.appReopen = reopen; this.window_.contentWindow.appReopen = reopen;
if (!this.window_.contentWindow.reload) {
// Currently the queue is not made to wait for window loading after
// creating window. Therefore contentWindow might not have the reload()
// function ready yet. This happens when launching the same app twice
// quickly. See crbug.com/789226.
console.error('Window reload requested before loaded. Skiping.');
} else {
this.window_.contentWindow.reload(); this.window_.contentWindow.reload();
}
if (opt_callback) if (opt_callback)
opt_callback(); opt_callback();
nextStep(); nextStep();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment