New issue
Advanced search Search tips

Issue 614805 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Dec 2016
Cc:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 2
Type: Bug



Sign in to add a comment

Browser tests inherited from chromeos::LoginManagerTest are flaky and produce JS errors

Project Member Reported by emaxx@chromium.org, May 25 2016

Issue description

Chrome OS tests inherited from LoginManagerTest produce pretty often JavaScript errors like these:
* [ERROR:CONSOLE(1)] "Uncaught ReferenceError: cr is not defined", source:  (1)
* [ERROR:CONSOLE(1)] "Uncaught TypeError: Cannot read property 'reloadContent' of undefined", source:  (1)

Examples of test classes that produce these errors (unreliably): LoginUITest, LoginStateNotificationBlockerChromeOSBrowserTest, LoginTest, LoginSigninTest.


Some of these tests are also flaky (however, not sure whether for the same reason).
 

Comment 1 by emaxx@chromium.org, May 25 2016

Status: Started (was: Assigned)
Debugging showed that some (or all) of these JS errors come as a result of calling CoreOobeHandler::ReloadContent.

Probably this method is called too early. I'm investigating the possible causes.

Comment 2 by emaxx@chromium.org, May 25 2016

I may be wrong, but I think the problem is that LoginDisplayHostImpl::StartWizard calls LoadURL(GURL(kOobeURL)) and, without any waiting for the completion, WizardController::Init.

This assumption was based on the fact that JS error occurred in the result of the following chain of calls:

LoginDisplayHostImpl::StartWizard -> WizardController::Init -> WizardController::AdvanceToScreen -> [async] WizardController::OnHIDScreenNecessityCheck -> WizardController::ShowNetworkScreen -> NetworkScreen::Initialize -> NetworkScreen::ScheduleResolveLanguageList -> [async] NetworkScreenHandler::ReloadLocalizedContent -> CoreOobeHandler::ReloadContent


Xiyuan, WDYT?

Comment 3 by xiy...@chromium.org, May 26 2016

Thanks for digging into this. The analysis looks correct to me.

Essentially, we should wait until one of the cr.ui.Oobe.initiliaze [1] is called. It should do chrome.send('screenStateInitialize') at the end and CoreOobeHandler::HandleInitialized gets that. We should defer all JS calls until this has happened.


[1]: There are three of those: oobe.js, login.js and lock.js. e.g.
https://code.google.com/p/chromium/codesearch#chromium/src/chrome/browser/resources/chromeos/login/oobe.js&l=69
Project Member

Comment 4 by bugdroid1@chromium.org, Jun 7 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/e873b56e4b1cec5bdb3ccf6e8b7ccd5e97d94c37

commit e873b56e4b1cec5bdb3ccf6e8b7ccd5e97d94c37
Author: emaxx <emaxx@chromium.org>
Date: Tue Jun 07 18:13:51 2016

Postpone JS calls from CoreOobeHandler until the JS side gets initialized

This fixes a race between loading JavaScript code and calling methods from it.

The race was caused by CoreOobeHandler class whose methods (like ReloadContent)
called JavaScript methods directly, while there was a possibility that JavaScript
files defining them were not loaded yet.
This was observed, for example, when running tests inherited from
LoginManagerTest, as the form of the following errors printed into console:
* [ERROR:CONSOLE(1)] "Uncaught ReferenceError: cr is not defined", source:  (1)
* [ERROR:CONSOLE(1)] "Uncaught TypeError: Cannot read property 'reloadContent'
  of undefined", source:  (1)

This CL adds a new condition that doesn't allow to call JS methods until
'screenStateInitialize' message is received from JS side. Any attempts to call
JS method too early are deferred and executed when the 'screenStateInitialize'
is finally received.

BUG= 614805 
TEST=manual: run login-related tests and check that no JavaScript errors appear in the console.

Review-Url: https://codereview.chromium.org/2042283002
Cr-Commit-Position: refs/heads/master@{#398342}

[modify] https://crrev.com/e873b56e4b1cec5bdb3ccf6e8b7ccd5e97d94c37/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc
[modify] https://crrev.com/e873b56e4b1cec5bdb3ccf6e8b7ccd5e97d94c37/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h

Comment 5 by emaxx@chromium.org, Dec 2 2016

Status: Fixed (was: Started)

Sign in to add a comment