| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 SecurityOrigin* origin = document->securityOrigin(); | 178 SecurityOrigin* origin = document->securityOrigin(); |
| 179 EXPECT_STRNE("localhost", origin->domain().ascii().data()); | 179 EXPECT_STRNE("localhost", origin->domain().ascii().data()); |
| 180 } | 180 } |
| 181 | 181 |
| 182 TEST_F(MHTMLTest, TestMHTMLEncoding) | 182 TEST_F(MHTMLTest, TestMHTMLEncoding) |
| 183 { | 183 { |
| 184 addTestResources(); | 184 addTestResources(); |
| 185 RefPtr<SharedBuffer> data = serialize("Test Serialization", "text/html", MH
TMLArchive::UseDefaultEncoding); | 185 RefPtr<SharedBuffer> data = serialize("Test Serialization", "text/html", MH
TMLArchive::UseDefaultEncoding); |
| 186 | 186 |
| 187 // Read the MHTML data line per line and do some pseudo-parsing to make sure
the right encoding is used for the different sections. | 187 // Read the MHTML data line per line and do some pseudo-parsing to make sure
the right encoding is used for the different sections. |
| 188 LineReader lineReader(std::string(data->data())); | 188 LineReader lineReader(std::string(data->data(), data->size())); |
| 189 int sectionCheckedCount = 0; | 189 int sectionCheckedCount = 0; |
| 190 const char* expectedEncoding = 0; | 190 const char* expectedEncoding = 0; |
| 191 std::string line; | 191 std::string line; |
| 192 while (lineReader.getNextLine(&line)) { | 192 while (lineReader.getNextLine(&line)) { |
| 193 if (line.compare(0, 13, "Content-Type:") == 0) { | 193 if (line.compare(0, 13, "Content-Type:") == 0) { |
| 194 ASSERT_FALSE(expectedEncoding); | 194 ASSERT_FALSE(expectedEncoding); |
| 195 if (line.find("multipart/related;") != std::string::npos) { | 195 if (line.find("multipart/related;") != std::string::npos) { |
| 196 // Skip this one, it's part of the MHTML header. | 196 // Skip this one, it's part of the MHTML header. |
| 197 continue; | 197 continue; |
| 198 } | 198 } |
| 199 if (line.find("text/") != std::string::npos) | 199 if (line.find("text/") != std::string::npos) |
| 200 expectedEncoding = "quoted-printable"; | 200 expectedEncoding = "quoted-printable"; |
| 201 else if (line.find("image/") != std::string::npos) | 201 else if (line.find("image/") != std::string::npos) |
| 202 expectedEncoding = "base64"; | 202 expectedEncoding = "base64"; |
| 203 else | 203 else |
| 204 FAIL() << "Unexpected Content-Type: " << line; | 204 FAIL() << "Unexpected Content-Type: " << line; |
| 205 continue; | 205 continue; |
| 206 } | 206 } |
| 207 if (line.compare(0, 26, "Content-Transfer-Encoding:") == 0) { | 207 if (line.compare(0, 26, "Content-Transfer-Encoding:") == 0) { |
| 208 ASSERT_TRUE(expectedEncoding); | 208 ASSERT_TRUE(expectedEncoding); |
| 209 EXPECT_NE(line.find(expectedEncoding), std::string::npos); | 209 EXPECT_NE(line.find(expectedEncoding), std::string::npos); |
| 210 expectedEncoding = 0; | 210 expectedEncoding = 0; |
| 211 sectionCheckedCount++; | 211 sectionCheckedCount++; |
| 212 } | 212 } |
| 213 } | 213 } |
| 214 EXPECT_EQ(12, sectionCheckedCount); | 214 EXPECT_EQ(12, sectionCheckedCount); |
| 215 } | 215 } |
| 216 | 216 |
| 217 } // namespace blink | 217 } // namespace blink |
| OLD | NEW |