Bug 1530557 - tabprompt dialog box size restrictions are completely broken, r=MattN a=lizzard
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Tue, 05 Mar 2019 10:42:32 +0000
changeset 516289 1639f365cc4cf6034fca350ca332a5d2bf32c56b
parent 516288 3b0bc8cad66fcf18a00a9185ff534aad7b45f7db
child 516290 4e252aec24d866bc6ad408c05e8cea9d82b06be5
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN, lizzard
bugs1530557
milestone66.0
Bug 1530557 - tabprompt dialog box size restrictions are completely broken, r=MattN a=lizzard Differential Revision: https://phabricator.services.mozilla.com/D22020
browser/base/content/test/general/browser_double_close_tab.js
toolkit/components/prompts/content/tabprompts.jsm
--- a/browser/base/content/test/general/browser_double_close_tab.js
+++ b/browser/base/content/test/general/browser_double_close_tab.js
@@ -1,19 +1,18 @@
 /* eslint-disable mozilla/no-arbitrary-setTimeout */
 "use strict";
 const TEST_PAGE = "http://mochi.test:8888/browser/browser/base/content/test/general/file_double_close_tab.html";
 var testTab;
 
-SpecialPowers.pushPrefEnv({"set": [["dom.require_user_interaction_for_beforeunload", false]]});
-
 function waitForDialog(callback) {
   function onTabModalDialogLoaded(node) {
     Services.obs.removeObserver(onTabModalDialogLoaded, "tabmodal-dialog-loaded");
-    callback(node);
+    // Allow dialog's onLoad call to run to completion
+    Promise.resolve().then(() => callback(node));
   }
 
   // Listen for the dialog being created
   Services.obs.addObserver(onTabModalDialogLoaded, "tabmodal-dialog-loaded");
 }
 
 function waitForDialogDestroyed(node, callback) {
   // Now listen for the dialog going away again...
@@ -33,18 +32,19 @@ function waitForDialogDestroyed(node, ca
     clearTimeout(failureTimeout);
     observer.disconnect();
     observer = null;
     callback();
   }
 }
 
 add_task(async function() {
-  testTab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
-  await promiseTabLoadEvent(testTab, TEST_PAGE);
+  await SpecialPowers.pushPrefEnv({"set": [["dom.require_user_interaction_for_beforeunload", false]]});
+
+  testTab = await BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_PAGE);
   // XXXgijs the reason this has nesting and callbacks rather than promises is
   // that DOM promises resolve on the next tick. So they're scheduled
   // in an event queue. So when we spin a new event queue for a modal dialog...
   // everything gets messed up and the promise's .then callbacks never get
   // called, despite resolve() being called just fine.
   await new Promise(resolveOuter => {
     waitForDialog(dialogNode => {
       waitForDialogDestroyed(dialogNode, () => {
@@ -65,17 +65,19 @@ add_task(async function() {
     });
     // Click once:
     document.getAnonymousElementByAttribute(testTab, "anonid", "close-button").click();
   });
   await promiseWaitForCondition(() => !testTab.parentNode);
   ok(!testTab.parentNode, "Tab should be closed completely");
 });
 
-registerCleanupFunction(function() {
+registerCleanupFunction(async function() {
   if (testTab.parentNode) {
     // Remove the handler, or closing this tab will prove tricky:
     try {
-      testTab.linkedBrowser.contentWindow.onbeforeunload = null;
+      await ContentTask.spawn(testTab.linkedBrowser, null, function() {
+        content.window.onbeforeunload = null;
+      });
     } catch (ex) {}
     gBrowser.removeTab(testTab);
   }
 });
--- a/toolkit/components/prompts/content/tabprompts.jsm
+++ b/toolkit/components/prompts/content/tabprompts.jsm
@@ -240,18 +240,18 @@ var TabModalPrompt = class {
       case "unload":
       case "TabClose":
         this.abortPrompt();
         break;
     }
   }
 
   onResize() {
-    let availWidth = this.clientWidth;
-    let availHeight = this.clientHeight;
+    let availWidth = this.element.clientWidth;
+    let availHeight = this.element.clientHeight;
     if (availWidth == this.availWidth && availHeight == this.availHeight)
       return;
     this.availWidth = availWidth;
     this.availHeight = availHeight;
 
     let main = this.ui.mainContainer;
     let info = this.ui.infoContainer;
     let body = this.ui.infoBody;