OLD | NEW |
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 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 EXPECT_FALSE(origin->isSameSchemeHostPortAndSuborigin(other2.get())); | 327 EXPECT_FALSE(origin->isSameSchemeHostPortAndSuborigin(other2.get())); |
328 EXPECT_FALSE(origin->isSameSchemeHostPortAndSuborigin(other3.get())); | 328 EXPECT_FALSE(origin->isSameSchemeHostPortAndSuborigin(other3.get())); |
329 EXPECT_FALSE(origin->isSameSchemeHostPortAndSuborigin(other4.get())); | 329 EXPECT_FALSE(origin->isSameSchemeHostPortAndSuborigin(other4.get())); |
330 } | 330 } |
331 | 331 |
332 TEST_F(SecurityOriginTest, CanAccess) { | 332 TEST_F(SecurityOriginTest, CanAccess) { |
333 RuntimeEnabledFeatures::setSuboriginsEnabled(true); | 333 RuntimeEnabledFeatures::setSuboriginsEnabled(true); |
334 | 334 |
335 struct TestCase { | 335 struct TestCase { |
336 bool canAccess; | 336 bool canAccess; |
337 bool canAccessCheckSuborigins; | |
338 const char* origin1; | 337 const char* origin1; |
339 const char* origin2; | 338 const char* origin2; |
340 }; | 339 }; |
341 | 340 |
342 TestCase tests[] = { | 341 TestCase tests[] = { |
343 {true, true, "https://foobar.com", "https://foobar.com"}, | 342 {true, "https://foobar.com", "https://foobar.com"}, |
344 {false, false, "https://foobar.com", "https://bazbar.com"}, | 343 {false, "https://foobar.com", "https://bazbar.com"}, |
345 {true, false, "https://foobar.com", "https-so://name.foobar.com"}, | 344 {false, "https://foobar.com", "https-so://name.foobar.com"}, |
346 {true, false, "https-so://name.foobar.com", "https://foobar.com"}, | 345 {false, "https-so://name.foobar.com", "https://foobar.com"}, |
347 {true, true, "https-so://name.foobar.com", "https-so://name.foobar.com"}, | 346 {true, "https-so://name.foobar.com", "https-so://name.foobar.com"}, |
348 }; | 347 }; |
349 | 348 |
350 for (size_t i = 0; i < WTF_ARRAY_LENGTH(tests); ++i) { | 349 for (size_t i = 0; i < WTF_ARRAY_LENGTH(tests); ++i) { |
351 RefPtr<SecurityOrigin> origin1 = | 350 RefPtr<SecurityOrigin> origin1 = |
352 SecurityOrigin::createFromString(tests[i].origin1); | 351 SecurityOrigin::createFromString(tests[i].origin1); |
353 RefPtr<SecurityOrigin> origin2 = | 352 RefPtr<SecurityOrigin> origin2 = |
354 SecurityOrigin::createFromString(tests[i].origin2); | 353 SecurityOrigin::createFromString(tests[i].origin2); |
355 EXPECT_EQ(tests[i].canAccess, origin1->canAccess(origin2.get())); | 354 EXPECT_EQ(tests[i].canAccess, origin1->canAccess(origin2.get())); |
356 EXPECT_EQ(tests[i].canAccessCheckSuborigins, | |
357 origin1->canAccessCheckSuborigins(origin2.get())); | |
358 } | 355 } |
359 } | 356 } |
360 | 357 |
361 TEST_F(SecurityOriginTest, CanRequest) { | 358 TEST_F(SecurityOriginTest, CanRequest) { |
362 RuntimeEnabledFeatures::setSuboriginsEnabled(true); | 359 RuntimeEnabledFeatures::setSuboriginsEnabled(true); |
363 | 360 |
364 struct TestCase { | 361 struct TestCase { |
365 bool canRequest; | 362 bool canRequest; |
366 bool canRequestNoSuborigin; | 363 bool canRequestNoSuborigin; |
367 const char* origin; | 364 const char* origin; |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 SCOPED_TRACE(testing::Message() << "raw host: '" << test.host << "'"); | 519 SCOPED_TRACE(testing::Message() << "raw host: '" << test.host << "'"); |
523 String host = String::fromUTF8(test.host); | 520 String host = String::fromUTF8(test.host); |
524 bool success = false; | 521 bool success = false; |
525 String canonicalHost = SecurityOrigin::canonicalizeHost(host, &success); | 522 String canonicalHost = SecurityOrigin::canonicalizeHost(host, &success); |
526 EXPECT_EQ(test.canonicalOutput, canonicalHost); | 523 EXPECT_EQ(test.canonicalOutput, canonicalHost); |
527 EXPECT_EQ(test.expectedSuccess, success); | 524 EXPECT_EQ(test.expectedSuccess, success); |
528 } | 525 } |
529 } | 526 } |
530 | 527 |
531 } // namespace blink | 528 } // namespace blink |
OLD | NEW |