chromium/chrome/browser/trusted_vault/trusted_vault_encryption_keys_tab_helper_unittest.cc

// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/trusted_vault/trusted_vault_encryption_keys_tab_helper.h"

#include "base/memory/scoped_refptr.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/signin/chrome_signin_client_factory.h"
#include "chrome/browser/signin/test_signin_client_builder.h"
#include "chrome/browser/trusted_vault/trusted_vault_service_factory.h"
#include "chrome/common/trusted_vault_encryption_keys_extension.mojom.h"
#include "chrome/test/base/chrome_render_view_host_test_harness.h"
#include "components/site_isolation/features.h"
#include "content/public/browser/child_process_security_policy.h"
#include "content/public/browser/site_isolation_policy.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/test/navigation_simulator.h"
#include "content/public/test/prerender_test_util.h"
#include "content/public/test/test_renderer_host.h"
#include "content/public/test/web_contents_tester.h"
#include "google_apis/gaia/gaia_urls.h"
#include "net/base/net_errors.h"
#include "net/http/http_response_headers.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/features.h"

namespace {

class TrustedVaultEncryptionKeysTabHelperTest
    : public ChromeRenderViewHostTestHarness {};

TEST_F(TrustedVaultEncryptionKeysTabHelperTest,
       ShouldExposeMojoApiToAllowedOrigin) {}

TEST_F(TrustedVaultEncryptionKeysTabHelperTest,
       ShouldNotExposeMojoApiToUnallowedOrigin) {}

// TODO(crbug.com/40881433): flaky on android bots.
TEST_F(TrustedVaultEncryptionKeysTabHelperTest,
       DISABLED_ShouldNotExposeMojoApiIfNavigatedAway) {}

TEST_F(TrustedVaultEncryptionKeysTabHelperTest,
       ShouldExposeMojoApiEvenIfSubframeNavigatedAway) {}

TEST_F(TrustedVaultEncryptionKeysTabHelperTest,
       ShouldNotExposeMojoApiIfNavigationFailed) {}

// TODO(crbug.com/40881433): flaky on android bots.
TEST_F(TrustedVaultEncryptionKeysTabHelperTest,
       DISABLED_ShouldNotExposeMojoApiIfNavigatedAwayToErrorPage) {}

class TrustedVaultEncryptionKeysTabHelperPrerenderingTest
    : public TrustedVaultEncryptionKeysTabHelperTest {};

// Tests that EncryptionKeys works based on a main frame. A prerendered page
// also creates EncryptionKeys as it's a main frame. But, if EncryptionKeys
// is accessed thrugh Mojo in prerendering, it causes canceling prerendering.
// See the browser test, 'ShouldNotBindEncryptionKeysApiInPrerendering', from
// 'trusted_vault_keys_tab_helper_browsertest.cc' for the details about
// canceling prerendering.
TEST_F(TrustedVaultEncryptionKeysTabHelperPrerenderingTest,
       CreateEncryptionKeysInPrerendering) {}
}  // namespace