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

Side by Side Diff: third_party/WebKit/Source/web/tests/FrameTestHelpers.cpp

Issue 1635873003: Replicating WebFrame::uniqueName across renderers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dump-render-tree3
Patch Set: Rebasing... Created 4 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 unified diff | Download patch
OLDNEW
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 22 matching lines...) Expand all
33 #include "platform/testing/URLTestHelpers.h" 33 #include "platform/testing/URLTestHelpers.h"
34 #include "platform/testing/UnitTestHelpers.h" 34 #include "platform/testing/UnitTestHelpers.h"
35 #include "public/platform/Platform.h" 35 #include "public/platform/Platform.h"
36 #include "public/platform/WebData.h" 36 #include "public/platform/WebData.h"
37 #include "public/platform/WebString.h" 37 #include "public/platform/WebString.h"
38 #include "public/platform/WebThread.h" 38 #include "public/platform/WebThread.h"
39 #include "public/platform/WebURLRequest.h" 39 #include "public/platform/WebURLRequest.h"
40 #include "public/platform/WebURLResponse.h" 40 #include "public/platform/WebURLResponse.h"
41 #include "public/platform/WebUnitTestSupport.h" 41 #include "public/platform/WebUnitTestSupport.h"
42 #include "public/web/WebFrameWidget.h" 42 #include "public/web/WebFrameWidget.h"
43 #include "public/web/WebRemoteFrame.h"
43 #include "public/web/WebSettings.h" 44 #include "public/web/WebSettings.h"
44 #include "public/web/WebTreeScopeType.h" 45 #include "public/web/WebTreeScopeType.h"
45 #include "public/web/WebViewClient.h" 46 #include "public/web/WebViewClient.h"
46 #include "web/WebLocalFrameImpl.h" 47 #include "web/WebLocalFrameImpl.h"
47 #include "web/WebRemoteFrameImpl.h" 48 #include "web/WebRemoteFrameImpl.h"
48 #include "wtf/Functional.h" 49 #include "wtf/Functional.h"
49 #include "wtf/StdLibExtras.h" 50 #include "wtf/StdLibExtras.h"
51 #include "wtf/text/StringBuilder.h"
50 52
51 namespace blink { 53 namespace blink {
52 namespace FrameTestHelpers { 54 namespace FrameTestHelpers {
53 55
54 namespace { 56 namespace {
55 57
56 // The frame test helpers coordinate frame loads in a carefully choreographed 58 // The frame test helpers coordinate frame loads in a carefully choreographed
57 // dance. Since the parser is threaded, simply spinning the run loop once is not 59 // dance. Since the parser is threaded, simply spinning the run loop once is not
58 // enough to ensure completion of a load. Instead, the following pattern is 60 // enough to ensure completion of a load. Instead, the following pattern is
59 // used to ensure that tests see the final state: 61 // used to ensure that tests see the final state:
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 { 135 {
134 frame->reload(true); 136 frame->reload(true);
135 pumpPendingRequests(frame); 137 pumpPendingRequests(frame);
136 } 138 }
137 139
138 void pumpPendingRequestsDoNotUse(WebFrame* frame) 140 void pumpPendingRequestsDoNotUse(WebFrame* frame)
139 { 141 {
140 pumpPendingRequests(frame); 142 pumpPendingRequests(frame);
141 } 143 }
142 144
145 WebLocalFrame* createLocalChild(WebRemoteFrame* parent, const WebString& name, W ebFrameClient* client, WebFrame* previousSibling, const WebFrameOwnerProperties& properties)
146 {
147 if (!client)
148 client = defaultWebFrameClient();
149
150 // |uniqueName| is normally calculated in a somewhat complicated way by the
151 // FrameTree class, but for test purposes the approximation below should be
152 // close enough.
153 static int uniqueNameCounter = 0;
154 StringBuilder uniqueName;
155 uniqueName.append(name);
156 uniqueName.appendNumber(uniqueNameCounter++);
157
158 return parent->createLocalChild(WebTreeScopeType::Document, name, uniqueName .toString(), WebSandboxFlags::None, client, previousSibling, properties);
159 }
160
143 WebViewHelper::WebViewHelper(SettingOverrider* settingOverrider) 161 WebViewHelper::WebViewHelper(SettingOverrider* settingOverrider)
144 : m_webView(nullptr) 162 : m_webView(nullptr)
145 , m_webViewWidget(nullptr) 163 , m_webViewWidget(nullptr)
146 , m_settingOverrider(settingOverrider) 164 , m_settingOverrider(settingOverrider)
147 { 165 {
148 } 166 }
149 167
150 WebViewHelper::~WebViewHelper() 168 WebViewHelper::~WebViewHelper()
151 { 169 {
152 reset(); 170 reset();
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 m_testWebViewClient->clearAnimationScheduled(); 234 m_testWebViewClient->clearAnimationScheduled();
217 webViewImpl()->resize(size); 235 webViewImpl()->resize(size);
218 EXPECT_FALSE(m_testWebViewClient->animationScheduled()); 236 EXPECT_FALSE(m_testWebViewClient->animationScheduled());
219 m_testWebViewClient->clearAnimationScheduled(); 237 m_testWebViewClient->clearAnimationScheduled();
220 } 238 }
221 239
222 TestWebFrameClient::TestWebFrameClient() : m_loadsInProgress(0) 240 TestWebFrameClient::TestWebFrameClient() : m_loadsInProgress(0)
223 { 241 {
224 } 242 }
225 243
226 WebFrame* TestWebFrameClient::createChildFrame(WebLocalFrame* parent, WebTreeSco peType scope, const WebString& frameName, WebSandboxFlags sandboxFlags, const We bFrameOwnerProperties& frameOwnerProperties) 244 WebFrame* TestWebFrameClient::createChildFrame(WebLocalFrame* parent, WebTreeSco peType scope, const WebString& name, const WebString& uniqueName, WebSandboxFlag s sandboxFlags, const WebFrameOwnerProperties& frameOwnerProperties)
227 { 245 {
228 WebFrame* frame = WebLocalFrame::create(scope, this); 246 WebFrame* frame = WebLocalFrame::create(scope, this);
229 parent->appendChild(frame); 247 parent->appendChild(frame);
230 return frame; 248 return frame;
231 } 249 }
232 250
233 void TestWebFrameClient::frameDetached(WebFrame* frame, DetachType type) 251 void TestWebFrameClient::frameDetached(WebFrame* frame, DetachType type)
234 { 252 {
235 if (type == DetachType::Remove && frame->parent()) 253 if (type == DetachType::Remove && frame->parent())
236 frame->parent()->removeChild(frame); 254 frame->parent()->removeChild(frame);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 } 294 }
277 295
278 void TestWebViewClient::initializeLayerTreeView() 296 void TestWebViewClient::initializeLayerTreeView()
279 { 297 {
280 m_layerTreeView = adoptPtr(Platform::current()->unitTestSupport()->createLay erTreeViewForTesting()); 298 m_layerTreeView = adoptPtr(Platform::current()->unitTestSupport()->createLay erTreeViewForTesting());
281 ASSERT(m_layerTreeView); 299 ASSERT(m_layerTreeView);
282 } 300 }
283 301
284 } // namespace FrameTestHelpers 302 } // namespace FrameTestHelpers
285 } // namespace blink 303 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/tests/FrameTestHelpers.h ('k') | third_party/WebKit/Source/web/tests/FrameThrottlingTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698