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

Unified Diff: third_party/WebKit/Source/web/tests/MHTMLTest.cpp

Issue 2234543002: Allow loading MHTML archive from http/https schemes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update comments per feedback 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/platform/mhtml/MHTMLArchive.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/web/tests/MHTMLTest.cpp
diff --git a/third_party/WebKit/Source/web/tests/MHTMLTest.cpp b/third_party/WebKit/Source/web/tests/MHTMLTest.cpp
index cada31a962b31888dc24405a597260592761bc15..57d252c88d69dbe7850e2e85ad1963376b48a2f6 100644
--- a/third_party/WebKit/Source/web/tests/MHTMLTest.cpp
+++ b/third_party/WebKit/Source/web/tests/MHTMLTest.cpp
@@ -28,6 +28,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include "bindings/core/v8/ScriptController.h"
#include "core/dom/Document.h"
#include "core/frame/LocalFrame.h"
#include "core/frame/Location.h"
@@ -104,7 +105,7 @@ protected:
void registerMockedURLLoad(const std::string& url, const WebString& fileName)
{
- URLTestHelpers::registerMockedURLLoad(toKURL(url), fileName, WebString::fromUTF8("mhtml/"), WebString::fromUTF8("text/html"));
+ URLTestHelpers::registerMockedURLLoad(toKURL(url), fileName, WebString::fromUTF8("mhtml/"), WebString::fromUTF8("multipart/related"));
}
void loadURLInTopFrame(const WebURL& url)
@@ -243,12 +244,36 @@ TEST_F(MHTMLTest, MHTMLFromScheme)
KURL fileURL = toKURL("file://foo");
KURL specialSchemeURL = toKURL("fooscheme://bar");
- // MHTMLArchives can be initialized from any local scheme, but never a remote scheme.
- EXPECT_EQ(nullptr, MHTMLArchive::create(httpURL, data.get()));
+ // MHTMLArchives can only be initialized from local schemes and http/https schemes.
+ EXPECT_NE(nullptr, MHTMLArchive::create(httpURL, data.get()));
EXPECT_NE(nullptr, MHTMLArchive::create(fileURL, data.get()));
EXPECT_EQ(nullptr, MHTMLArchive::create(specialSchemeURL, data.get()));
SchemeRegistry::registerURLSchemeAsLocal("fooscheme");
EXPECT_NE(nullptr, MHTMLArchive::create(specialSchemeURL, data.get()));
}
+// Checks that full sandboxing protection has been turned on.
+TEST_F(MHTMLTest, EnforceSandboxFlags)
+{
+ const char kURL[] = "http://www.example.com";
+
+ // Register the mocked frame and load it.
+ registerMockedURLLoad(kURL, WebString::fromUTF8("simple_test.mht"));
+ loadURLInTopFrame(toKURL(kURL));
+ ASSERT_TRUE(page());
+ LocalFrame* frame = toLocalFrame(page()->mainFrame());
+ ASSERT_TRUE(frame);
+ Document* document = frame->document();
+ ASSERT_TRUE(document);
+
+ // Full sandboxing should be turned on.
+ EXPECT_TRUE(document->isSandboxed(SandboxAll));
+
+ // MHTML document should be loaded into unique origin.
+ EXPECT_TRUE(document->getSecurityOrigin()->isUnique());
+ // Script execution should be disabled.
+ EXPECT_FALSE(frame->script().canExecuteScripts(NotAboutToExecuteScript));
+}
+
+
} // namespace blink
« 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