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

Side by Side Diff: components/html_viewer/layout_test_content_handler_impl.cc

Issue 1297173002: html_viewer: Make sure window.internals is set-up correctly in layout-tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | components/html_viewer/web_test_delegate_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/html_viewer/layout_test_content_handler_impl.h" 5 #include "components/html_viewer/layout_test_content_handler_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "components/html_viewer/html_document_application_delegate.h" 8 #include "components/html_viewer/html_document_application_delegate.h"
9 #include "components/html_viewer/web_test_delegate_impl.h" 9 #include "components/html_viewer/web_test_delegate_impl.h"
10 #include "components/test_runner/web_frame_test_proxy.h" 10 #include "components/test_runner/web_frame_test_proxy.h"
11 #include "components/test_runner/web_test_proxy.h" 11 #include "components/test_runner/web_test_proxy.h"
12 #include "third_party/WebKit/public/web/WebTestingSupport.h" 12 #include "third_party/WebKit/public/web/WebTestingSupport.h"
13 #include "third_party/WebKit/public/web/WebView.h" 13 #include "third_party/WebKit/public/web/WebView.h"
14 14
15 namespace html_viewer { 15 namespace html_viewer {
16 16
17 class TestHTMLFrame : public HTMLFrame {
18 public:
19 explicit TestHTMLFrame(HTMLFrame::CreateParams* params) : HTMLFrame(params) {}
20
21 ~TestHTMLFrame() override {}
22
23 private:
24 // blink::WebFrameClient::
25 void didClearWindowObject(blink::WebLocalFrame* frame) override {
26 blink::WebTestingSupport::injectInternalsObject(frame);
sky 2015/08/18 18:13:57 Should you call through to the base class?
sadrul 2015/08/18 20:06:34 Done.
27 }
28
29 DISALLOW_COPY_AND_ASSIGN(TestHTMLFrame);
30 };
31
17 LayoutTestContentHandlerImpl::LayoutTestContentHandlerImpl( 32 LayoutTestContentHandlerImpl::LayoutTestContentHandlerImpl(
18 GlobalState* global_state, 33 GlobalState* global_state,
19 mojo::ApplicationImpl* app, 34 mojo::ApplicationImpl* app,
20 mojo::InterfaceRequest<mojo::ContentHandler> request, 35 mojo::InterfaceRequest<mojo::ContentHandler> request,
21 test_runner::WebTestInterfaces* test_interfaces, 36 test_runner::WebTestInterfaces* test_interfaces,
22 WebTestDelegateImpl* test_delegate) 37 WebTestDelegateImpl* test_delegate)
23 : ContentHandlerImpl(global_state, app, request.Pass()), 38 : ContentHandlerImpl(global_state, app, request.Pass()),
24 test_interfaces_(test_interfaces), 39 test_interfaces_(test_interfaces),
25 test_delegate_(test_delegate) { 40 test_delegate_(test_delegate) {
26 } 41 }
(...skipping 13 matching lines...) Expand all
40 request.Pass(), response.Pass(), global_state(), 55 request.Pass(), response.Pass(), global_state(),
41 app()->app_lifetime_helper()->CreateAppRefCount()); 56 app()->app_lifetime_helper()->CreateAppRefCount());
42 57
43 delegate->SetHTMLFrameCreationCallback(base::Bind( 58 delegate->SetHTMLFrameCreationCallback(base::Bind(
44 &LayoutTestContentHandlerImpl::CreateHTMLFrame, base::Unretained(this))); 59 &LayoutTestContentHandlerImpl::CreateHTMLFrame, base::Unretained(this)));
45 } 60 }
46 61
47 HTMLFrame* LayoutTestContentHandlerImpl::CreateHTMLFrame( 62 HTMLFrame* LayoutTestContentHandlerImpl::CreateHTMLFrame(
48 HTMLFrame::CreateParams* params) { 63 HTMLFrame::CreateParams* params) {
49 using ProxyType = test_runner::WebTestProxy< 64 using ProxyType = test_runner::WebTestProxy<
50 test_runner::WebFrameTestProxy<HTMLFrame, HTMLFrame::CreateParams*>, 65 test_runner::WebFrameTestProxy<TestHTMLFrame, HTMLFrame::CreateParams*>,
51 HTMLFrame::CreateParams*>; 66 HTMLFrame::CreateParams*>;
52 // TODO(sky): this isn't right for all frame types, eg remote frames. 67 // TODO(sky): this isn't right for all frame types, eg remote frames.
53 ProxyType* proxy = new ProxyType(params); 68 ProxyType* proxy = new ProxyType(params);
69 blink::WebView* web_view = proxy->web_view();
70 if (!web_view)
71 web_view = params->manager->GetWebView();
sadrul 2015/08/18 08:00:13 This does avoid a crash on start-up below (line ~7
sky 2015/08/18 18:13:57 Are you trying to run a test that creates multiple
sadrul 2015/08/18 20:06:34 Indeed, the test this was failing on did have an i
72 CHECK(web_view);
54 proxy->SetInterfaces(test_interfaces_); 73 proxy->SetInterfaces(test_interfaces_);
55 proxy->SetDelegate(test_delegate_); 74 proxy->SetDelegate(test_delegate_);
56 proxy->set_base_proxy(proxy); 75 proxy->set_base_proxy(proxy);
57 test_delegate_->set_test_proxy(proxy); 76 test_delegate_->set_test_proxy(proxy);
58 test_interfaces_->SetWebView(proxy->web_view(), proxy); 77 test_interfaces_->SetWebView(web_view, proxy);
59 proxy->set_widget(proxy->web_view()); 78 proxy->set_widget(web_view);
60 blink::WebTestingSupport::injectInternalsObject( 79 test_interfaces_->BindTo(web_view->mainFrame());
61 proxy->web_view()->mainFrame()->toWebLocalFrame());
62 test_interfaces_->BindTo(proxy->web_view()->mainFrame());
63 return proxy; 80 return proxy;
64 } 81 }
65 82
66 } // namespace html_viewer 83 } // namespace html_viewer
OLDNEW
« no previous file with comments | « no previous file | components/html_viewer/web_test_delegate_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698