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

Side by Side Diff: third_party/WebKit/Source/web/tests/MHTMLTest.cpp

Issue 2247063002: Allow loading MHTML archive from content scheme (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move checks into a helper function Created 4 years, 4 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
« no previous file with comments | « third_party/WebKit/Source/platform/mhtml/MHTMLArchive.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/mhtml/MHTMLArchive.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698