browser_cmd_appcache_valid.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /* Any copyright is dedicated to the Public Domain.
  2. * http://creativecommons.org/publicdomain/zero/1.0/ */
  3. // Tests that the appcache commands works as they should
  4. const TEST_URI = "http://sub1.test2.example.com/browser/devtools/client/" +
  5. "commandline/test/browser_cmd_appcache_valid_index.html";
  6. function test() {
  7. return Task.spawn(spawnTest).then(finish, helpers.handleError);
  8. }
  9. function* spawnTest() {
  10. let options = yield helpers.openTab(TEST_URI);
  11. info("adding cache listener.");
  12. // Wait for site to be cached.
  13. yield helpers.listenOnce(gBrowser.contentWindow.applicationCache, "cached");
  14. yield helpers.openToolbar(options);
  15. // Pages containing an appcache the notification bar gives options to allow
  16. // or deny permission for the app to save data offline. Let's click Allow.
  17. let notificationID = "offline-app-requested-sub1.test2.example.com";
  18. let notification = PopupNotifications.getNotification(notificationID, gBrowser.selectedBrowser);
  19. if (notification) {
  20. info("Authorizing offline storage.");
  21. notification.mainAction.callback();
  22. } else {
  23. info("No notification box is available.");
  24. }
  25. info("Site now cached, running tests.");
  26. yield helpers.audit(options, [
  27. {
  28. setup: "appcache",
  29. check: {
  30. input: "appcache",
  31. markup: "IIIIIIII",
  32. status: "ERROR",
  33. args: {}
  34. },
  35. },
  36. {
  37. setup: function () {
  38. Services.prefs.setBoolPref("browser.cache.disk.enable", false);
  39. return helpers.setInput(options, "appcache list", 13);
  40. },
  41. check: {
  42. input: "appcache list",
  43. markup: "VVVVVVVVVVVVV",
  44. status: "VALID",
  45. args: {},
  46. },
  47. exec: {
  48. output: [ /cache is disabled/ ]
  49. },
  50. post: function (output) {
  51. Services.prefs.setBoolPref("browser.cache.disk.enable", true);
  52. }
  53. },
  54. {
  55. setup: "appcache list",
  56. check: {
  57. input: "appcache list",
  58. markup: "VVVVVVVVVVVVV",
  59. status: "VALID",
  60. args: {},
  61. },
  62. exec: {
  63. output: [ /index/, /page1/, /page2/, /page3/ ]
  64. },
  65. },
  66. {
  67. setup: "appcache list page",
  68. check: {
  69. input: "appcache list page",
  70. markup: "VVVVVVVVVVVVVVVVVV",
  71. status: "VALID",
  72. args: {
  73. search: { value: "page" },
  74. }
  75. },
  76. exec: {
  77. output: [ /page1/, /page2/, /page3/ ]
  78. },
  79. post: function (output, text) {
  80. ok(!text.includes("index"), "index is not contained in output");
  81. }
  82. },
  83. {
  84. setup: "appcache validate",
  85. check: {
  86. input: "appcache validate",
  87. markup: "VVVVVVVVVVVVVVVVV",
  88. status: "VALID",
  89. args: {}
  90. },
  91. exec: {
  92. output: [ /successfully/ ]
  93. },
  94. },
  95. {
  96. setup: "appcache validate " + TEST_URI,
  97. check: {
  98. input: "appcache validate " + TEST_URI,
  99. // appcache validate http://sub1.test2.example.com/browser/devtools/client/commandline/test/browser_cmd_appcache_valid_index.html
  100. markup: "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV",
  101. status: "VALID",
  102. args: {
  103. uri: {
  104. value: TEST_URI
  105. },
  106. }
  107. },
  108. exec: {
  109. output: [ /successfully/ ]
  110. },
  111. },
  112. {
  113. setup: "appcache clear",
  114. check: {
  115. input: "appcache clear",
  116. markup: "VVVVVVVVVVVVVV",
  117. status: "VALID",
  118. args: {},
  119. },
  120. exec: {
  121. output: [ /successfully/ ]
  122. },
  123. },
  124. {
  125. setup: "appcache list",
  126. check: {
  127. input: "appcache list",
  128. markup: "VVVVVVVVVVVVV",
  129. status: "VALID",
  130. args: {},
  131. },
  132. exec: {
  133. output: [ /no results/ ]
  134. },
  135. post: function (output, text) {
  136. ok(!text.includes("index"), "index is not contained in output");
  137. ok(!text.includes("page1"), "page1 is not contained in output");
  138. ok(!text.includes("page2"), "page1 is not contained in output");
  139. ok(!text.includes("page3"), "page1 is not contained in output");
  140. }
  141. },
  142. {
  143. setup: "appcache viewentry --key " + TEST_URI,
  144. check: {
  145. input: "appcache viewentry --key " + TEST_URI,
  146. // appcache viewentry --key http://sub1.test2.example.com/browser/devtools/client/commandline/test/browser_cmd_appcache_valid_index.html
  147. markup: "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV",
  148. status: "VALID",
  149. args: {}
  150. },
  151. },
  152. ]);
  153. yield helpers.closeToolbar(options);
  154. yield helpers.closeTab(options);
  155. }