1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
ChromeUtils.defineESModuleGetters(this, {
UrlbarTestUtils: "resource://testing-common/UrlbarTestUtils.sys.mjs",
});
var updateService = Cc["@mozilla.org/updates/update-service;1"].getService(
Ci.nsIApplicationUpdateService
);
add_task(async function test_updates_post_policy() {
is(
Services.policies.isAllowed("appUpdate"),
false,
"appUpdate should be disabled by policy."
);
is(
updateService.canCheckForUpdates,
false,
"Should not be able to check for updates with DisableAppUpdate enabled."
);
});
add_task(async function test_update_preferences_ui() {
let tab = await BrowserTestUtils.openNewForegroundTab(
gBrowser,
"about:preferences"
);
await SpecialPowers.spawn(tab.linkedBrowser, [], async function () {
let setting = content.document.getElementById("updateSettingsContainer");
is(
setting.hidden,
true,
"Update choices should be disabled when app update is locked by policy"
);
});
BrowserTestUtils.removeTab(tab);
});
add_task(async function test_update_about_ui() {
let aboutDialog = await waitForAboutDialog();
let panelId = "policyDisabled";
await BrowserTestUtils.waitForCondition(
() => aboutDialog.gAppUpdater?.selectedPanel?.id == panelId,
'Waiting for expected panel ID - expected "' + panelId + '"'
);
is(
aboutDialog.gAppUpdater.selectedPanel.id,
panelId,
"The About Dialog panel Id should equal " + panelId
);
// Make sure that we still remain on the "disabled by policy" panel after
// `AppUpdater.stop()` is called.
aboutDialog.gAppUpdater._appUpdater.stop();
is(
aboutDialog.gAppUpdater.selectedPanel.id,
panelId,
"The About Dialog panel Id should still equal " + panelId
);
aboutDialog.close();
});
/**
* Waits for the About Dialog to load.
*
* @return A promise that returns the domWindow for the About Dialog and
* resolves when the About Dialog loads.
*/
function waitForAboutDialog() {
return new Promise(resolve => {
var listener = {
onOpenWindow: aXULWindow => {
Services.wm.removeListener(listener);
async function aboutDialogOnLoad() {
domwindow.removeEventListener("load", aboutDialogOnLoad, true);
let chromeURI = "chrome://browser/content/aboutDialog.xhtml";
is(
domwindow.document.location.href,
chromeURI,
"About dialog appeared"
);
resolve(domwindow);
}
var domwindow = aXULWindow.docShell.domWindow;
domwindow.addEventListener("load", aboutDialogOnLoad, true);
},
onCloseWindow: aXULWindow => {},
};
Services.wm.addListener(listener);
openAboutDialog();
});
}
add_task(async function test_no_update_intervention() {
await BrowserTestUtils.withNewTab("about:blank", async () => {
let context = await UrlbarTestUtils.promiseAutocompleteResultPopup({
window,
value: "update firefox",
waitForFocus,
fireInputEvent: true,
});
for (let result of context.results) {
Assert.notEqual(result.type, UrlbarUtils.RESULT_TYPE.TIP);
}
await UrlbarTestUtils.promisePopupClose(window, () =>
window.gURLBar.blur()
);
});
});
|