Bug 1540530 - Don't tear down Customize Mode when reloading about:blank. r=dao
authorOriol Brufau <oriol-bugzilla@hotmail.com>
Tue, 09 Apr 2019 17:54:01 +0000
changeset 468613 dfe05bf32adb3591ae15b0b3f4016b73db92037b
parent 468612 bd12a191e5af168f52a03e0546cf4b02054d5414
child 468614 bba6d1554446f902ce948c8700406c53a5f662de
push id35843
push usernbeleuzu@mozilla.com
push dateTue, 09 Apr 2019 22:08:13 +0000
treeherdermozilla-central@a31032a16330 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdao
bugs1540530
milestone68.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 1540530 - Don't tear down Customize Mode when reloading about:blank. r=dao Differential Revision: https://phabricator.services.mozilla.com/D25547
browser/components/customizableui/CustomizeMode.jsm
browser/components/customizableui/test/browser.ini
browser/components/customizableui/test/browser_reload_tab.js
--- a/browser/components/customizableui/CustomizeMode.jsm
+++ b/browser/components/customizableui/CustomizeMode.jsm
@@ -67,17 +67,20 @@ function closeGlobalTab() {
     win.BrowserOpenTab();
   }
   win.gBrowser.removeTab(gTab);
   gTab = null;
 }
 
 var gTabsProgressListener = {
   onLocationChange(aBrowser, aWebProgress, aRequest, aLocation, aFlags) {
-    if (!gTab || gTab.linkedBrowser != aBrowser) {
+    // Tear down customize mode when the customize mode tab loads some other page.
+    // Customize mode will be re-entered if "about:blank" is loaded again, so
+    // don't tear down in this case.
+    if (!gTab || gTab.linkedBrowser != aBrowser || aLocation.spec == "about:blank") {
       return;
     }
 
     unregisterGlobalTab();
   },
 };
 
 function unregisterGlobalTab() {
--- a/browser/components/customizableui/test/browser.ini
+++ b/browser/components/customizableui/test/browser.ini
@@ -169,16 +169,17 @@ tags = fullscreen
 [browser_backfwd_enabled_post_customize.js]
 [browser_check_tooltips_in_navbar.js]
 [browser_editcontrols_update.js]
 subsuite = clipboard
 [browser_customization_context_menus.js]
 [browser_newtab_button_customizemode.js]
 [browser_open_from_popup.js]
 [browser_PanelMultiView_focus.js]
+[browser_reload_tab.js]
 [browser_sidebar_toggle.js]
 skip-if = verify
 [browser_tabbar_big_widgets.js]
 [browser_remote_tabs_button.js]
 skip-if = (verify && debug && (os == 'linux' || os == 'mac'))
 [browser_widget_animation.js]
 [browser_lwt_telemetry.js]
 
new file mode 100644
--- /dev/null
+++ b/browser/components/customizableui/test/browser_reload_tab.js
@@ -0,0 +1,48 @@
+"use strict";
+
+/**
+ * Check that customize mode doesn't break when its tab is reloaded.
+ */
+add_task(async function reload_tab() {
+  let customizationContainer = document.getElementById("customization-container");
+  let initialTab = gBrowser.selectedTab;
+  let customizeTab = BrowserTestUtils.addTab(gBrowser, "about:blank");
+  gCustomizeMode.setTab(customizeTab);
+
+  is(customizationContainer.clientWidth, 0, "Customization container shouldn't be visible (X)");
+  is(customizationContainer.clientHeight, 0, "Customization container shouldn't be visible (Y)");
+
+  let customizePromise = BrowserTestUtils.waitForEvent(gNavToolbox, "customizationready");
+  gCustomizeMode.enter();
+  await customizePromise;
+
+  let tabReloaded = new Promise((resolve) => {
+    gBrowser.addTabsProgressListener({async onLocationChange(aBrowser) {
+      if (customizeTab.linkedBrowser == aBrowser) {
+        gBrowser.removeTabsProgressListener(this);
+        await Promise.resolve();
+        resolve();
+      }
+    }});
+  });
+  gBrowser.reloadTab(customizeTab);
+  await tabReloaded;
+
+  is(customizeTab.getAttribute("customizemode"), "true", "Tab should be in customize mode");
+  ok(customizationContainer.clientWidth > 0, "Customization container should be visible (X)");
+  ok(customizationContainer.clientHeight > 0, "Customization container should be visible (Y)");
+
+  customizePromise = BrowserTestUtils.waitForEvent(gNavToolbox, "aftercustomization");
+  await BrowserTestUtils.switchTab(gBrowser, initialTab);
+  await customizePromise;
+
+  customizePromise = BrowserTestUtils.waitForEvent(gNavToolbox, "customizationready");
+  await BrowserTestUtils.switchTab(gBrowser, customizeTab);
+  await customizePromise;
+
+  is(customizeTab.getAttribute("customizemode"), "true", "Tab should still be in customize mode");
+  ok(customizationContainer.clientWidth > 0, "Customization container should still be visible (X)");
+  ok(customizationContainer.clientHeight > 0, "Customization container should still be visible (Y)");
+
+  await endCustomizing();
+});