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

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

Issue 1266963002: Correctly construct ("file", "", 0) SecurityOrigins. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@plugin
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 unified diff | Download patch
« no previous file with comments | « Source/platform/weborigin/SecurityOrigin.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) 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 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 {444, 444, "https://example.com:444"}, 355 {444, 444, "https://example.com:444"},
356 }; 356 };
357 357
358 for (const auto& test : cases) { 358 for (const auto& test : cases) {
359 RefPtr<SecurityOrigin> origin = SecurityOrigin::createFromString(test.or igin); 359 RefPtr<SecurityOrigin> origin = SecurityOrigin::createFromString(test.or igin);
360 EXPECT_EQ(test.port, origin->port()); 360 EXPECT_EQ(test.port, origin->port());
361 EXPECT_EQ(test.effectivePort, origin->effectivePort()); 361 EXPECT_EQ(test.effectivePort, origin->effectivePort());
362 } 362 }
363 } 363 }
364 364
365 TEST_F(SecurityOriginTest, CreateFromTuple)
366 {
367 struct TestCase {
368 const char* scheme;
369 const char* host;
370 unsigned short port;
371 const char* origin;
372 } cases[] = {
373 {"http", "example.com", 80, "http://example.com"},
374 {"http", "example.com", 81, "http://example.com:81"},
375 {"https", "example.com", 443, "https://example.com"},
376 {"https", "example.com", 444, "https://example.com:444"},
377 {"file", "", 0, "file://"},
378 {"file", "example.com", 0, "file://"},
jochen (gone - plz use gerrit) 2015/07/31 08:15:01 Hm, file: can have a host, no?
Mike West 2015/07/31 15:21:27 Yup. We serialize every `file:` URL as `file://` a
379 };
380
381 for (const auto& test : cases) {
382 RefPtr<SecurityOrigin> origin = SecurityOrigin::create(test.scheme, test .host, test.port);
383 EXPECT_EQ(test.origin, origin->toString()) << test.origin;
384 }
385
386 }
387
365 } // namespace blink 388 } // namespace blink
OLDNEW
« 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