| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/memory/shared_memory.h" | 8 #include "base/memory/shared_memory.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "content/public/common/url_constants.h" | 24 #include "content/public/common/url_constants.h" |
| 25 #include "content/public/common/url_utils.h" | 25 #include "content/public/common/url_utils.h" |
| 26 #include "content/public/renderer/content_renderer_client.h" | 26 #include "content/public/renderer/content_renderer_client.h" |
| 27 #include "content/public/renderer/document_state.h" | 27 #include "content/public/renderer/document_state.h" |
| 28 #include "content/public/renderer/navigation_state.h" | 28 #include "content/public/renderer/navigation_state.h" |
| 29 #include "content/public/test/browser_test_utils.h" | 29 #include "content/public/test/browser_test_utils.h" |
| 30 #include "content/public/test/frame_load_waiter.h" | 30 #include "content/public/test/frame_load_waiter.h" |
| 31 #include "content/public/test/render_view_test.h" | 31 #include "content/public/test/render_view_test.h" |
| 32 #include "content/public/test/test_utils.h" | 32 #include "content/public/test/test_utils.h" |
| 33 #include "content/renderer/accessibility/renderer_accessibility.h" | 33 #include "content/renderer/accessibility/renderer_accessibility.h" |
| 34 #include "content/renderer/devtools/devtools_agent.h" |
| 34 #include "content/renderer/history_controller.h" | 35 #include "content/renderer/history_controller.h" |
| 35 #include "content/renderer/history_serialization.h" | 36 #include "content/renderer/history_serialization.h" |
| 36 #include "content/renderer/navigation_state_impl.h" | 37 #include "content/renderer/navigation_state_impl.h" |
| 37 #include "content/renderer/render_process.h" | 38 #include "content/renderer/render_process.h" |
| 38 #include "content/renderer/render_view_impl.h" | 39 #include "content/renderer/render_view_impl.h" |
| 39 #include "content/shell/browser/shell.h" | 40 #include "content/shell/browser/shell.h" |
| 40 #include "content/shell/browser/shell_browser_context.h" | 41 #include "content/shell/browser/shell_browser_context.h" |
| 41 #include "content/test/mock_keyboard.h" | 42 #include "content/test/mock_keyboard.h" |
| 42 #include "net/base/net_errors.h" | 43 #include "net/base/net_errors.h" |
| 43 #include "net/cert/cert_status_flags.h" | 44 #include "net/cert/cert_status_flags.h" |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 } | 282 } |
| 282 | 283 |
| 283 void SetZoomLevel(double level) { | 284 void SetZoomLevel(double level) { |
| 284 view()->OnSetZoomLevelForView(false, level); | 285 view()->OnSetZoomLevelForView(false, level); |
| 285 } | 286 } |
| 286 | 287 |
| 287 private: | 288 private: |
| 288 scoped_ptr<MockKeyboard> mock_keyboard_; | 289 scoped_ptr<MockKeyboard> mock_keyboard_; |
| 289 }; | 290 }; |
| 290 | 291 |
| 292 class DevToolsAgentTest : public RenderViewImplTest { |
| 293 public: |
| 294 void Attach() { |
| 295 std::string host_id = "host_id"; |
| 296 agent()->OnAttach(host_id); |
| 297 } |
| 298 |
| 299 void Detach() { |
| 300 agent()->OnDetach(); |
| 301 } |
| 302 |
| 303 bool IsPaused() { |
| 304 return agent()->paused_; |
| 305 } |
| 306 |
| 307 void DispatchDevToolsMessage(const std::string& message) { |
| 308 agent()->OnDispatchOnInspectorBackend(message); |
| 309 } |
| 310 |
| 311 void CloseWhilePaused() { |
| 312 EXPECT_TRUE(IsPaused()); |
| 313 view()->NotifyOnClose(); |
| 314 } |
| 315 |
| 316 private: |
| 317 DevToolsAgent* agent() { |
| 318 return frame()->devtools_agent(); |
| 319 } |
| 320 }; |
| 321 |
| 291 // Test for https://crbug.com/461191. | 322 // Test for https://crbug.com/461191. |
| 292 TEST_F(RenderViewImplTest, RenderFrameMessageAfterDetach) { | 323 TEST_F(RenderViewImplTest, RenderFrameMessageAfterDetach) { |
| 293 // Create a new main frame RenderFrame so that we don't interfere with the | 324 // Create a new main frame RenderFrame so that we don't interfere with the |
| 294 // shutdown of frame() in RenderViewTest.TearDown. | 325 // shutdown of frame() in RenderViewTest.TearDown. |
| 295 blink::WebURLRequest popup_request(GURL("http://foo.com")); | 326 blink::WebURLRequest popup_request(GURL("http://foo.com")); |
| 296 blink::WebView* new_web_view = view()->createView( | 327 blink::WebView* new_web_view = view()->createView( |
| 297 GetMainFrame(), popup_request, blink::WebWindowFeatures(), "foo", | 328 GetMainFrame(), popup_request, blink::WebWindowFeatures(), "foo", |
| 298 blink::WebNavigationPolicyNewForegroundTab, false); | 329 blink::WebNavigationPolicyNewForegroundTab, false); |
| 299 RenderViewImpl* new_view = RenderViewImpl::FromWebView(new_web_view); | 330 RenderViewImpl* new_view = RenderViewImpl::FromWebView(new_web_view); |
| 300 RenderFrameImpl* new_frame = | 331 RenderFrameImpl* new_frame = |
| (...skipping 2032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2333 request_params.page_id = -1; | 2364 request_params.page_id = -1; |
| 2334 frame()->OnNavigate(CommonNavigationParams(), StartNavigationParams(), | 2365 frame()->OnNavigate(CommonNavigationParams(), StartNavigationParams(), |
| 2335 request_params); | 2366 request_params); |
| 2336 | 2367 |
| 2337 // The history list in RenderView should have been updated. | 2368 // The history list in RenderView should have been updated. |
| 2338 EXPECT_EQ(1, view()->historyBackListCount()); | 2369 EXPECT_EQ(1, view()->historyBackListCount()); |
| 2339 EXPECT_EQ(2, view()->historyBackListCount() + | 2370 EXPECT_EQ(2, view()->historyBackListCount() + |
| 2340 view()->historyForwardListCount() + 1); | 2371 view()->historyForwardListCount() + 1); |
| 2341 } | 2372 } |
| 2342 | 2373 |
| 2374 TEST_F(DevToolsAgentTest, DevToolsResumeOnClose) { |
| 2375 Attach(); |
| 2376 EXPECT_FALSE(IsPaused()); |
| 2377 DispatchDevToolsMessage("{\"id\":1,\"method\":\"Debugger.enable\"}"); |
| 2378 |
| 2379 // Executing javascript will pause the thread and create nested message loop. |
| 2380 // Posting task simulates message coming from browser. |
| 2381 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind( |
| 2382 &DevToolsAgentTest::CloseWhilePaused, base::Unretained(this))); |
| 2383 ExecuteJavaScript("debugger;"); |
| 2384 |
| 2385 // CloseWhilePaused should resume execution and continue here. |
| 2386 EXPECT_FALSE(IsPaused()); |
| 2387 Detach(); |
| 2388 } |
| 2389 |
| 2343 } // namespace content | 2390 } // namespace content |
| OLD | NEW |