Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/shell/browser/layout_test/blink_test_controller.h" | 5 #include "content/shell/browser/layout_test/blink_test_controller.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <iostream> | 9 #include <iostream> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 285 if (test_url.spec().find("W3C-SVG-1.1") != std::string::npos) | 285 if (test_url.spec().find("W3C-SVG-1.1") != std::string::npos) |
| 286 initial_size_ = gfx::Size(kTestSVGWindowWidthDip, kTestSVGWindowHeightDip); | 286 initial_size_ = gfx::Size(kTestSVGWindowWidthDip, kTestSVGWindowHeightDip); |
| 287 if (!main_window_) { | 287 if (!main_window_) { |
| 288 main_window_ = content::Shell::CreateNewWindow( | 288 main_window_ = content::Shell::CreateNewWindow( |
| 289 browser_context, | 289 browser_context, |
| 290 GURL(), | 290 GURL(), |
| 291 NULL, | 291 NULL, |
| 292 initial_size_); | 292 initial_size_); |
| 293 WebContentsObserver::Observe(main_window_->web_contents()); | 293 WebContentsObserver::Observe(main_window_->web_contents()); |
| 294 current_pid_ = base::kNullProcessId; | 294 current_pid_ = base::kNullProcessId; |
| 295 default_prefs_ = | |
| 296 main_window_->web_contents()->GetRenderViewHost()->GetWebkitPreferences(); | |
| 295 main_window_->LoadURL(test_url); | 297 main_window_->LoadURL(test_url); |
| 296 } else { | 298 } else { |
| 297 #if defined(OS_MACOSX) | 299 #if defined(OS_MACOSX) |
| 298 // Shell::SizeTo is not implemented on all platforms. | 300 // Shell::SizeTo is not implemented on all platforms. |
| 299 main_window_->SizeTo(initial_size_); | 301 main_window_->SizeTo(initial_size_); |
| 300 #endif | 302 #endif |
| 301 main_window_->web_contents() | 303 main_window_->web_contents() |
| 302 ->GetRenderViewHost() | 304 ->GetRenderViewHost() |
| 303 ->GetWidget() | 305 ->GetWidget() |
| 304 ->GetView() | 306 ->GetView() |
| 305 ->SetSize(initial_size_); | 307 ->SetSize(initial_size_); |
| 306 main_window_->web_contents() | 308 main_window_->web_contents() |
| 307 ->GetRenderViewHost() | 309 ->GetRenderViewHost() |
| 308 ->GetWidget() | 310 ->GetWidget() |
| 309 ->WasResized(); | 311 ->WasResized(); |
| 310 RenderViewHost* render_view_host = | 312 RenderViewHost* render_view_host = |
| 311 main_window_->web_contents()->GetRenderViewHost(); | 313 main_window_->web_contents()->GetRenderViewHost(); |
| 312 WebPreferences prefs = render_view_host->GetWebkitPreferences(); | 314 render_view_host->UpdateWebkitPreferences(default_prefs_); |
| 313 OverrideWebkitPrefs(&prefs); | |
|
Mike West
2016/07/08 13:16:37
I think you still need to call this against `defau
carlosk
2016/07/11 08:21:00
The default we save up there @ 295 does already in
| |
| 314 render_view_host->UpdateWebkitPreferences(prefs); | |
| 315 HandleNewRenderFrameHost(render_view_host->GetMainFrame()); | 315 HandleNewRenderFrameHost(render_view_host->GetMainFrame()); |
| 316 | 316 |
| 317 NavigationController::LoadURLParams params(test_url); | 317 NavigationController::LoadURLParams params(test_url); |
| 318 params.transition_type = ui::PageTransitionFromInt( | 318 params.transition_type = ui::PageTransitionFromInt( |
| 319 ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR); | 319 ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR); |
| 320 params.should_clear_history_list = true; | 320 params.should_clear_history_list = true; |
| 321 main_window_->web_contents()->GetController().LoadURLWithParams(params); | 321 main_window_->web_contents()->GetController().LoadURLWithParams(params); |
| 322 main_window_->web_contents()->Focus(); | 322 main_window_->web_contents()->Focus(); |
| 323 } | 323 } |
| 324 main_window_->web_contents()->GetRenderViewHost()->GetWidget()->SetActive( | 324 main_window_->web_contents()->GetRenderViewHost()->GetWidget()->SetActive( |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 750 render_view_host->GetRoutingID(), stitched_layout_dump)); | 750 render_view_host->GetRoutingID(), stitched_layout_dump)); |
| 751 } | 751 } |
| 752 | 752 |
| 753 void BlinkTestController::OnPrintMessage(const std::string& message) { | 753 void BlinkTestController::OnPrintMessage(const std::string& message) { |
| 754 printer_->AddMessageRaw(message); | 754 printer_->AddMessageRaw(message); |
| 755 } | 755 } |
| 756 | 756 |
| 757 void BlinkTestController::OnOverridePreferences(const WebPreferences& prefs) { | 757 void BlinkTestController::OnOverridePreferences(const WebPreferences& prefs) { |
| 758 should_override_prefs_ = true; | 758 should_override_prefs_ = true; |
| 759 prefs_ = prefs; | 759 prefs_ = prefs; |
| 760 | |
| 761 // Notifies the main RenderViewHost that Blink preferences changed so | |
| 762 // immediately apply the new settings and to avoid re-usage of cached | |
| 763 // preferences that are now stale. RenderViewHost::UpdateWebkitPreferences is | |
| 764 // not used here because it would send an unneeded preferences update to the | |
| 765 // renderer. | |
| 766 RenderViewHost* main_render_view_host = | |
| 767 main_window_->web_contents()->GetRenderViewHost(); | |
| 768 main_render_view_host->OnWebkitPreferencesChanged(); | |
| 760 } | 769 } |
| 761 | 770 |
| 762 void BlinkTestController::OnClearDevToolsLocalStorage() { | 771 void BlinkTestController::OnClearDevToolsLocalStorage() { |
| 763 ShellBrowserContext* browser_context = | 772 ShellBrowserContext* browser_context = |
| 764 ShellContentBrowserClient::Get()->browser_context(); | 773 ShellContentBrowserClient::Get()->browser_context(); |
| 765 StoragePartition* storage_partition = | 774 StoragePartition* storage_partition = |
| 766 BrowserContext::GetStoragePartition(browser_context, NULL); | 775 BrowserContext::GetStoragePartition(browser_context, NULL); |
| 767 storage_partition->GetDOMStorageContext()->DeleteLocalStorage( | 776 storage_partition->GetDOMStorageContext()->DeleteLocalStorage( |
| 768 content::LayoutTestDevToolsFrontend::GetDevToolsPathAsURL("", "") | 777 content::LayoutTestDevToolsFrontend::GetDevToolsPathAsURL("", "") |
| 769 .GetOrigin()); | 778 .GetOrigin()); |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 928 } else { | 937 } else { |
| 929 printer_->AddErrorMessage(base::StringPrintf( | 938 printer_->AddErrorMessage(base::StringPrintf( |
| 930 "FAIL: Unexpected sendBluetoothManualChooserEvent() event name '%s'.", | 939 "FAIL: Unexpected sendBluetoothManualChooserEvent() event name '%s'.", |
| 931 event_name.c_str())); | 940 event_name.c_str())); |
| 932 return; | 941 return; |
| 933 } | 942 } |
| 934 bluetooth_chooser_factory_->SendEvent(event, argument); | 943 bluetooth_chooser_factory_->SendEvent(event, argument); |
| 935 } | 944 } |
| 936 | 945 |
| 937 } // namespace content | 946 } // namespace content |
| OLD | NEW |