summaryrefslogtreecommitdiffstats
path: root/browser/base/content/test/newtab/browser_newtab_focus.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /browser/base/content/test/newtab/browser_newtab_focus.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'browser/base/content/test/newtab/browser_newtab_focus.js')
-rw-r--r--browser/base/content/test/newtab/browser_newtab_focus.js48
1 files changed, 48 insertions, 0 deletions
diff --git a/browser/base/content/test/newtab/browser_newtab_focus.js b/browser/base/content/test/newtab/browser_newtab_focus.js
new file mode 100644
index 000000000..ae0dd8d29
--- /dev/null
+++ b/browser/base/content/test/newtab/browser_newtab_focus.js
@@ -0,0 +1,48 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/*
+ * These tests make sure that focusing the 'New Tab Page' works as expected.
+ */
+add_task(function* () {
+ yield pushPrefs(["accessibility.tabfocus", 7]);
+
+ // Focus count in new tab page.
+ // 30 = 9 * 3 + 3 = 9 sites, each with link, pin and remove buttons; search
+ // bar; search button; and toggle button. Additionaly there may or may not be
+ // a scroll bar caused by fix to 1180387, which will eat an extra focus
+ let FOCUS_COUNT = 30;
+
+ // Create a new tab page.
+ yield setLinks("0,1,2,3,4,5,6,7,8");
+ setPinnedLinks("");
+
+ yield* addNewTabPageTab();
+ gURLBar.focus();
+
+ // Count the focus with the enabled page.
+ countFocus(FOCUS_COUNT);
+
+ // Disable page and count the focus with the disabled page.
+ NewTabUtils.allPages.enabled = false;
+
+ countFocus(4);
+
+ NewTabUtils.allPages.enabled = true;
+});
+
+/**
+ * Focus the urlbar and count how many focus stops to return again to the urlbar.
+ */
+function countFocus(aExpectedCount) {
+ let focusCount = 0;
+ do {
+ EventUtils.synthesizeKey("VK_TAB", {});
+ if (document.activeElement == gBrowser.selectedBrowser) {
+ focusCount++;
+ }
+ } while (document.activeElement != gURLBar.inputField);
+
+ ok(focusCount == aExpectedCount || focusCount == (aExpectedCount + 1),
+ "Validate focus count in the new tab page.");
+}