| 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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 } | 234 } |
| 235 } | 235 } |
| 236 EXPECT_EQ(12, sectionCheckedCount); | 236 EXPECT_EQ(12, sectionCheckedCount); |
| 237 } | 237 } |
| 238 | 238 |
| 239 TEST_F(MHTMLTest, MHTMLFromScheme) | 239 TEST_F(MHTMLTest, MHTMLFromScheme) |
| 240 { | 240 { |
| 241 addTestResources(); | 241 addTestResources(); |
| 242 RefPtr<SharedBuffer> data = serialize("Test Serialization", "text/html", MHT
MLArchive::UseDefaultEncoding); | 242 RefPtr<SharedBuffer> data = serialize("Test Serialization", "text/html", MHT
MLArchive::UseDefaultEncoding); |
| 243 KURL httpURL = toKURL("http://www.example.com"); | 243 KURL httpURL = toKURL("http://www.example.com"); |
| 244 KURL contentURL = toKURL("content://foo"); |
| 244 KURL fileURL = toKURL("file://foo"); | 245 KURL fileURL = toKURL("file://foo"); |
| 245 KURL specialSchemeURL = toKURL("fooscheme://bar"); | 246 KURL specialSchemeURL = toKURL("fooscheme://bar"); |
| 246 | 247 |
| 247 // MHTMLArchives can only be initialized from local schemes and http/https s
chemes. | 248 // MHTMLArchives can only be initialized from local schemes, http/https sche
mes, and content scheme(Android specific). |
| 248 EXPECT_NE(nullptr, MHTMLArchive::create(httpURL, data.get())); | 249 EXPECT_NE(nullptr, MHTMLArchive::create(httpURL, data.get())); |
| 250 #if OS(ANDROID) |
| 251 EXPECT_NE(nullptr, MHTMLArchive::create(contentURL, data.get())); |
| 252 #else |
| 253 EXPECT_EQ(nullptr, MHTMLArchive::create(contentURL, data.get())); |
| 254 #endif |
| 249 EXPECT_NE(nullptr, MHTMLArchive::create(fileURL, data.get())); | 255 EXPECT_NE(nullptr, MHTMLArchive::create(fileURL, data.get())); |
| 250 EXPECT_EQ(nullptr, MHTMLArchive::create(specialSchemeURL, data.get())); | 256 EXPECT_EQ(nullptr, MHTMLArchive::create(specialSchemeURL, data.get())); |
| 251 SchemeRegistry::registerURLSchemeAsLocal("fooscheme"); | 257 SchemeRegistry::registerURLSchemeAsLocal("fooscheme"); |
| 252 EXPECT_NE(nullptr, MHTMLArchive::create(specialSchemeURL, data.get())); | 258 EXPECT_NE(nullptr, MHTMLArchive::create(specialSchemeURL, data.get())); |
| 253 } | 259 } |
| 254 | 260 |
| 255 // Checks that full sandboxing protection has been turned on. | 261 // Checks that full sandboxing protection has been turned on. |
| 256 TEST_F(MHTMLTest, EnforceSandboxFlags) | 262 TEST_F(MHTMLTest, EnforceSandboxFlags) |
| 257 { | 263 { |
| 258 const char kURL[] = "http://www.example.com"; | 264 const char kURL[] = "http://www.example.com"; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 270 EXPECT_TRUE(document->isSandboxed(SandboxAll)); | 276 EXPECT_TRUE(document->isSandboxed(SandboxAll)); |
| 271 | 277 |
| 272 // MHTML document should be loaded into unique origin. | 278 // MHTML document should be loaded into unique origin. |
| 273 EXPECT_TRUE(document->getSecurityOrigin()->isUnique()); | 279 EXPECT_TRUE(document->getSecurityOrigin()->isUnique()); |
| 274 // Script execution should be disabled. | 280 // Script execution should be disabled. |
| 275 EXPECT_FALSE(frame->script().canExecuteScripts(NotAboutToExecuteScript)); | 281 EXPECT_FALSE(frame->script().canExecuteScripts(NotAboutToExecuteScript)); |
| 276 } | 282 } |
| 277 | 283 |
| 278 | 284 |
| 279 } // namespace blink | 285 } // namespace blink |
| OLD | NEW |