Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(189)

Side by Side Diff: components/web_restrictions/browser/web_restrictions_resource_throttle_unittest.cc

Issue 2854423003: Mark a WebRestrictionsResourceThrottleTest test flaky (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/run_loop.h" 6 #include "base/run_loop.h"
7 #include "components/web_restrictions/browser/mock_web_restrictions_client.h" 7 #include "components/web_restrictions/browser/mock_web_restrictions_client.h"
8 #include "components/web_restrictions/browser/web_restrictions_client.h" 8 #include "components/web_restrictions/browser/web_restrictions_client.h"
9 #include "components/web_restrictions/browser/web_restrictions_resource_throttle .h" 9 #include "components/web_restrictions/browser/web_restrictions_resource_throttle .h"
10 #include "content/public/browser/resource_throttle.h" 10 #include "content/public/browser/resource_throttle.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 SetAuthority("Bad"); 107 SetAuthority("Bad");
108 bool defer; 108 bool defer;
109 throttle_.WillStartRequest(&defer); 109 throttle_.WillStartRequest(&defer);
110 EXPECT_TRUE(defer); 110 EXPECT_TRUE(defer);
111 run_loop_.Run(); 111 run_loop_.Run();
112 EXPECT_FALSE(delegate_.ResumeCalled()); 112 EXPECT_FALSE(delegate_.ResumeCalled());
113 EXPECT_TRUE(delegate_.CancelWithErrorCalled()); 113 EXPECT_TRUE(delegate_.CancelWithErrorCalled());
114 EXPECT_EQ(net::ERR_BLOCKED_BY_ADMINISTRATOR, delegate_.GetErrorCode()); 114 EXPECT_EQ(net::ERR_BLOCKED_BY_ADMINISTRATOR, delegate_.GetErrorCode());
115 } 115 }
116 116
117 TEST_F(WebRestrictionsResourceThrottleTest, WillStartRequest_Subresource) { 117 #if defined(OS_ANDROID)
118 // Flaky on android: https://crbug.com/718066
119 #define MAYBE_WillStartRequest_Subresource DISABLED_WillStartRequest_Subresource
120 #else
121 #define MAYBE_WillStartRequest_Subresource WillStartRequest_Subresource
122 #endif
123
124 TEST_F(WebRestrictionsResourceThrottleTest,
125 MAYBE_WillStartRequest_Subresource) {
118 // Only the main frame should be deferred. 126 // Only the main frame should be deferred.
119 // Initialization of the delegate is asynchronous, and this will only work 127 // Initialization of the delegate is asynchronous, and this will only work
120 // correctly if the provider is initialized. Run a main frame through this 128 // correctly if the provider is initialized. Run a main frame through this
121 // first to ensure that everything is initialized. 129 // first to ensure that everything is initialized.
122 StartProvider(); 130 StartProvider();
123 // Now the real test. 131 // Now the real test.
124 WebRestrictionsResourceThrottle throttle( 132 WebRestrictionsResourceThrottle throttle(
125 &provider_, GURL("http://example.com/sub"), false); 133 &provider_, GURL("http://example.com/sub"), false);
126 base::RunLoop test_run_loop; 134 base::RunLoop test_run_loop;
127 TestResourceThrottleDelegate test_delegate(test_run_loop.QuitClosure()); 135 TestResourceThrottleDelegate test_delegate(test_run_loop.QuitClosure());
(...skipping 25 matching lines...) Expand all
153 throttle_.set_delegate_for_testing(&test_delegate); 161 throttle_.set_delegate_for_testing(&test_delegate);
154 bool defer; 162 bool defer;
155 throttle_.WillRedirectRequest(redirect, &defer); 163 throttle_.WillRedirectRequest(redirect, &defer);
156 ASSERT_TRUE(defer); 164 ASSERT_TRUE(defer);
157 // If we don't wait for the callback it may happen after the exit, which 165 // If we don't wait for the callback it may happen after the exit, which
158 // results in accesses the redirect_url after the stack frame is freed. 166 // results in accesses the redirect_url after the stack frame is freed.
159 test_run_loop.Run(); 167 test_run_loop.Run();
160 } 168 }
161 169
162 } // namespace web_restrictions 170 } // namespace web_restrictions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698