LoadTainting.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef mozilla_LoadTainting_h
  6. #define mozilla_LoadTainting_h
  7. namespace mozilla {
  8. // Define an enumeration to reflect the concept of response tainting from the
  9. // the fetch spec:
  10. //
  11. // https://fetch.spec.whatwg.org/#concept-request-response-tainting
  12. //
  13. // Roughly the tainting means:
  14. //
  15. // * Basic: the request resulted in a same-origin or non-http load
  16. // * CORS: the request resulted in a cross-origin load with CORS headers
  17. // * Opaque: the request resulted in a cross-origin load without CORS headers
  18. //
  19. // The enumeration is purposefully designed such that more restrictive tainting
  20. // corresponds to a higher integral value.
  21. //
  22. // NOTE: Checking the tainting is not currently adequate. You *must* still
  23. // check the final URL and CORS mode on the channel.
  24. //
  25. // These values are currently only set on the channel LoadInfo when the request
  26. // was initiated through fetch() or when a service worker interception occurs.
  27. // In the future we should set the tainting value within necko so that it is
  28. // consistently applied. Once that is done consumers can replace checks against
  29. // the final URL and CORS mode with checks against tainting.
  30. enum class LoadTainting : uint8_t
  31. {
  32. Basic = 0,
  33. CORS = 1,
  34. Opaque = 2
  35. };
  36. } // namespace mozilla
  37. #endif // mozilla_LoadTainting_h