TOP-CONTRIB-about-redirector-jscomp2esmodule.patch 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. # HG changeset patch
  2. # User Matt A. Tobin <email@mattatobin.com>
  3. # Date 1659988365 0
  4. # Parent 2cb9b1aa1ef82c6a91d8de9a1f148f5375876e34
  5. 9999999 - Update suite AboutRedirector and change about: to about:version
  6. diff --git a/suite/base/content/utilityOverlay.js b/suite/base/content/utilityOverlay.js
  7. --- a/suite/base/content/utilityOverlay.js
  8. +++ b/suite/base/content/utilityOverlay.js
  9. @@ -593,17 +593,17 @@ function isRestricted( url )
  10. } catch (e) {
  11. return false;
  12. }
  13. }
  14. function goAbout(aProtocol)
  15. {
  16. var target;
  17. - var url = "about:" + (aProtocol || "");
  18. + var url = "about:version" + (aProtocol || "");
  19. var defaultAboutState = Services.prefs.getIntPref("browser.link.open_external");
  20. switch (defaultAboutState) {
  21. case Ci.nsIBrowserDOMWindow.OPEN_NEWWINDOW:
  22. target = "window";
  23. break;
  24. case Ci.nsIBrowserDOMWindow.OPEN_CURRENTWINDOW:
  25. target = "current";
  26. diff --git a/suite/components/AboutRedirector.sys.mjs b/suite/components/AboutRedirector.sys.mjs
  27. new file mode 100644
  28. --- /dev/null
  29. +++ b/suite/components/AboutRedirector.sys.mjs
  30. @@ -0,0 +1,121 @@
  31. +/* This Source Code Form is subject to the terms of the Mozilla Public
  32. + * License, v. 2.0. If a copy of the MPL was not distributed with this
  33. + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  34. +
  35. +export function AboutRedirector() {}
  36. +
  37. +AboutRedirector.prototype = {
  38. + QueryInterface: ChromeUtils.generateQI(["nsIAboutModule"]),
  39. +
  40. + // Each entry in the map has the key as the part after the "about:" and the
  41. + // value as a record with url and flags entries. Note that each addition here
  42. + // should be coupled with a corresponding addition in components.conf.
  43. + _redirMap: {
  44. + version: {
  45. + url: "chrome://communicator/content/about.xhtml",
  46. + flags:
  47. + Ci.nsIAboutModule.ALLOW_SCRIPT,
  48. + },
  49. + blocked: {
  50. + url: "chrome://communicator/content/blockedSite.xhtml",
  51. + flags:
  52. + Ci.nsIAboutModule.ALLOW_SCRIPT |
  53. + Ci.nsIAboutModule.URI_SAFE_FOR_UNTRUSTED_CONTENT,
  54. + },
  55. + data: {
  56. + url: "chrome://communicator/content/dataman/dataman.xhtml",
  57. + flags:
  58. + Ci.nsIAboutModule.ALLOW_SCRIPT,
  59. + },
  60. + feeds: {
  61. + url: "chrome://communicator/content/feeds/subscribe.xhtml",
  62. + flags:
  63. + Ci.nsIAboutModule.ALLOW_SCRIPT |
  64. + Ci.nsIAboutModule.URI_SAFE_FOR_UNTRUSTED_CONTENT,
  65. + },
  66. + life: {
  67. + url: "chrome://communicator/content/aboutLife.xhtml",
  68. + flags:
  69. + Ci.nsIAboutModule.ALLOW_SCRIPT |
  70. + Ci.nsIAboutModule.URI_SAFE_FOR_UNTRUSTED_CONTENT,
  71. + },
  72. + newserror: {
  73. + url: "chrome://messenger/content/newsError.xhtml",
  74. + flags:
  75. + Ci.nsIAboutModule.ALLOW_SCRIPT,
  76. + },
  77. + privatebrowsing: {
  78. + url: "chrome://communicator/content/aboutPrivateBrowsing.xhtml",
  79. + flags:
  80. + Ci.nsIAboutModule.ALLOW_SCRIPT,
  81. + },
  82. + rights: {
  83. + url: "chrome://branding/content/aboutRights.xhtml",
  84. + flags:
  85. + Ci.nsIAboutModule.ALLOW_SCRIPT |
  86. + Ci.nsIAboutModule.URI_SAFE_FOR_UNTRUSTED_CONTENT,
  87. + },
  88. + sessionrestore: {
  89. + url: "chrome://communicator/content/aboutSessionRestore.xhtml",
  90. + flags:
  91. + Ci.nsIAboutModule.ALLOW_SCRIPT,
  92. + },
  93. + profiling: {
  94. + url: "chrome://devtools/content/performance-new/aboutprofiling/index.xhtml",
  95. + flags:
  96. + Ci.nsIAboutModule.ALLOW_SCRIPT | Ci.nsIAboutModule.IS_SECURE_CHROME_UI,
  97. + },
  98. + },
  99. +
  100. + /**
  101. + * Gets the module name from the given URI.
  102. + */
  103. + _getModuleName(aURI) {
  104. + // Strip out the first ? or #, and anything following it
  105. + const name = /[^?#]+/.exec(aURI.pathQueryRef)[0];
  106. + return name.toLowerCase();
  107. + },
  108. +
  109. + getURIFlags(aURI) {
  110. + const name = this._getModuleName(aURI);
  111. + if (!(name in this._redirMap)) {
  112. + throw Components.Exception(`no about:${name}`, Cr.NS_ERROR_ILLEGAL_VALUE);
  113. + }
  114. + return this._redirMap[name].flags;
  115. + },
  116. +
  117. + newChannel(aURI, aLoadInfo) {
  118. + const name = this._getModuleName(aURI);
  119. + if (!(name in this._redirMap)) {
  120. + throw Components.Exception(`no about:${name}`, Cr.NS_ERROR_ILLEGAL_VALUE);
  121. + }
  122. +
  123. + const newURI = Services.io.newURI(this._redirMap[name].url);
  124. + const channel = Services.io.newChannelFromURIWithLoadInfo(
  125. + newURI,
  126. + aLoadInfo
  127. + );
  128. + channel.originalURI = aURI;
  129. +
  130. + if (
  131. + this._redirMap[name].flags &
  132. + Ci.nsIAboutModule.URI_SAFE_FOR_UNTRUSTED_CONTENT
  133. + ) {
  134. + const principal = Services.scriptSecurityManager.createContentPrincipal(
  135. + aURI,
  136. + {}
  137. + );
  138. + channel.owner = principal;
  139. + }
  140. +
  141. + return channel;
  142. + },
  143. +
  144. + getChromeURI(aURI) {
  145. + const name = this._getModuleName(aURI);
  146. + if (!(name in this._redirMap)) {
  147. + throw Components.Exception(`no about:${name}`, Cr.NS_ERROR_ILLEGAL_VALUE);
  148. + }
  149. + return Services.io.newURI(this._redirMap[name].url);
  150. + },
  151. +};
  152. diff --git a/suite/components/SuiteComponents.manifest b/suite/components/SuiteComponents.manifest
  153. --- a/suite/components/SuiteComponents.manifest
  154. +++ b/suite/components/SuiteComponents.manifest
  155. @@ -1,18 +1,7 @@
  156. -component {d54f2c89-8fd6-4eeb-a7a4-51d4dcdf460f} nsAbout.js
  157. -contract @mozilla.org/network/protocol/about;1?what= {d54f2c89-8fd6-4eeb-a7a4-51d4dcdf460f}
  158. -contract @mozilla.org/network/protocol/about;1?what=blocked {d54f2c89-8fd6-4eeb-a7a4-51d4dcdf460f}
  159. -contract @mozilla.org/network/protocol/about;1?what=certerror {d54f2c89-8fd6-4eeb-a7a4-51d4dcdf460f}
  160. -contract @mozilla.org/network/protocol/about;1?what=data {d54f2c89-8fd6-4eeb-a7a4-51d4dcdf460f}
  161. -contract @mozilla.org/network/protocol/about;1?what=feeds {d54f2c89-8fd6-4eeb-a7a4-51d4dcdf460f}
  162. -contract @mozilla.org/network/protocol/about;1?what=life {d54f2c89-8fd6-4eeb-a7a4-51d4dcdf460f}
  163. -contract @mozilla.org/network/protocol/about;1?what=newserror {d54f2c89-8fd6-4eeb-a7a4-51d4dcdf460f}
  164. -contract @mozilla.org/network/protocol/about;1?what=privatebrowsing {d54f2c89-8fd6-4eeb-a7a4-51d4dcdf460f}
  165. -contract @mozilla.org/network/protocol/about;1?what=rights {d54f2c89-8fd6-4eeb-a7a4-51d4dcdf460f}
  166. -contract @mozilla.org/network/protocol/about;1?what=sessionrestore {d54f2c89-8fd6-4eeb-a7a4-51d4dcdf460f}
  167. component {22042bdb-56e4-47c6-8b12-fdfa859c05a9} nsGopherProtocolStubHandler.js
  168. contract @mozilla.org/network/protocol;1?name=gopher {22042bdb-56e4-47c6-8b12-fdfa859c05a9}
  169. component {bbbbe845-5a1b-40ee-813c-f84b8faaa07c} nsSuiteGlue.js
  170. contract @mozilla.org/suite/suiteglue;1 {bbbbe845-5a1b-40ee-813c-f84b8faaa07c}
  171. category app-startup nsSuiteGlue service,@mozilla.org/suite/suiteglue;1
  172. component {9d4c845d-3f09-402a-b66d-50f291d7d50f} nsSuiteGlue.js
  173. contract @mozilla.org/content-permission/prompt;1 {9d4c845d-3f09-402a-b66d-50f291d7d50f}
  174. diff --git a/suite/components/components.conf b/suite/components/components.conf
  175. new file mode 100644
  176. --- /dev/null
  177. +++ b/suite/components/components.conf
  178. @@ -0,0 +1,25 @@
  179. +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
  180. +# vim: set filetype=python:
  181. +# This Source Code Form is subject to the terms of the Mozilla Public
  182. +# License, v. 2.0. If a copy of the MPL was not distributed with this
  183. +# file, You can obtain one at http://mozilla.org/MPL/2.0/.
  184. +
  185. +Classes = [
  186. + {
  187. + 'cid': '{d54f2c89-8fd6-4eeb-a7a4-51d4dcdf460f}',
  188. + 'contract_ids': [
  189. + '@mozilla.org/network/protocol/about;1?what=version',
  190. + '@mozilla.org/network/protocol/about;1?what=blocked',
  191. + '@mozilla.org/network/protocol/about;1?what=certerror',
  192. + '@mozilla.org/network/protocol/about;1?what=data',
  193. + '@mozilla.org/network/protocol/about;1?what=feeds',
  194. + '@mozilla.org/network/protocol/about;1?what=life',
  195. + '@mozilla.org/network/protocol/about;1?what=newserror',
  196. + '@mozilla.org/network/protocol/about;1?what=privatebrowsing',
  197. + '@mozilla.org/network/protocol/about;1?what=rights',
  198. + '@mozilla.org/network/protocol/about;1?what=sessionrestore',
  199. + ],
  200. + 'esModule': 'resource://gre/modules/AboutRedirector.sys.mjs',
  201. + 'constructor': 'AboutRedirector',
  202. + },
  203. +]
  204. diff --git a/suite/components/moz.build b/suite/components/moz.build
  205. --- a/suite/components/moz.build
  206. +++ b/suite/components/moz.build
  207. @@ -41,13 +41,20 @@ MOCHITEST_CHROME_MANIFESTS += [
  208. XPIDL_SOURCES += [
  209. "nsISuiteGlue.idl",
  210. ]
  211. XPIDL_MODULE = "suite-components"
  212. EXTRA_COMPONENTS += [
  213. - "nsAbout.js",
  214. "nsGopherProtocolStubHandler.js",
  215. "nsSuiteGlue.js",
  216. "SuiteComponents.manifest",
  217. ]
  218. +
  219. +EXTRA_JS_MODULES += [
  220. + "AboutRedirector.sys.mjs",
  221. +]
  222. +
  223. +XPCOM_MANIFESTS += [
  224. + 'components.conf',
  225. +]
  226. \ No newline at end of file
  227. diff --git a/suite/components/nsAbout.js b/suite/components/nsAbout.js
  228. deleted file mode 100644
  229. --- a/suite/components/nsAbout.js
  230. +++ /dev/null
  231. @@ -1,75 +0,0 @@
  232. -/* This Source Code Form is subject to the terms of the Mozilla Public
  233. - * License, v. 2.0. If a copy of the MPL was not distributed with this
  234. - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  235. -
  236. -var {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
  237. -
  238. -const SCRIPT = Ci.nsIAboutModule.ALLOW_SCRIPT;
  239. -const UNTRUSTED = Ci.nsIAboutModule.URI_SAFE_FOR_UNTRUSTED_CONTENT;
  240. -const HIDE = Ci.nsIAboutModule.HIDE_FROM_ABOUTABOUT;
  241. -const INDEXEDDB = Ci.nsIAboutModule.ENABLE_INDEXED_DB;
  242. -
  243. -function About() { }
  244. -About.prototype = {
  245. - Flags: SCRIPT,
  246. - URI: "chrome://communicator/content/about.xhtml",
  247. - blockedFlags: SCRIPT | UNTRUSTED | HIDE,
  248. - blockedURI: "chrome://communicator/content/blockedSite.xhtml",
  249. - certerrorFlags: SCRIPT | UNTRUSTED | HIDE,
  250. - certerrorURI: "chrome://communicator/content/certError.xhtml",
  251. - dataFlags: SCRIPT,
  252. - dataURI: "chrome://communicator/content/dataman/dataman.xhtml",
  253. - feedsFlags: SCRIPT | UNTRUSTED | HIDE,
  254. - feedsURI: "chrome://communicator/content/feeds/subscribe.xhtml",
  255. - lifeFlags: SCRIPT | UNTRUSTED | HIDE,
  256. - lifeURI: "chrome://communicator/content/aboutLife.xhtml",
  257. - newserrorFlags: SCRIPT | HIDE,
  258. - newserrorURI: "chrome://messenger/content/newsError.xhtml",
  259. - privatebrowsingFlags: SCRIPT,
  260. - privatebrowsingURI: "chrome://communicator/content/aboutPrivateBrowsing.xhtml",
  261. - rightsFlags: SCRIPT | UNTRUSTED,
  262. - rightsURI: "chrome://branding/content/aboutRights.xhtml",
  263. - sessionrestoreFlags: SCRIPT | HIDE,
  264. - sessionrestoreURI: "chrome://communicator/content/aboutSessionRestore.xhtml",
  265. - // synctabsFlags: SCRIPT,
  266. - // synctabsURI: "chrome://communicator/content/aboutSyncTabs.xhtml",
  267. -
  268. - classID: Components.ID("{d54f2c89-8fd6-4eeb-a7a4-51d4dcdf460f}"),
  269. - QueryInterface: ChromeUtils.generateQI([Ci.nsIAboutModule]),
  270. -
  271. - getModule: function(aURI) {
  272. - return aURI.pathQueryRef.replace(/-|\W.*$/g, "").toLowerCase();
  273. - },
  274. -
  275. - getURIFlags: function(aURI) {
  276. - return this[this.getModule(aURI) + "Flags"];
  277. - },
  278. -
  279. - newChannel: function(aURI, aLoadInfo) {
  280. - let module = this.getModule(aURI);
  281. - let newURI = Services.io.newURI(this[module + "URI"]);
  282. -
  283. - // We want a happy family which is always providing a loadInfo object.
  284. - if (!aLoadInfo) {
  285. - // Write out an error so that we have a stack and can fix the caller.
  286. - Cu.reportError('aLoadInfo was not provided in nsAbout.newChannel!');
  287. - }
  288. -
  289. - let channel = aLoadInfo ?
  290. - Services.io.newChannelFromURIWithLoadInfo(newURI, aLoadInfo) :
  291. - Services.io.newChannelFromURI(newURI, null,
  292. - Services.scriptSecurityManager.getSystemPrincipal(),
  293. - null,
  294. - Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_SEC_CONTEXT_IS_NULL,
  295. - Ci.nsIContentPolicy.TYPE_OTHER);
  296. -
  297. - channel.originalURI = aURI;
  298. - if (this[module + "Flags"] & UNTRUSTED) {
  299. - let principal = Services.scriptSecurityManager.createCodebasePrincipal(aURI, {});
  300. - channel.owner = principal;
  301. - }
  302. - return channel;
  303. - },
  304. -};
  305. -
  306. -var NSGetFactory = XPCOMUtils.generateNSGetFactory([About]);
  307. diff --git a/suite/installer/package-manifest.in b/suite/installer/package-manifest.in
  308. --- a/suite/installer/package-manifest.in
  309. +++ b/suite/installer/package-manifest.in
  310. @@ -157,17 +157,16 @@
  311. @RESPATH@/components/SuiteFeeds.manifest
  312. @RESPATH@/components/SuiteSidebar.manifest
  313. ; JavaScript components
  314. @RESPATH@/components/cryptoComponents.manifest
  315. @RESPATH@/components/FeedConverter.js
  316. @RESPATH@/components/FeedWriter.js
  317. @RESPATH@/components/jsconsole-clhandler.js
  318. @RESPATH@/components/jsconsole-clhandler.manifest
  319. -@RESPATH@/components/nsAbout.js
  320. @RESPATH@/components/nsBrowserContentHandler.js
  321. @RESPATH@/components/nsComposerCmdLineHandler.js
  322. @RESPATH@/components/nsComposerCmdLineHandler.manifest
  323. @RESPATH@/components/nsGopherProtocolStubHandler.js
  324. @RESPATH@/components/nsPlacesAutoComplete.js
  325. @RESPATH@/components/nsPlacesAutoComplete.manifest
  326. @RESPATH@/components/nsSessionStartup.js
  327. @RESPATH@/components/nsSessionStartup.manifest