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

Side by Side Diff: third_party/WebKit/Source/platform/weborigin/SecurityOriginTest.cpp

Issue 2449233002: Add suborigins to WebSecurityOrigin (Closed)
Patch Set: Rebase on ToT Created 4 years, 1 month 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 {"file", "example.com", 0, "file://"}, 422 {"file", "example.com", 0, "file://"},
423 }; 423 };
424 424
425 for (const auto& test : cases) { 425 for (const auto& test : cases) {
426 RefPtr<SecurityOrigin> origin = 426 RefPtr<SecurityOrigin> origin =
427 SecurityOrigin::create(test.scheme, test.host, test.port); 427 SecurityOrigin::create(test.scheme, test.host, test.port);
428 EXPECT_EQ(test.origin, origin->toString()) << test.origin; 428 EXPECT_EQ(test.origin, origin->toString()) << test.origin;
429 } 429 }
430 } 430 }
431 431
432 TEST_F(SecurityOriginTest, CreateFromTupleWithSuborigin) {
433 struct TestCase {
434 const char* scheme;
435 const char* host;
436 unsigned short port;
437 const char* suborigin;
438 const char* origin;
439 } cases[] = {
440 {"http", "example.com", 80, "", "http://example.com"},
441 {"http", "example.com", 81, "", "http://example.com:81"},
442 {"https", "example.com", 443, "", "https://example.com"},
443 {"https", "example.com", 444, "", "https://example.com:444"},
444 {"file", "", 0, "", "file://"},
445 {"file", "example.com", 0, "", "file://"},
446 {"http", "example.com", 80, "foobar", "http-so://foobar.example.com"},
447 {"http", "example.com", 81, "foobar", "http-so://foobar.example.com:81"},
448 {"https", "example.com", 443, "foobar", "https-so://foobar.example.com"},
449 {"https", "example.com", 444, "foobar",
450 "https-so://foobar.example.com:444"},
451 {"file", "", 0, "foobar", "file://"},
452 {"file", "example.com", 0, "foobar", "file://"},
453 };
454
455 for (const auto& test : cases) {
456 RefPtr<SecurityOrigin> origin = SecurityOrigin::create(
457 test.scheme, test.host, test.port, test.suborigin);
458 EXPECT_EQ(test.origin, origin->toString()) << test.origin;
459 }
460 }
461
432 TEST_F(SecurityOriginTest, UniquenessPropagatesToBlobUrls) { 462 TEST_F(SecurityOriginTest, UniquenessPropagatesToBlobUrls) {
433 struct TestCase { 463 struct TestCase {
434 const char* url; 464 const char* url;
435 bool expectedUniqueness; 465 bool expectedUniqueness;
436 const char* expectedOriginString; 466 const char* expectedOriginString;
437 } cases[]{ 467 } cases[]{
438 {"", true, "null"}, 468 {"", true, "null"},
439 {"null", true, "null"}, 469 {"null", true, "null"},
440 {"data:text/plain,hello_world", true, "null"}, 470 {"data:text/plain,hello_world", true, "null"},
441 {"file:///path", false, "file://"}, 471 {"file:///path", false, "file://"},
(...skipping 24 matching lines...) Expand all
466 SecurityOrigin::createFromString("http://example.com"); 496 SecurityOrigin::createFromString("http://example.com");
467 497
468 EXPECT_TRUE(uniqueOrigin->isSameSchemeHostPort(uniqueOrigin.get())); 498 EXPECT_TRUE(uniqueOrigin->isSameSchemeHostPort(uniqueOrigin.get()));
469 EXPECT_FALSE( 499 EXPECT_FALSE(
470 SecurityOrigin::createUnique()->isSameSchemeHostPort(uniqueOrigin.get())); 500 SecurityOrigin::createUnique()->isSameSchemeHostPort(uniqueOrigin.get()));
471 EXPECT_FALSE(tupleOrigin->isSameSchemeHostPort(uniqueOrigin.get())); 501 EXPECT_FALSE(tupleOrigin->isSameSchemeHostPort(uniqueOrigin.get()));
472 EXPECT_FALSE(uniqueOrigin->isSameSchemeHostPort(tupleOrigin.get())); 502 EXPECT_FALSE(uniqueOrigin->isSameSchemeHostPort(tupleOrigin.get()));
473 } 503 }
474 504
475 } // namespace blink 505 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698