TestOriginAttributes.cpp 994 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. #include "gtest/gtest.h"
  5. #include "mozilla/BasePrincipal.h"
  6. using mozilla::PrincipalOriginAttributes;
  7. static void
  8. TestSuffix(const PrincipalOriginAttributes& attrs)
  9. {
  10. nsAutoCString suffix;
  11. attrs.CreateSuffix(suffix);
  12. PrincipalOriginAttributes attrsFromSuffix;
  13. bool success = attrsFromSuffix.PopulateFromSuffix(suffix);
  14. EXPECT_TRUE(success);
  15. EXPECT_EQ(attrs, attrsFromSuffix);
  16. }
  17. TEST(PrincipalOriginAttributes, Suffix_default)
  18. {
  19. PrincipalOriginAttributes attrs;
  20. TestSuffix(attrs);
  21. }
  22. TEST(PrincipalOriginAttributes, Suffix_appId_inIsolatedMozBrowser)
  23. {
  24. PrincipalOriginAttributes attrs(1, true);
  25. TestSuffix(attrs);
  26. }
  27. TEST(PrincipalOriginAttributes, Suffix_maxAppId_inIsolatedMozBrowser)
  28. {
  29. PrincipalOriginAttributes attrs(4294967295, true);
  30. TestSuffix(attrs);
  31. }