TOP-CONTRIB-devtools-with-chrome-clh.patch 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  1. # HG changeset patch
  2. # User Matt A. Tobin <email@mattatobin.com>
  3. # Date 1659988365 0
  4. # Parent 23bd821e05a4192fadb4ff91d64fde5e22541684
  5. 9999999 - Port a slightly modified version of devtools-loader to suite.
  6. Also, includes the --chrome flag normally handled by nsBrowserContentHandler.
  7. diff --git a/suite/browser/nsBrowserContentHandler.js b/suite/browser/nsBrowserContentHandler.js
  8. --- a/suite/browser/nsBrowserContentHandler.js
  9. +++ b/suite/browser/nsBrowserContentHandler.js
  10. @@ -389,28 +389,31 @@ var nsBrowserContentHandler = {
  11. nsIBrowserDOMWindow.OPEN_NEWTAB,
  12. features,
  13. Services.scriptSecurityManager.getSystemPrincipal());
  14. cmdLine.preventDefault = true;
  15. }
  16. } catch (e) {
  17. }
  18. + /* XXXTobin: This code is currently relocated into the devtools-loader clh
  19. + until this component is converted to an ESModule.
  20. try {
  21. var chromeParam = cmdLine.handleFlagWithParam("chrome", false);
  22. if (chromeParam) {
  23. // only load URIs which do not inherit chrome privs
  24. var uri = resolveURIInternal(cmdLine, chromeParam);
  25. if (!Services.netUtils.URIChainHasFlags(uri, URI_INHERITS_SECURITY_CONTEXT)) {
  26. openWindow(null, uri.spec, features);
  27. cmdLine.preventDefault = true;
  28. }
  29. }
  30. } catch (e) {
  31. }
  32. + */
  33. try {
  34. var fileParam = cmdLine.handleFlagWithParam("file", false);
  35. if (fileParam) {
  36. fileParam = resolveURIInternal(cmdLine, fileParam);
  37. handURIToExistingBrowser(fileParam,
  38. nsIBrowserDOMWindow.OPEN_DEFAULTWINDOW,
  39. features,
  40. diff --git a/suite/components/devtools/all-devtools.js b/suite/components/devtools/all-devtools.js
  41. new file mode 100644
  42. --- /dev/null
  43. +++ b/suite/components/devtools/all-devtools.js
  44. @@ -0,0 +1,368 @@
  45. +// Developer Tools related preferences
  46. +pref("devtools.chrome.enabled", true);
  47. +pref("devtools.debugger.remote-enabled", true);
  48. +pref("devtools.selfxss.count", 5);
  49. +// Enable extensionStorage storage actor by default
  50. +pref("devtools.storage.extensionStorage.enabled", true);
  51. +
  52. +// Toolbox preferences
  53. +pref("devtools.toolbox.footer.height", 250);
  54. +pref("devtools.toolbox.sidebar.width", 500);
  55. +pref("devtools.toolbox.host", "bottom");
  56. +pref("devtools.toolbox.previousHost", "right");
  57. +pref("devtools.toolbox.selectedTool", "inspector");
  58. +pref("devtools.toolbox.sideEnabled", true);
  59. +pref("devtools.toolbox.zoomValue", "1");
  60. +pref("devtools.toolbox.splitconsoleEnabled", false);
  61. +pref("devtools.toolbox.splitconsoleHeight", 100);
  62. +pref("devtools.toolbox.tabsOrder", "");
  63. +pref("devtools.netmonitor.features.newEditAndResend", false);
  64. +
  65. +// The fission pref for enabling the "Multiprocess Browser Toolbox", which will
  66. +// make it possible to debug anything in Firefox (See Bug 1570639 for more
  67. +// information).
  68. +pref("devtools.browsertoolbox.fission", true);
  69. +
  70. +// When the Multiprocess Browser Toolbox is enabled, you can configure the scope of it:
  71. +// - "everything" will enable debugging absolutely everything in the browser
  72. +// All processes, all documents, all workers, all add-ons.
  73. +// - "parent-process" will restrict debugging to the parent process
  74. +// All privileged javascript, documents and workers running in the parent process.
  75. +pref("devtools.browsertoolbox.scope", "everything");
  76. +
  77. +// Toolbox Button preferences
  78. +pref("devtools.command-button-pick.enabled", true);
  79. +pref("devtools.command-button-frames.enabled", true);
  80. +pref("devtools.command-button-splitconsole.enabled", true);
  81. +pref("devtools.command-button-responsive.enabled", true);
  82. +pref("devtools.command-button-screenshot.enabled", false);
  83. +pref("devtools.command-button-rulers.enabled", false);
  84. +pref("devtools.command-button-measure.enabled", false);
  85. +pref("devtools.command-button-noautohide.enabled", false);
  86. +pref("devtools.command-button-errorcount.enabled", true);
  87. + pref("devtools.command-button-experimental-prefs.enabled", true);
  88. +
  89. +// Inspector preferences
  90. +// Enable the Inspector
  91. +pref("devtools.inspector.enabled", true);
  92. +// What was the last active sidebar in the inspector
  93. +pref("devtools.inspector.selectedSidebar", "layoutview");
  94. +pref("devtools.inspector.activeSidebar", "layoutview");
  95. +pref("devtools.inspector.remote", false);
  96. +
  97. +// Enable the 3 pane mode in the inspector
  98. +pref("devtools.inspector.three-pane-enabled", true);
  99. +// Enable the 3 pane mode in the chrome inspector
  100. +pref("devtools.inspector.chrome.three-pane-enabled", false);
  101. +// Collapse pseudo-elements by default in the rule-view
  102. +pref("devtools.inspector.show_pseudo_elements", false);
  103. +// The default size for image preview tooltips in the rule-view/computed-view/markup-view
  104. +pref("devtools.inspector.imagePreviewTooltipSize", 300);
  105. +// Enable user agent style inspection in rule-view
  106. +pref("devtools.inspector.showUserAgentStyles", false);
  107. +// Show native anonymous content and user agent shadow roots
  108. +pref("devtools.inspector.showAllAnonymousContent", false);
  109. +// Enable the inline CSS compatibility warning in inspector rule view
  110. +pref("devtools.inspector.ruleview.inline-compatibility-warning.enabled", false);
  111. +// Enable the compatibility tool in the inspector.
  112. +pref("devtools.inspector.compatibility.enabled", true);
  113. +// Enable color scheme simulation in the inspector.
  114. +pref("devtools.inspector.color-scheme-simulation.enabled", true);
  115. +
  116. +// Grid highlighter preferences
  117. +pref("devtools.gridinspector.gridOutlineMaxColumns", 50);
  118. +pref("devtools.gridinspector.gridOutlineMaxRows", 50);
  119. +pref("devtools.gridinspector.showGridAreas", false);
  120. +pref("devtools.gridinspector.showGridLineNumbers", false);
  121. +pref("devtools.gridinspector.showInfiniteLines", false);
  122. +// Max number of grid highlighters that can be displayed
  123. +pref("devtools.gridinspector.maxHighlighters", 3);
  124. +
  125. +// Whether or not simplified highlighters should be used when
  126. +// prefers-reduced-motion is enabled.
  127. +pref("devtools.inspector.simple-highlighters-reduced-motion", false);
  128. +
  129. +// Whether or not the box model panel is opened in the layout view
  130. +pref("devtools.layout.boxmodel.opened", true);
  131. +// Whether or not the flexbox panel is opened in the layout view
  132. +pref("devtools.layout.flexbox.opened", true);
  133. +// Whether or not the flexbox container panel is opened in the layout view
  134. +pref("devtools.layout.flex-container.opened", true);
  135. +// Whether or not the flexbox item panel is opened in the layout view
  136. +pref("devtools.layout.flex-item.opened", true);
  137. +// Whether or not the grid inspector panel is opened in the layout view
  138. +pref("devtools.layout.grid.opened", true);
  139. +
  140. +// Enable hovering Box Model values and jumping to their source CSS rule in the
  141. +// rule-view.
  142. +#if defined(NIGHTLY_BUILD)
  143. + pref("devtools.layout.boxmodel.highlightProperty", true);
  144. +#else
  145. + pref("devtools.layout.boxmodel.highlightProperty", false);
  146. +#endif
  147. +
  148. +// By how many times eyedropper will magnify pixels
  149. +pref("devtools.eyedropper.zoom", 6);
  150. +
  151. +// Enable to collapse attributes that are too long.
  152. +pref("devtools.markup.collapseAttributes", true);
  153. +// Length to collapse attributes
  154. +pref("devtools.markup.collapseAttributeLength", 120);
  155. +// Whether to auto-beautify the HTML on copy.
  156. +pref("devtools.markup.beautifyOnCopy", false);
  157. +// Whether or not the DOM mutation breakpoints context menu are enabled in the
  158. +// markup view.
  159. +pref("devtools.markup.mutationBreakpoints.enabled", true);
  160. +
  161. +// DevTools default color unit
  162. +pref("devtools.defaultColorUnit", "authored");
  163. +
  164. +// Enable the Memory tools
  165. +pref("devtools.memory.enabled", true);
  166. +
  167. +pref("devtools.memory.custom-census-displays", "{}");
  168. +pref("devtools.memory.custom-label-displays", "{}");
  169. +pref("devtools.memory.custom-tree-map-displays", "{}");
  170. +
  171. +pref("devtools.memory.max-individuals", 1000);
  172. +pref("devtools.memory.max-retaining-paths", 10);
  173. +
  174. +// Enable the Performance tools
  175. +pref("devtools.performance.enabled", true);
  176. +// But not the pop-up.
  177. +pref("devtools.performance.popup.feature-flag", false);
  178. +// Override the default preset, which is "web-developer" on beta and release.
  179. +pref("devtools.performance.recording.preset", "firefox-platform");
  180. +pref("devtools.performance.recording.preset.remote", "firefox-platform");
  181. +
  182. +// The default cache UI setting
  183. +pref("devtools.cache.disabled", false);
  184. +
  185. +// The default service workers UI setting
  186. +pref("devtools.serviceWorkers.testing.enabled", false);
  187. +
  188. +// Enable the Network Monitor
  189. +pref("devtools.netmonitor.enabled", true);
  190. +
  191. +pref("devtools.netmonitor.features.search", true);
  192. +pref("devtools.netmonitor.features.requestBlocking", true);
  193. +
  194. +// Enable the Application panel
  195. +pref("devtools.application.enabled", false);
  196. +
  197. +// Enable the custom formatters feature
  198. +// This preference represents the user's choice to enable the custom formatters feature.
  199. +// While the preference above will be removed once the feature is stable, this one is menat to stay.
  200. +pref("devtools.custom-formatters.enabled", false);
  201. +
  202. +// The default Network Monitor UI settings
  203. +pref("devtools.netmonitor.panes-network-details-width", 550);
  204. +pref("devtools.netmonitor.panes-network-details-height", 450);
  205. +pref("devtools.netmonitor.panes-search-width", 550);
  206. +pref("devtools.netmonitor.panes-search-height", 450);
  207. +pref("devtools.netmonitor.filters", "[\"all\"]");
  208. +pref("devtools.netmonitor.visibleColumns",
  209. + "[\"status\",\"method\",\"domain\",\"file\",\"initiator\",\"type\",\"transferred\",\"contentSize\",\"waterfall\"]"
  210. +);
  211. +pref("devtools.netmonitor.columnsData",
  212. + '[{"name":"status","minWidth":30,"width":5}, {"name":"method","minWidth":30,"width":5}, {"name":"domain","minWidth":30,"width":10}, {"name":"file","minWidth":30,"width":25}, {"name":"url","minWidth":30,"width":25},{"name":"initiator","minWidth":30,"width":10},{"name":"type","minWidth":30,"width":5},{"name":"transferred","minWidth":30,"width":10},{"name":"contentSize","minWidth":30,"width":5},{"name":"waterfall","minWidth":150,"width":15}]');
  213. +pref("devtools.netmonitor.msg.payload-preview-height", 128);
  214. +pref("devtools.netmonitor.msg.visibleColumns",
  215. + '["data", "time"]'
  216. +);
  217. +pref("devtools.netmonitor.msg.displayed-messages.limit", 500);
  218. +
  219. +pref("devtools.netmonitor.response.ui.limit", 10240);
  220. +
  221. +// Save request/response bodies yes/no.
  222. +pref("devtools.netmonitor.saveRequestAndResponseBodies", true);
  223. +
  224. +// The default Network monitor HAR export setting
  225. +pref("devtools.netmonitor.har.defaultLogDir", "");
  226. +pref("devtools.netmonitor.har.defaultFileName", "%hostname_Archive [%date]");
  227. +pref("devtools.netmonitor.har.jsonp", false);
  228. +pref("devtools.netmonitor.har.jsonpCallback", "");
  229. +pref("devtools.netmonitor.har.includeResponseBodies", true);
  230. +pref("devtools.netmonitor.har.compress", false);
  231. +pref("devtools.netmonitor.har.forceExport", false);
  232. +pref("devtools.netmonitor.har.pageLoadedTimeout", 1500);
  233. +pref("devtools.netmonitor.har.enableAutoExportToFile", false);
  234. +
  235. +pref("devtools.netmonitor.features.webSockets", true);
  236. +
  237. +// netmonitor audit
  238. +pref("devtools.netmonitor.audits.slow", 500);
  239. +
  240. +// Disable the EventSource Inspector.
  241. +pref("devtools.netmonitor.features.serverSentEvents", false);
  242. +
  243. +// Enable the Storage Inspector
  244. +pref("devtools.storage.enabled", true);
  245. +
  246. +// Enable the Style Editor.
  247. +pref("devtools.styleeditor.enabled", true);
  248. +pref("devtools.styleeditor.autocompletion-enabled", true);
  249. +pref("devtools.styleeditor.showMediaSidebar", true);
  250. +pref("devtools.styleeditor.mediaSidebarWidth", 238);
  251. +pref("devtools.styleeditor.navSidebarWidth", 245);
  252. +pref("devtools.styleeditor.transitions", true);
  253. +
  254. +// Screenshot Option Settings.
  255. +pref("devtools.screenshot.clipboard.enabled", false);
  256. +pref("devtools.screenshot.audio.enabled", true);
  257. +
  258. +// Make sure the DOM panel is hidden by default
  259. +pref("devtools.dom.enabled", false);
  260. +
  261. +// Enable the Accessibility panel.
  262. +pref("devtools.accessibility.enabled", true);
  263. +
  264. +// Web console filters
  265. +pref("devtools.webconsole.filter.error", true);
  266. +pref("devtools.webconsole.filter.warn", true);
  267. +pref("devtools.webconsole.filter.info", true);
  268. +pref("devtools.webconsole.filter.log", true);
  269. +pref("devtools.webconsole.filter.debug", true);
  270. +pref("devtools.webconsole.filter.css", false);
  271. +pref("devtools.webconsole.filter.net", false);
  272. +pref("devtools.webconsole.filter.netxhr", false);
  273. +
  274. +// Webconsole autocomplete preference
  275. +pref("devtools.webconsole.input.autocomplete",true);
  276. + pref("devtools.webconsole.input.context", false);
  277. +
  278. +// Set to true to eagerly show the results of webconsole terminal evaluations
  279. +// when they don't have side effects.
  280. +pref("devtools.webconsole.input.eagerEvaluation", true);
  281. +
  282. +// Browser console filters
  283. +pref("devtools.browserconsole.filter.error", true);
  284. +pref("devtools.browserconsole.filter.warn", true);
  285. +pref("devtools.browserconsole.filter.info", true);
  286. +pref("devtools.browserconsole.filter.log", true);
  287. +pref("devtools.browserconsole.filter.debug", true);
  288. +pref("devtools.browserconsole.filter.css", false);
  289. +pref("devtools.browserconsole.filter.net", false);
  290. +pref("devtools.browserconsole.filter.netxhr", false);
  291. +
  292. +// Max number of inputs to store in web console history.
  293. +pref("devtools.webconsole.inputHistoryCount", 300);
  294. +
  295. +// Persistent logging: |true| if you want the relevant tool to keep all of the
  296. +// logged messages after reloading the page, |false| if you want the output to
  297. +// be cleared each time page navigation happens.
  298. +pref("devtools.webconsole.persistlog", false);
  299. +pref("devtools.netmonitor.persistlog", false);
  300. +
  301. +// Web Console timestamp: |true| if you want the logs and instructions
  302. +// in the Web Console to display a timestamp, or |false| to not display
  303. +// any timestamps.
  304. +pref("devtools.webconsole.timestampMessages", false);
  305. +
  306. +// Enable the webconsole sidebar toggle in Nightly builds.
  307. + pref("devtools.webconsole.sidebarToggle", false);
  308. +
  309. +// Saved editor mode state in the console.
  310. +pref("devtools.webconsole.input.editor", false);
  311. +pref("devtools.browserconsole.input.editor", false);
  312. +
  313. +// Editor width for webconsole and browserconsole.
  314. +pref("devtools.webconsole.input.editorWidth", 0);
  315. +pref("devtools.browserconsole.input.editorWidth", 0);
  316. +
  317. +// Display an onboarding UI for the Editor mode.
  318. +pref("devtools.webconsole.input.editorOnboarding", true);
  319. +
  320. +// Enable message grouping in the console, true by default
  321. +pref("devtools.webconsole.groupWarningMessages", true);
  322. +
  323. +// Saved state of the Display content messages checkbox in the browser console.
  324. +pref("devtools.browserconsole.contentMessages", true);
  325. +
  326. +// Enable network monitoring the browser toolbox console/browser console.
  327. +pref("devtools.browserconsole.enableNetworkMonitoring", false);
  328. +
  329. +// Enable client-side mapping service for source maps
  330. +pref("devtools.source-map.client-service.enabled", true);
  331. +
  332. +// The number of lines that are displayed in the web console.
  333. +pref("devtools.hud.loglimit", 10000);
  334. +
  335. +// The developer tools editor configuration:
  336. +// - tabsize: how many spaces to use when a Tab character is displayed.
  337. +// - expandtab: expand Tab characters to spaces.
  338. +// - keymap: which keymap to use (can be 'default', 'emacs' or 'vim')
  339. +// - autoclosebrackets: whether to permit automatic bracket/quote closing.
  340. +// - detectindentation: whether to detect the indentation from the file
  341. +// - enableCodeFolding: Whether to enable code folding or not.
  342. +pref("devtools.editor.tabsize", 2);
  343. +pref("devtools.editor.expandtab", true);
  344. +pref("devtools.editor.keymap", "default");
  345. +pref("devtools.editor.autoclosebrackets", true);
  346. +pref("devtools.editor.detectindentation", true);
  347. +pref("devtools.editor.enableCodeFolding", true);
  348. +pref("devtools.editor.autocomplete", true);
  349. +
  350. +// The angle of the viewport.
  351. +pref("devtools.responsive.viewport.angle", 0);
  352. +// The width of the viewport.
  353. +pref("devtools.responsive.viewport.width", 320);
  354. +// The height of the viewport.
  355. +pref("devtools.responsive.viewport.height", 480);
  356. +// The pixel ratio of the viewport.
  357. +pref("devtools.responsive.viewport.pixelRatio", 0);
  358. +// Whether or not the viewports are left aligned.
  359. +pref("devtools.responsive.leftAlignViewport.enabled", false);
  360. +// Whether to reload when touch simulation is toggled
  361. +pref("devtools.responsive.reloadConditions.touchSimulation", false);
  362. +// Whether to reload when user agent is changed
  363. +pref("devtools.responsive.reloadConditions.userAgent", false);
  364. +// Whether to show the notification about reloading to apply emulation
  365. +pref("devtools.responsive.reloadNotification.enabled", true);
  366. +// Whether or not touch simulation is enabled.
  367. +pref("devtools.responsive.touchSimulation.enabled", false);
  368. +// The user agent of the viewport.
  369. +pref("devtools.responsive.userAgent", "");
  370. +
  371. +// Show the custom user agent input in Nightly builds.
  372. +#if defined(NIGHTLY_BUILD)
  373. + pref("devtools.responsive.showUserAgentInput", true);
  374. +#else
  375. + pref("devtools.responsive.showUserAgentInput", false);
  376. +#endif
  377. +
  378. +// Show tab debug targets for This Firefox (on by default for local builds).
  379. + pref("devtools.aboutdebugging.local-tab-debugging", true);
  380. +
  381. +// Show process debug targets.
  382. +pref("devtools.aboutdebugging.process-debugging", true);
  383. +// Stringified array of network locations that users can connect to.
  384. +pref("devtools.aboutdebugging.network-locations", "[]");
  385. +// Debug target pane collapse/expand settings.
  386. +pref("devtools.aboutdebugging.collapsibilities.installedExtension", false);
  387. +pref("devtools.aboutdebugging.collapsibilities.otherWorker", false);
  388. +pref("devtools.aboutdebugging.collapsibilities.serviceWorker", false);
  389. +pref("devtools.aboutdebugging.collapsibilities.sharedWorker", false);
  390. +pref("devtools.aboutdebugging.collapsibilities.tab", false);
  391. +pref("devtools.aboutdebugging.collapsibilities.temporaryExtension", false);
  392. +
  393. +// about:debugging: only show system and hidden extensions in local builds by
  394. +// default.
  395. + pref("devtools.aboutdebugging.showHiddenAddons", true);
  396. +
  397. +// Map top-level await expressions in the console
  398. +pref("devtools.debugger.features.map-await-expression", true);
  399. +
  400. +// This relies on javascript.options.asyncstack as well or it has no effect.
  401. +pref("devtools.debugger.features.async-captured-stacks", true);
  402. +pref("devtools.debugger.features.async-live-stacks", false);
  403. +
  404. +// Disable autohide for DevTools popups and tooltips.
  405. +// This is currently not exposed by any UI to avoid making
  406. +// about:devtools-toolbox tabs unusable by mistake.
  407. +pref("devtools.popup.disable_autohide", false);
  408. +
  409. +// Enable overflow debugging in the inspector.
  410. +pref("devtools.overflow.debugging.enabled", true);
  411. +// Enable drag to edit properties in the inspector rule view.
  412. +pref("devtools.inspector.draggable_properties", true);
  413. diff --git a/suite/components/devtools/components.conf b/suite/components/devtools/components.conf
  414. new file mode 100644
  415. --- /dev/null
  416. +++ b/suite/components/devtools/components.conf
  417. @@ -0,0 +1,15 @@
  418. +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
  419. +# vim: set filetype=python:
  420. +# This Source Code Form is subject to the terms of the Mozilla Public
  421. +# License, v. 2.0. If a copy of the MPL was not distributed with this
  422. +# file, You can obtain one at http://mozilla.org/MPL/2.0/.
  423. +
  424. +Classes = [
  425. + {
  426. + 'cid': '{089694e9-106a-4704-abf7-62a88545e194}',
  427. + 'contract_ids': ['@xulvolution.org/generic/devtools-startup-clh;1'],
  428. + 'esModule': 'resource:///modules/devtools-loader.sys.mjs',
  429. + 'constructor': 'DevToolsStartup',
  430. + 'categories': {'command-line-handler': 'm-aaa-xre-devtools'},
  431. + },
  432. +]
  433. diff --git a/suite/components/devtools/devtools-loader.sys.mjs b/suite/components/devtools/devtools-loader.sys.mjs
  434. new file mode 100644
  435. --- /dev/null
  436. +++ b/suite/components/devtools/devtools-loader.sys.mjs
  437. @@ -0,0 +1,118 @@
  438. +/* This Source Code Form is subject to the terms of the Mozilla Public
  439. + * License, v. 2.0. If a copy of the MPL was not distributed with this
  440. + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  441. +
  442. +const lazy = {};
  443. +ChromeUtils.defineESModuleGetters(lazy, {
  444. + NetUtil: "resource://gre/modules/NetUtil.sys.mjs",
  445. +});
  446. +
  447. +function resolveURIInternal(aCmdLine, aArgument) {
  448. + var uri = aCmdLine.resolveURI(aArgument);
  449. +
  450. + if (!(uri instanceof Ci.nsIFileURL)) {
  451. + return uri;
  452. + }
  453. +
  454. + try {
  455. + if (uri.file.exists()) {
  456. + return uri;
  457. + }
  458. + } catch (e) {
  459. + console.error(e);
  460. + }
  461. +
  462. + // We have interpreted the argument as a relative file URI, but the file
  463. + // doesn't exist. Try URI fixup heuristics: see bug 290782.
  464. +
  465. + try {
  466. + uri = Services.uriFixup.getFixupURIInfo(aArgument, 0).preferredURI;
  467. + } catch (e) {
  468. + console.error(e);
  469. + }
  470. +
  471. + return uri;
  472. +}
  473. +
  474. +export function DevToolsStartup() {}
  475. +
  476. +DevToolsStartup.prototype = {
  477. + QueryInterface: ChromeUtils.generateQI(["nsICommandLineHandler"]),
  478. +
  479. + helpInfo: "",
  480. + handle(cmdLine) {
  481. + this.initialize();
  482. +
  483. + // We want to overwrite the -devtools flag and open the toolbox instead
  484. + const devtoolsFlag = cmdLine.handleFlag("devtools", false);
  485. + if (devtoolsFlag) {
  486. + this.handleDevToolsFlag(cmdLine);
  487. + }
  488. +
  489. + var chromeFlag = cmdLine.handleFlagWithParam("chrome", false);
  490. + if (chromeFlag) {
  491. + // The parameter specifies the window to open.
  492. + this.handleChromeFlag(cmdLine, chromeFlag);
  493. + }
  494. + },
  495. +
  496. + handleDevToolsFlag(cmdLine) {
  497. + const { BrowserToolboxLauncher } = ChromeUtils.importESModule(
  498. + "resource://devtools/client/framework/browser-toolbox/Launcher.sys.mjs"
  499. + );
  500. + BrowserToolboxLauncher.init();
  501. +
  502. + if (cmdLine.state == Ci.nsICommandLine.STATE_REMOTE_AUTO) {
  503. + cmdLine.preventDefault = true;
  504. + }
  505. + },
  506. +
  507. + handleChromeFlag(cmdLine, chromeParam) {
  508. + try {
  509. + const argstring = Cc["@mozilla.org/supports-string;1"].createInstance(
  510. + Ci.nsISupportsString
  511. + );
  512. +
  513. + const _uri = resolveURIInternal(cmdLine, chromeParam);
  514. +
  515. + // only load URIs which do not inherit chrome privs
  516. + if (!Services.io.URIChainHasFlags(_uri, Ci.nsIProtocolHandler.URI_INHERITS_SECURITY_CONTEXT)) {
  517. + Services.ww.openWindow(null, _uri.spec, "_blank", "chrome,dialog=no,all", argstring);
  518. + cmdLine.preventDefault = true;
  519. + }
  520. + } catch (e) { dump(e); }
  521. + },
  522. +
  523. + initialize() {
  524. + const { loader, require, DevToolsLoader } = ChromeUtils.importESModule(
  525. + "resource://devtools/shared/loader/Loader.sys.mjs"
  526. + );
  527. + const { DevToolsServer } = require("devtools/server/devtools-server");
  528. + const { gDevTools } = require("devtools/client/framework/devtools");
  529. +
  530. + // Make sure our root actor is always registered, no matter how devtools are called.
  531. + const devtoolsRegisterActors =
  532. + DevToolsServer.registerActors.bind(DevToolsServer);
  533. + DevToolsServer.registerActors = function (options) {
  534. + devtoolsRegisterActors(options);
  535. + if (options.root) {
  536. + const {
  537. + createRootActor,
  538. + } = require("resource:///modules/devtools-root-actor.js");
  539. + DevToolsServer.setRootActor(createRootActor);
  540. + }
  541. + };
  542. +
  543. + // Make the loader visible to the debugger by default and for the already
  544. + // loaded instance. Thunderbird now also provides the Browser Toolbox for
  545. + // chrome debugging, which uses its own separate loader instance.
  546. + DevToolsLoader.prototype.invisibleToDebugger = false;
  547. + loader.invisibleToDebugger = false;
  548. + DevToolsServer.allowChromeProcess = true;
  549. +
  550. + // Initialize and load the toolkit/browser actors. This will also call above function to set the
  551. + // Thunderbird root actor
  552. + DevToolsServer.init();
  553. + DevToolsServer.registerAllActors();
  554. + },
  555. +};
  556. diff --git a/suite/components/devtools/devtools-root-actor.js b/suite/components/devtools/devtools-root-actor.js
  557. new file mode 100644
  558. --- /dev/null
  559. +++ b/suite/components/devtools/devtools-root-actor.js
  560. @@ -0,0 +1,67 @@
  561. +/* This Source Code Form is subject to the terms of the Mozilla Public
  562. + * License, v. 2.0. If a copy of the MPL was not distributed with this
  563. + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  564. +
  565. +/* globals loader, require, exports */
  566. +
  567. +/**
  568. + * Actors for Developer Tools.
  569. + */
  570. +
  571. +var { ActorRegistry } = require("devtools/server/actors/utils/actor-registry");
  572. +
  573. +loader.lazyRequireGetter(
  574. + this,
  575. + "RootActor",
  576. + "devtools/server/actors/root",
  577. + true
  578. +);
  579. +loader.lazyRequireGetter(
  580. + this,
  581. + "sendShutdownEvent",
  582. + "devtools/server/actors/webbrowser",
  583. + true
  584. +);
  585. +loader.lazyRequireGetter(
  586. + this,
  587. + "WorkerDescriptorActorList",
  588. + "devtools/server/actors/worker/worker-descriptor-actor-list",
  589. + true
  590. +);
  591. +loader.lazyRequireGetter(
  592. + this,
  593. + "ServiceWorkerRegistrationActorList",
  594. + "devtools/server/actors/worker/service-worker-registration-list",
  595. + true
  596. +);
  597. +loader.lazyRequireGetter(
  598. + this,
  599. + "ProcessActorList",
  600. + "devtools/server/actors/process",
  601. + true
  602. +);
  603. +
  604. +/**
  605. + * Create the basic root actor for any XRE Application.
  606. + *
  607. + * @param aConnection The debugger connection to create the actor for.
  608. + * @returns The actor for the connection.
  609. + */
  610. +exports.createRootActor = function (aConnection) {
  611. + const parameters = {
  612. + workerList: new WorkerDescriptorActorList(aConnection, {}),
  613. + serviceWorkerRegistrationList: new ServiceWorkerRegistrationActorList(
  614. + aConnection
  615. + ),
  616. + processList: new ProcessActorList(),
  617. + globalActorFactories: ActorRegistry.globalActorFactories,
  618. + onShutdown: sendShutdownEvent,
  619. + };
  620. +
  621. + // Create the root actor and set the application type
  622. + const rootActor = new RootActor(aConnection, parameters);
  623. + rootActor.applicationType = "generic";
  624. +
  625. + return rootActor;
  626. +};
  627. +
  628. diff --git a/suite/components/devtools/moz.build b/suite/components/devtools/moz.build
  629. new file mode 100644
  630. --- /dev/null
  631. +++ b/suite/components/devtools/moz.build
  632. @@ -0,0 +1,15 @@
  633. +# vim: set filetype=python:
  634. +# This Source Code Form is subject to the terms of the Mozilla Public
  635. +# License, v. 2.0. If a copy of the MPL was not distributed with this
  636. +# file, You can obtain one at http://mozilla.org/MPL/2.0/.
  637. +
  638. +EXTRA_JS_MODULES += [
  639. + "devtools-loader.sys.mjs",
  640. + "devtools-root-actor.js",
  641. +]
  642. +
  643. +XPCOM_MANIFESTS += [
  644. + "components.conf",
  645. +]
  646. +
  647. +JS_PREFERENCE_FILES += ['all-devtools.js']
  648. diff --git a/suite/components/moz.build b/suite/components/moz.build
  649. --- a/suite/components/moz.build
  650. +++ b/suite/components/moz.build
  651. @@ -4,16 +4,17 @@
  652. # License, v. 2.0. If a copy of the MPL was not distributed with this
  653. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
  654. DIRS += [
  655. "autocomplete",
  656. "bindings",
  657. "console",
  658. "dataman",
  659. + "devtools",
  660. "downloads",
  661. "feeds",
  662. "helpviewer",
  663. "migration",
  664. "permissions",
  665. "places",
  666. "pref",
  667. "profile",