Backed out 2 changesets (bug 1653392, bug 1648868) for causing failures in browser_modal_print.js CLOSED TREE
authorNoemi Erli <nerli@mozilla.com>
Fri, 24 Jul 2020 20:38:06 +0300
changeset 542084 4a5520ecb0752ea1264c0c580964b995cda4e191
parent 542083 12870b9169ab9e6cbc298ba6dfcfe77321fa4eeb
child 542085 564081c2d0cdd4a047bf7ac02d786c89313133e2
push id122624
push usernerli@mozilla.com
push dateFri, 24 Jul 2020 17:38:47 +0000
treeherderautoland@4a5520ecb075 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1653392, 1648868
milestone80.0a1
backs out7fac5bd02bb3c962c2b68ea682877772ddd98268
9f8b675f0f6bcb72c974a913572afb04d9258b69
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
Backed out 2 changesets (bug 1653392, bug 1648868) for causing failures in browser_modal_print.js CLOSED TREE Backed out changeset 7fac5bd02bb3 (bug 1653392) Backed out changeset 9f8b675f0f6b (bug 1648868)
browser/base/content/browser.xhtml
toolkit/components/printing/content/print.css
toolkit/components/printing/content/print.js
toolkit/components/printing/content/printUtils.js
toolkit/components/printing/tests/browser.ini
toolkit/components/printing/tests/browser_modal_print.js
toolkit/components/printing/tests/head.js
toolkit/components/prompts/content/tabprompts.css
--- a/browser/base/content/browser.xhtml
+++ b/browser/base/content/browser.xhtml
@@ -263,28 +263,16 @@
                  activateontab="true" position="after_start"
                  level="parent"
 #ifdef XP_WIN
                  consumeoutsideclicks="false" ignorekeys="shortcuts"
 #endif
         />
     </menulist>
 
-    <html:template id="printTabModalTemplate">
-      <vbox id="printTabModalTemplate" class="tabSubDialogBoxContainer printDialogContainer" hidden="true">
-        <vbox class="dialogBox" pack="end" role="dialog" aria-labelledby="dialogTitle">
-          <hbox class="dialogTitleBar" align="center" hidden="true">
-            <label class="dialogTitle" flex="1"/>
-            <button class="dialogClose close-icon"/>
-          </hbox>
-          <browser class="dialogFrame"/>
-        </vbox>
-      </vbox>
-    </html:template>
-
     <html:template id="invalidFormTemplate">
       <!-- for invalid form error message -->
       <panel id="invalid-form-popup" type="arrow" orient="vertical" noautofocus="true" level="parent">
         <description/>
       </panel>
     </html:template>
 
     <html:template id="editBookmarkPanelTemplate">
--- a/toolkit/components/printing/content/print.css
+++ b/toolkit/components/printing/content/print.css
@@ -1,26 +1,25 @@
 /* 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/. */
 
 html, body {
-  width: 250px;
-  height: 600px;
+  height: 100%;
 }
 
 body {
   display: flex;
   flex-direction: column;
   justify-content: flex-start;
   overflow: hidden;
 }
 
 .row {
-  padding-inline-start: 18px;
+  padding-inline-start: 34px;
   margin-block: 18px;
 }
 
 .row .block-label {
   display: block;
   margin-bottom: 4px;
 }
 .row .block-label + input,
--- a/toolkit/components/printing/content/print.js
+++ b/toolkit/components/printing/content/print.js
@@ -52,17 +52,19 @@ const PrintUI = {
       switch (event.submitter.name) {
         case "print":
           PrintUtils.printWindow(this.sourceBrowser.browsingContext, {
             printSilent: true,
             printerName: this._printerPicker.value,
           });
           break;
         case "cancel":
-          window.close();
+          console.log(
+            "TODO: trigger any teardown, exit the print preview and close the tab-modal"
+          );
           break;
       }
     }
     /* TODO:
      * handle clicks to the system dialog link
      * handle change of the selected printer/destination
      * handle changes from each of the print settings controls
      */
--- a/toolkit/components/printing/content/printUtils.js
+++ b/toolkit/components/printing/content/printUtils.js
@@ -109,81 +109,29 @@ var PrintUtils = {
     } catch (e) {
       Cu.reportError(e);
     }
 
     return null;
   },
 
   /**
-   * Retrieve the template for the tab modal print UI. The element
-   * could be inside of a template tag, so we'll want to unwrap it
-   * the first time it's accessed.
-   */
-  _tabModalTemplate() {
-    let template = document.getElementById("printTabModalTemplate");
-    if (template.localName == "template") {
-      template.replaceWith(template.content);
-      return document.getElementById("printTabModalTemplate");
-    }
-    return template;
-  },
-
-  /**
    * Opens the tab modal version of the print UI for the current tab.
    *
    * @param aBrowsingContext
    *        The BrowsingContext of the window to print.
    */
   _openTabModalPrint(aBrowsingContext) {
-    const { SubDialog } = ChromeUtils.import(
-      "resource://gre/modules/SubDialog.jsm"
-    );
-
-    let container = gBrowser.getBrowserContainer(
-      aBrowsingContext.embedderElement
-    );
-    if (container.querySelector(".printDialogContainer")) {
-      // Don't open another dialog if we're already printing.
-      return;
-    }
-
-    let dialog = new SubDialog({
-      id: `printModal${aBrowsingContext.id}`,
-      template: this._tabModalTemplate(),
-      parentElement: container,
-    });
-
-    // Store some Promises on the overlay for use in the tests.
-    dialog._overlay._ready = dialog._frameCreated;
-    let resolveDialogClosed;
-    dialog._overlay._closed = new Promise(
-      resolve => (resolveDialogClosed = resolve)
-    );
-
-    // Move the overlay so it overlaps the chrome and content.
-    container.prepend(dialog._overlay);
-
-    dialog.open(
-      `chrome://global/content/print.html?browsingContextId=${aBrowsingContext.id}`,
-      null,
-      null,
-      async () => {
-        // Cleanup the overlay since a new one will be created the next time
-        // a print is initiated for this tab.
-        let overlay = dialog._overlay;
-        await dialog._closingPromise;
-        overlay.remove();
-
-        // Cleanup all our references to the dialog.
-        dialog = null;
-        overlay._dialog = null;
-
-        // Let the tests know the dialog has been closed.
-        resolveDialogClosed();
+    let printPath = "chrome://global/content/print.html";
+    gBrowser.loadOneTab(
+      `${printPath}?browsingContextId=${aBrowsingContext.id}`,
+      {
+        inBackground: false,
+        relatedToCurrent: true,
+        triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
       }
     );
   },
 
   /**
    * Initialize a print, this will open the tab modal UI if it is enabled or
    * defer to the native dialog/silent print.
    *
@@ -285,17 +233,17 @@ var PrintUtils = {
    *
    *        These methods must be defined. printPreview can be called
    *        with aListenerObj as null iff this window is already displaying
    *        print preview (in which case, the previous aListenerObj passed
    *        to it will be used).
    */
   printPreview(aListenerObj) {
     if (PRINT_TAB_MODAL) {
-      this._openTabModalPrint(gBrowser.selectedBrowser.browsingContext);
+      this._openTabModalPrint(aListenerObj.getSourceBrowser().browsingContext);
       return;
     }
 
     // If we already have a toolbar someone is calling printPreview() to get us
     // to refresh the display and aListenerObj won't be passed.
     let printPreviewTB = document.getElementById("print-preview-toolbar");
     if (!printPreviewTB) {
       this._listener = aListenerObj;
--- a/toolkit/components/printing/tests/browser.ini
+++ b/toolkit/components/printing/tests/browser.ini
@@ -1,16 +1,8 @@
-[DEFAULT]
-support-files =
-  head.js
-
-[browser_modal_print.js]
-support-files =
-  simplifyArticleSample.html
-
 [browser_page_change_print_original.js]
 support-files =
   file_page_change_print_original_1.html
   file_page_change_print_original_2.html
 skip-if = os == "mac"
 
 [browser_preview_print_simplify_non_article.js]
 support-files =
deleted file mode 100644
--- a/toolkit/components/printing/tests/browser_modal_print.js
+++ /dev/null
@@ -1,69 +0,0 @@
-function assertExpectedPrintPage(helper) {
-  let printBrowser = helper.win.getSourceBrowser();
-  is(
-    printBrowser,
-    gBrowser.selectedBrowser,
-    "The current browser is being printed"
-  );
-  is(
-    printBrowser.currentURI.spec,
-    PrintHelper.defaultTestPageUrl,
-    "The URL of the browser is the one we expect"
-  );
-}
-
-add_task(async function testModalPrintDialog() {
-  await PrintHelper.withTestPage(async helper => {
-    helper.assertDialogHidden();
-
-    await helper.startPrint();
-
-    helper.assertDialogVisible();
-
-    // Check that we're printing the right page.
-    assertExpectedPrintPage(helper);
-
-    // Close the dialog with Escape.
-    await helper.withClosingFn(() => {
-      EventUtils.synthesizeKey("VK_ESCAPE", {}, helper.win);
-    });
-
-    helper.assertDialogHidden();
-  });
-});
-
-add_task(async function testPrintMultiple() {
-  await PrintHelper.withTestPage(async helper => {
-    helper.assertDialogHidden();
-
-    // First print as usual.
-    await helper.startPrint();
-    helper.assertDialogVisible();
-    assertExpectedPrintPage(helper);
-
-    // Trigger the command a few more times, verify the overlay still exists.
-    await helper.startPrint();
-    await helper.startPrint();
-    await helper.startPrint();
-    helper.assertDialogVisible();
-
-    // Verify it's still the correct page.
-    assertExpectedPrintPage(helper);
-  });
-});
-
-add_task(async function testCancelButton() {
-  await PrintHelper.withTestPage(async helper => {
-    helper.assertDialogHidden();
-    await helper.startPrint();
-    helper.assertDialogVisible();
-
-    let cancelButton = helper.doc.querySelector("button[name=cancel]");
-    ok(cancelButton, "Got the cancel button");
-    info(helper.doc.body.innerHTML + "\n");
-    await helper.withClosingFn(() =>
-      EventUtils.synthesizeMouseAtCenter(cancelButton, {}, helper.win)
-    );
-    helper.assertDialogHidden();
-  });
-});
deleted file mode 100644
--- a/toolkit/components/printing/tests/head.js
+++ /dev/null
@@ -1,72 +0,0 @@
-class PrintHelper {
-  static withTestPage(testFn) {
-    SpecialPowers.pushPrefEnv({
-      set: [["print.tab_modal.enabled", true]],
-    });
-
-    return BrowserTestUtils.withNewTab(
-      this.defaultTestPageUrl,
-      async browser => {
-        await testFn(new PrintHelper(browser));
-        SpecialPowers.popPrefEnv();
-      }
-    );
-  }
-
-  static get defaultTestPageUrl() {
-    const testPath = getRootDirectory(gTestPath).replace(
-      "chrome://mochitests/content",
-      "http://example.com"
-    );
-    return testPath + "simplifyArticleSample.html";
-  }
-
-  constructor(browser) {
-    this.browser = browser;
-  }
-
-  async startPrint() {
-    document.getElementById("cmd_print").doCommand();
-    let dialog = await TestUtils.waitForCondition(() => this._dialogs[0]);
-    await dialog._ready;
-  }
-
-  async withClosingFn(closeFn) {
-    let closed = this._dialogs[0]._closed;
-    await closeFn();
-    await closed;
-  }
-
-  assertDialogHidden() {
-    is(this._dialogs.length, 0, "There are no print dialogs");
-  }
-
-  assertDialogVisible() {
-    is(this._dialogs.length, 1, "There is one print dialog");
-    BrowserTestUtils.is_visible(this._dialogs[0], "The dialog is visible");
-  }
-
-  get _container() {
-    return this.browser.ownerGlobal.gBrowser.getBrowserContainer(this.browser);
-  }
-
-  get _dialogs() {
-    return this._container.querySelectorAll(".printDialogContainer");
-  }
-
-  get _printBrowser() {
-    let dialogs = this._dialogs;
-    is(dialogs.length, 1, "There's one dialog");
-    let frame = dialogs[0].querySelector(".dialogFrame");
-    ok(frame, "Found the print dialog frame");
-    return frame;
-  }
-
-  get doc() {
-    return this._printBrowser.contentDocument;
-  }
-
-  get win() {
-    return this._printBrowser.contentWindow;
-  }
-}
--- a/toolkit/components/prompts/content/tabprompts.css
+++ b/toolkit/components/prompts/content/tabprompts.css
@@ -86,26 +86,8 @@ tabmodalprompt label[value=""] {
   width: 600px;
 }
 
 .paymentDialogContainerFrame {
   box-sizing: border-box;
   height: 100%;
   width: 100%;
 }
-
-/**
- * Tab modal SubDialog hosted overlay.
- */
-.tabSubDialogBoxContainer {
-  display: flex;
-  justify-content: center;
-  position: absolute;
-  /* TODO: figure out which element is preventing this from showing */
-  z-index: 1;
-  width: 100%;
-  margin-top: -3px;
-}
-
-.tabSubDialogBoxContainer .dialogBox {
-  box-shadow: 0 2px 8px rgba(12,12,13,.3);
-  outline: 1px solid rgba(12,12,13,.2);
-}