main.js 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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. "use strict";
  5. const { LoaderWithHookedConsole } = require('sdk/test/loader');
  6. const { loader } = LoaderWithHookedConsole(module);
  7. const app = require("sdk/system/xul-app");
  8. // This test makes sure that require statements used by all AMO hosted
  9. // add-ons will be able to use old require statements.
  10. // Tests are based on following usage data:
  11. // https://docs.google.com/spreadsheet/ccc?key=0ApEBy-GRnGxzdHlRMHJ5RXN1aWJ4RGhINkxSd0FCQXc#gid=0
  12. exports["test compatibility"] = function(assert) {
  13. assert.equal(require("self"),
  14. require("sdk/self"), "sdk/self -> self");
  15. assert.equal(require("tabs"),
  16. require("sdk/tabs"), "sdk/tabs -> tabs");
  17. if (app.is("Firefox")) {
  18. assert.equal(require("widget"),
  19. require("sdk/widget"), "sdk/widget -> widget");
  20. }
  21. assert.equal(require("page-mod"),
  22. require("sdk/page-mod"), "sdk/page-mod -> page-mod");
  23. if (app.is("Firefox")) {
  24. assert.equal(require("panel"),
  25. require("sdk/panel"), "sdk/panel -> panel");
  26. }
  27. assert.equal(require("request"),
  28. require("sdk/request"), "sdk/request -> request");
  29. assert.equal(require("chrome"),
  30. require("chrome"), "chrome -> chrome");
  31. assert.equal(require("simple-storage"),
  32. require("sdk/simple-storage"), "sdk/simple-storage -> simple-storage");
  33. if (app.is("Firefox")) {
  34. assert.equal(require("context-menu"),
  35. require("sdk/context-menu"), "sdk/context-menu -> context-menu");
  36. }
  37. assert.equal(require("notifications"),
  38. require("sdk/notifications"), "sdk/notifications -> notifications");
  39. assert.equal(require("preferences-service"),
  40. require("sdk/preferences/service"), "sdk/preferences/service -> preferences-service");
  41. assert.equal(require("window-utils"),
  42. require("sdk/deprecated/window-utils"), "sdk/deprecated/window-utils -> window-utils");
  43. assert.equal(require("url"),
  44. require("sdk/url"), "sdk/url -> url");
  45. if (app.is("Firefox")) {
  46. assert.equal(require("selection"),
  47. require("sdk/selection"), "sdk/selection -> selection");
  48. }
  49. assert.equal(require("timers"),
  50. require("sdk/timers"), "sdk/timers -> timers");
  51. assert.equal(require("simple-prefs"),
  52. require("sdk/simple-prefs"), "sdk/simple-prefs -> simple-prefs");
  53. assert.equal(require("traceback"),
  54. require("sdk/console/traceback"), "sdk/console/traceback -> traceback");
  55. assert.equal(require("unload"),
  56. require("sdk/system/unload"), "sdk/system/unload -> unload");
  57. assert.equal(require("hotkeys"),
  58. require("sdk/hotkeys"), "sdk/hotkeys -> hotkeys");
  59. if (app.is("Firefox")) {
  60. assert.equal(require("clipboard"),
  61. require("sdk/clipboard"), "sdk/clipboard -> clipboard");
  62. }
  63. assert.equal(require("windows"),
  64. require("sdk/windows"), "sdk/windows -> windows");
  65. assert.equal(require("page-worker"),
  66. require("sdk/page-worker"), "sdk/page-worker -> page-worker");
  67. assert.equal(require("timer"),
  68. require("sdk/timers"), "sdk/timers -> timer");
  69. assert.equal(require("xhr"),
  70. require("sdk/net/xhr"), "sdk/io/xhr -> xhr");
  71. assert.equal(require("private-browsing"),
  72. require("sdk/private-browsing"), "sdk/private-browsing -> private-browsing");
  73. assert.equal(require("passwords"),
  74. require("sdk/passwords"), "sdk/passwords -> passwords");
  75. assert.equal(require("events"),
  76. require("sdk/deprecated/events"), "sdk/deprecated/events -> events");
  77. assert.equal(require("match-pattern"),
  78. require("sdk/util/match-pattern"), "sdk/util/match-pattern -> match-pattern");
  79. assert.equal(require("file"),
  80. require("sdk/io/file"), "sdk/io/file -> file");
  81. assert.equal(require("xul-app"),
  82. require("sdk/system/xul-app"), "sdk/system/xul-app -> xul-app");
  83. assert.equal(require("api-utils"),
  84. require("sdk/deprecated/api-utils"), "sdk/deprecated/api-utils -> api-utils");
  85. assert.equal(require("runtime"),
  86. require("sdk/system/runtime"), "sdk/system/runtime -> runtime");
  87. assert.equal(require("base64"),
  88. require("sdk/base64"), "sdk/base64 -> base64");
  89. assert.equal(require("xpcom"),
  90. require("sdk/platform/xpcom"), "sdk/platform/xpcom -> xpcom");
  91. assert.equal(require("traits"),
  92. require("sdk/deprecated/traits"), "sdk/deprecated/traits -> traits");
  93. assert.equal(require("keyboard/utils"),
  94. require("sdk/keyboard/utils"), "sdk/keyboard/utils -> keyboard/utils");
  95. assert.equal(require("system"),
  96. require("sdk/system"), "sdk/system -> system");
  97. assert.equal(require("querystring"),
  98. require("sdk/querystring"), "sdk/querystring -> querystring");
  99. assert.equal(loader.require("addon-page"),
  100. loader.require("sdk/addon-page"), "sdk/addon-page -> addon-page");
  101. assert.equal(require("tabs/utils"),
  102. require("sdk/tabs/utils"), "sdk/tabs/utils -> tabs/utils");
  103. assert.equal(require("dom/events"),
  104. require("sdk/dom/events"), "sdk/dom/events -> dom/events");
  105. assert.equal(require("tabs/tab.js"),
  106. require("sdk/tabs/tab"), "sdk/tabs/tab -> tabs/tab.js");
  107. assert.equal(require("memory"),
  108. require("sdk/deprecated/memory"), "sdk/deprecated/memory -> memory");
  109. assert.equal(require("light-traits"),
  110. require("sdk/deprecated/light-traits"), "sdk/deprecated/light-traits -> light-traits");
  111. assert.equal(require("environment"),
  112. require("sdk/system/environment"), "sdk/system/environment -> environment");
  113. if (app.is("Firefox")) {
  114. // This module fails on fennec because of favicon xpcom component
  115. // being not implemented on it.
  116. assert.equal(require("utils/data"),
  117. require("sdk/io/data"), "sdk/io/data -> utils/data");
  118. }
  119. assert.equal(require("test/assert"),
  120. require("sdk/test/assert"), "sdk/test/assert -> test/assert");
  121. assert.equal(require("hidden-frame"),
  122. require("sdk/frame/hidden-frame"), "sdk/frame/hidden-frame -> hidden-frame");
  123. assert.equal(require("collection"),
  124. require("sdk/util/collection"), "sdk/util/collection -> collection");
  125. assert.equal(require("array"),
  126. require("sdk/util/array"), "sdk/util/array -> array");
  127. assert.equal(require("api-utils/cortex"),
  128. require("sdk/deprecated/cortex"),
  129. "api-utils/cortex -> sdk/deprecated/cortex");
  130. };
  131. require("sdk/test/runner").runTestsFromModule(module);