test_fetch-chrome.js 908 B

12345678910111213141516171819202122232425262728293031
  1. /* Any copyright is dedicated to the Public Domain.
  2. http://creativecommons.org/publicdomain/zero/1.0/ */
  3. "use strict";
  4. // Tests for DevToolsUtils.fetch on chrome:// URI's.
  5. const URL_FOUND = "chrome://devtools-shared/locale/debugger.properties";
  6. const URL_NOT_FOUND = "chrome://this/is/not/here.js";
  7. /**
  8. * Test that non-existent files are handled correctly.
  9. */
  10. add_task(function* test_missing() {
  11. yield DevToolsUtils.fetch(URL_NOT_FOUND).then(result => {
  12. do_print(result);
  13. ok(false, "fetch resolved unexpectedly for non-existent chrome:// URI");
  14. }, () => {
  15. ok(true, "fetch rejected as the chrome:// URI was non-existent.");
  16. });
  17. });
  18. /**
  19. * Tests that existing files are handled correctly.
  20. */
  21. add_task(function* test_normal() {
  22. yield DevToolsUtils.fetch(URL_FOUND).then(result => {
  23. notDeepEqual(result.content, "",
  24. "chrome:// URI seems to be read correctly.");
  25. });
  26. });