Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "chrome/test/chromedriver/chrome/navigation_tracker.h" | 5 #include "chrome/test/chromedriver/chrome/navigation_tracker.h" |
| 6 | 6 |
| 7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/test/chromedriver/chrome/browser_info.h" | 9 #include "chrome/test/chromedriver/chrome/browser_info.h" |
| 10 #include "chrome/test/chromedriver/chrome/devtools_client.h" | 10 #include "chrome/test/chromedriver/chrome/devtools_client.h" |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 214 if (!params.GetString("frameId", &frame_id)) | 214 if (!params.GetString("frameId", &frame_id)) |
| 215 return Status(kUnknownError, "missing or invalid 'frameId'"); | 215 return Status(kUnknownError, "missing or invalid 'frameId'"); |
| 216 pending_frame_set_.insert(frame_id); | 216 pending_frame_set_.insert(frame_id); |
| 217 loading_state_ = kLoading; | 217 loading_state_ = kLoading; |
| 218 } else if (method == "Page.frameStoppedLoading") { | 218 } else if (method == "Page.frameStoppedLoading") { |
| 219 // Versions of Blink before revision 170248 sent a single | 219 // Versions of Blink before revision 170248 sent a single |
| 220 // Page.frameStoppedLoading event per page, but 170248 and newer revisions | 220 // Page.frameStoppedLoading event per page, but 170248 and newer revisions |
| 221 // only send one event for each frame on the page. | 221 // only send one event for each frame on the page. |
| 222 // | 222 // |
| 223 // This change was rolled into the Chromium tree in revision 260203. | 223 // This change was rolled into the Chromium tree in revision 260203. |
| 224 // Versions of Chrome with build number 1916 and earlier do not contain this | 224 // Versions of Chrome with build number 1916 and earlier do not contain this |
|
stgao
2016/09/20 23:45:38
Nit: I guess this part could be cleaned now.
samuong
2016/09/21 14:36:55
Unfortunately we still need to keep this around fo
| |
| 225 // change. | 225 // change. |
| 226 bool expecting_single_stop_event = false; | 226 bool expecting_single_stop_event = false; |
| 227 | 227 |
| 228 if (browser_info_->browser_name == "chrome") { | 228 if (browser_info_->browser_name == "chrome") { |
| 229 // If we're talking to a version of Chrome with an old build number, we | 229 // If we're talking to a version of Chrome with an old build number, we |
| 230 // are using a branched version of Blink which does not contain 170248 | 230 // are using a branched version of Blink which does not contain 170248 |
| 231 // (even if blink_revision > 170248). | 231 // (even if blink_revision > 170248). |
| 232 expecting_single_stop_event = browser_info_->build_no <= 1916; | 232 expecting_single_stop_event = browser_info_->build_no <= 1916; |
| 233 } else { | 233 } else { |
| 234 // If we're talking to a non-Chrome embedder (e.g. Content Shell, Android | 234 // If we're talking to a non-Chrome embedder (e.g. Content Shell, Android |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 274 const base::Value* unused_value; | 274 const base::Value* unused_value; |
| 275 if (!params.Get("frame.parentId", &unused_value)) { | 275 if (!params.Get("frame.parentId", &unused_value)) { |
| 276 if (IsExpectingFrameLoadingEvents()) { | 276 if (IsExpectingFrameLoadingEvents()) { |
| 277 // If the main frame just navigated, discard any pending scheduled | 277 // If the main frame just navigated, discard any pending scheduled |
| 278 // navigations. For some reasons at times the cleared event is not | 278 // navigations. For some reasons at times the cleared event is not |
| 279 // received when navigating. | 279 // received when navigating. |
| 280 // See crbug.com/180742. | 280 // See crbug.com/180742. |
| 281 pending_frame_set_.clear(); | 281 pending_frame_set_.clear(); |
| 282 scheduled_frame_set_.clear(); | 282 scheduled_frame_set_.clear(); |
| 283 } else { | 283 } else { |
| 284 // Discard pending and scheduled frames, except for the frame that just | |
|
stgao
2016/09/20 23:44:19
It might worth mentioning this is the root frame.
samuong
2016/09/21 14:36:55
Done.
| |
| 285 // navigated (which we should consider pending until we receive a | |
| 286 // Page.frameStoppedLoading event for it). | |
| 287 std::string frame_id; | |
| 288 if (!params.GetString("frame.id", &frame_id)) | |
| 289 return Status(kUnknownError, "missing or invalid 'frame.id'"); | |
| 290 bool frame_was_pending = pending_frame_set_.count(frame_id) > 0; | |
| 291 pending_frame_set_.clear(); | |
| 292 scheduled_frame_set_.clear(); | |
| 293 if (frame_was_pending) | |
| 294 pending_frame_set_.insert(frame_id); | |
| 284 // If the URL indicates that the web page is unreachable (the sad tab | 295 // If the URL indicates that the web page is unreachable (the sad tab |
| 285 // page) then discard any pending or scheduled navigations. | 296 // page) then discard all pending navigations. |
| 286 std::string frame_url; | 297 std::string frame_url; |
| 287 if (!params.GetString("frame.url", &frame_url)) | 298 if (!params.GetString("frame.url", &frame_url)) |
| 288 return Status(kUnknownError, "missing or invalid 'frame.url'"); | 299 return Status(kUnknownError, "missing or invalid 'frame.url'"); |
| 289 if (frame_url == kUnreachableWebDataURL) { | 300 if (frame_url == kUnreachableWebDataURL) |
| 290 pending_frame_set_.clear(); | 301 pending_frame_set_.clear(); |
| 291 scheduled_frame_set_.clear(); | |
| 292 } | |
| 293 } | 302 } |
| 294 } else { | 303 } else { |
| 295 // If a child frame just navigated, check if it is the dummy frame that | 304 // If a child frame just navigated, check if it is the dummy frame that |
| 296 // was attached by IsPendingNavigation(). We don't want to track execution | 305 // was attached by IsPendingNavigation(). We don't want to track execution |
| 297 // contexts created and destroyed for this dummy frame. | 306 // contexts created and destroyed for this dummy frame. |
| 298 std::string name; | 307 std::string name; |
| 299 if (!params.GetString("frame.name", &name)) | 308 if (!params.GetString("frame.name", &name)) |
| 300 return Status(kUnknownError, "missing or invalid 'frame.name'"); | 309 return Status(kUnknownError, "missing or invalid 'frame.name'"); |
| 301 std::string url; | 310 std::string url; |
| 302 if (!params.GetString("frame.url", &url)) | 311 if (!params.GetString("frame.url", &url)) |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 435 // modal dialogs. This pauses the render process so we need to be careful not | 444 // modal dialogs. This pauses the render process so we need to be careful not |
| 436 // to issue Runtime.evaluate commands while an alert is up, otherwise the call | 445 // to issue Runtime.evaluate commands while an alert is up, otherwise the call |
| 437 // will block and timeout. For details refer to | 446 // will block and timeout. For details refer to |
| 438 // https://bugs.chromium.org/p/chromedriver/issues/detail?id=1381. | 447 // https://bugs.chromium.org/p/chromedriver/issues/detail?id=1381. |
| 439 // TODO(samuong): Remove this once we stop supporting M51. | 448 // TODO(samuong): Remove this once we stop supporting M51. |
| 440 if (browser_info_->browser_name == "chrome") | 449 if (browser_info_->browser_name == "chrome") |
| 441 return browser_info_->build_no >= 2743; | 450 return browser_info_->build_no >= 2743; |
| 442 else | 451 else |
| 443 return browser_info_->major_version >= 52; | 452 return browser_info_->major_version >= 52; |
| 444 } | 453 } |
| OLD | NEW |