OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/browser/frame_host/frame_tree_node_blame_context.h" | 5 #include "content/browser/frame_host/frame_tree_node_blame_context.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "base/test/trace_event_analyzer.h" | 9 #include "base/test/trace_event_analyzer.h" |
10 #include "base/trace_event/trace_buffer.h" | 10 #include "base/trace_event/trace_buffer.h" |
11 #include "base/trace_event/trace_event_argument.h" | 11 #include "base/trace_event/trace_event_argument.h" |
12 #include "content/browser/frame_host/frame_tree.h" | 12 #include "content/browser/frame_host/frame_tree.h" |
13 #include "content/browser/frame_host/frame_tree_node.h" | 13 #include "content/browser/frame_host/frame_tree_node.h" |
| 14 #include "content/common/frame_owner_properties.h" |
14 #include "content/test/test_render_view_host.h" | 15 #include "content/test/test_render_view_host.h" |
15 #include "content/test/test_web_contents.h" | 16 #include "content/test/test_web_contents.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
17 #include "third_party/WebKit/public/web/WebSandboxFlags.h" | 18 #include "third_party/WebKit/public/web/WebSandboxFlags.h" |
18 | 19 |
19 namespace content { | 20 namespace content { |
20 | 21 |
21 namespace { | 22 namespace { |
22 | 23 |
23 bool EventPointerCompare(const trace_analyzer::TraceEvent* lhs, | 24 bool EventPointerCompare(const trace_analyzer::TraceEvent* lhs, |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 | 124 |
124 return base::WrapUnique( | 125 return base::WrapUnique( |
125 trace_analyzer::TraceAnalyzer::Create(trace_output.json_output)); | 126 trace_analyzer::TraceAnalyzer::Create(trace_output.json_output)); |
126 } | 127 } |
127 | 128 |
128 private: | 129 private: |
129 int CreateSubframes(FrameTreeNode* node, int self_id, const char* shape) { | 130 int CreateSubframes(FrameTreeNode* node, int self_id, const char* shape) { |
130 int consumption = 0; | 131 int consumption = 0; |
131 for (int child_num = 1; shape[consumption++] == '('; ++child_num) { | 132 for (int child_num = 1; shape[consumption++] == '('; ++child_num) { |
132 int child_id = self_id * 10 + child_num; | 133 int child_id = self_id * 10 + child_num; |
133 tree()->AddFrame( | 134 tree()->AddFrame(node, process_id(), child_id, |
134 node, process_id(), child_id, blink::WebTreeScopeType::Document, | 135 blink::WebTreeScopeType::Document, std::string(), |
135 std::string(), base::StringPrintf("uniqueName%d", child_id), | 136 base::StringPrintf("uniqueName%d", child_id), |
136 blink::WebSandboxFlags::None, blink::WebFrameOwnerProperties()); | 137 blink::WebSandboxFlags::None, FrameOwnerProperties()); |
137 FrameTreeNode* child = node->child_at(child_num - 1); | 138 FrameTreeNode* child = node->child_at(child_num - 1); |
138 consumption += CreateSubframes(child, child_id, shape + consumption); | 139 consumption += CreateSubframes(child, child_id, shape + consumption); |
139 } | 140 } |
140 return consumption; | 141 return consumption; |
141 } | 142 } |
142 }; | 143 }; |
143 | 144 |
144 // Creates a frame tree, tests if (i) the creation of each new frame is | 145 // Creates a frame tree, tests if (i) the creation of each new frame is |
145 // correctly traced, and (ii) the topology given by the snapshots is correct. | 146 // correctly traced, and (ii) the topology given by the snapshots is correct. |
146 TEST_F(FrameTreeNodeBlameContextTest, FrameCreation) { | 147 TEST_F(FrameTreeNodeBlameContextTest, FrameCreation) { |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 std::sort(events.begin(), events.end(), EventPointerCompare); | 255 std::sort(events.begin(), events.end(), EventPointerCompare); |
255 | 256 |
256 // Three snapshots are traced, one for each URL change. | 257 // Three snapshots are traced, one for each URL change. |
257 EXPECT_EQ(3u, events.size()); | 258 EXPECT_EQ(3u, events.size()); |
258 EXPECT_EQ(url1.spec(), GetSnapshotURL(events[0])); | 259 EXPECT_EQ(url1.spec(), GetSnapshotURL(events[0])); |
259 EXPECT_EQ(url2.spec(), GetSnapshotURL(events[1])); | 260 EXPECT_EQ(url2.spec(), GetSnapshotURL(events[1])); |
260 EXPECT_EQ("", GetSnapshotURL(events[2])); | 261 EXPECT_EQ("", GetSnapshotURL(events[2])); |
261 } | 262 } |
262 | 263 |
263 } // namespace content | 264 } // namespace content |
OLD | NEW |