| OLD | NEW |
| 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 "platform/network/HTTPParsers.h" | 5 #include "platform/network/HTTPParsers.h" |
| 6 | 6 |
| 7 #include "platform/heap/Handle.h" | 7 #include "platform/heap/Handle.h" |
| 8 #include "platform/weborigin/Suborigin.h" | 8 #include "platform/weborigin/Suborigin.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "wtf/MathExtras.h" | 10 #include "wtf/MathExtras.h" |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 EXPECT_FALSE(blink::isValidHTTPFieldContentRFC7230(String("t\0t", 3))); | 131 EXPECT_FALSE(blink::isValidHTTPFieldContentRFC7230(String("t\0t", 3))); |
| 132 EXPECT_FALSE(blink::isValidHTTPFieldContentRFC7230(String("\0", 1))); | 132 EXPECT_FALSE(blink::isValidHTTPFieldContentRFC7230(String("\0", 1))); |
| 133 EXPECT_FALSE(blink::isValidHTTPFieldContentRFC7230(String("test \0, 6"))); | 133 EXPECT_FALSE(blink::isValidHTTPFieldContentRFC7230(String("test \0, 6"))); |
| 134 EXPECT_FALSE(blink::isValidHTTPFieldContentRFC7230(String("test "))); | 134 EXPECT_FALSE(blink::isValidHTTPFieldContentRFC7230(String("test "))); |
| 135 EXPECT_FALSE(blink::isValidHTTPFieldContentRFC7230("test\r\n data")); | 135 EXPECT_FALSE(blink::isValidHTTPFieldContentRFC7230("test\r\n data")); |
| 136 EXPECT_FALSE(blink::isValidHTTPFieldContentRFC7230(String(hiraganaA))); | 136 EXPECT_FALSE(blink::isValidHTTPFieldContentRFC7230(String(hiraganaA))); |
| 137 } | 137 } |
| 138 | 138 |
| 139 TEST(HTTPParsersTest, ExtractMIMETypeFromMediaType) | 139 TEST(HTTPParsersTest, ExtractMIMETypeFromMediaType) |
| 140 { | 140 { |
| 141 const AtomicString textHtml("text/html", AtomicString::ConstructFromLiteral)
; | 141 const AtomicString textHtml("text/html"); |
| 142 EXPECT_EQ(textHtml, extractMIMETypeFromMediaType(AtomicString("text/html; ch
arset=iso-8859-1"))); | 142 EXPECT_EQ(textHtml, extractMIMETypeFromMediaType(AtomicString("text/html; ch
arset=iso-8859-1"))); |
| 143 EXPECT_EQ(textHtml, extractMIMETypeFromMediaType(AtomicString("text/html ; c
harset=iso-8859-1"))); | 143 EXPECT_EQ(textHtml, extractMIMETypeFromMediaType(AtomicString("text/html ; c
harset=iso-8859-1"))); |
| 144 EXPECT_EQ(textHtml, extractMIMETypeFromMediaType(AtomicString("text/html,tex
t/plain"))); | 144 EXPECT_EQ(textHtml, extractMIMETypeFromMediaType(AtomicString("text/html,tex
t/plain"))); |
| 145 EXPECT_EQ(textHtml, extractMIMETypeFromMediaType(AtomicString("text/html , t
ext/plain"))); | 145 EXPECT_EQ(textHtml, extractMIMETypeFromMediaType(AtomicString("text/html , t
ext/plain"))); |
| 146 EXPECT_EQ(textHtml, extractMIMETypeFromMediaType(AtomicString("text/html\t,\
ttext/plain"))); | 146 EXPECT_EQ(textHtml, extractMIMETypeFromMediaType(AtomicString("text/html\t,\
ttext/plain"))); |
| 147 EXPECT_EQ(textHtml, extractMIMETypeFromMediaType(AtomicString(" text/html
"))); | 147 EXPECT_EQ(textHtml, extractMIMETypeFromMediaType(AtomicString(" text/html
"))); |
| 148 EXPECT_EQ(textHtml, extractMIMETypeFromMediaType(AtomicString("\ttext/html \
t"))); | 148 EXPECT_EQ(textHtml, extractMIMETypeFromMediaType(AtomicString("\ttext/html \
t"))); |
| 149 EXPECT_EQ(textHtml, extractMIMETypeFromMediaType(AtomicString("\r\ntext/html
\r\n"))); | 149 EXPECT_EQ(textHtml, extractMIMETypeFromMediaType(AtomicString("\r\ntext/html
\r\n"))); |
| 150 EXPECT_EQ(textHtml, extractMIMETypeFromMediaType(AtomicString("text/html,tex
t/plain;charset=iso-8859-1"))); | 150 EXPECT_EQ(textHtml, extractMIMETypeFromMediaType(AtomicString("text/html,tex
t/plain;charset=iso-8859-1"))); |
| 151 EXPECT_EQ(emptyString(), extractMIMETypeFromMediaType(AtomicString(", text/h
tml"))); | 151 EXPECT_EQ(emptyString(), extractMIMETypeFromMediaType(AtomicString(", text/h
tml"))); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 expectParsePolicyFail("One policy, no suborigin name", "'unsafe-postmessage-
send';"); | 271 expectParsePolicyFail("One policy, no suborigin name", "'unsafe-postmessage-
send';"); |
| 272 expectParsePolicyFail("One policy, invalid characters", "foobar 'un$afe-post
message-send';"); | 272 expectParsePolicyFail("One policy, invalid characters", "foobar 'un$afe-post
message-send';"); |
| 273 expectParsePolicyFail("One policy, caps", "foobar 'UNSAFE-POSTMESSAGE-SEND';
"); | 273 expectParsePolicyFail("One policy, caps", "foobar 'UNSAFE-POSTMESSAGE-SEND';
"); |
| 274 expectParsePolicyFail("One policy, missing first quote", "foobar unsafe-post
message-send';"); | 274 expectParsePolicyFail("One policy, missing first quote", "foobar unsafe-post
message-send';"); |
| 275 expectParsePolicyFail("One policy, missing last quote", "foobar 'unsafe-post
message-send;"); | 275 expectParsePolicyFail("One policy, missing last quote", "foobar 'unsafe-post
message-send;"); |
| 276 expectParsePolicyFail("One policy, missing semicolon at end", "foobar 'unsaf
e-postmessage-send'"); | 276 expectParsePolicyFail("One policy, missing semicolon at end", "foobar 'unsaf
e-postmessage-send'"); |
| 277 expectParsePolicyFail("Multiple policies, missing semicolon between options"
, "foobar 'unsafe-postmessage-send' 'unsafe-postmessage-send';"); | 277 expectParsePolicyFail("Multiple policies, missing semicolon between options"
, "foobar 'unsafe-postmessage-send' 'unsafe-postmessage-send';"); |
| 278 } | 278 } |
| 279 | 279 |
| 280 } // namespace blink | 280 } // namespace blink |
| OLD | NEW |