mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-01 17:23:59 +00:00
Bug 1692716 - Make browser_quit_disabled.js more robust. r=Gijs
I realized that we wouldn't notice if the quit-application-requested observer wasn't called. Differential Revision: https://phabricator.services.mozilla.com/D105121
This commit is contained in:
parent
e6322c7b6f
commit
98018ecb9a
@ -8,3 +8,5 @@ reason = test depends on update channel
|
||||
[browser_initial_tab_remoteType.js]
|
||||
[browser_startup_homepage.js]
|
||||
[browser_quit_disabled.js]
|
||||
# On macOS we can't change browser.quitShortcut.disabled during runtime.
|
||||
skip-if = os == 'mac'
|
||||
|
@ -25,6 +25,7 @@ add_task(async function test_quit_shortcut_disabled() {
|
||||
async function testQuitShortcut(shouldQuit) {
|
||||
let win = await BrowserTestUtils.openNewBrowserWindow();
|
||||
|
||||
let quitRequested = false;
|
||||
let observer = {
|
||||
observe(subject, topic, data) {
|
||||
is(topic, "quit-application-requested", "Right observer topic");
|
||||
@ -33,6 +34,8 @@ add_task(async function test_quit_shortcut_disabled() {
|
||||
// Don't actually quit the browser when testing.
|
||||
let cancelQuit = subject.QueryInterface(Ci.nsISupportsPRBool);
|
||||
cancelQuit.data = true;
|
||||
|
||||
quitRequested = true;
|
||||
},
|
||||
};
|
||||
Services.obs.addObserver(observer, "quit-application-requested");
|
||||
@ -44,8 +47,9 @@ add_task(async function test_quit_shortcut_disabled() {
|
||||
EventUtils.synthesizeKey("q", modifiers, win);
|
||||
|
||||
await BrowserTestUtils.closeWindow(win);
|
||||
|
||||
Services.obs.removeObserver(observer, "quit-application-requested");
|
||||
|
||||
is(quitRequested, shouldQuit, "Expected quit state");
|
||||
}
|
||||
|
||||
// Quit shortcut should work when pref is not set.
|
||||
|
Loading…
Reference in New Issue
Block a user