Bug 1530557 - tabprompt dialog box size restrictions are completely broken, r=MattN
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Tue, 05 Mar 2019 10:42:32 +0000
changeset 520235 654017ec58a77c584a0c4067a528f222e58c0f50
parent 520234 4bb1dd0270b6cf251823b865184d1dc0f3250eb6
child 520236 eff76a5ca4f81428ce42ae445d9eb1f7b80c8816
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN
bugs1530557
milestone67.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 1530557 - tabprompt dialog box size restrictions are completely broken, r=MattN 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 TestUtils.waitForCondition(() => !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;