forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1839845 - Add a few tests for about:settings behavior. r=Gijs,rob…
…wu,settings-reviewers Differential Revision: https://phabricator.services.mozilla.com/D203052
- Loading branch information
1 parent
061e6bc
commit 4ad24f7
Showing
4 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
browser/components/preferences/tests/browser_about_settings.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* Any copyright is dedicated to the Public Domain. | ||
http://creativecommons.org/publicdomain/zero/1.0/ */ | ||
|
||
"use strict"; | ||
|
||
add_task(async function test_openPreferences_aboutSettings() { | ||
await BrowserTestUtils.withNewTab( | ||
{ | ||
gBrowser, | ||
url: "about:settings", | ||
}, | ||
async () => { | ||
is( | ||
gBrowser.currentURI.spec, | ||
"about:settings", | ||
"about:settings should open normally" | ||
); | ||
|
||
// using `openPreferencesViaOpenPreferencesAPI` would introduce an extra about:blank tab we need to take care of | ||
await openPreferences("paneGeneral"); | ||
|
||
is( | ||
gBrowser.currentURI.spec, | ||
"about:settings#general", | ||
"openPreferences should keep about:settings" | ||
); | ||
} | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
toolkit/mozapps/extensions/test/browser/browser_sidebar_preferences_button.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* Any copyright is dedicated to the Public Domain. | ||
http://creativecommons.org/publicdomain/zero/1.0/ */ | ||
|
||
"use strict"; | ||
|
||
add_task(async function testNoOtherTabsPresent() { | ||
let addonsWin = await loadInitialView("extension"); | ||
let preferencesButton = | ||
addonsWin.document.querySelector("#preferencesButton"); | ||
|
||
let preferencesPromise = BrowserTestUtils.waitForNewTab( | ||
gBrowser, | ||
"about:preferences" | ||
); | ||
|
||
preferencesButton.click(); | ||
|
||
let preferencesTab = await preferencesPromise; | ||
|
||
is( | ||
gBrowser.currentURI.spec, | ||
"about:preferences", | ||
"about:preferences should open if neither it nor about:settings are present" | ||
); | ||
|
||
gBrowser.removeTab(preferencesTab); | ||
|
||
await closeView(addonsWin); | ||
}); | ||
|
||
async function ensurePreferencesButtonFocusesTab(expectedUri) { | ||
let addonsWin = await loadInitialView("extension"); | ||
let preferencesButton = | ||
addonsWin.document.querySelector("#preferencesButton"); | ||
|
||
let tabCountBeforeClick = gBrowser.tabCount; | ||
preferencesButton.click(); | ||
let tabCountAfterClick = gBrowser.tabCount; | ||
|
||
is( | ||
tabCountAfterClick, | ||
tabCountBeforeClick, | ||
"preferences button should not open new tabs" | ||
); | ||
is( | ||
gBrowser.currentURI.spec, | ||
expectedUri, | ||
"the correct tab should be focused" | ||
); | ||
|
||
addonsWin.focus(); | ||
await closeView(addonsWin); | ||
} | ||
|
||
add_task(async function testAboutPreferencesPresent() { | ||
await BrowserTestUtils.withNewTab("about:preferences", async () => { | ||
await ensurePreferencesButtonFocusesTab("about:preferences"); | ||
}); | ||
}); | ||
|
||
add_task(async function testAboutSettingsPresent() { | ||
await BrowserTestUtils.withNewTab("about:settings", async () => { | ||
await ensurePreferencesButtonFocusesTab("about:settings"); | ||
}); | ||
}); | ||
|
||
add_task(async function testAboutSettingsAndPreferencesPresent() { | ||
await BrowserTestUtils.withNewTab("about:settings", async () => { | ||
await BrowserTestUtils.withNewTab("about:preferences", async () => { | ||
await ensurePreferencesButtonFocusesTab("about:settings"); | ||
}); | ||
}); | ||
}); |