| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "chrome/browser/extensions/extension_browsertest.h" | 9 #include "chrome/browser/extensions/extension_browsertest.h" |
| 10 #include "chrome/browser/profiles/profile_io_data.h" | 10 #include "chrome/browser/profiles/profile_io_data.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 -1, | 97 -1, |
| 98 | 98 |
| 99 // Don't use initial delay unless the last request was an error. | 99 // Don't use initial delay unless the last request was an error. |
| 100 false, | 100 false, |
| 101 }); | 101 }); |
| 102 manager->SetBackoffPolicyForTests(policy.Pass()); | 102 manager->SetBackoffPolicyForTests(policy.Pass()); |
| 103 } | 103 } |
| 104 // Requests to 127.0.0.1 bypass throttling, so set up a host resolver rule | 104 // Requests to 127.0.0.1 bypass throttling, so set up a host resolver rule |
| 105 // to use a fake domain. | 105 // to use a fake domain. |
| 106 host_resolver()->AddRule("www.example.com", "127.0.0.1"); | 106 host_resolver()->AddRule("www.example.com", "127.0.0.1"); |
| 107 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 107 ASSERT_TRUE(embedded_test_server()->Start()); |
| 108 extension_ = | 108 extension_ = |
| 109 LoadExtension(test_data_dir_.AppendASCII("extension_throttle")); | 109 LoadExtension(test_data_dir_.AppendASCII("extension_throttle")); |
| 110 ASSERT_TRUE(extension_); | 110 ASSERT_TRUE(extension_); |
| 111 } | 111 } |
| 112 | 112 |
| 113 void RunTest(const std::string& file_path, const std::string& request_url) { | 113 void RunTest(const std::string& file_path, const std::string& request_url) { |
| 114 ResultCatcher catcher; | 114 ResultCatcher catcher; |
| 115 GURL test_url = net::AppendQueryParameter( | 115 GURL test_url = net::AppendQueryParameter( |
| 116 extension_->GetResourceURL(file_path), "url", request_url); | 116 extension_->GetResourceURL(file_path), "url", request_url); |
| 117 ui_test_utils::NavigateToURL(browser(), test_url); | 117 ui_test_utils::NavigateToURL(browser(), test_url); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 ThrottleRequestDisabled) { | 231 ThrottleRequestDisabled) { |
| 232 embedded_test_server()->RegisterRequestHandler( | 232 embedded_test_server()->RegisterRequestHandler( |
| 233 base::Bind(&HandleRequest, false, false)); | 233 base::Bind(&HandleRequest, false, false)); |
| 234 ASSERT_NO_FATAL_FAILURE( | 234 ASSERT_NO_FATAL_FAILURE( |
| 235 RunTest("test_request_not_throttled.html", | 235 RunTest("test_request_not_throttled.html", |
| 236 base::StringPrintf("http://www.example.com:%d/test_throttle", | 236 base::StringPrintf("http://www.example.com:%d/test_throttle", |
| 237 embedded_test_server()->port()))); | 237 embedded_test_server()->port()))); |
| 238 } | 238 } |
| 239 | 239 |
| 240 } // namespace extensions | 240 } // namespace extensions |
| OLD | NEW |