diff --git a/.eslintignore b/.eslintignore index 1d5d40d264d3..ae97d88107d4 100644 --- a/.eslintignore +++ b/.eslintignore @@ -138,9 +138,8 @@ devtools/shared/qrcode/tests/mochitest/test_decode.html devtools/shared/tests/mochitest/*.html devtools/shared/webconsole/test/test_*.html -# Ignore devtools preferences files +# Ignore devtools pre-processed files devtools/client/preferences/** -devtools/shim/devtools-startup-prefs.js # Ignore devtools third-party libs devtools/shared/jsbeautify/* diff --git a/browser/installer/allowed-dupes.mn b/browser/installer/allowed-dupes.mn index f52e7b067cfb..f356ea994425 100644 --- a/browser/installer/allowed-dupes.mn +++ b/browser/installer/allowed-dupes.mn @@ -55,13 +55,57 @@ browser/chrome/browser/skin/classic/browser/connection-secure.svg browser/chrome/browser/skin/classic/browser/controlcenter/warning-gray.svg browser/chrome/browser/skin/classic/browser/newtab/close.png # devtools reduction is bug 1311178 -browser/features/devtools@mozilla.org/chrome/skin/images/security-state-broken.svg -browser/features/devtools@mozilla.org/chrome/skin/images/security-state-secure.svg -browser/features/devtools@mozilla.org/chrome/skin/toolbars.css -browser/features/devtools@mozilla.org/chrome/modules/client/themes/toolbars.css +browser/chrome/devtools/content/dom/content/dom-view.css +browser/chrome/devtools/content/dom/dom.html +browser/chrome/devtools/content/dom/main.js +browser/chrome/devtools/content/framework/toolbox-options.js +browser/chrome/devtools/content/inspector/fonts/fonts.js +browser/chrome/devtools/content/inspector/inspector.xhtml +browser/chrome/devtools/content/memory/initializer.js +browser/chrome/devtools/content/projecteditor/lib/helpers/readdir.js +browser/chrome/devtools/content/shared/frame-script-utils.js +browser/chrome/devtools/content/shared/theme-switching.js +browser/chrome/devtools/modules/devtools/client/dom/content/dom-view.css +browser/chrome/devtools/modules/devtools/client/dom/dom.html +browser/chrome/devtools/modules/devtools/client/dom/main.js +browser/chrome/devtools/modules/devtools/client/framework/toolbox-options.js +browser/chrome/devtools/modules/devtools/client/inspector/fonts/fonts.js +browser/chrome/devtools/modules/devtools/client/inspector/inspector.xhtml +browser/chrome/devtools/modules/devtools/client/jsonview/css/controls.png +browser/chrome/devtools/modules/devtools/client/jsonview/css/controls@2x.png +browser/chrome/devtools/modules/devtools/client/memory/initializer.js +browser/chrome/devtools/modules/devtools/client/projecteditor/lib/helpers/readdir.js +browser/chrome/devtools/modules/devtools/client/shared/frame-script-utils.js +browser/chrome/devtools/modules/devtools/client/shared/theme-switching.js +browser/chrome/devtools/modules/devtools/client/themes/common.css +browser/chrome/devtools/modules/devtools/client/themes/toolbars.css +browser/chrome/devtools/modules/devtools/client/themes/variables.css +browser/chrome/devtools/skin/common.css +browser/chrome/devtools/skin/toolbars.css +browser/chrome/devtools/skin/images/command-scratchpad.svg +browser/chrome/devtools/skin/images/controls.png +browser/chrome/devtools/skin/images/controls@2x.png +browser/chrome/devtools/skin/images/debugger-blackbox.svg +browser/chrome/devtools/skin/images/debugger-prettyprint.svg +browser/chrome/devtools/skin/images/filetypes/store.svg +browser/chrome/devtools/skin/images/itemToggle.svg +browser/chrome/devtools/skin/images/security-state-broken.svg +browser/chrome/devtools/skin/images/security-state-local.svg +browser/chrome/devtools/skin/images/security-state-secure.svg +browser/chrome/devtools/skin/images/tabs-icon.svg +browser/chrome/devtools/skin/images/tool-scratchpad.svg +browser/chrome/devtools/skin/images/tool-storage.svg +browser/chrome/devtools/skin/images/tool-styleeditor.svg +browser/chrome/devtools/skin/promisedebugger.css +browser/chrome/devtools/skin/variables.css +modules/devtools/Console.jsm modules/devtools/Loader.jsm +modules/devtools/Simulator.jsm +modules/devtools/shared/Console.jsm modules/devtools/shared/Loader.jsm - +modules/devtools/shared/apps/Simulator.jsm +browser/modules/devtools/client/framework/gDevTools.jsm +browser/modules/devtools/gDevTools.jsm browser/chrome/icons/default/default16.png browser/chrome/icons/default/default32.png browser/chrome/icons/default/default48.png diff --git a/browser/installer/package-manifest.in b/browser/installer/package-manifest.in index e7206bf67fd1..177f20a31680 100644 --- a/browser/installer/package-manifest.in +++ b/browser/installer/package-manifest.in @@ -627,10 +627,20 @@ #endif @RESPATH@/browser/features/* +; [Webide Files] +@RESPATH@/browser/chrome/webide@JAREXT@ +@RESPATH@/browser/chrome/webide.manifest +@RESPATH@/browser/@PREF_DIR@/webide-prefs.js + ; [DevTools Shim Files] @RESPATH@/browser/chrome/devtools-shim@JAREXT@ @RESPATH@/browser/chrome/devtools-shim.manifest -@RESPATH@/browser/@PREF_DIR@/devtools-startup-prefs.js + +; DevTools +@RESPATH@/browser/chrome/devtools@JAREXT@ +@RESPATH@/browser/chrome/devtools.manifest +@RESPATH@/browser/@PREF_DIR@/devtools.js +@RESPATH@/browser/@PREF_DIR@/debugger.js ; shell icons #ifdef XP_UNIX diff --git a/devtools/bootstrap.js b/devtools/bootstrap.js index a2d83aa43bc8..4fd14cae4794 100644 --- a/devtools/bootstrap.js +++ b/devtools/bootstrap.js @@ -8,7 +8,176 @@ "use strict"; const Cu = Components.utils; +const Ci = Components.interfaces; const {Services} = Cu.import("resource://gre/modules/Services.jsm", {}); +const {NetUtil} = Cu.import("resource://gre/modules/NetUtil.jsm", {}); +const {AppConstants} = Cu.import("resource://gre/modules/AppConstants.jsm", {}); + +// MultiWindowKeyListener instance for Ctrl+Alt+R key +let listener; +// nsIURI to the addon root folder +let resourceURI; + +function actionOccurred(id) { + let {require} = Cu.import("resource://devtools/shared/Loader.jsm", {}); + let Telemetry = require("devtools/client/shared/telemetry"); + let telemetry = new Telemetry(); + telemetry.actionOccurred(id); +} + +// Synchronously fetch the content of a given URL +function readURI(uri) { + let stream = NetUtil.newChannel({ + uri: NetUtil.newURI(uri, "UTF-8"), + loadUsingSystemPrincipal: true} + ).open2(); + let count = stream.available(); + let data = NetUtil.readInputStreamToString(stream, count, { + charset: "UTF-8" + }); + + stream.close(); + + return data; +} + +/** + * Interpret the processing instructions contained in a preferences file, based on a + * limited set of supported #if statements. After we ship as an addon, we don't want to + * introduce anymore processing instructions, so all unrecognized preprocessing + * instructions will be treated as an error. + * + * This function is mostly copied from devtools/client/inspector/webpack/prefs-loader.js + * + * @param {String} content + * The string content of a preferences file. + * @return {String} the content stripped of preprocessing instructions. + */ +function interpretPreprocessingInstructions(content) { + const ifMap = { + "#if MOZ_UPDATE_CHANNEL == beta": AppConstants.MOZ_UPDATE_CHANNEL === "beta", + "#if defined(NIGHTLY_BUILD)": AppConstants.NIGHTLY_BUILD, + "#ifdef MOZ_DEV_EDITION": AppConstants.MOZ_DEV_EDITION, + "#ifdef RELEASE_OR_BETA": AppConstants.RELEASE_OR_BETA, + }; + + let lines = content.split("\n"); + let ignoring = false; + let newLines = []; + let continuation = false; + for (let line of lines) { + if (line.startsWith("#if")) { + if (!(line in ifMap)) { + throw new Error("missing line in ifMap: " + line); + } + ignoring = !ifMap[line]; + } else if (line.startsWith("#else")) { + ignoring = !ignoring; + } else if (line.startsWith("#endif")) { + ignoring = false; + } + + let isPrefLine = /^ *(sticky_)?pref\("([^"]+)"/.test(line); + if (continuation || (!ignoring && isPrefLine)) { + newLines.push(line); + + // The call to pref(...); might span more than one line. + continuation = !/\);/.test(line); + } + } + return newLines.join("\n"); +} + +// Read a preference file and set all of its defined pref as default values +// (This replicates the behavior of preferences files from mozilla-central) +function processPrefFile(url) { + let content = readURI(url); + content = interpretPreprocessingInstructions(content); + content.match(/pref\("[^"]+",\s*.+\s*\)/g).forEach(item => { + let m = item.match(/pref\("([^"]+)",\s*(.+)\s*\)/); + let name = m[1]; + let val = m[2].trim(); + + // Prevent overriding prefs that have been changed by the user + if (Services.prefs.prefHasUserValue(name)) { + return; + } + let defaultBranch = Services.prefs.getDefaultBranch(""); + if ((val.startsWith("\"") && val.endsWith("\"")) || + (val.startsWith("'") && val.endsWith("'"))) { + val = val.substr(1, val.length - 2); + val = val.replace(/\\"/g, '"'); + defaultBranch.setCharPref(name, val); + } else if (val.match(/[0-9]+/)) { + defaultBranch.setIntPref(name, parseInt(val, 10)); + } else if (val == "true" || val == "false") { + defaultBranch.setBoolPref(name, val == "true"); + } else { + console.log("Unable to match preference type for value:", val); + } + }); +} + +function setPrefs() { + processPrefFile(resourceURI.spec + "./client/preferences/devtools.js"); + processPrefFile(resourceURI.spec + "./client/preferences/debugger.js"); + processPrefFile(resourceURI.spec + "./client/webide/webide-prefs.js"); +} + +// Helper to listen to a key on all windows +function MultiWindowKeyListener({ keyCode, ctrlKey, altKey, callback }) { + let keyListener = function (event) { + if (event.ctrlKey == !!ctrlKey && + event.altKey == !!altKey && + event.keyCode === keyCode) { + callback(event); + + // Call preventDefault to avoid duplicated events when + // doing the key stroke within a tab. + event.preventDefault(); + } + }; + + let observer = function (window, topic, data) { + // Listen on keyup to call keyListener only once per stroke + if (topic === "domwindowopened") { + window.addEventListener("keyup", keyListener); + } else { + window.removeEventListener("keyup", keyListener); + } + }; + + return { + start: function () { + // Automatically process already opened windows + let e = Services.ww.getWindowEnumerator(); + while (e.hasMoreElements()) { + let window = e.getNext(); + observer(window, "domwindowopened", null); + } + // And listen for new ones to come + Services.ww.registerNotification(observer); + }, + + stop: function () { + Services.ww.unregisterNotification(observer); + let e = Services.ww.getWindowEnumerator(); + while (e.hasMoreElements()) { + let window = e.getNext(); + observer(window, "domwindowclosed", null); + } + } + }; +} + +let getTopLevelWindow = function (window) { + return window.QueryInterface(Ci.nsIInterfaceRequestor) + .getInterface(Ci.nsIWebNavigation) + .QueryInterface(Ci.nsIDocShellTreeItem) + .rootTreeItem + .QueryInterface(Ci.nsIInterfaceRequestor) + .getInterface(Ci.nsIDOMWindow); +}; function unload(reason) { // This frame script is going to be executed in all processes: @@ -46,17 +215,132 @@ function unload(reason) { Cu.unload("resource://devtools/shared/deprecated-sync-thenables.js"); } -function startup(data) {} +function reload(event) { + // We automatically reload the toolbox if we are on a browser tab + // with a toolbox already opened + let reloadToolbox = false; + if (event) { + let top = getTopLevelWindow(event.view); + let isBrowser = top.location.href.includes("/browser.xul"); + if (isBrowser && top.gBrowser) { + // We do not use any devtools code before the call to Loader.jsm reload as + // any attempt to use Loader.jsm to load a module will instanciate a new + // Loader. + let nbox = top.gBrowser.getNotificationBox(); + reloadToolbox = + top.document.getAnonymousElementByAttribute(nbox, "class", + "devtools-toolbox-bottom-iframe") || + top.document.getAnonymousElementByAttribute(nbox, "class", + "devtools-toolbox-side-iframe") || + Services.wm.getMostRecentWindow("devtools:toolbox"); + } + } + let browserConsole = Services.wm.getMostRecentWindow("devtools:webconsole"); + let reopenBrowserConsole = false; + if (browserConsole) { + browserConsole.close(); + reopenBrowserConsole = true; + } + dump("Reload DevTools. (reload-toolbox:" + reloadToolbox + ")\n"); + + // Invalidate xul cache in order to see changes made to chrome:// files + Services.obs.notifyObservers(null, "startupcache-invalidate"); + + unload("reload"); + + // Update the preferences before starting new code + setPrefs(); + + const {devtools} = Cu.import("resource://devtools/shared/Loader.jsm", {}); + devtools.require("devtools/client/framework/devtools-browser"); + + // Go over all top level windows to reload all devtools related things + let windowsEnum = Services.wm.getEnumerator(null); + while (windowsEnum.hasMoreElements()) { + let window = windowsEnum.getNext(); + let windowtype = window.document.documentElement.getAttribute("windowtype"); + if (windowtype == "navigator:browser" && window.gBrowser) { + // Enumerate tabs on firefox windows + for (let tab of window.gBrowser.tabs) { + let browser = tab.linkedBrowser; + let location = browser.documentURI.spec; + let mm = browser.messageManager; + // To reload JSON-View tabs and any devtools document + if (location.startsWith("about:debugging") || + location.startsWith("chrome://devtools/")) { + browser.reload(); + } + // We have to use a frame script to query "baseURI" + mm.loadFrameScript("data:text/javascript,new " + function () { + let isJSONView = + content.document.baseURI.startsWith("resource://devtools/"); + if (isJSONView) { + content.location.reload(); + } + }, false); + } + } else if (windowtype === "devtools:webide") { + window.location.reload(); + } + } + + if (reloadToolbox) { + // Reopen the toolbox automatically if we are reloading from toolbox + // shortcut and are on a browser window. + // Wait for a second before opening the toolbox to avoid races + // between the old and the new one. + let {setTimeout} = Cu.import("resource://gre/modules/Timer.jsm", {}); + setTimeout(() => { + let { TargetFactory } = devtools.require("devtools/client/framework/target"); + let { gDevTools } = devtools.require("devtools/client/framework/devtools"); + let top = getTopLevelWindow(event.view); + let target = TargetFactory.forTab(top.gBrowser.selectedTab); + gDevTools.showToolbox(target); + }, 1000); + } + + // Browser console document can't just be reloaded. + // HUDService is going to close it on unload. + // Instead we have to manually toggle it. + if (reopenBrowserConsole) { + let HUDService = devtools.require("devtools/client/webconsole/hudservice"); + HUDService.toggleBrowserConsole(); + } + + actionOccurred("reloadAddonReload"); +} + +function startup(data) { + dump("DevTools addon started.\n"); + + resourceURI = data.resourceURI; + + listener = new MultiWindowKeyListener({ + keyCode: Ci.nsIDOMKeyEvent.DOM_VK_R, ctrlKey: true, altKey: true, + callback: reload + }); + listener.start(); + + reload(); +} function shutdown(data, reason) { // On browser shutdown, do not try to cleanup anything if (reason == APP_SHUTDOWN) { return; } + listener.stop(); + listener = null; + unload("disable"); } - -function install() {} - +function install() { + try { + actionOccurred("reloadAddonInstalled"); + } catch (e) { + // When installing on Firefox builds without devtools, telemetry doesn't + // work yet and throws. + } +} function uninstall() {} diff --git a/devtools/client/aboutdebugging/test/xpcshell.ini b/devtools/client/aboutdebugging/test/xpcshell.ini index 3a4921c2b4ec..cf2e8bd2d5da 100644 --- a/devtools/client/aboutdebugging/test/xpcshell.ini +++ b/devtools/client/aboutdebugging/test/xpcshell.ini @@ -1,6 +1,6 @@ [DEFAULT] tags = devtools -head = ../../../shared/tests/shared-xpcshell-head.js xpcshell-head.js +head = xpcshell-head.js firefox-appdir = browser skip-if = toolkit == 'android' diff --git a/devtools/client/animationinspector/test/unit/xpcshell.ini b/devtools/client/animationinspector/test/unit/xpcshell.ini index 57f899993438..c0f26adcc35d 100644 --- a/devtools/client/animationinspector/test/unit/xpcshell.ini +++ b/devtools/client/animationinspector/test/unit/xpcshell.ini @@ -1,6 +1,6 @@ [DEFAULT] tags = devtools -head = ../../../../shared/tests/shared-xpcshell-head.js +head = firefox-appdir = browser skip-if = toolkit == 'android' diff --git a/devtools/shim/devtools-startup.js b/devtools/client/devtools-startup.js similarity index 100% rename from devtools/shim/devtools-startup.js rename to devtools/client/devtools-startup.js diff --git a/devtools/shim/devtools-startup.manifest b/devtools/client/devtools-startup.manifest similarity index 100% rename from devtools/shim/devtools-startup.manifest rename to devtools/client/devtools-startup.manifest diff --git a/devtools/client/framework/ToolboxProcess.jsm b/devtools/client/framework/ToolboxProcess.jsm index 85fef64967f3..c8f06bd4c373 100644 --- a/devtools/client/framework/ToolboxProcess.jsm +++ b/devtools/client/framework/ToolboxProcess.jsm @@ -187,7 +187,6 @@ BrowserToolboxProcess.prototype = { // We would like to copy prefs into this new profile... let prefsFile = debuggingProfileDir.clone(); prefsFile.append("prefs.js"); - // ... but unfortunately, when we run tests, it seems the starting profile // clears out the prefs file before re-writing it, and in practice the // file is empty when we get here. So just copying doesn't work in that @@ -195,21 +194,8 @@ BrowserToolboxProcess.prototype = { // We could force a sync pref flush and then copy it... but if we're doing // that, we might as well just flush directly to the new profile, which // always works: - - // Before dumping the preferences to prefsFile, clear the current pref for - // extensions.lastAppVersion. The AddonManager expects this pref to be undefined - // when loading a new profile, this will trigger the installation of system addons - // without showing the addon update popup. - let appVersion = Services.prefs.getCharPref("extensions.lastAppVersion", ""); - Services.prefs.clearUserPref("extensions.lastAppVersion"); - Services.prefs.savePrefFile(prefsFile); - // Restore the overridden extensions.lastAppVersion preference. - if (appVersion) { - Services.prefs.setCharPref("extensions.lastAppVersion", appVersion); - } - dumpn("Finished creating the chrome toolbox user profile at: " + this._dbgProfilePath); }, diff --git a/devtools/client/inspector/grids/test/unit/xpcshell.ini b/devtools/client/inspector/grids/test/unit/xpcshell.ini index 2c28f2aebf95..c52a930c717f 100644 --- a/devtools/client/inspector/grids/test/unit/xpcshell.ini +++ b/devtools/client/inspector/grids/test/unit/xpcshell.ini @@ -1,6 +1,6 @@ [DEFAULT] tags = devtools firefox-appdir = browser -head = ../../../../../shared/tests/shared-xpcshell-head.js head.js +head = head.js [test_compare_fragments_geometry.js] diff --git a/devtools/client/jar.mn b/devtools/client/jar.mn index 168fee0c716e..81447c70ab2a 100644 --- a/devtools/client/jar.mn +++ b/devtools/client/jar.mn @@ -2,12 +2,8 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -[features/devtools@mozilla.org] chrome.jar: +devtools.jar: % content devtools %content/ - content/preferences/debugger.js (preferences/debugger.js) -* content/preferences/devtools.js (preferences/devtools.js) - content/preferences/DevToolsPreferences.jsm (preferences/DevToolsPreferences.jsm) - content/webide/webide-prefs.js (webide/webide-prefs.js) content/shared/vendor/d3.js (shared/vendor/d3.js) content/shared/vendor/dagre-d3.js (shared/vendor/dagre-d3.js) content/shared/widgets/widgets.css (shared/widgets/widgets.css) diff --git a/devtools/client/locales/jar.mn b/devtools/client/locales/jar.mn index cff8b5927d0e..43ce3aef2c69 100644 --- a/devtools/client/locales/jar.mn +++ b/devtools/client/locales/jar.mn @@ -3,6 +3,6 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -[features/devtools@mozilla.org] chrome.jar: +@AB_CD@.jar: % locale devtools @AB_CD@ %locale/@AB_CD@/devtools/client/ locale/@AB_CD@/devtools/client/ (%*) diff --git a/devtools/client/memory/test/unit/xpcshell.ini b/devtools/client/memory/test/unit/xpcshell.ini index 1c6ce604f67c..ccb1a02e1aa9 100644 --- a/devtools/client/memory/test/unit/xpcshell.ini +++ b/devtools/client/memory/test/unit/xpcshell.ini @@ -1,6 +1,6 @@ [DEFAULT] tags = devtools devtools-memory -head = ../../../../shared/tests/shared-xpcshell-head.js head.js ../../../framework/test/shared-redux-head.js +head = head.js ../../../framework/test/shared-redux-head.js firefox-appdir = browser skip-if = toolkit == 'android' diff --git a/devtools/client/moz.build b/devtools/client/moz.build index f1ca9fd58e51..2ebb7e4511c1 100644 --- a/devtools/client/moz.build +++ b/devtools/client/moz.build @@ -20,6 +20,7 @@ DIRS += [ 'memory', 'netmonitor', 'performance', + 'preferences', 'responsive.html', 'responsivedesign', 'scratchpad', @@ -39,6 +40,11 @@ DIRS += [ if CONFIG['MOZ_BUILD_APP'] == 'browser': DIRS += ['themes/shims'] +EXTRA_COMPONENTS += [ + 'devtools-startup.js', + 'devtools-startup.manifest', +] + JAR_MANIFESTS += ['jar.mn'] DevToolsModules( diff --git a/devtools/client/performance/test/unit/xpcshell.ini b/devtools/client/performance/test/unit/xpcshell.ini index 8c19a80a2016..3860d0308f5c 100644 --- a/devtools/client/performance/test/unit/xpcshell.ini +++ b/devtools/client/performance/test/unit/xpcshell.ini @@ -1,6 +1,6 @@ [DEFAULT] tags = devtools -head = ../../../../shared/tests/shared-xpcshell-head.js head.js +head = head.js firefox-appdir = browser skip-if = toolkit == 'android' diff --git a/devtools/client/preferences/DevToolsPreferences.jsm b/devtools/client/preferences/DevToolsPreferences.jsm deleted file mode 100644 index 8e9c819c7177..000000000000 --- a/devtools/client/preferences/DevToolsPreferences.jsm +++ /dev/null @@ -1,88 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -"use strict"; - -const Cu = Components.utils; - -const {NetUtil} = Cu.import("resource://gre/modules/NetUtil.jsm", {}); -const {Services} = Cu.import("resource://gre/modules/Services.jsm", {}); - -this.EXPORTED_SYMBOLS = ["DevToolsPreferences"]; - -// Synchronously fetch the content of a given URL -function readURI(uri) { - let stream = NetUtil.newChannel({ - uri: NetUtil.newURI(uri, "UTF-8"), - loadUsingSystemPrincipal: true} - ).open2(); - let count = stream.available(); - let data = NetUtil.readInputStreamToString(stream, count, { - charset: "UTF-8" - }); - - stream.close(); - - return data; -} - -/** - * Cleanup the preferences file content from all empty and comment lines. - * - * @param {String} content - * The string content of a preferences file. - * @return {String} the content stripped of unnecessary lines. - */ -function cleanupPreferencesFileContent(content) { - let lines = content.split("\n"); - let newLines = []; - let continuation = false; - for (let line of lines) { - let isPrefLine = /^ *pref\("([^"]+)"/.test(line); - if (continuation || isPrefLine) { - newLines.push(line); - // The call to pref(...); might span more than one line. - continuation = !/\);/.test(line); - } - } - return newLines.join("\n"); -} - -// Read a preference file and set all of its defined pref as default values -// (This replicates the behavior of preferences files from mozilla-central) -function processPrefFile(url) { - let content = readURI(url); - content = cleanupPreferencesFileContent(content); - content.match(/pref\("[^"]+",\s*.+\s*\)/g).forEach(item => { - let m = item.match(/pref\("([^"]+)",\s*(.+)\s*\)/); - let name = m[1]; - let val = m[2].trim(); - - // Prevent overriding prefs that have been changed by the user - if (Services.prefs.prefHasUserValue(name)) { - return; - } - let defaultBranch = Services.prefs.getDefaultBranch(""); - if ((val.startsWith("\"") && val.endsWith("\"")) || - (val.startsWith("'") && val.endsWith("'"))) { - val = val.substr(1, val.length - 2); - val = val.replace(/\\"/g, '"'); - defaultBranch.setCharPref(name, val); - } else if (val.match(/[0-9]+/)) { - defaultBranch.setIntPref(name, parseInt(val, 10)); - } else if (val == "true" || val == "false") { - defaultBranch.setBoolPref(name, val == "true"); - } else { - console.log("Unable to match preference type for value:", val); - } - }); -} - -this.DevToolsPreferences = { - loadPrefs: function () { - processPrefFile("chrome://devtools/content/preferences/devtools.js"); - processPrefFile("chrome://devtools/content/preferences/debugger.js"); - processPrefFile("chrome://devtools/content/webide/webide-prefs.js"); - } -}; diff --git a/devtools/client/preferences/devtools.js b/devtools/client/preferences/devtools.js index 160417a0a0a7..f9faf7c1aa3b 100644 --- a/devtools/client/preferences/devtools.js +++ b/devtools/client/preferences/devtools.js @@ -47,6 +47,8 @@ pref("devtools.command-button-measure.enabled", false); pref("devtools.command-button-noautohide.enabled", false); // Inspector preferences +// Enable the Inspector +pref("devtools.inspector.enabled", true); // What was the last active sidebar in the inspector pref("devtools.inspector.activeSidebar", "ruleview"); pref("devtools.inspector.remote", false); @@ -229,6 +231,13 @@ pref("devtools.dom.enabled", false); // Web Audio Editor Inspector Width should be a preference pref("devtools.webaudioeditor.inspectorWidth", 300); +// Default theme ("dark" or "light") +#ifdef MOZ_DEV_EDITION +sticky_pref("devtools.theme", "dark"); +#else +sticky_pref("devtools.theme", "light"); +#endif + // Web console filters pref("devtools.webconsole.filter.error", true); pref("devtools.webconsole.filter.warn", true); @@ -344,5 +353,8 @@ pref("devtools.editor.autocomplete", true); // version for each user. pref("devtools.telemetry.tools.opened.version", "{}"); +// Enable the JSON View tool (an inspector for application/json documents). +pref("devtools.jsonview.enabled", true); + // Enable the HTML responsive design mode for all channels. pref("devtools.responsive.html.enabled", true); diff --git a/devtools/client/preferences/moz.build b/devtools/client/preferences/moz.build new file mode 100644 index 000000000000..f07d09285d99 --- /dev/null +++ b/devtools/client/preferences/moz.build @@ -0,0 +1,13 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +JS_PREFERENCE_PP_FILES += [ + 'devtools.js' +] + +JS_PREFERENCE_FILES += [ + 'debugger.js', +] diff --git a/devtools/client/responsive.html/test/unit/xpcshell.ini b/devtools/client/responsive.html/test/unit/xpcshell.ini index bdfc18f2ddfe..ed745c18c593 100644 --- a/devtools/client/responsive.html/test/unit/xpcshell.ini +++ b/devtools/client/responsive.html/test/unit/xpcshell.ini @@ -1,6 +1,6 @@ [DEFAULT] tags = devtools -head = ../../../../shared/tests/shared-xpcshell-head.js head.js ../../../framework/test/shared-redux-head.js +head = head.js ../../../framework/test/shared-redux-head.js firefox-appdir = browser [test_add_device.js] diff --git a/devtools/client/shared/redux/middleware/test/xpcshell.ini b/devtools/client/shared/redux/middleware/test/xpcshell.ini index 49e8313dd940..ec33920b13e4 100644 --- a/devtools/client/shared/redux/middleware/test/xpcshell.ini +++ b/devtools/client/shared/redux/middleware/test/xpcshell.ini @@ -1,6 +1,6 @@ [DEFAULT] tags = devtools -head = ../../../../../shared/tests/shared-xpcshell-head.js head.js +head = head.js firefox-appdir = browser skip-if = toolkit == 'android' diff --git a/devtools/client/shared/test/unit/xpcshell.ini b/devtools/client/shared/test/unit/xpcshell.ini index 1bf50cbbc363..99d6d1bb6da3 100644 --- a/devtools/client/shared/test/unit/xpcshell.ini +++ b/devtools/client/shared/test/unit/xpcshell.ini @@ -1,6 +1,6 @@ [DEFAULT] tags = devtools -head = ../../../../shared/tests/shared-xpcshell-head.js +head = firefox-appdir = browser skip-if = toolkit == 'android' diff --git a/devtools/client/shared/vendor/stringvalidator/tests/unit/xpcshell.ini b/devtools/client/shared/vendor/stringvalidator/tests/unit/xpcshell.ini index 4249ecc21541..1c90bf2baa3f 100644 --- a/devtools/client/shared/vendor/stringvalidator/tests/unit/xpcshell.ini +++ b/devtools/client/shared/vendor/stringvalidator/tests/unit/xpcshell.ini @@ -1,6 +1,6 @@ [DEFAULT] tags = devtools -head = ../../../../../../shared/tests/shared-xpcshell-head.js head_stringvalidator.js +head = head_stringvalidator.js firefox-appdir = browser skip-if = toolkit == 'android' diff --git a/devtools/client/sourceeditor/tern/tests/unit/xpcshell.ini b/devtools/client/sourceeditor/tern/tests/unit/xpcshell.ini index 928a2861e89a..4d378c22489a 100644 --- a/devtools/client/sourceeditor/tern/tests/unit/xpcshell.ini +++ b/devtools/client/sourceeditor/tern/tests/unit/xpcshell.ini @@ -1,6 +1,6 @@ [DEFAULT] tags = devtools -head = ../../../../../shared/tests/shared-xpcshell-head.js head_tern.js +head = head_tern.js firefox-appdir = browser [test_autocompletion.js] diff --git a/devtools/client/themes/firebug-theme.css b/devtools/client/themes/firebug-theme.css index fdba0fc13276..567729e6af00 100644 --- a/devtools/client/themes/firebug-theme.css +++ b/devtools/client/themes/firebug-theme.css @@ -7,7 +7,7 @@ @import url(resource://devtools/client/themes/common.css); @import url(chrome://devtools/skin/light-theme.css); -:root.theme-firebug { +:root { font-size: 11px; font-family: var(--proportional-font-family); } diff --git a/devtools/client/webconsole/net/main.js b/devtools/client/webconsole/net/main.js index 93eb01ea54ec..671f288a6ed3 100644 --- a/devtools/client/webconsole/net/main.js +++ b/devtools/client/webconsole/net/main.js @@ -38,7 +38,7 @@ var styleSheets = [ // on the right CSS strategy FIXME. // It would also be nice to include them using @import. styleSheets.forEach(url => { - loadSheet(window, url, "author"); + loadSheet(this, url, "author"); }); // Localization API used by React components diff --git a/devtools/client/webconsole/net/test/unit/xpcshell.ini b/devtools/client/webconsole/net/test/unit/xpcshell.ini index 22289e951372..15cd83a9e94a 100644 --- a/devtools/client/webconsole/net/test/unit/xpcshell.ini +++ b/devtools/client/webconsole/net/test/unit/xpcshell.ini @@ -1,6 +1,6 @@ [DEFAULT] tags = devtools -head = ../../../../../shared/tests/shared-xpcshell-head.js +head = firefox-appdir = browser skip-if = toolkit == 'android' diff --git a/devtools/client/webide/content/jar.mn b/devtools/client/webide/content/jar.mn index 663faf201b55..dfb28c2ef920 100644 --- a/devtools/client/webide/content/jar.mn +++ b/devtools/client/webide/content/jar.mn @@ -2,7 +2,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -[features/devtools@mozilla.org] webide.jar: +webide.jar: % content webide %content/ content/webide.xul (webide.xul) content/webide.js (webide.js) diff --git a/devtools/client/webide/content/webide.js b/devtools/client/webide/content/webide.js index 77fea77d23b7..f843b47edcfa 100644 --- a/devtools/client/webide/content/webide.js +++ b/devtools/client/webide/content/webide.js @@ -116,12 +116,6 @@ var UI = { this.configureSimulator = this.configureSimulator.bind(this); Simulators.on("configure", this.configureSimulator); - - // This allows to use mac specific selectors in webide css files, using - // `:root[platform="mac"]`. - if (navigator.platform.startsWith("Mac")) { - document.documentElement.setAttribute("platform", "mac"); - } }, destroy: function () { diff --git a/devtools/client/webide/moz.build b/devtools/client/webide/moz.build index 05b6f1573142..42e048491d9b 100644 --- a/devtools/client/webide/moz.build +++ b/devtools/client/webide/moz.build @@ -17,5 +17,9 @@ MOCHITEST_CHROME_MANIFESTS += [ 'test/chrome.ini' ] +JS_PREFERENCE_FILES += [ + 'webide-prefs.js', +] + with Files('**'): BUG_COMPONENT = ('Firefox', 'Developer Tools: WebIDE') diff --git a/devtools/client/webide/themes/jar.mn b/devtools/client/webide/themes/jar.mn index a57dc64cc43d..6bf5da892584 100644 --- a/devtools/client/webide/themes/jar.mn +++ b/devtools/client/webide/themes/jar.mn @@ -2,9 +2,9 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -[features/devtools@mozilla.org] webide.jar: +webide.jar: % skin webide classic/1.0 %skin/ - skin/webide.css (webide.css) +* skin/webide.css (webide.css) skin/icons.png (icons.png) skin/details.css (details.css) skin/newapp.css (newapp.css) diff --git a/devtools/client/webide/themes/webide.css b/devtools/client/webide/themes/webide.css index 12aabf31e300..0dea91a5f6b6 100644 --- a/devtools/client/webide/themes/webide.css +++ b/devtools/client/webide/themes/webide.css @@ -138,11 +138,9 @@ window.busy-determined #action-busy-undetermined { background-repeat: no-repeat, repeat; background-size: 35%, auto; background-position: center center, top left; +%ifndef XP_MACOSX border-top: 1px solid #AAA; -} - -:root[platform="mac"] #deck { - border-top-width: 0; +%endif } .devtools-horizontal-splitter { diff --git a/devtools/install.rdf b/devtools/install.rdf index 8c26468e59f1..0a4df1d0f6a6 100644 --- a/devtools/install.rdf +++ b/devtools/install.rdf @@ -17,7 +17,6 @@ true true - {ec8030f7-c20a-464f-9b0e-13a3a9e97384} @@ -25,13 +24,5 @@ * - - - - {aa3c5121-dab2-40e2-81ca-7ea25febc110} - 44.0a1 - * - - diff --git a/devtools/moz.build b/devtools/moz.build index 2fa28b8c0fa2..6367a0eb7928 100644 --- a/devtools/moz.build +++ b/devtools/moz.build @@ -26,20 +26,6 @@ if CONFIG['MOZ_DEVTOOLS'] != 'addon': 'server', 'shared', ] - FINAL_TARGET_FILES.features['devtools@mozilla.org'] += [ - 'install.rdf', - ] - -# For Fennec, provide an empty bootstrap.js that doesn't do anything. -# DevTools initialization is handled by mobile/android/chrome/content/RemoteDebugger.js -if CONFIG['MOZ_DEVTOOLS'] == 'server': - FINAL_TARGET_FILES.features['devtools@mozilla.org'] += [ - 'server/bootstrap.js', - ] -elif CONFIG['MOZ_DEVTOOLS'] != 'addon': - FINAL_TARGET_FILES.features['devtools@mozilla.org'] += [ - 'bootstrap.js', - ] # /browser uses DIST_SUBDIR. We opt-in to this treatment when building # DevTools for the browser to keep the root omni.ja slim for use by external XUL diff --git a/devtools/platform/tests/unit/xpcshell.ini b/devtools/platform/tests/unit/xpcshell.ini index a85741f576e4..91430971a75f 100644 --- a/devtools/platform/tests/unit/xpcshell.ini +++ b/devtools/platform/tests/unit/xpcshell.ini @@ -1,6 +1,5 @@ [DEFAULT] tags = devtools -head = ../../../shared/tests/shared-xpcshell-head.js firefox-appdir = browser skip-if = toolkit == 'android' diff --git a/devtools/server/bootstrap.js b/devtools/server/bootstrap.js deleted file mode 100644 index 3c64a04d6b27..000000000000 --- a/devtools/server/bootstrap.js +++ /dev/null @@ -1,18 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* exported startup, shutdown, install, uninstall */ - -// Fake bootstrap used when shipping only server part of devtools. - -"use strict"; - -function startup(data) { -} - -function shutdown(data, reason) { -} - -function install() {} -function uninstall() {} diff --git a/devtools/server/shims/moz.build b/devtools/server/shims/moz.build index 55c93261a929..cebaa79b4593 100644 --- a/devtools/server/shims/moz.build +++ b/devtools/server/shims/moz.build @@ -13,6 +13,6 @@ DIRS += [ # installed to previously defined locations. # Extra compatibility layer for old path after relocation in bug 1270173 -FINAL_TARGET_FILES.features['devtools@mozilla.org'].chrome.modules.server += [ +FINAL_TARGET_FILES.chrome.devtools.modules.devtools.server += [ 'protocol.js', ] diff --git a/devtools/server/tests/unit/xpcshell.ini b/devtools/server/tests/unit/xpcshell.ini index e0c91545710a..2bc56e7cd590 100644 --- a/devtools/server/tests/unit/xpcshell.ini +++ b/devtools/server/tests/unit/xpcshell.ini @@ -1,6 +1,6 @@ [DEFAULT] tags = devtools -head = ../../../shared/tests/shared-xpcshell-head.js head_dbg.js +head = head_dbg.js firefox-appdir = browser skip-if = toolkit == 'android' diff --git a/devtools/shared/Loader.jsm b/devtools/shared/Loader.jsm index ee8437c9811f..a9912989577e 100644 --- a/devtools/shared/Loader.jsm +++ b/devtools/shared/Loader.jsm @@ -16,21 +16,6 @@ var { requireRawId } = Cu.import("resource://devtools/shared/loader-plugin-raw.j this.EXPORTED_SYMBOLS = ["DevToolsLoader", "devtools", "BuiltinProvider", "require", "loader"]; -// Fire an event to notify the DevTools addon bootstrap that DevTools are being -// initialized. The loader is always the first entry point for all DevTools consumers. -Services.obs.notifyObservers(null, "devtools-loader-starting"); - -// Load DevToolsPreferences as soon as DevTools code starts being required. -// With DevTools as an addon, the DevTools preferences need to be dynamically loaded. -const isParentProcess = - Services.appinfo.processType === Services.appinfo.PROCESS_TYPE_DEFAULT; -const isFirefox = Services.appinfo.ID == "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"; -if (isParentProcess && isFirefox) { - // Load client preferences if we are in Firefox's parent process only. - const {DevToolsPreferences} = - Cu.import("chrome://devtools/content/preferences/DevToolsPreferences.jsm", {}); - DevToolsPreferences.loadPrefs(); -} /** * Providers are different strategies for loading the devtools. */ diff --git a/devtools/shared/acorn/tests/unit/xpcshell.ini b/devtools/shared/acorn/tests/unit/xpcshell.ini index 53e6c5313d44..68197e2130ec 100644 --- a/devtools/shared/acorn/tests/unit/xpcshell.ini +++ b/devtools/shared/acorn/tests/unit/xpcshell.ini @@ -1,6 +1,6 @@ [DEFAULT] tags = devtools -head = ../../../tests/shared-xpcshell-head.js head_acorn.js +head = head_acorn.js firefox-appdir = browser skip-if = toolkit == 'android' diff --git a/devtools/shared/discovery/tests/unit/xpcshell.ini b/devtools/shared/discovery/tests/unit/xpcshell.ini index 7e1f6d93a002..145c2d3e2e06 100644 --- a/devtools/shared/discovery/tests/unit/xpcshell.ini +++ b/devtools/shared/discovery/tests/unit/xpcshell.ini @@ -1,7 +1,6 @@ [DEFAULT] tags = devtools -head = ../../../tests/shared-xpcshell-head.js +head = firefox-appdir = browser -skip-if = toolkit == 'android' # Bug 1380687 - xpcshell-tests can not run for system addons on android [test_discovery.js] diff --git a/devtools/shared/heapsnapshot/moz.build b/devtools/shared/heapsnapshot/moz.build index 0a95ce47cd1e..d020da727b07 100644 --- a/devtools/shared/heapsnapshot/moz.build +++ b/devtools/shared/heapsnapshot/moz.build @@ -10,11 +10,7 @@ with Files('**'): if CONFIG['ENABLE_TESTS']: DIRS += ['tests/gtest'] -XPCSHELL_TESTS_MANIFESTS += [ - 'tests/unit/xpcshell.ini', - 'tests/unit/xpcshell_ipc.ini', -] - +XPCSHELL_TESTS_MANIFESTS += [ 'tests/unit/xpcshell.ini' ] MOCHITEST_MANIFESTS += [ 'tests/mochitest/mochitest.ini' ] MOCHITEST_CHROME_MANIFESTS += [ 'tests/mochitest/chrome.ini' ] diff --git a/devtools/shared/heapsnapshot/tests/unit/head_heapsnapshot_ipc.js b/devtools/shared/heapsnapshot/tests/unit/head_heapsnapshot_ipc.js deleted file mode 100644 index 668bb32e165c..000000000000 --- a/devtools/shared/heapsnapshot/tests/unit/head_heapsnapshot_ipc.js +++ /dev/null @@ -1,10 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -"use strict"; - -/* exported Cu, CC */ - -// Simplistic head.js simply gathering dependencies needed for test_SaveHeapSnapshot.js -var Cu = Components.utils; -var CC = Components.Constructor; diff --git a/devtools/shared/heapsnapshot/tests/unit/xpcshell.ini b/devtools/shared/heapsnapshot/tests/unit/xpcshell.ini index 912fa6618247..2610e3b22fb1 100644 --- a/devtools/shared/heapsnapshot/tests/unit/xpcshell.ini +++ b/devtools/shared/heapsnapshot/tests/unit/xpcshell.ini @@ -1,6 +1,6 @@ [DEFAULT] tags = devtools heapsnapshot devtools-memory -head = ../../../tests/shared-xpcshell-head.js head_heapsnapshot.js +head = head_heapsnapshot.js firefox-appdir = browser skip-if = toolkit == 'android' @@ -94,3 +94,4 @@ skip-if = os == 'linux' # Bug 1176173 [test_ReadHeapSnapshot_worker.js] skip-if = os == 'linux' # Bug 1176173 [test_SaveHeapSnapshot.js] +[test_saveHeapSnapshot_e10s_01.js] diff --git a/devtools/shared/heapsnapshot/tests/unit/xpcshell_ipc.ini b/devtools/shared/heapsnapshot/tests/unit/xpcshell_ipc.ini deleted file mode 100644 index 76530e3e5df6..000000000000 --- a/devtools/shared/heapsnapshot/tests/unit/xpcshell_ipc.ini +++ /dev/null @@ -1,11 +0,0 @@ -[DEFAULT] -tags = devtools heapsnapshot devtools-memory -head = head_heapsnapshot_ipc.js -firefox-appdir = browser -skip-if = toolkit == 'android' -support-files = - test_SaveHeapSnapshot.js - -[test_saveHeapSnapshot_e10s_01.js] -# Using a separate test suite for this test to avoid loading the shared xpcshell head.js -# test file which will fail when trying to load preferences in content. diff --git a/devtools/shared/jar.mn b/devtools/shared/jar.mn index 8d08172f9341..4d0823550c5a 100644 --- a/devtools/shared/jar.mn +++ b/devtools/shared/jar.mn @@ -2,8 +2,8 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -[features/devtools@mozilla.org] chrome.jar: -% resource devtools %modules/ +devtools.jar: +% resource devtools %modules/devtools/ # The typical approach would be to list all the resource files in this manifest # for installation. Instead of doing this, use the DevToolsModules syntax via # moz.build files to do the installation so that we can enforce correct paths diff --git a/devtools/shared/jsbeautify/tests/unit/xpcshell.ini b/devtools/shared/jsbeautify/tests/unit/xpcshell.ini index 379c7162e9b8..0f97810b3c8b 100644 --- a/devtools/shared/jsbeautify/tests/unit/xpcshell.ini +++ b/devtools/shared/jsbeautify/tests/unit/xpcshell.ini @@ -1,6 +1,6 @@ [DEFAULT] tags = devtools -head = ../../../tests/shared-xpcshell-head.js head_jsbeautify.js +head = head_jsbeautify.js firefox-appdir = browser skip-if = toolkit == 'android' diff --git a/devtools/shared/locales/jar.mn b/devtools/shared/locales/jar.mn index 717804c60c62..2d33b5425234 100644 --- a/devtools/shared/locales/jar.mn +++ b/devtools/shared/locales/jar.mn @@ -3,6 +3,6 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -[features/devtools@mozilla.org] chrome.jar: +@AB_CD@.jar: % locale devtools-shared @AB_CD@ %locale/@AB_CD@/devtools/shared/ locale/@AB_CD@/devtools/shared/ (%*) diff --git a/devtools/shared/moz.build b/devtools/shared/moz.build index c9ab1f31e298..ecad30051405 100644 --- a/devtools/shared/moz.build +++ b/devtools/shared/moz.build @@ -6,10 +6,6 @@ include('../templates.mozbuild') -TEST_HARNESS_FILES.xpcshell.devtools.shared.tests += [ - 'tests/shared-xpcshell-head.js', -] - DIRS += [ 'acorn', 'apps', diff --git a/devtools/shared/performance/test/xpcshell.ini b/devtools/shared/performance/test/xpcshell.ini index 64df30cdd0a5..87760a972e3f 100644 --- a/devtools/shared/performance/test/xpcshell.ini +++ b/devtools/shared/performance/test/xpcshell.ini @@ -1,6 +1,6 @@ [DEFAULT] tags = devtools -head = ../../../shared/tests/shared-xpcshell-head.js head.js +head = head.js firefox-appdir = browser skip-if = toolkit == 'android' diff --git a/devtools/shared/platform/content/test/xpcshell.ini b/devtools/shared/platform/content/test/xpcshell.ini index cd767c8d560a..b01f3fb4fd4f 100644 --- a/devtools/shared/platform/content/test/xpcshell.ini +++ b/devtools/shared/platform/content/test/xpcshell.ini @@ -1,7 +1,6 @@ [DEFAULT] tags = devtools -head = ../../../tests/shared-xpcshell-head.js +head = firefox-appdir = browser -skip-if = toolkit == 'android' # Bug 1380687 - xpcshell-tests can not run for system addons on android [test_stack.js] diff --git a/devtools/shared/pretty-fast/tests/unit/xpcshell.ini b/devtools/shared/pretty-fast/tests/unit/xpcshell.ini index df65174f95c1..e997f6c37049 100644 --- a/devtools/shared/pretty-fast/tests/unit/xpcshell.ini +++ b/devtools/shared/pretty-fast/tests/unit/xpcshell.ini @@ -1,6 +1,6 @@ [DEFAULT] tags = devtools -head = ../../../tests/shared-xpcshell-head.js head_pretty-fast.js +head = head_pretty-fast.js firefox-appdir = browser skip-if = toolkit == 'android' diff --git a/devtools/shared/qrcode/tests/unit/xpcshell.ini b/devtools/shared/qrcode/tests/unit/xpcshell.ini index 9ebf11b0b71c..68d274268d7c 100644 --- a/devtools/shared/qrcode/tests/unit/xpcshell.ini +++ b/devtools/shared/qrcode/tests/unit/xpcshell.ini @@ -1,7 +1,6 @@ [DEFAULT] tags = devtools -head = ../../../tests/shared-xpcshell-head.js +head = firefox-appdir = browser -skip-if = toolkit == 'android' # Bug 1380687 - xpcshell-tests can not run for system addons on android [test_encode.js] diff --git a/devtools/shared/security/tests/unit/xpcshell.ini b/devtools/shared/security/tests/unit/xpcshell.ini index 2442bc3cb7ba..4af95f76a37b 100644 --- a/devtools/shared/security/tests/unit/xpcshell.ini +++ b/devtools/shared/security/tests/unit/xpcshell.ini @@ -1,8 +1,7 @@ [DEFAULT] tags = devtools -head = ../../../tests/shared-xpcshell-head.js head_dbg.js +head = head_dbg.js firefox-appdir = browser -skip-if = toolkit == 'android' # Bug 1380687 - xpcshell-tests can not run for system addons on android support-files= testactors.js diff --git a/devtools/shared/shims/fronts/moz.build b/devtools/shared/shims/fronts/moz.build index 806bc32853a4..3e7977ef55d2 100644 --- a/devtools/shared/shims/fronts/moz.build +++ b/devtools/shared/shims/fronts/moz.build @@ -4,8 +4,6 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -DIST_SUBDIR = 'browser' - DevToolsModules( 'timeline.js', ) diff --git a/devtools/shared/tests/shared-xpcshell-head.js b/devtools/shared/tests/shared-xpcshell-head.js deleted file mode 100644 index 1518d0e2cd65..000000000000 --- a/devtools/shared/tests/shared-xpcshell-head.js +++ /dev/null @@ -1,30 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -"use strict"; - -(() => { - const {interfaces: Ci, utils: Cu} = Components; - const {Services} = Cu.import("resource://gre/modules/Services.jsm", {}); - - // Load our bootstrap extension manifest so we can access our chrome/resource URIs. - const EXTENSION_ID = "devtools@mozilla.org"; - let extensionDir = Services.dirsvc.get("GreD", Ci.nsIFile); - extensionDir.append("browser"); - extensionDir.append("features"); - extensionDir.append(EXTENSION_ID); - // If the unpacked extension doesn't exist, use the packed version. - // Typically running tests on a local build will rely on the unpacked version - // while running tests against a packaged Firefox build (on try for instance) will - // rely on the xpi. - if (!extensionDir.exists()) { - extensionDir = extensionDir.parent; - extensionDir.append(EXTENSION_ID + ".xpi"); - } - Components.manager.addBootstrappedManifestLocation(extensionDir); - - // Load devtools preferences that should normally be loaded by bootstrap.js - let {DevToolsPreferences} = - Cu.import("chrome://devtools/content/preferences/DevToolsPreferences.jsm", {}); - DevToolsPreferences.loadPrefs(); -})(); diff --git a/devtools/shared/tests/unit/xpcshell.ini b/devtools/shared/tests/unit/xpcshell.ini index de6dfde7bdf0..8a01a3ee1354 100644 --- a/devtools/shared/tests/unit/xpcshell.ini +++ b/devtools/shared/tests/unit/xpcshell.ini @@ -1,6 +1,6 @@ [DEFAULT] tags = devtools -head = ../shared-xpcshell-head.js head_devtools.js +head = head_devtools.js firefox-appdir = browser skip-if = toolkit == 'android' support-files = diff --git a/devtools/shared/transport/tests/unit/xpcshell.ini b/devtools/shared/transport/tests/unit/xpcshell.ini index d585aa957a63..fe8e771fd023 100644 --- a/devtools/shared/transport/tests/unit/xpcshell.ini +++ b/devtools/shared/transport/tests/unit/xpcshell.ini @@ -1,6 +1,6 @@ [DEFAULT] tags = devtools -head = ../../../tests/shared-xpcshell-head.js head_dbg.js +head = head_dbg.js firefox-appdir = browser skip-if = toolkit == 'android' diff --git a/devtools/shared/webconsole/test/unit/xpcshell.ini b/devtools/shared/webconsole/test/unit/xpcshell.ini index c1226a2fb160..f394537d9b9b 100644 --- a/devtools/shared/webconsole/test/unit/xpcshell.ini +++ b/devtools/shared/webconsole/test/unit/xpcshell.ini @@ -1,6 +1,6 @@ [DEFAULT] tags = devtools -head = ../../../tests/shared-xpcshell-head.js +head = firefox-appdir = browser skip-if = toolkit == 'android' support-files = diff --git a/devtools/shim/DevToolsShim.jsm b/devtools/shim/DevToolsShim.jsm index 0d8db0a14d27..406f012f680a 100644 --- a/devtools/shim/DevToolsShim.jsm +++ b/devtools/shim/DevToolsShim.jsm @@ -209,7 +209,11 @@ this.DevToolsShim = { return; } - this.gDevTools.restoreScratchpadSession(scratchpads); + if (!this.isInitialized()) { + this._initDevTools(); + } + + this._gDevTools.restoreScratchpadSession(scratchpads); }, /** diff --git a/devtools/shim/devtools-startup-prefs.js b/devtools/shim/devtools-startup-prefs.js deleted file mode 100644 index 1ab086425e0c..000000000000 --- a/devtools/shim/devtools-startup-prefs.js +++ /dev/null @@ -1,22 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -// This Devtools preferences file will be loaded as a usual Firefox preferences file. -// Most DevTools prefs are included with the addon and loaded dynamically during the addon -// startup. For preferences that are required before the addon is loaded or that we can't -// process in JS, they can be defined in this file. -// Note that this preference file follows Firefox release cycle. - -// Enable the JSON View tool (an inspector for application/json documents). -pref("devtools.jsonview.enabled", true); - -// Enable the Inspector, this preference is used from mozilla-central. -pref("devtools.inspector.enabled", true); - -// Default theme ("dark" or "light") -#ifdef MOZ_DEV_EDITION -sticky_pref("devtools.theme", "dark"); -#else -sticky_pref("devtools.theme", "light"); -#endif diff --git a/devtools/shim/moz.build b/devtools/shim/moz.build index 321f0ccc7bf4..4c73beef419b 100644 --- a/devtools/shim/moz.build +++ b/devtools/shim/moz.build @@ -6,15 +6,6 @@ JAR_MANIFESTS += ['jar.mn'] -EXTRA_COMPONENTS += [ - 'devtools-startup.js', - 'devtools-startup.manifest', -] - -JS_PREFERENCE_PP_FILES += [ - 'devtools-startup-prefs.js', -] - # Register the about:debugging page only for 'addon' and 'all' builds. if CONFIG['MOZ_DEVTOOLS'] != 'server': EXTRA_COMPONENTS += [ diff --git a/devtools/shim/tests/unit/test_devtools_shim.js b/devtools/shim/tests/unit/test_devtools_shim.js index 535e5eac6d5c..9d0d0b030e4d 100644 --- a/devtools/shim/tests/unit/test_devtools_shim.js +++ b/devtools/shim/tests/unit/test_devtools_shim.js @@ -4,9 +4,12 @@ "use strict"; -const { DevToolsShim } = +const { DevToolsShim: realDevToolsShim } = Components.utils.import("chrome://devtools-shim/content/DevToolsShim.jsm", {}); +// Create a copy of the DevToolsShim for the test. +const DevToolsShim = Object.assign({}, realDevToolsShim); + // Test the DevToolsShim /** @@ -41,13 +44,11 @@ function createMockDevTools() { return mock; } -let isInstalledMethodBackup = DevToolsShim.isInstalled; function mockDevToolsInstalled() { DevToolsShim.isInstalled = () => true; } - -function restoreDevToolsInstalled() { - DevToolsShim.isInstalled = isInstalledMethodBackup; +function mockDevToolsUninstalled() { + DevToolsShim.isInstalled = () => false; } /** @@ -71,8 +72,6 @@ function checkCalls(mock, method, length, lastArgs) { } function test_register_unregister() { - mockDevToolsInstalled(); - ok(!DevToolsShim.isInitialized(), "DevTools are not initialized"); DevToolsShim.register(createMockDevTools()); @@ -80,8 +79,6 @@ function test_register_unregister() { DevToolsShim.unregister(); ok(!DevToolsShim.isInitialized(), "DevTools are not initialized"); - - restoreDevToolsInstalled(); } function test_on_is_forwarded_to_devtools() { @@ -97,13 +94,9 @@ function test_on_is_forwarded_to_devtools() { DevToolsShim.on("other_event", cb2); checkCalls(mock, "on", 2, ["other_event", cb2]); - - restoreDevToolsInstalled(); } function test_off_called_before_registering_devtools() { - mockDevToolsInstalled(); - ok(!DevToolsShim.isInitialized(), "DevTools are not initialized"); function cb1() {} @@ -114,13 +107,9 @@ function test_off_called_before_registering_devtools() { DevToolsShim.register(mock); checkCalls(mock, "on", 0); - - restoreDevToolsInstalled(); } function test_off_called_before_with_bad_callback() { - mockDevToolsInstalled(); - ok(!DevToolsShim.isInitialized(), "DevTools are not initialized"); function cb1() {} @@ -135,13 +124,9 @@ function test_off_called_before_with_bad_callback() { checkCalls(mock, "on", 1, ["test_event", cb1]); // Calls to off should not be held and forwarded. checkCalls(mock, "off", 0); - - restoreDevToolsInstalled(); } function test_registering_tool() { - mockDevToolsInstalled(); - ok(!DevToolsShim.isInitialized(), "DevTools are not initialized"); let tool1 = {}; @@ -168,13 +153,9 @@ function test_registering_tool() { mock = createMockDevTools(); DevToolsShim.register(mock); checkCalls(mock, "registerTool", 0); - - restoreDevToolsInstalled(); } function test_registering_theme() { - mockDevToolsInstalled(); - ok(!DevToolsShim.isInitialized(), "DevTools are not initialized"); let theme1 = {}; @@ -201,13 +182,9 @@ function test_registering_theme() { mock = createMockDevTools(); DevToolsShim.register(mock); checkCalls(mock, "registerTheme", 0); - - restoreDevToolsInstalled(); } function test_events() { - mockDevToolsInstalled(); - ok(!DevToolsShim.isInitialized(), "DevTools are not initialized"); let mock = createMockDevTools(); @@ -221,11 +198,11 @@ function test_events() { // Check emit is called once with the devtools-unregistered event. DevToolsShim.unregister(); checkCalls(mock, "emit", 2, ["devtools-unregistered"]); - - restoreDevToolsInstalled(); } function test_scratchpad_apis() { + mockDevToolsUninstalled(); + ok(!DevToolsShim.isInstalled(), "DevTools are not installed"); ok(!DevToolsShim.isInitialized(), "DevTools are not initialized"); @@ -262,8 +239,6 @@ function test_scratchpad_apis() { DevToolsShim.getOpenedScratchpads(); checkCalls(mock, "getOpenedScratchpads", 1, []); - - restoreDevToolsInstalled(); } function run_test() { diff --git a/devtools/templates.mozbuild b/devtools/templates.mozbuild index ab834636d5a7..002cbf5c9d0a 100644 --- a/devtools/templates.mozbuild +++ b/devtools/templates.mozbuild @@ -29,10 +29,7 @@ def DevToolsModules(*modules): # locations. Instead of doing this, use this DevToolsModules syntax via # moz.build files to do the installation so that we can enforce correct # paths based on source tree location. - base = FINAL_TARGET_FILES.features['devtools@mozilla.org'].chrome.modules - relative = RELATIVEDIR.split('/') - # Remove 'devtools' to got straight to client, shared or server folders - relative.pop(0) - for dir in relative: + base = FINAL_TARGET_FILES.chrome.devtools.modules + for dir in RELATIVEDIR.split('/'): base = base[dir] base += [m for m in modules]