From 4a8f004c6864bbeddcbd8506f8d324070c10814e Mon Sep 17 00:00:00 2001 From: Julian Descottes Date: Thu, 14 Nov 2019 08:11:07 +0000 Subject: [PATCH] Bug 1594885 - Basic scaffolding for whatsnew panel in DevTools r=jlast,nchevobbe Differential Revision: https://phabricator.services.mozilla.com/D52733 --HG-- extra : moz-landing-system : lando --- browser/app/profile/firefox.js | 7 +++ devtools/client/definitions.js | 44 +++++++++++++++++++ .../browser_toolbox_toolbar_reorder_by_dnd.js | 4 ++ ..._toolbox_toolbar_reorder_with_extension.js | 4 ++ ...x_toolbar_reorder_with_hidden_extension.js | 4 ++ ..._toolbox_tools_per_toolbox_registration.js | 8 +++- devtools/client/jar.mn | 3 ++ devtools/client/moz.build | 1 + devtools/client/whats-new/index.html | 31 +++++++++++++ devtools/client/whats-new/moz.build | 11 +++++ devtools/client/whats-new/panel.js | 26 +++++++++++ devtools/client/whats-new/src/base.css | 5 +++ devtools/client/whats-new/src/main.js | 10 +++++ devtools/client/whats-new/src/moz.build | 9 ++++ devtools/client/whats-new/src/whats-new.css | 5 +++ toolkit/components/telemetry/Events.yaml | 4 +- 16 files changed, 173 insertions(+), 3 deletions(-) create mode 100644 devtools/client/whats-new/index.html create mode 100644 devtools/client/whats-new/moz.build create mode 100644 devtools/client/whats-new/panel.js create mode 100644 devtools/client/whats-new/src/base.css create mode 100644 devtools/client/whats-new/src/main.js create mode 100644 devtools/client/whats-new/src/moz.build create mode 100644 devtools/client/whats-new/src/whats-new.css diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js index d8abd292d1af..c782150beffd 100644 --- a/browser/app/profile/firefox.js +++ b/browser/app/profile/firefox.js @@ -2338,5 +2338,12 @@ pref("devtools.popup.disable_autohide", false); // should be removed. pref("devtools.toolbox.content-frame", true); +// Visibility switch preference for the WhatsNew panel. +pref("devtools.whatsnew.enabled", true); + +// Temporary preference to fully disable the WhatsNew panel on any target. +// Should be removed in https://bugzilla.mozilla.org/show_bug.cgi?id=1596037 +pref("devtools.whatsnew.feature-enabled", true); + // FirstStartup service time-out in ms pref("first-startup.timeout", 30000); diff --git a/devtools/client/definitions.js b/devtools/client/definitions.js index 9b5c43364e57..bf4e511880d4 100644 --- a/devtools/client/definitions.js +++ b/devtools/client/definitions.js @@ -73,6 +73,11 @@ loader.lazyGetter( "ApplicationPanel", () => require("devtools/client/application/panel").ApplicationPanel ); +loader.lazyGetter( + this, + "WhatsNewPanel", + () => require("devtools/client/whats-new/panel").WhatsNewPanel +); loader.lazyGetter( this, "reloadAndRecordTab", @@ -472,6 +477,44 @@ Tools.application = { }, }; +Tools.whatsnew = { + id: "whatsnew", + ordinal: 12, + visibilityswitch: "devtools.whatsnew.enabled", + icon: "chrome://browser/skin/whatsnew.svg", + url: "chrome://devtools/content/whats-new/index.html", + // TODO: This panel is currently for english users only. + // This should be properly localized in Bug 1596038 + label: "What’s New", + panelLabel: "What’s New", + tooltip: "What’s New", + inMenu: false, + + isTargetSupported: function(target) { + // The panel is currently not localized and should only be displayed to + // english users. See Bug 1596038 for cleanup. + const isEnglishUser = Services.locale.negotiateLanguages( + ["en"], + [Services.locale.appLocaleAsBCP47] + ).length; + + // In addition to the basic visibility switch preference, we also have a + // higher level preference to disable the whole panel regardless of other + // settings. Should be removed in Bug 1596037. + const isFeatureEnabled = Services.prefs.getBoolPref( + "devtools.whatsnew.feature-enabled", + false + ); + + // This panel should only be enabled for regular web toolboxes. + return target.isLocalTab && isEnglishUser && isFeatureEnabled; + }, + + build: function(iframeWindow, toolbox) { + return new WhatsNewPanel(iframeWindow, toolbox); + }, +}; + var defaultTools = [ Tools.options, Tools.webConsole, @@ -485,6 +528,7 @@ var defaultTools = [ Tools.dom, Tools.accessibility, Tools.application, + Tools.whatsnew, ]; exports.defaultTools = defaultTools; diff --git a/devtools/client/framework/test/browser_toolbox_toolbar_reorder_by_dnd.js b/devtools/client/framework/test/browser_toolbox_toolbar_reorder_by_dnd.js index 7b121fa666ed..cab9f15a6b25 100644 --- a/devtools/client/framework/test/browser_toolbox_toolbar_reorder_by_dnd.js +++ b/devtools/client/framework/test/browser_toolbox_toolbar_reorder_by_dnd.js @@ -119,6 +119,10 @@ const TEST_DATA = [ ]; add_task(async function() { + // Temporarily disable the panel added in Bug 1594885. + // Should be cleaned up when the panel is properly implemented. + await pushPref("devtools.whatsnew.enabled", false); + const tab = await addTab("about:blank"); const toolbox = await openToolboxForTab( tab, diff --git a/devtools/client/framework/test/browser_toolbox_toolbar_reorder_with_extension.js b/devtools/client/framework/test/browser_toolbox_toolbar_reorder_with_extension.js index c252cf5d6547..3ad1d0897d41 100644 --- a/devtools/client/framework/test/browser_toolbox_toolbar_reorder_with_extension.js +++ b/devtools/client/framework/test/browser_toolbox_toolbar_reorder_with_extension.js @@ -23,6 +23,10 @@ const TEST_STARTING_ORDER = [ ]; add_task(async function() { + // Temporarily disable the panel added in Bug 1594885. + // Should be cleaned up when the panel is properly implemented. + await pushPref("devtools.whatsnew.enabled", false); + const extension = ExtensionTestUtils.loadExtension({ useAddonManager: "temporary", manifest: { diff --git a/devtools/client/framework/test/browser_toolbox_toolbar_reorder_with_hidden_extension.js b/devtools/client/framework/test/browser_toolbox_toolbar_reorder_with_hidden_extension.js index fb2277b6289a..6b2942626968 100644 --- a/devtools/client/framework/test/browser_toolbox_toolbar_reorder_with_hidden_extension.js +++ b/devtools/client/framework/test/browser_toolbox_toolbar_reorder_with_hidden_extension.js @@ -131,6 +131,10 @@ const TEST_DATA = [ ]; add_task(async function() { + // Temporarily disable the panel added in Bug 1594885. + // Should be cleaned up when the panel is properly implemented. + await pushPref("devtools.whatsnew.enabled", false); + registerCleanupFunction(() => { Services.prefs.clearUserPref("devtools.toolbox.tabsOrder"); }); diff --git a/devtools/client/framework/test/browser_toolbox_tools_per_toolbox_registration.js b/devtools/client/framework/test/browser_toolbox_tools_per_toolbox_registration.js index 427d8f569d8e..f744c93f60f4 100644 --- a/devtools/client/framework/test/browser_toolbox_tools_per_toolbox_registration.js +++ b/devtools/client/framework/test/browser_toolbox_tools_per_toolbox_registration.js @@ -47,7 +47,9 @@ function toolboxRegister(aToolbox) { toolbox.addAdditionalTool({ id: TOOL_ID, - label: "per-toolbox Test Tool", + // The size of the label can make the test fail if it's too long. + // See ok(tab, ...) assert below and Bug 1596345. + label: "Test Tool", inMenu: true, isTargetSupported: () => true, build: function() { @@ -78,6 +80,10 @@ function testToolRegistered() { // Test that the tool appeared in the UI. const doc = toolbox.doc; const tab = doc.getElementById("toolbox-tab-" + TOOL_ID); + + // Note that this assert can fail if the tab is pushed to the overflow menu + // because of a lack of available space in the toolbar. The test should be + // rewritten to avoid that. See Bug 1596345 for a follow-up fix. ok(tab, "new tool's tab exists in toolbox UI"); const panel = doc.getElementById("toolbox-panel-" + TOOL_ID); diff --git a/devtools/client/jar.mn b/devtools/client/jar.mn index 901ab2a80022..5de5fecb9e86 100644 --- a/devtools/client/jar.mn +++ b/devtools/client/jar.mn @@ -242,3 +242,6 @@ devtools.jar: # Application panel content/application/index.html (application/index.html) + + # WhatsNew panel + content/whats-new/index.html (whats-new/index.html) diff --git a/devtools/client/moz.build b/devtools/client/moz.build index d7e8fc2ac658..6ea6fe765837 100644 --- a/devtools/client/moz.build +++ b/devtools/client/moz.build @@ -28,6 +28,7 @@ DIRS += [ 'themes', 'webconsole', 'webreplay', + 'whats-new', ] JAR_MANIFESTS += ['jar.mn'] diff --git a/devtools/client/whats-new/index.html b/devtools/client/whats-new/index.html new file mode 100644 index 000000000000..6ac98235b7e4 --- /dev/null +++ b/devtools/client/whats-new/index.html @@ -0,0 +1,31 @@ + + + + + + + + + + +
+ + diff --git a/devtools/client/whats-new/moz.build b/devtools/client/whats-new/moz.build new file mode 100644 index 000000000000..959640dedaed --- /dev/null +++ b/devtools/client/whats-new/moz.build @@ -0,0 +1,11 @@ +# 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/. + +DevToolsModules( + 'panel.js' +) + +DIRS += [ + 'src' +] diff --git a/devtools/client/whats-new/panel.js b/devtools/client/whats-new/panel.js new file mode 100644 index 000000000000..abe4346477b1 --- /dev/null +++ b/devtools/client/whats-new/panel.js @@ -0,0 +1,26 @@ +/* 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 . */ + +"use strict"; + +function WhatsNewPanel(iframeWindow, toolbox) { + this.panelWin = iframeWindow; + this.toolbox = toolbox; +} + +WhatsNewPanel.prototype = { + open: async function() { + this.panelWin.WhatsNew.bootstrap(); + this.emit("ready"); + this.isReady = true; + return this; + }, + + destroy: function() { + this.panelWin.WhatsNew.destroy(); + this.emit("destroyed"); + }, +}; + +exports.WhatsNewPanel = WhatsNewPanel; diff --git a/devtools/client/whats-new/src/base.css b/devtools/client/whats-new/src/base.css new file mode 100644 index 000000000000..1116cf1e03fd --- /dev/null +++ b/devtools/client/whats-new/src/base.css @@ -0,0 +1,5 @@ +/* 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/. */ + +/* base.css */ diff --git a/devtools/client/whats-new/src/main.js b/devtools/client/whats-new/src/main.js new file mode 100644 index 000000000000..83dcef0f193e --- /dev/null +++ b/devtools/client/whats-new/src/main.js @@ -0,0 +1,10 @@ +/* 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 . */ + +"use strict"; + +module.exports = { + bootstrap: () => {}, + destroy: () => {}, +}; diff --git a/devtools/client/whats-new/src/moz.build b/devtools/client/whats-new/src/moz.build new file mode 100644 index 000000000000..11858c39f52f --- /dev/null +++ b/devtools/client/whats-new/src/moz.build @@ -0,0 +1,9 @@ +# 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/. + +DevToolsModules( + 'base.css', + 'main.js', + 'whats-new.css' +) diff --git a/devtools/client/whats-new/src/whats-new.css b/devtools/client/whats-new/src/whats-new.css new file mode 100644 index 000000000000..f42aada8fe02 --- /dev/null +++ b/devtools/client/whats-new/src/whats-new.css @@ -0,0 +1,5 @@ +/* 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/. */ + +/* whats-new.css */ diff --git a/toolkit/components/telemetry/Events.yaml b/toolkit/components/telemetry/Events.yaml index 1fd6cd6f3a52..03803ffbd43d 100644 --- a/toolkit/components/telemetry/Events.yaml +++ b/toolkit/components/telemetry/Events.yaml @@ -1076,7 +1076,7 @@ devtools.main: extra_keys: session_id: The start time of the session in milliseconds since epoch (Unix Timestamp) e.g. 1396381378123. enter: - objects: ["accessibility", "application", "dom", "inspector", "jsdebugger", "memory", "netmonitor", "options", "performance", "storage", "styleeditor", "webconsole", "other", "fakeTool4242", "testBlankPanel", "testTool", "testtool1", "testTool1072208", "testtool2"] + objects: ["accessibility", "application", "dom", "inspector", "jsdebugger", "memory", "netmonitor", "options", "performance", "storage", "styleeditor", "webconsole", "whatsnew","other", "fakeTool4242", "testBlankPanel", "testTool", "testtool1", "testTool1072208", "testtool2"] bug_numbers: [1441070] notification_emails: ["dev-developer-tools@lists.mozilla.org", "hkirschner@mozilla.com"] products: @@ -1112,7 +1112,7 @@ devtools.main: lines: The number of lines contained in the command. session_id: The start time of the session in milliseconds since epoch (Unix Timestamp) e.g. 1396381378123. exit: - objects: ["accessibility", "application", "dom", "inspector", "jsdebugger", "memory", "netmonitor", "options", "performance", "storage", "styleeditor", "webconsole", "other", "fakeTool4242", "testBlankPanel", "testTool", "testtool1", "testTool1072208", "testtool2"] + objects: ["accessibility", "application", "dom", "inspector", "jsdebugger", "memory", "netmonitor", "options", "performance", "storage", "styleeditor", "webconsole", "whatsnew", "other", "fakeTool4242", "testBlankPanel", "testTool", "testtool1", "testTool1072208", "testtool2"] bug_numbers: [1455270] notification_emails: ["dev-developer-tools@lists.mozilla.org", "hkirschner@mozilla.com"] products: