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
|
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
async function openLibrary() {
return new Promise(resolve => {
let library = window.openDialog(
"chrome://browser/content/places/places.xhtml",
"",
"chrome,toolbar=yes,dialog=no,resizable"
);
waitForFocus(() => resolve(library), library);
});
}
add_task(async function test_disable_profile_import() {
await setupPolicyEngineWithJson({
policies: {
DisableProfileImport: true,
},
});
let library = await openLibrary();
let menu = library.document.getElementById("maintenanceButtonPopup");
let promisePopupShown = BrowserTestUtils.waitForEvent(menu, "popupshown");
menu.openPopup();
await promisePopupShown;
let profileImportButton = library.document.getElementById("browserImport");
is(
profileImportButton.disabled,
true,
"Profile Import button should be disabled"
);
let promisePopupHidden = BrowserTestUtils.waitForEvent(menu, "popuphidden");
menu.hidePopup();
await promisePopupHidden;
await BrowserTestUtils.closeWindow(library);
checkLockedPref("browser.newtabpage.activity-stream.migrationExpired", true);
});
add_task(async function test_file_menu() {
gFileMenu.updateImportCommandEnabledState();
let command = document.getElementById("cmd_file_importFromAnotherBrowser");
ok(
command.getAttribute("disabled"),
"The `Import from Another Browser…` File menu item command should be disabled"
);
if (Services.appinfo.OS == "Darwin") {
// We would need to have a lot of boilerplate to open the menus on Windows
// and Linux to test this there.
let menuitem = document.getElementById("menu_importFromAnotherBrowser");
ok(
menuitem.disabled,
"The `Import from Another Browser…` File menu item should be disabled"
);
}
});
add_task(async function test_import_button() {
await PlacesUIUtils.maybeAddImportButton();
ok(
!document.getElementById("import-button"),
"Import button should be hidden."
);
});
add_task(async function test_prefs_entrypoint() {
await SpecialPowers.pushPrefEnv({
set: [["browser.migrate.preferences-entrypoint.enabled", true]],
});
let finalPaneEvent = Services.prefs.getBoolPref("identity.fxaccounts.enabled")
? "sync-pane-loaded"
: "privacy-pane-loaded";
let finalPrefPaneLoaded = TestUtils.topicObserved(finalPaneEvent, () => true);
await BrowserTestUtils.withNewTab(
"about:preferences#general-migrate",
async browser => {
await finalPrefPaneLoaded;
await browser.contentWindow.customElements.whenDefined(
"migration-wizard"
);
let doc = browser.contentDocument;
ok(
!doc.getElementById("dataMigrationGroup"),
"Should remove import entrypoint in prefs if disabled via policy."
);
ok(
!doc.getElementById("migrationWizardDialog").open,
"Should not have opened the migration wizard."
);
}
);
});
|