New issue
Advanced search Search tips

Issue 707819 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Apr 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: iOS
Pri: 3
Type: Bug

Blocked on:
issue 707820



Sign in to add a comment

Transient item can only be added for pending non-app-specific loads.

Project Member Reported by liaoyuke@chromium.org, Apr 3 2017

Issue description

This should be a valid assumption in |AddTransientItem| in NavigationManagerImpl, but for now, we cannot add a DCHECK for it because some tests are trying to add a transient item without first adding a pending item, such as: https://cs.chromium.org/chromium/src/ios/chrome/browser/ssl/ios_ssl_error_handler_unittest.mm?type=cs&q=IOSSSLErrorHandlerTest+package:%5Echromium$&l=51

btw, we cannot modify the test to add pending item because it has no access to NavigationManagerImpl.

it makes more sense to convert those tests to eg tests once the https server is implemented, and then the DCHECK can be added in |AddTransientItem|. 
 
Blockedon: 707820
EG tests are end-to-end integration tests that test app via user interface. They are not a replacement for unit tests, so I don't think we should convert IOSSSLErrorHandlerTest.NonOverridable to EG.
IOSSSLErrorHandlerTest.NonOverridable is loading a URL and verifying that an interstitial page is showing, which sounds like an end-to-end integration test to me. But I think what you said makes sense: we should try refactoring IOSSSLErrorHandlerTest.NonOverridable first.
IOSSSLErrorHandler::HandleSSLError takes WebState. Test can pass TestWebState instead of a real web state. TestWebState allows using TestNavigationManager and we can change TestNavigationManager to allow adding pending and transient items. 
void WebStateImpl::ShowWebInterstitial(WebInterstitialImpl* interstitial) {
  DCHECK(Configured());
  DCHECK(interstitial);
  interstitial_ = interstitial;
  ShowTransientContentView(interstitial_->GetContentView());
}

it seems that this test requires a WebStateImpl, and if we use TestWebState, following line will be executed: return static_cast<web::WebStateImpl*>(web_state());

It doesn't feel right to me to cast a WebState to WebStateImpl, but I'm not sure what's the best solution for this situation.
Casting WebState to WebStateImpl violates Liskov Substitution Principle, which is bad, but that's unfortunately the code we have.

One way to fix the problem would be:
1.) Fix crbug.com/570699
2.) Start and Stop the load in the test

Another fix could be:
1.) Add WebTestWithWebState::AddPendingItem
2.) Use WebTestWithWebState::AddPendingItem in the test

I think adding WebTestWithWebState::AddPendingItem is just fine for a fix.
Thank you very much for thinking about this! AddPendingItem sounds like a reasonable fix given all the options we have.
+1 to Eugene's suggestion of adding API to WebTestWithWebState
Status: Fixed (was: Assigned)
Status: Started (was: Fixed)
Status: Fixed (was: Started)

Sign in to add a comment