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

Side by Side Diff: Source/platform/network/ResourceRequestTest.cpp

Issue 1071893003: WebURLRequest: Track the requesting document's URL through navigations. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Ugh. Created 5 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 | Annotate | Revision Log
« no previous file with comments | « Source/platform/network/ResourceRequest.cpp ('k') | public/platform/WebURLRequest.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "config.h" 5 #include "config.h"
6 #include "ResourceRequest.h" 6 #include "ResourceRequest.h"
7 7
8 #include "platform/network/FormData.h" 8 #include "platform/network/FormData.h"
9 #include "platform/weborigin/KURL.h" 9 #include "platform/weborigin/KURL.h"
10 #include "platform/weborigin/Referrer.h" 10 #include "platform/weborigin/Referrer.h"
11 #include "public/platform/WebURLRequest.h" 11 #include "public/platform/WebURLRequest.h"
12 #include "wtf/text/AtomicString.h" 12 #include "wtf/text/AtomicString.h"
13 #include <gtest/gtest.h> 13 #include <gtest/gtest.h>
14 14
15 namespace blink { 15 namespace blink {
16 16
17 TEST(ResourceRequestTest, CrossThreadResourceRequestData) 17 TEST(ResourceRequestTest, CrossThreadResourceRequestData)
18 { 18 {
19 ResourceRequest original; 19 ResourceRequest original;
20 original.setURL(KURL(ParsedURLString, "http://www.example.com/test.htm")); 20 original.setURL(KURL(ParsedURLString, "http://www.example.com/test.htm"));
21 original.setCachePolicy(UseProtocolCachePolicy); 21 original.setCachePolicy(UseProtocolCachePolicy);
22 original.setTimeoutInterval(10); 22 original.setTimeoutInterval(10);
23 original.setFirstPartyForCookies(KURL(ParsedURLString, "http://www.example.c om/first_party.htm")); 23 original.setFirstPartyForCookies(KURL(ParsedURLString, "http://www.example.c om/first_party.htm"));
24 original.setRequestorOrigin(SecurityOrigin::create(KURL(ParsedURLString, "ht tp://www.example.com/first_party.htm")));
24 original.setHTTPMethod(AtomicString("GET", AtomicString::ConstructFromLitera l)); 25 original.setHTTPMethod(AtomicString("GET", AtomicString::ConstructFromLitera l));
25 original.setHTTPHeaderField(AtomicString("Foo"), AtomicString("Bar")); 26 original.setHTTPHeaderField(AtomicString("Foo"), AtomicString("Bar"));
26 original.setHTTPHeaderField(AtomicString("Piyo"), AtomicString("Fuga")); 27 original.setHTTPHeaderField(AtomicString("Piyo"), AtomicString("Fuga"));
27 original.setPriority(ResourceLoadPriorityLow, 20); 28 original.setPriority(ResourceLoadPriorityLow, 20);
28 29
29 RefPtr<FormData> originalBody(FormData::create("Test Body")); 30 RefPtr<FormData> originalBody(FormData::create("Test Body"));
30 original.setHTTPBody(originalBody); 31 original.setHTTPBody(originalBody);
31 original.setAllowStoredCredentials(false); 32 original.setAllowStoredCredentials(false);
32 original.setReportUploadProgress(false); 33 original.setReportUploadProgress(false);
33 original.setHasUserGesture(false); 34 original.setHasUserGesture(false);
34 original.setDownloadToFile(false); 35 original.setDownloadToFile(false);
35 original.setSkipServiceWorker(false); 36 original.setSkipServiceWorker(false);
36 original.setFetchRequestMode(WebURLRequest::FetchRequestModeCORS); 37 original.setFetchRequestMode(WebURLRequest::FetchRequestModeCORS);
37 original.setFetchCredentialsMode(WebURLRequest::FetchCredentialsModeSameOrig in); 38 original.setFetchCredentialsMode(WebURLRequest::FetchCredentialsModeSameOrig in);
38 original.setRequestorID(30); 39 original.setRequestorID(30);
39 original.setRequestorProcessID(40); 40 original.setRequestorProcessID(40);
40 original.setAppCacheHostID(50); 41 original.setAppCacheHostID(50);
41 original.setRequestContext(WebURLRequest::RequestContextAudio); 42 original.setRequestContext(WebURLRequest::RequestContextAudio);
42 original.setFrameType(WebURLRequest::FrameTypeNested); 43 original.setFrameType(WebURLRequest::FrameTypeNested);
43 original.setHTTPReferrer(Referrer("http://www.example.com/referrer.htm", Ref errerPolicyDefault)); 44 original.setHTTPReferrer(Referrer("http://www.example.com/referrer.htm", Ref errerPolicyDefault));
44 45
45 EXPECT_STREQ("http://www.example.com/test.htm", original.url().string().utf8 ().data()); 46 EXPECT_STREQ("http://www.example.com/test.htm", original.url().string().utf8 ().data());
46 EXPECT_EQ(UseProtocolCachePolicy, original.cachePolicy()); 47 EXPECT_EQ(UseProtocolCachePolicy, original.cachePolicy());
47 EXPECT_EQ(10, original.timeoutInterval()); 48 EXPECT_EQ(10, original.timeoutInterval());
48 EXPECT_STREQ("http://www.example.com/first_party.htm", original.firstPartyFo rCookies().string().utf8().data()); 49 EXPECT_STREQ("http://www.example.com/first_party.htm", original.firstPartyFo rCookies().string().utf8().data());
50 EXPECT_STREQ("www.example.com", original.requestorOrigin()->host().utf8().da ta());
49 EXPECT_STREQ("GET", original.httpMethod().utf8().data()); 51 EXPECT_STREQ("GET", original.httpMethod().utf8().data());
50 EXPECT_STREQ("Bar", original.httpHeaderFields().get("Foo").utf8().data()); 52 EXPECT_STREQ("Bar", original.httpHeaderFields().get("Foo").utf8().data());
51 EXPECT_STREQ("Fuga", original.httpHeaderFields().get("Piyo").utf8().data()); 53 EXPECT_STREQ("Fuga", original.httpHeaderFields().get("Piyo").utf8().data());
52 EXPECT_EQ(ResourceLoadPriorityLow, original.priority()); 54 EXPECT_EQ(ResourceLoadPriorityLow, original.priority());
53 EXPECT_STREQ("Test Body", original.httpBody()->flattenToString().utf8().data ()); 55 EXPECT_STREQ("Test Body", original.httpBody()->flattenToString().utf8().data ());
54 EXPECT_FALSE(original.allowStoredCredentials()); 56 EXPECT_FALSE(original.allowStoredCredentials());
55 EXPECT_FALSE(original.reportUploadProgress()); 57 EXPECT_FALSE(original.reportUploadProgress());
56 EXPECT_FALSE(original.hasUserGesture()); 58 EXPECT_FALSE(original.hasUserGesture());
57 EXPECT_FALSE(original.downloadToFile()); 59 EXPECT_FALSE(original.downloadToFile());
58 EXPECT_FALSE(original.skipServiceWorker()); 60 EXPECT_FALSE(original.skipServiceWorker());
59 EXPECT_EQ(WebURLRequest::FetchRequestModeCORS, original.fetchRequestMode()); 61 EXPECT_EQ(WebURLRequest::FetchRequestModeCORS, original.fetchRequestMode());
60 EXPECT_EQ(WebURLRequest::FetchCredentialsModeSameOrigin, original.fetchCrede ntialsMode()); 62 EXPECT_EQ(WebURLRequest::FetchCredentialsModeSameOrigin, original.fetchCrede ntialsMode());
61 EXPECT_EQ(30, original.requestorID()); 63 EXPECT_EQ(30, original.requestorID());
62 EXPECT_EQ(40, original.requestorProcessID()); 64 EXPECT_EQ(40, original.requestorProcessID());
63 EXPECT_EQ(50, original.appCacheHostID()); 65 EXPECT_EQ(50, original.appCacheHostID());
64 EXPECT_EQ(WebURLRequest::RequestContextAudio, original.requestContext()); 66 EXPECT_EQ(WebURLRequest::RequestContextAudio, original.requestContext());
65 EXPECT_EQ(WebURLRequest::FrameTypeNested, original.frameType()); 67 EXPECT_EQ(WebURLRequest::FrameTypeNested, original.frameType());
66 EXPECT_STREQ("http://www.example.com/referrer.htm", original.httpReferrer(). utf8().data()); 68 EXPECT_STREQ("http://www.example.com/referrer.htm", original.httpReferrer(). utf8().data());
67 EXPECT_EQ(ReferrerPolicyDefault, original.referrerPolicy()); 69 EXPECT_EQ(ReferrerPolicyDefault, original.referrerPolicy());
68 70
69 OwnPtr<CrossThreadResourceRequestData> data1(original.copyData()); 71 OwnPtr<CrossThreadResourceRequestData> data1(original.copyData());
70 OwnPtr<ResourceRequest> copy1(ResourceRequest::adopt(data1.release())); 72 OwnPtr<ResourceRequest> copy1(ResourceRequest::adopt(data1.release()));
71 73
72 EXPECT_STREQ("http://www.example.com/test.htm", copy1->url().string().utf8() .data()); 74 EXPECT_STREQ("http://www.example.com/test.htm", copy1->url().string().utf8() .data());
73 EXPECT_EQ(UseProtocolCachePolicy, copy1->cachePolicy()); 75 EXPECT_EQ(UseProtocolCachePolicy, copy1->cachePolicy());
74 EXPECT_EQ(10, copy1->timeoutInterval()); 76 EXPECT_EQ(10, copy1->timeoutInterval());
75 EXPECT_STREQ("http://www.example.com/first_party.htm", copy1->firstPartyForC ookies().string().utf8().data()); 77 EXPECT_STREQ("http://www.example.com/first_party.htm", copy1->firstPartyForC ookies().string().utf8().data());
78 EXPECT_STREQ("www.example.com", copy1->requestorOrigin()->host().utf8().data ());
76 EXPECT_STREQ("GET", copy1->httpMethod().utf8().data()); 79 EXPECT_STREQ("GET", copy1->httpMethod().utf8().data());
77 EXPECT_STREQ("Bar", copy1->httpHeaderFields().get("Foo").utf8().data()); 80 EXPECT_STREQ("Bar", copy1->httpHeaderFields().get("Foo").utf8().data());
78 EXPECT_EQ(ResourceLoadPriorityLow, copy1->priority()); 81 EXPECT_EQ(ResourceLoadPriorityLow, copy1->priority());
79 EXPECT_STREQ("Test Body", copy1->httpBody()->flattenToString().utf8().data() ); 82 EXPECT_STREQ("Test Body", copy1->httpBody()->flattenToString().utf8().data() );
80 EXPECT_FALSE(copy1->allowStoredCredentials()); 83 EXPECT_FALSE(copy1->allowStoredCredentials());
81 EXPECT_FALSE(copy1->reportUploadProgress()); 84 EXPECT_FALSE(copy1->reportUploadProgress());
82 EXPECT_FALSE(copy1->hasUserGesture()); 85 EXPECT_FALSE(copy1->hasUserGesture());
83 EXPECT_FALSE(copy1->downloadToFile()); 86 EXPECT_FALSE(copy1->downloadToFile());
84 EXPECT_FALSE(copy1->skipServiceWorker()); 87 EXPECT_FALSE(copy1->skipServiceWorker());
85 EXPECT_EQ(WebURLRequest::FetchRequestModeCORS, copy1->fetchRequestMode()); 88 EXPECT_EQ(WebURLRequest::FetchRequestModeCORS, copy1->fetchRequestMode());
(...skipping 29 matching lines...) Expand all
115 { 118 {
116 ResourceRequest original; 119 ResourceRequest original;
117 EXPECT_FALSE(original.hasUserGesture()); 120 EXPECT_FALSE(original.hasUserGesture());
118 original.setHasUserGesture(true); 121 original.setHasUserGesture(true);
119 EXPECT_TRUE(original.hasUserGesture()); 122 EXPECT_TRUE(original.hasUserGesture());
120 original.setHasUserGesture(false); 123 original.setHasUserGesture(false);
121 EXPECT_TRUE(original.hasUserGesture()); 124 EXPECT_TRUE(original.hasUserGesture());
122 } 125 }
123 126
124 } // namespace blink 127 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/network/ResourceRequest.cpp ('k') | public/platform/WebURLRequest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698