OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 TestWebWidgetClient* defaultWebWidgetClient() { | 93 TestWebWidgetClient* defaultWebWidgetClient() { |
94 DEFINE_STATIC_LOCAL(TestWebWidgetClient, client, ()); | 94 DEFINE_STATIC_LOCAL(TestWebWidgetClient, client, ()); |
95 return &client; | 95 return &client; |
96 } | 96 } |
97 | 97 |
98 TestWebViewClient* defaultWebViewClient() { | 98 TestWebViewClient* defaultWebViewClient() { |
99 DEFINE_STATIC_LOCAL(TestWebViewClient, client, ()); | 99 DEFINE_STATIC_LOCAL(TestWebViewClient, client, ()); |
100 return &client; | 100 return &client; |
101 } | 101 } |
102 | 102 |
103 // |uniqueName| is normally calculated in a somewhat complicated way by the | |
104 // FrameTree class, but for test purposes the approximation below should be | |
105 // close enough. | |
106 String nameToUniqueName(const String& name) { | |
107 static int uniqueNameCounter = 0; | |
108 StringBuilder uniqueName; | |
109 uniqueName.append(name); | |
110 uniqueName.append(' '); | |
111 uniqueName.appendNumber(uniqueNameCounter++); | |
112 return uniqueName.toString(); | |
113 } | |
114 | |
115 } // namespace | 103 } // namespace |
116 | 104 |
117 void loadFrame(WebFrame* frame, const std::string& url) { | 105 void loadFrame(WebFrame* frame, const std::string& url) { |
118 WebURLRequest urlRequest(URLTestHelpers::toKURL(url)); | 106 WebURLRequest urlRequest(URLTestHelpers::toKURL(url)); |
119 frame->loadRequest(urlRequest); | 107 frame->loadRequest(urlRequest); |
120 pumpPendingRequestsForFrameToLoad(frame); | 108 pumpPendingRequestsForFrameToLoad(frame); |
121 } | 109 } |
122 | 110 |
123 void loadHTMLString(WebFrame* frame, | 111 void loadHTMLString(WebFrame* frame, |
124 const std::string& html, | 112 const std::string& html, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 WebLocalFrameImpl* createLocalChild(WebRemoteFrame* parent, | 157 WebLocalFrameImpl* createLocalChild(WebRemoteFrame* parent, |
170 const WebString& name, | 158 const WebString& name, |
171 WebFrameClient* client, | 159 WebFrameClient* client, |
172 WebWidgetClient* widgetClient, | 160 WebWidgetClient* widgetClient, |
173 WebFrame* previousSibling, | 161 WebFrame* previousSibling, |
174 const WebFrameOwnerProperties& properties) { | 162 const WebFrameOwnerProperties& properties) { |
175 if (!client) | 163 if (!client) |
176 client = defaultWebFrameClient(); | 164 client = defaultWebFrameClient(); |
177 | 165 |
178 WebLocalFrameImpl* frame = toWebLocalFrameImpl(parent->createLocalChild( | 166 WebLocalFrameImpl* frame = toWebLocalFrameImpl(parent->createLocalChild( |
179 WebTreeScopeType::Document, name, nameToUniqueName(name), | 167 WebTreeScopeType::Document, name, WebSandboxFlags::None, client, |
180 WebSandboxFlags::None, client, | |
181 static_cast<TestWebFrameClient*>(client)->interfaceProvider(), nullptr, | 168 static_cast<TestWebFrameClient*>(client)->interfaceProvider(), nullptr, |
182 previousSibling, properties, nullptr)); | 169 previousSibling, properties, nullptr)); |
183 | 170 |
184 if (!widgetClient) | 171 if (!widgetClient) |
185 widgetClient = defaultWebWidgetClient(); | 172 widgetClient = defaultWebWidgetClient(); |
186 WebFrameWidget::create(widgetClient, frame); | 173 WebFrameWidget::create(widgetClient, frame); |
187 | 174 |
188 return frame; | 175 return frame; |
189 } | 176 } |
190 | 177 |
191 WebRemoteFrameImpl* createRemoteChild(WebRemoteFrame* parent, | 178 WebRemoteFrameImpl* createRemoteChild(WebRemoteFrame* parent, |
192 WebRemoteFrameClient* client, | 179 WebRemoteFrameClient* client, |
193 const WebString& name) { | 180 const WebString& name) { |
194 return toWebRemoteFrameImpl(parent->createRemoteChild( | 181 return toWebRemoteFrameImpl( |
195 WebTreeScopeType::Document, name, nameToUniqueName(name), | 182 parent->createRemoteChild(WebTreeScopeType::Document, name, |
196 WebSandboxFlags::None, client, nullptr)); | 183 WebSandboxFlags::None, client, nullptr)); |
197 } | 184 } |
198 | 185 |
199 WebViewHelper::WebViewHelper(SettingOverrider* settingOverrider) | 186 WebViewHelper::WebViewHelper(SettingOverrider* settingOverrider) |
200 : m_webView(nullptr), m_settingOverrider(settingOverrider) {} | 187 : m_webView(nullptr), m_settingOverrider(settingOverrider) {} |
201 | 188 |
202 WebViewHelper::~WebViewHelper() { | 189 WebViewHelper::~WebViewHelper() { |
203 reset(); | 190 reset(); |
204 } | 191 } |
205 | 192 |
206 WebViewImpl* WebViewHelper::initializeWithOpener( | 193 WebViewImpl* WebViewHelper::initializeWithOpener( |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 if (frame->frameWidget()) | 296 if (frame->frameWidget()) |
310 frame->frameWidget()->close(); | 297 frame->frameWidget()->close(); |
311 | 298 |
312 frame->close(); | 299 frame->close(); |
313 } | 300 } |
314 | 301 |
315 WebLocalFrame* TestWebFrameClient::createChildFrame( | 302 WebLocalFrame* TestWebFrameClient::createChildFrame( |
316 WebLocalFrame* parent, | 303 WebLocalFrame* parent, |
317 WebTreeScopeType scope, | 304 WebTreeScopeType scope, |
318 const WebString& name, | 305 const WebString& name, |
319 const WebString& uniqueName, | 306 const WebString& fallbackName, |
320 WebSandboxFlags sandboxFlags, | 307 WebSandboxFlags sandboxFlags, |
321 const WebFrameOwnerProperties& frameOwnerProperties) { | 308 const WebFrameOwnerProperties& frameOwnerProperties) { |
322 WebLocalFrame* frame = | 309 WebLocalFrame* frame = |
323 WebLocalFrame::create(scope, this, interfaceProvider(), nullptr); | 310 WebLocalFrame::create(scope, this, interfaceProvider(), nullptr); |
324 parent->appendChild(frame); | 311 parent->appendChild(frame); |
325 return frame; | 312 return frame; |
326 } | 313 } |
327 | 314 |
328 void TestWebFrameClient::didStartLoading(bool) { | 315 void TestWebFrameClient::didStartLoading(bool) { |
329 ++m_loadsInProgress; | 316 ++m_loadsInProgress; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 m_testWebViewClient->scheduleAnimation(); | 350 m_testWebViewClient->scheduleAnimation(); |
364 } | 351 } |
365 | 352 |
366 void TestWebViewWidgetClient::didMeaningfulLayout( | 353 void TestWebViewWidgetClient::didMeaningfulLayout( |
367 WebMeaningfulLayout layoutType) { | 354 WebMeaningfulLayout layoutType) { |
368 m_testWebViewClient->didMeaningfulLayout(layoutType); | 355 m_testWebViewClient->didMeaningfulLayout(layoutType); |
369 } | 356 } |
370 | 357 |
371 } // namespace FrameTestHelpers | 358 } // namespace FrameTestHelpers |
372 } // namespace blink | 359 } // namespace blink |
OLD | NEW |