Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1216)

Unified Diff: content/renderer/render_view_browsertest_mac.mm

Issue 2656433002: Adding tests for two recent regressions due to RenderViewImpl's Swapped Out State (Closed)
Patch Set: Rebased Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_view_browsertest_mac.mm
diff --git a/content/renderer/render_view_browsertest_mac.mm b/content/renderer/render_view_browsertest_mac.mm
index d82228055a3f169e07b69b1dcf20e18c525ed880..ae6eba0a207fe7104359fbf6e5ee582cc981212d 100644
--- a/content/renderer/render_view_browsertest_mac.mm
+++ b/content/renderer/render_view_browsertest_mac.mm
@@ -5,6 +5,10 @@
#include "base/strings/string16.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
+#include "content/common/frame_messages.h"
+#include "content/common/frame_replication_state.h"
+#include "content/common/input_messages.h"
+#include "content/common/text_input_client_messages.h"
#include "content/public/browser/native_web_keyboard_event.h"
#include "content/public/common/web_preferences.h"
#include "content/public/test/render_view_test.h"
@@ -18,6 +22,7 @@
#include <Cocoa/Cocoa.h>
using blink::WebFrameContentDumper;
+using blink::WebCompositionUnderline;
namespace content {
@@ -152,4 +157,48 @@ TEST_F(RenderViewTest, MacTestCmdUp) {
EXPECT_EQ(kArrowUpNoScroll, output);
}
+// TODO(ekaramad): This test could be removed once we do not send irrelevant
+// IPCs from browser during the time RenderViewImpl is swapped out
+// (https://crbug.com/669219).
+// This test verfies that when RenderViewImpl is swapped out, handling IPCs
+// which need a WebFrameWidget will not lead to a crash.
+TEST_F(RenderViewTest, HandleIPCsInSwappedOutState) {
+ LoadHTML("<input/>");
+
+ // Normally, we have a WebFrameWidget.
+ EXPECT_TRUE(GetWebWidget()->isWebFrameWidget());
+
+ // Swap out the main frame so that the frame widget is destroyed.
+ auto* view = static_cast<RenderViewImpl*>(view_);
+ auto* main_frame = view->GetMainRenderFrame();
+ main_frame->OnMessageReceived(FrameMsg_SwapOut(
+ main_frame->GetRoutingID(), 123, true, FrameReplicationState()));
+
+ // We no longer have a frame widget.
+ EXPECT_FALSE(GetWebWidget()->isWebFrameWidget());
+
+ int routing_id = view->GetRoutingID();
+ // Now simulate some TextInputClientMac IPCs. These will be handled by
+ // RenderWidget which forwards them to the TextInputClientObserver
+ using Range = gfx::Range;
+ using Point = gfx::Point;
+ view->OnMessageReceived(
+ TextInputClientMsg_CharacterIndexForPoint(routing_id, Point()));
+ view->OnMessageReceived(
+ TextInputClientMsg_FirstRectForCharacterRange(routing_id, Range()));
+ view->OnMessageReceived(
+ TextInputClientMsg_StringForRange(routing_id, Range()));
+ view->OnMessageReceived(
+ TextInputClientMsg_CharacterIndexForPoint(routing_id, Point()));
+
+ // Simulate some IME related IPCs.
+ using Text = base::string16;
+ using Underlines = std::vector<blink::WebCompositionUnderline>;
+ view->OnMessageReceived(InputMsg_ImeSetComposition(
+ routing_id, Text(), Underlines(), Range(), 0, 0));
+ view->OnMessageReceived(
+ InputMsg_ImeCommitText(routing_id, Text(), Underlines(), Range(), 0));
+ view->OnMessageReceived(InputMsg_ImeFinishComposingText(routing_id, false));
+}
+
} // namespace content
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698