| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "base/base64.h" | 5 #include "base/base64.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
| 8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "content/public/browser/devtools_agent_host.h" | 10 #include "content/public/browser/devtools_agent_host.h" |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 // of the device that we're testing on, but in any case it should be greater | 324 // of the device that we're testing on, but in any case it should be greater |
| 325 // than 0. | 325 // than 0. |
| 326 ASSERT_TRUE(content::ExecuteScriptAndExtractInt( | 326 ASSERT_TRUE(content::ExecuteScriptAndExtractInt( |
| 327 shell()->web_contents(), | 327 shell()->web_contents(), |
| 328 "domAutomationController.send(document.body.scrollTop)", &scroll_top)); | 328 "domAutomationController.send(document.body.scrollTop)", &scroll_top)); |
| 329 ASSERT_GT(scroll_top, 0); | 329 ASSERT_GT(scroll_top, 0); |
| 330 } | 330 } |
| 331 #endif // defined(OS_ANDROID) | 331 #endif // defined(OS_ANDROID) |
| 332 | 332 |
| 333 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, NavigationPreservesMessages) { | 333 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, NavigationPreservesMessages) { |
| 334 ASSERT_TRUE(test_server()->Start()); | 334 ASSERT_TRUE(embedded_test_server()->Start()); |
| 335 GURL test_url = test_server()->GetURL("files/devtools/navigation.html"); | 335 GURL test_url = embedded_test_server()->GetURL("/devtools/navigation.html"); |
| 336 NavigateToURLBlockUntilNavigationsComplete(shell(), test_url, 1); | 336 NavigateToURLBlockUntilNavigationsComplete(shell(), test_url, 1); |
| 337 Attach(); | 337 Attach(); |
| 338 SendCommand("Page.enable", nullptr, false); | 338 SendCommand("Page.enable", nullptr, false); |
| 339 | 339 |
| 340 scoped_ptr<base::DictionaryValue> params(new base::DictionaryValue()); | 340 scoped_ptr<base::DictionaryValue> params(new base::DictionaryValue()); |
| 341 test_url = GetTestUrl("devtools", "navigation.html"); | 341 test_url = GetTestUrl("devtools", "navigation.html"); |
| 342 params->SetString("url", test_url.spec()); | 342 params->SetString("url", test_url.spec()); |
| 343 SendCommand("Page.navigate", params.Pass(), true); | 343 SendCommand("Page.navigate", params.Pass(), true); |
| 344 | 344 |
| 345 bool enough_results = result_ids_.size() >= 2u; | 345 bool enough_results = result_ids_.size() >= 2u; |
| 346 EXPECT_TRUE(enough_results); | 346 EXPECT_TRUE(enough_results); |
| 347 if (enough_results) { | 347 if (enough_results) { |
| 348 EXPECT_EQ(1, result_ids_[0]); // Page.enable | 348 EXPECT_EQ(1, result_ids_[0]); // Page.enable |
| 349 EXPECT_EQ(2, result_ids_[1]); // Page.navigate | 349 EXPECT_EQ(2, result_ids_[1]); // Page.navigate |
| 350 } | 350 } |
| 351 | 351 |
| 352 enough_results = notifications_.size() >= 1u; | 352 enough_results = notifications_.size() >= 1u; |
| 353 EXPECT_TRUE(enough_results); | 353 EXPECT_TRUE(enough_results); |
| 354 bool found_frame_notification = false; | 354 bool found_frame_notification = false; |
| 355 for (const std::string& notification : notifications_) { | 355 for (const std::string& notification : notifications_) { |
| 356 if (notification == "Page.frameStartedLoading") | 356 if (notification == "Page.frameStartedLoading") |
| 357 found_frame_notification = true; | 357 found_frame_notification = true; |
| 358 } | 358 } |
| 359 EXPECT_TRUE(found_frame_notification); | 359 EXPECT_TRUE(found_frame_notification); |
| 360 } | 360 } |
| 361 | 361 |
| 362 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, CrossSiteNoDetach) { | 362 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, CrossSiteNoDetach) { |
| 363 host_resolver()->AddRule("*", "127.0.0.1"); | 363 host_resolver()->AddRule("*", "127.0.0.1"); |
| 364 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 364 ASSERT_TRUE(embedded_test_server()->Start()); |
| 365 content::SetupCrossSiteRedirector(embedded_test_server()); | 365 content::SetupCrossSiteRedirector(embedded_test_server()); |
| 366 | 366 |
| 367 GURL test_url1 = embedded_test_server()->GetURL( | 367 GURL test_url1 = embedded_test_server()->GetURL( |
| 368 "A.com", "/devtools/navigation.html"); | 368 "A.com", "/devtools/navigation.html"); |
| 369 NavigateToURLBlockUntilNavigationsComplete(shell(), test_url1, 1); | 369 NavigateToURLBlockUntilNavigationsComplete(shell(), test_url1, 1); |
| 370 Attach(); | 370 Attach(); |
| 371 | 371 |
| 372 GURL test_url2 = embedded_test_server()->GetURL( | 372 GURL test_url2 = embedded_test_server()->GetURL( |
| 373 "B.com", "/devtools/navigation.html"); | 373 "B.com", "/devtools/navigation.html"); |
| 374 NavigateToURLBlockUntilNavigationsComplete(shell(), test_url2, 1); | 374 NavigateToURLBlockUntilNavigationsComplete(shell(), test_url2, 1); |
| 375 | 375 |
| 376 EXPECT_EQ(0u, notifications_.size()); | 376 EXPECT_EQ(0u, notifications_.size()); |
| 377 } | 377 } |
| 378 | 378 |
| 379 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, ReconnectPreservesState) { | 379 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, ReconnectPreservesState) { |
| 380 ASSERT_TRUE(test_server()->Start()); | 380 ASSERT_TRUE(embedded_test_server()->Start()); |
| 381 GURL test_url = test_server()->GetURL("files/devtools/navigation.html"); | 381 GURL test_url = embedded_test_server()->GetURL("/devtools/navigation.html"); |
| 382 NavigateToURLBlockUntilNavigationsComplete(shell(), test_url, 1); | 382 NavigateToURLBlockUntilNavigationsComplete(shell(), test_url, 1); |
| 383 | 383 |
| 384 Shell* second = CreateBrowser(); | 384 Shell* second = CreateBrowser(); |
| 385 NavigateToURLBlockUntilNavigationsComplete(second, test_url, 1); | 385 NavigateToURLBlockUntilNavigationsComplete(second, test_url, 1); |
| 386 | 386 |
| 387 Attach(); | 387 Attach(); |
| 388 SendCommand("Runtime.enable", nullptr); | 388 SendCommand("Runtime.enable", nullptr); |
| 389 | 389 |
| 390 agent_host_->DisconnectWebContents(); | 390 agent_host_->DisconnectWebContents(); |
| 391 agent_host_->ConnectWebContents(second->web_contents()); | 391 agent_host_->ConnectWebContents(second->web_contents()); |
| 392 WaitForNotification("Runtime.executionContextsCleared"); | 392 WaitForNotification("Runtime.executionContextsCleared"); |
| 393 } | 393 } |
| 394 | 394 |
| 395 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, CrossSitePauseInBeforeUnload) { | 395 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, CrossSitePauseInBeforeUnload) { |
| 396 host_resolver()->AddRule("*", "127.0.0.1"); | 396 host_resolver()->AddRule("*", "127.0.0.1"); |
| 397 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 397 ASSERT_TRUE(embedded_test_server()->Start()); |
| 398 content::SetupCrossSiteRedirector(embedded_test_server()); | 398 content::SetupCrossSiteRedirector(embedded_test_server()); |
| 399 | 399 |
| 400 NavigateToURLBlockUntilNavigationsComplete(shell(), | 400 NavigateToURLBlockUntilNavigationsComplete(shell(), |
| 401 embedded_test_server()->GetURL("A.com", "/devtools/navigation.html"), 1); | 401 embedded_test_server()->GetURL("A.com", "/devtools/navigation.html"), 1); |
| 402 Attach(); | 402 Attach(); |
| 403 SendCommand("Debugger.enable", nullptr); | 403 SendCommand("Debugger.enable", nullptr); |
| 404 | 404 |
| 405 ASSERT_TRUE(content::ExecuteScript( | 405 ASSERT_TRUE(content::ExecuteScript( |
| 406 shell()->web_contents(), | 406 shell()->web_contents(), |
| 407 "window.onbeforeunload = function() { debugger; return null; }")); | 407 "window.onbeforeunload = function() { debugger; return null; }")); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 // original tab. | 464 // original tab. |
| 465 success = false; | 465 success = false; |
| 466 EXPECT_TRUE(ExecuteScriptAndExtractBool(shell()->web_contents(), | 466 EXPECT_TRUE(ExecuteScriptAndExtractBool(shell()->web_contents(), |
| 467 "window.domAutomationController.send(" | 467 "window.domAutomationController.send(" |
| 468 " !!window.open('', 'foo'));", | 468 " !!window.open('', 'foo'));", |
| 469 &success)); | 469 &success)); |
| 470 EXPECT_TRUE(success); | 470 EXPECT_TRUE(success); |
| 471 } | 471 } |
| 472 | 472 |
| 473 } // namespace content | 473 } // namespace content |
| OLD | NEW |