blob: 108481a117fb131f33c52abeb0c2d4fdca25ce9c [file] [log] [blame]
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_SHELL_TEST_RUNNER_WEB_FRAME_TEST_PROXY_H_
#define CONTENT_SHELL_TEST_RUNNER_WEB_FRAME_TEST_PROXY_H_
#include <memory>
#include <string>
#include <utility>
#include "base/macros.h"
#include "content/renderer/render_frame_impl.h"
#include "content/shell/test_runner/test_runner_export.h"
#include "content/shell/test_runner/web_frame_test_client.h"
#include "third_party/blink/public/platform/web_effective_connection_type.h"
#include "third_party/blink/public/platform/web_string.h"
#include "third_party/blink/public/web/web_local_frame.h"
#include "third_party/blink/public/web/web_local_frame_client.h"
namespace content {
class RenderViewImpl;
} // namespace content
namespace test_runner {
class WebTestInterfaces;
// WebFrameTestProxy is used during running web tests instead of a
// RenderFrameImpl to inject test-only behaviour by overriding methods in the
// base class.
class TEST_RUNNER_EXPORT WebFrameTestProxy : public content::RenderFrameImpl {
public:
template <typename... Args>
explicit WebFrameTestProxy(Args&&... args)
: RenderFrameImpl(std::forward<Args>(args)...) {}
~WebFrameTestProxy() override;
void Initialize(WebTestInterfaces* interfaces,
content::RenderViewImpl* render_view_for_frame);
// RenderFrameImpl overrides.
void UpdateAllLifecyclePhasesAndCompositeForTesting() override;
// WebLocalFrameClient implementation.
blink::WebPlugin* CreatePlugin(const blink::WebPluginParams& params) override;
void DidAddMessageToConsole(const blink::WebConsoleMessage& message,
const blink::WebString& source_name,
unsigned source_line,
const blink::WebString& stack_trace) override;
void DownloadURL(const blink::WebURLRequest& request,
network::mojom::RedirectMode cross_origin_redirect_behavior,
mojo::ScopedMessagePipeHandle blob_url_token) override;
void DidReceiveTitle(const blink::WebString& title,
blink::WebTextDirection direction) override;
void DidChangeIcon(blink::WebIconURL::Type icon_type) override;
void DidFailLoad(const blink::WebURLError& error,
blink::WebHistoryCommitType commit_type) override;
void DidStartLoading() override;
void DidStopLoading() override;
void DidChangeSelection(bool is_selection_empty) override;
void DidChangeContents() override;
blink::WebEffectiveConnectionType GetEffectiveConnectionType() override;
void RunModalAlertDialog(const blink::WebString& message) override;
bool RunModalConfirmDialog(const blink::WebString& message) override;
bool RunModalPromptDialog(const blink::WebString& message,
const blink::WebString& default_value,
blink::WebString* actual_value) override;
bool RunModalBeforeUnloadDialog(bool is_reload) override;
void ShowContextMenu(
const blink::WebContextMenuData& context_menu_data) override;
void DidDispatchPingLoader(const blink::WebURL& url) override;
void WillSendRequest(blink::WebURLRequest& request) override;
void BeginNavigation(std::unique_ptr<blink::WebNavigationInfo> info) override;
void PostAccessibilityEvent(const blink::WebAXObject& object,
ax::mojom::Event event,
ax::mojom::EventFrom event_from) override;
void MarkWebAXObjectDirty(const blink::WebAXObject& object,
bool subtree) override;
void CheckIfAudioSinkExistsAndIsAuthorized(
const blink::WebString& sink_id,
blink::WebSetSinkIdCompleteCallback completion_callback) override;
void DidClearWindowObject() override;
private:
std::unique_ptr<WebFrameTestClient> test_client_;
DISALLOW_COPY_AND_ASSIGN(WebFrameTestProxy);
};
} // namespace test_runner
#endif // CONTENT_SHELL_TEST_RUNNER_WEB_FRAME_TEST_PROXY_H_