| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 scoped_ptr<base::DictionaryValue> root(static_cast<base::DictionaryValue*>( | 409 scoped_ptr<base::DictionaryValue> root(static_cast<base::DictionaryValue*>( |
| 410 base::JSONReader::Read(message).release())); | 410 base::JSONReader::Read(message).release())); |
| 411 int id; | 411 int id; |
| 412 if (!root->GetInteger("id", &id)) { | 412 if (!root->GetInteger("id", &id)) { |
| 413 std::string notification; | 413 std::string notification; |
| 414 EXPECT_TRUE(root->GetString("method", ¬ification)); | 414 EXPECT_TRUE(root->GetString("method", ¬ification)); |
| 415 notifications_.push_back(notification); | 415 notifications_.push_back(notification); |
| 416 } | 416 } |
| 417 } | 417 } |
| 418 | 418 |
| 419 bool HasNotifications(const std::string& notification, int count) { | 419 int CountNotifications(const std::string& notification) { |
| 420 int result = 0; |
| 420 for (const std::string& s : notifications_) { | 421 for (const std::string& s : notifications_) { |
| 421 if (s == notification) | 422 if (s == notification) |
| 422 --count; | 423 ++result; |
| 423 } | 424 } |
| 424 return count <= 0; | 425 return result; |
| 425 } | 426 } |
| 426 | 427 |
| 427 private: | 428 private: |
| 428 DevToolsAgent* agent() { | 429 DevToolsAgent* agent() { |
| 429 return frame()->devtools_agent(); | 430 return frame()->devtools_agent(); |
| 430 } | 431 } |
| 431 | 432 |
| 432 std::vector<std::string> notifications_; | 433 std::vector<std::string> notifications_; |
| 433 }; | 434 }; |
| 434 | 435 |
| (...skipping 1941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2376 base::ThreadTaskRunnerHandle::Get()->PostTask( | 2377 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 2377 FROM_HERE, | 2378 FROM_HERE, |
| 2378 base::Bind(&DevToolsAgentTest::CloseWhilePaused, base::Unretained(this))); | 2379 base::Bind(&DevToolsAgentTest::CloseWhilePaused, base::Unretained(this))); |
| 2379 ExecuteJavaScriptForTests("debugger;"); | 2380 ExecuteJavaScriptForTests("debugger;"); |
| 2380 | 2381 |
| 2381 // CloseWhilePaused should resume execution and continue here. | 2382 // CloseWhilePaused should resume execution and continue here. |
| 2382 EXPECT_FALSE(IsPaused()); | 2383 EXPECT_FALSE(IsPaused()); |
| 2383 Detach(); | 2384 Detach(); |
| 2384 } | 2385 } |
| 2385 | 2386 |
| 2386 TEST_F(DevToolsAgentTest, RuntimeEnableForcesMainContext) { | 2387 TEST_F(DevToolsAgentTest, RuntimeEnableForcesContexts) { |
| 2387 LoadHTML(""); | 2388 LoadHTML("<body>page<iframe></iframe></body>"); |
| 2388 Attach(); | 2389 Attach(); |
| 2389 DispatchDevToolsMessage("{\"id\":1,\"method\":\"Runtime.enable\"}"); | 2390 DispatchDevToolsMessage("{\"id\":1,\"method\":\"Runtime.enable\"}"); |
| 2390 EXPECT_TRUE(HasNotifications("Runtime.executionContextCreated", 1)); | 2391 EXPECT_EQ(2, CountNotifications("Runtime.executionContextCreated")); |
| 2391 } | 2392 } |
| 2392 | 2393 |
| 2393 TEST_F(DevToolsAgentTest, RuntimeEnableForcesContextsAfterNavigation) { | 2394 TEST_F(DevToolsAgentTest, RuntimeEnableForcesContextsAfterNavigation) { |
| 2394 Attach(); | 2395 Attach(); |
| 2395 DispatchDevToolsMessage("{\"id\":1,\"method\":\"Runtime.enable\"}"); | 2396 DispatchDevToolsMessage("{\"id\":1,\"method\":\"Runtime.enable\"}"); |
| 2396 EXPECT_FALSE(HasNotifications("Runtime.executionContextCreated", 1)); | 2397 EXPECT_EQ(0, CountNotifications("Runtime.executionContextCreated")); |
| 2397 LoadHTML("<body>page<iframe></iframe></body>"); | 2398 LoadHTML("<body>page<iframe></iframe></body>"); |
| 2398 EXPECT_TRUE(HasNotifications("Runtime.executionContextCreated", 2)); | 2399 EXPECT_EQ(2, CountNotifications("Runtime.executionContextCreated")); |
| 2399 } | 2400 } |
| 2400 | 2401 |
| 2401 } // namespace content | 2402 } // namespace content |
| OLD | NEW |