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

Unified Diff: media/blink/buffered_data_source_unittest.cc

Issue 1356353003: Relax cross-origin partial response requirements for CORS presence. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert accidental php change. Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: media/blink/buffered_data_source_unittest.cc
diff --git a/media/blink/buffered_data_source_unittest.cc b/media/blink/buffered_data_source_unittest.cc
index 878d5f7ea007d663509dca2b131239f303645ad0..aed8453eba0dc1020438c91ed5aa6105839474e3 100644
--- a/media/blink/buffered_data_source_unittest.cc
+++ b/media/blink/buffered_data_source_unittest.cc
@@ -51,11 +51,12 @@ class MockBufferedDataSource : public BufferedDataSource {
public:
MockBufferedDataSource(
const GURL& url,
+ BufferedResourceLoader::CORSMode cors_mode,
const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
WebLocalFrame* frame,
BufferedDataSourceHost* host)
: BufferedDataSource(url,
- BufferedResourceLoader::kUnspecified,
+ cors_mode,
task_runner,
frame,
new media::MediaLog(),
@@ -128,13 +129,13 @@ class BufferedDataSourceTest : public testing::Test {
MOCK_METHOD1(OnInitialize, void(bool));
- void Initialize(const char* url, bool expected) {
+ void InitializeWithCORS(const char* url,
+ bool expected,
+ BufferedResourceLoader::CORSMode cors_mode) {
GURL gurl(url);
- data_source_.reset(
- new MockBufferedDataSource(gurl,
- message_loop_.task_runner(),
- view_->mainFrame()->toWebLocalFrame(),
- &host_));
+ data_source_.reset(new MockBufferedDataSource(
+ gurl, cors_mode, message_loop_.task_runner(),
+ view_->mainFrame()->toWebLocalFrame(), &host_));
data_source_->SetPreload(preload_);
response_generator_.reset(new TestResponseGenerator(gurl, kFileSize));
@@ -148,6 +149,10 @@ class BufferedDataSourceTest : public testing::Test {
EXPECT_EQ(data_source_->downloading(), is_http);
}
+ void Initialize(const char* url, bool expected) {
+ InitializeWithCORS(url, expected, BufferedResourceLoader::kUnspecified);
+ }
+
// Helper to initialize tests with a valid 200 response.
void InitializeWith200Response() {
Initialize(kHttpUrl, true);
@@ -577,6 +582,20 @@ TEST_F(BufferedDataSourceTest,
ExecuteMixedResponseFailureTest(response1, response2);
}
+TEST_F(BufferedDataSourceTest,
+ Http_MixedResponse_ServiceWorkerProxiedAndDifferentOriginResponseCORS) {
+ InitializeWithCORS(kHttpUrl, true, BufferedResourceLoader::kAnonymous);
+ WebURLResponse response1 =
+ response_generator_->GeneratePartial206(0, kDataSize - 1);
+ response1.setWasFetchedViaServiceWorker(true);
+ response1.setOriginalURLViaServiceWorker(GURL(kHttpDifferentOriginUrl));
+ WebURLResponse response2 =
+ response_generator_->GeneratePartial206(kDataSize, kDataSize * 2 - 1);
+ // The origin URL of response1 and response2 are different, but a CORS check
+ // has been passed for each request, so expect success.
+ ExecuteMixedResponseSuccessTest(response1, response2);
+}
+
TEST_F(BufferedDataSourceTest, File_Retry) {
InitializeWithFileResponse();
« no previous file with comments | « media/blink/buffered_data_source.cc ('k') | third_party/WebKit/LayoutTests/http/tests/media/mixed-range-response.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698