Bug 1435142 - Part 2: add a browser mochitest for closeTabByDblclick. r=dao
☠☠ backed out by c7d3eda7dedc ☠ ☠
authorHector Zhao <bzhao@mozilla.com>
Tue, 06 Mar 2018 16:50:38 +0800
changeset 408991 ff4b0af1e773b93201023c51b27ccac110c08b2b
parent 408990 79b72c904600680e1393117ddca6b99d1f1da6a7
child 408992 9193e64cfe29d8df8e30d957b4f58785389d9ed5
push id33671
push usercsabou@mozilla.com
push dateTue, 20 Mar 2018 22:23:32 +0000
treeherdermozilla-central@e2e874ceae78 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdao
bugs1435142
milestone61.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 1435142 - Part 2: add a browser mochitest for closeTabByDblclick. r=dao MozReview-Commit-ID: 1UEnYflvtLw
browser/base/content/test/tabs/browser.ini
browser/base/content/test/tabs/browser_close_tab_by_dblclick.js
--- a/browser/base/content/test/tabs/browser.ini
+++ b/browser/base/content/test/tabs/browser.ini
@@ -2,16 +2,17 @@
 support-files =
   head.js
   dummy_page.html
 
 [browser_abandonment_telemetry.js]
 [browser_accessibility_indicator.js]
 [browser_allow_process_switches_despite_related_browser.js]
 [browser_bug580956.js]
+[browser_close_tab_by_dblclick.js]
 [browser_contextmenu_openlink_after_tabnavigated.js]
 support-files =
   test_bug1358314.html
 [browser_isLocalAboutURI.js]
 [browser_tabCloseProbes.js]
 [browser_tabSpinnerProbe.js]
 skip-if = !e10s # Tab spinner is e10s only.
 [browser_tabSwitchPrintPreview.js]
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/tabs/browser_close_tab_by_dblclick.js
@@ -0,0 +1,41 @@
+/* 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/. */
+
+
+const PREF_CLOSE_TAB_BY_DBLCLICK = "browser.tabs.closeTabByDblclick";
+
+function triggerDblclickOn(target) {
+  EventUtils.synthesizeMouseAtCenter(target, { clickCount: 1 });
+  EventUtils.synthesizeMouseAtCenter(target, { clickCount: 2 });
+}
+
+add_task(async function dblclick() {
+  let tab = gBrowser.selectedTab;
+
+  let promise = BrowserTestUtils.waitForEvent(tab, "dblclick");
+  triggerDblclickOn(tab);
+  await promise;
+  ok(!tab.closing, "Double click the selected tab won't close it");
+});
+
+add_task(async function dblclickWithPrefSet() {
+  await SpecialPowers.pushPrefEnv({set: [
+    [PREF_CLOSE_TAB_BY_DBLCLICK, true]
+  ]});
+
+  let promise = BrowserTestUtils.waitForNewTab(gBrowser, "about:mozilla");
+  BrowserTestUtils.addTab(gBrowser, "about:mozilla");
+  let tab = await promise;
+  isnot(tab, gBrowser.selectedTab, "The new tab is in the background");
+
+  promise = BrowserTestUtils.waitForEvent(tab, "dblclick");
+  triggerDblclickOn(tab);
+  await promise;
+  is(tab, gBrowser.selectedTab, "Double click a background tab will select it");
+
+  promise = BrowserTestUtils.waitForEvent(tab, "dblclick");
+  triggerDblclickOn(tab);
+  await promise;
+  ok(tab.closing, "Double click the selected tab will close it");
+});