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

Unified Diff: Source/platform/weborigin/SecurityOriginTest.cpp

Issue 1309333004: Reland of Take care of a FIXME in SecurityOrigin.cpp to check the validity (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 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 | « Source/platform/weborigin/SecurityOrigin.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/weborigin/SecurityOriginTest.cpp
diff --git a/Source/platform/weborigin/SecurityOriginTest.cpp b/Source/platform/weborigin/SecurityOriginTest.cpp
index aed3b260ed5cb6baa9628213c4ca1857630892af..a4765df5969a6e0ba9eff1988a480dcbad5afc8b 100644
--- a/Source/platform/weborigin/SecurityOriginTest.cpp
+++ b/Source/platform/weborigin/SecurityOriginTest.cpp
@@ -32,6 +32,7 @@
#include "platform/weborigin/SecurityOrigin.h"
#include "platform/RuntimeEnabledFeatures.h"
+#include "platform/blob/BlobURL.h"
#include "platform/weborigin/KURL.h"
#include "platform/weborigin/SecurityPolicy.h"
#include "wtf/text/StringBuilder.h"
@@ -385,4 +386,36 @@
}
+TEST_F(SecurityOriginTest, UniquenessPropagatesToBlobUrls)
+{
+ struct TestCase {
+ const char* url;
+ bool expectedUniqueness;
+ const char* expectedOriginString;
+ } cases[] {
+ { "", true, "null" },
+ { "null", true, "null" },
+ { "data:text/plain,hello_world", true, "null" },
+ { "file:///path", false, "file://" },
+ { "filesystem:http://host/filesystem-path", false, "http://host" },
+ { "filesystem:file:///filesystem-path", false, "file://" },
+ { "filesystem:null/filesystem-path", true, "null" },
+ { "blob:http://host/blob-id", false, "http://host" },
+ { "blob:file:///blob-id", false, "file://" },
+ { "blob:null/blob-id", true, "null" },
+ };
+
+ for (const TestCase& test : cases) {
+ RefPtr<SecurityOrigin> origin = SecurityOrigin::createFromString(test.url);
+ EXPECT_EQ(test.expectedUniqueness, origin->isUnique());
+ EXPECT_EQ(test.expectedOriginString, origin->toString());
+
+ KURL blobUrl = BlobURL::createPublicURL(origin.get());
+ RefPtr<SecurityOrigin> blobUrlOrigin = SecurityOrigin::create(blobUrl);
+ EXPECT_EQ(blobUrlOrigin->isUnique(), origin->isUnique());
+ EXPECT_EQ(blobUrlOrigin->toString(), origin->toString());
+ EXPECT_EQ(blobUrlOrigin->toRawString(), origin->toRawString());
+ }
+}
+
} // namespace blink
« no previous file with comments | « Source/platform/weborigin/SecurityOrigin.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698