Bug 1569653 - Added button to invalidate startup cache and restart in about:support r=mossop,fluent-reviewers,flod
authorPriyank Singh <priyanksingh8@gmail.com>
Tue, 02 Jun 2020 05:59:20 +0000
changeset 598236 a63a27cde0b2dd0b7c17ec31de946d4c35e17463
parent 598235 ad832014f2d291af829bf3c0d1c646387efce805
child 598237 56cc12211adf546d4fdb7505399b62a1b33f7361
push id13310
push userffxbld-merge
push dateMon, 29 Jun 2020 14:50:06 +0000
treeherdermozilla-beta@15a59a0afa5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmossop, fluent-reviewers, flod
bugs1569653
milestone79.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1569653 - Added button to invalidate startup cache and restart in about:support r=mossop,fluent-reviewers,flod Differential Revision: https://phabricator.services.mozilla.com/D77592
toolkit/content/aboutSupport.js
toolkit/content/aboutSupport.xhtml
toolkit/locales/en-US/toolkit/about/aboutSupport.ftl
toolkit/themes/shared/aboutSupport.css
--- a/toolkit/content/aboutSupport.js
+++ b/toolkit/content/aboutSupport.js
@@ -1459,21 +1459,19 @@ function openProfileDirectory() {
 }
 
 /**
  * Profile reset is only supported for the default profile if the appropriate migrator exists.
  */
 function populateActionBox() {
   if (ResetProfile.resetSupported()) {
     $("reset-box").style.display = "block";
-    $("action-box").style.display = "block";
   }
   if (!Services.appinfo.inSafeMode && AppConstants.platform !== "android") {
     $("safe-mode-box").style.display = "block";
-    $("action-box").style.display = "block";
 
     if (Services.policies && !Services.policies.isAllowed("safeMode")) {
       $("restart-in-safe-mode-button").setAttribute("disabled", "true");
     }
   }
 }
 
 // Prompt user to restart the browser in safe mode
@@ -1496,16 +1494,52 @@ function safeModeRestart() {
  */
 function setupEventListeners() {
   let button = $("reset-box-button");
   if (button) {
     button.addEventListener("click", function(event) {
       ResetProfile.openConfirmationDialog(window);
     });
   }
+  button = $("clear-startup-cache-button");
+  if (button) {
+    button.addEventListener("click", async function(event) {
+      const [
+        promptTitle,
+        promptBody,
+        restartButtonLabel,
+      ] = await document.l10n.formatValues([
+        { id: "startup-cache-dialog-title" },
+        { id: "startup-cache-dialog-body" },
+        { id: "restart-button-label" },
+      ]);
+      const buttonFlags =
+        Services.prompt.BUTTON_POS_0 * Services.prompt.BUTTON_TITLE_IS_STRING +
+        Services.prompt.BUTTON_POS_1 * Services.prompt.BUTTON_TITLE_CANCEL +
+        Services.prompt.BUTTON_POS_0_DEFAULT;
+      const result = Services.prompt.confirmEx(
+        window,
+        promptTitle,
+        promptBody,
+        buttonFlags,
+        restartButtonLabel,
+        null,
+        null,
+        null,
+        {}
+      );
+      if (result !== 0) {
+        return;
+      }
+      Services.appinfo.invalidateCachesOnRestart();
+      Services.startup.quit(
+        Ci.nsIAppStartup.eRestart | Ci.nsIAppStartup.eAttemptQuit
+      );
+    });
+  }
   button = $("restart-in-safe-mode-button");
   if (button) {
     button.addEventListener("click", function(event) {
       if (
         Services.obs
           .enumerateObservers("restart-in-safe-mode")
           .hasMoreElements()
       ) {
--- a/toolkit/content/aboutSupport.xhtml
+++ b/toolkit/content/aboutSupport.xhtml
@@ -33,16 +33,20 @@
       <div id="reset-box">
         <h3 data-l10n-id="refresh-profile"/>
         <button id="reset-box-button" data-l10n-id="refresh-profile-button"/>
       </div>
       <div id="safe-mode-box">
         <h3 data-l10n-id="safe-mode-title"/>
         <button id="restart-in-safe-mode-button" data-l10n-id="restart-in-safe-mode-label"/>
       </div>
+      <div id="clear-startup-cache-box">
+        <h3 data-l10n-id="clear-startup-cache-title"/>
+        <button id="clear-startup-cache-button" data-l10n-id="clear-startup-cache-label"/>
+      </div>
     </div>
 #endif
 
     <h1 data-l10n-id="page-title"/>
 
     <div class="page-subtitle" data-l10n-id="page-subtitle">
       <a id="supportLink" data-l10n-name="support-link"></a>
     </div>
--- a/toolkit/locales/en-US/toolkit/about/aboutSupport.ftl
+++ b/toolkit/locales/en-US/toolkit/about/aboutSupport.ftl
@@ -113,16 +113,21 @@ sandbox-sys-call-index = #
 sandbox-sys-call-age = Seconds Ago
 sandbox-sys-call-pid = PID
 sandbox-sys-call-tid = TID
 sandbox-sys-call-proc-type = Process Type
 sandbox-sys-call-number = Syscall
 sandbox-sys-call-args = Arguments
 safe-mode-title = Try Safe Mode
 restart-in-safe-mode-label = Restart with Add-ons Disabled…
+clear-startup-cache-title = Try clearing the startup cache
+clear-startup-cache-label = Clear startup cache…
+startup-cache-dialog-title = Clear startup cache
+startup-cache-dialog-body = Restart { -brand-short-name } to clear startup cache. This will not change your settings or remove extensions you’ve added to { -brand-short-name }.
+restart-button-label = Restart
 
 ## Media titles
 
 audio-backend = Audio Backend
 max-audio-channels = Max Channels
 sample-rate = Preferred Sample Rate
 roundtrip-latency = Roundtrip latency (standard deviation)
 media-title = Media
--- a/toolkit/themes/shared/aboutSupport.css
+++ b/toolkit/themes/shared/aboutSupport.css
@@ -67,17 +67,16 @@ td.integer {
   float: inline-end;
   margin-top: 2em;
   margin-bottom: 20px;
   margin-inline-start: 20px;
   margin-inline-end: 0;
   width: 30%;
 }
 
-#action-box,
 #reset-box,
 #safe-mode-box {
   display: none;
 }
 
 #reset-box > h3 {
   margin-top: 0;
 }