зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1745810 - remove use of ChromeUtils.import(..., null) from CustomizableUI tests, r=Standard8
Differential Revision: https://phabricator.services.mozilla.com/D139477
This commit is contained in:
Родитель
63f7179055
Коммит
ac056a416f
|
@ -542,13 +542,6 @@ module.exports = {
|
|||
// TODO: Bug 1609271 Fix all violations for ChromeUtils.import(..., null)
|
||||
files: [
|
||||
"browser/base/content/test/sync/browser_fxa_web_channel.js",
|
||||
"browser/components/customizableui/test/browser_1042100_default_placements_update.js",
|
||||
"browser/components/customizableui/test/browser_1096763_seen_widgets_post_reset.js",
|
||||
"browser/components/customizableui/test/browser_1161838_inserted_new_default_buttons.js",
|
||||
"browser/components/customizableui/test/browser_989338_saved_placements_not_resaved.js",
|
||||
"browser/components/customizableui/test/browser_currentset_post_reset.js",
|
||||
"browser/components/customizableui/test/browser_panel_keyboard_navigation.js",
|
||||
"browser/components/customizableui/test/browser_proton_toolbar_hide_toolbarbuttons.js",
|
||||
"browser/components/migration/tests/unit/test_Edge_db_migration.js",
|
||||
"browser/components/translation/test/unit/test_cld2.js",
|
||||
"browser/extensions/formautofill/test/unit/test_sync.js",
|
||||
|
|
|
@ -49,6 +49,8 @@ const kPrefSidebarButtonUsed = "browser.engagement.sidebar-button.has-used";
|
|||
|
||||
const kExpectedWindowURL = AppConstants.BROWSER_CHROME_URL;
|
||||
|
||||
const global = this;
|
||||
|
||||
var gDefaultTheme;
|
||||
var gSelectedTheme;
|
||||
|
||||
|
@ -4629,6 +4631,34 @@ var CustomizableUI = {
|
|||
getCustomizationTarget(aElement) {
|
||||
return CustomizableUIInternal.getCustomizationTarget(aElement);
|
||||
},
|
||||
|
||||
getTestOnlyInternalProp(aProp) {
|
||||
if (
|
||||
!Cu.isInAutomation ||
|
||||
![
|
||||
"CustomizableUIInternal",
|
||||
"gAreas",
|
||||
"gFuturePlacements",
|
||||
"gPalette",
|
||||
"gPlacements",
|
||||
"gSavedState",
|
||||
"gSeenWidgets",
|
||||
"kVersion",
|
||||
].includes(aProp)
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
return global[aProp];
|
||||
},
|
||||
setTestOnlyInternalProp(aProp, aValue) {
|
||||
if (
|
||||
!Cu.isInAutomation ||
|
||||
!["gSavedState", "kVersion", "gDirty"].includes(aProp)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
global[aProp] = aValue;
|
||||
},
|
||||
};
|
||||
Object.freeze(CustomizableUI);
|
||||
Object.freeze(CustomizableUI.windows);
|
||||
|
|
|
@ -3,6 +3,10 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
function getSavedStatePlacements(area) {
|
||||
return CustomizableUI.getTestOnlyInternalProp("gSavedState").placements[area];
|
||||
}
|
||||
|
||||
// NB: This uses some ugly hacks to get into the CUI module from elsewhere...
|
||||
// don't try this at home, kids.
|
||||
function test() {
|
||||
|
@ -12,30 +16,28 @@ function test() {
|
|||
CustomizableUI.AREA_NAVBAR
|
||||
);
|
||||
|
||||
// Check what version we're on:
|
||||
let CustomizableUIBSPass = ChromeUtils.import(
|
||||
"resource:///modules/CustomizableUI.jsm",
|
||||
null
|
||||
let oldState = CustomizableUI.getTestOnlyInternalProp("gSavedState");
|
||||
registerCleanupFunction(() =>
|
||||
CustomizableUI.setTestOnlyInternalProp("gSavedState", oldState)
|
||||
);
|
||||
|
||||
let oldState = CustomizableUIBSPass.gSavedState;
|
||||
registerCleanupFunction(() => (CustomizableUIBSPass.gSavedState = oldState));
|
||||
|
||||
let gFuturePlacements = CustomizableUI.getTestOnlyInternalProp(
|
||||
"gFuturePlacements"
|
||||
);
|
||||
is(
|
||||
CustomizableUIBSPass.gFuturePlacements.size,
|
||||
gFuturePlacements.size,
|
||||
0,
|
||||
"All future placements should be dealt with by now."
|
||||
);
|
||||
|
||||
let {
|
||||
CustomizableUIInternal,
|
||||
gFuturePlacements,
|
||||
gPalette,
|
||||
} = CustomizableUIBSPass;
|
||||
let gPalette = CustomizableUI.getTestOnlyInternalProp("gPalette");
|
||||
let CustomizableUIInternal = CustomizableUI.getTestOnlyInternalProp(
|
||||
"CustomizableUIInternal"
|
||||
);
|
||||
CustomizableUIInternal._updateForNewVersion();
|
||||
is(gFuturePlacements.size, 0, "No change to future placements initially.");
|
||||
|
||||
let currentVersion = CustomizableUIBSPass.kVersion;
|
||||
let currentVersion = CustomizableUI.getTestOnlyInternalProp("kVersion");
|
||||
|
||||
// Add our widget to the defaults:
|
||||
let testWidgetNew = {
|
||||
|
@ -53,7 +55,7 @@ function test() {
|
|||
if (!normalizedWidget) {
|
||||
return;
|
||||
}
|
||||
CustomizableUIBSPass.gPalette.set(testWidgetNew.id, normalizedWidget);
|
||||
gPalette.set(testWidgetNew.id, normalizedWidget);
|
||||
|
||||
let testWidgetOld = {
|
||||
id: "test-messing-with-default-placements-old",
|
||||
|
@ -70,16 +72,19 @@ function test() {
|
|||
if (!normalizedWidget) {
|
||||
return;
|
||||
}
|
||||
CustomizableUIBSPass.gPalette.set(testWidgetOld.id, normalizedWidget);
|
||||
gPalette.set(testWidgetOld.id, normalizedWidget);
|
||||
|
||||
// Now increase the version in the module:
|
||||
CustomizableUIBSPass.kVersion++;
|
||||
CustomizableUI.setTestOnlyInternalProp(
|
||||
"kVersion",
|
||||
CustomizableUI.getTestOnlyInternalProp("kVersion") + 1
|
||||
);
|
||||
|
||||
let hadSavedState = !!CustomizableUIBSPass.gSavedState;
|
||||
let hadSavedState = !!CustomizableUI.getTestOnlyInternalProp("gSavedState");
|
||||
if (!hadSavedState) {
|
||||
CustomizableUIBSPass.gSavedState = {
|
||||
currentVersion: CustomizableUIBSPass.kVersion - 1,
|
||||
};
|
||||
CustomizableUI.setTestOnlyInternalProp("gSavedState", {
|
||||
currentVersion: CustomizableUI.getTestOnlyInternalProp("kVersion") - 1,
|
||||
});
|
||||
}
|
||||
|
||||
// Then call the re-init routine so we re-add the builtin widgets
|
||||
|
@ -116,64 +121,45 @@ function test() {
|
|||
}
|
||||
|
||||
// Reset kVersion
|
||||
CustomizableUIBSPass.kVersion--;
|
||||
CustomizableUI.setTestOnlyInternalProp(
|
||||
"kVersion",
|
||||
CustomizableUI.getTestOnlyInternalProp("kVersion") - 1
|
||||
);
|
||||
|
||||
// Now test that the builtin photon migrations work:
|
||||
|
||||
CustomizableUIBSPass.gSavedState = {
|
||||
CustomizableUI.setTestOnlyInternalProp("gSavedState", {
|
||||
currentVersion: 6,
|
||||
placements: {
|
||||
"nav-bar": ["urlbar-container", "bookmarks-menu-button"],
|
||||
"PanelUI-contents": ["panic-button", "edit-controls"],
|
||||
},
|
||||
};
|
||||
});
|
||||
Services.prefs.setIntPref("browser.proton.toolbar.version", 0);
|
||||
CustomizableUIInternal._updateForNewVersion();
|
||||
CustomizableUIInternal._updateForNewProtonVersion();
|
||||
let navbarPlacements = CustomizableUIBSPass.gSavedState.placements["nav-bar"];
|
||||
let springs = navbarPlacements.filter(id => id.includes("spring"));
|
||||
is(springs.length, 2, "Should have 2 toolbarsprings in placements now");
|
||||
navbarPlacements = navbarPlacements.filter(id => !id.includes("spring"));
|
||||
let expectedItemLength = 6;
|
||||
is(
|
||||
navbarPlacements.length,
|
||||
expectedItemLength,
|
||||
`Should have ${expectedItemLength} items`
|
||||
);
|
||||
is(
|
||||
navbarPlacements.shift(),
|
||||
"back-button",
|
||||
"Back button is in the right place."
|
||||
);
|
||||
is(
|
||||
navbarPlacements.shift(),
|
||||
"forward-button",
|
||||
"Fwd button is in the right place."
|
||||
);
|
||||
is(
|
||||
navbarPlacements.shift(),
|
||||
"stop-reload-button",
|
||||
"Stop/reload button is in the right place."
|
||||
);
|
||||
is(
|
||||
navbarPlacements.shift(),
|
||||
"urlbar-container",
|
||||
"URL bar is in the right place."
|
||||
);
|
||||
is(
|
||||
navbarPlacements.shift(),
|
||||
"downloads-button",
|
||||
"Downloads button is in the right place."
|
||||
);
|
||||
is(
|
||||
navbarPlacements.shift(),
|
||||
"fxa-toolbar-menu-button",
|
||||
"FxA button is in the right place."
|
||||
);
|
||||
{
|
||||
let navbarPlacements = getSavedStatePlacements("nav-bar");
|
||||
let springs = navbarPlacements.filter(id => id.includes("spring"));
|
||||
is(springs.length, 2, "Should have 2 toolbarsprings in placements now");
|
||||
navbarPlacements = navbarPlacements.filter(id => !id.includes("spring"));
|
||||
Assert.deepEqual(
|
||||
navbarPlacements,
|
||||
[
|
||||
"back-button",
|
||||
"forward-button",
|
||||
"stop-reload-button",
|
||||
"urlbar-container",
|
||||
"downloads-button",
|
||||
"fxa-toolbar-menu-button",
|
||||
],
|
||||
"Nav-bar placements should be correct."
|
||||
);
|
||||
|
||||
let overflowPlacements =
|
||||
CustomizableUIBSPass.gSavedState.placements["widget-overflow-fixed-list"];
|
||||
Assert.deepEqual(overflowPlacements, ["panic-button"]);
|
||||
Assert.deepEqual(getSavedStatePlacements("widget-overflow-fixed-list"), [
|
||||
"panic-button",
|
||||
]);
|
||||
}
|
||||
|
||||
// Finally, test the downloads and fxa avatar button migrations work.
|
||||
let oldNavbarPlacements = [
|
||||
|
@ -181,36 +167,34 @@ function test() {
|
|||
"customizableui-special-spring3",
|
||||
"search-container",
|
||||
];
|
||||
CustomizableUIBSPass.gSavedState = {
|
||||
CustomizableUI.setTestOnlyInternalProp("gSavedState", {
|
||||
currentVersion: 10,
|
||||
placements: {
|
||||
"nav-bar": Array.from(oldNavbarPlacements),
|
||||
"widget-overflow-fixed-list": ["downloads-button"],
|
||||
},
|
||||
};
|
||||
});
|
||||
CustomizableUIInternal._updateForNewVersion();
|
||||
navbarPlacements = CustomizableUIBSPass.gSavedState.placements["nav-bar"];
|
||||
Assert.deepEqual(
|
||||
navbarPlacements,
|
||||
getSavedStatePlacements("nav-bar"),
|
||||
oldNavbarPlacements.concat(["downloads-button", "fxa-toolbar-menu-button"]),
|
||||
"Downloads button inserted in navbar"
|
||||
);
|
||||
Assert.deepEqual(
|
||||
CustomizableUIBSPass.gSavedState.placements["widget-overflow-fixed-list"],
|
||||
getSavedStatePlacements("widget-overflow-fixed-list"),
|
||||
[],
|
||||
"Overflow panel is empty"
|
||||
);
|
||||
|
||||
CustomizableUIBSPass.gSavedState = {
|
||||
CustomizableUI.setTestOnlyInternalProp("gSavedState", {
|
||||
currentVersion: 10,
|
||||
placements: {
|
||||
"nav-bar": ["downloads-button"].concat(oldNavbarPlacements),
|
||||
},
|
||||
};
|
||||
});
|
||||
CustomizableUIInternal._updateForNewVersion();
|
||||
navbarPlacements = CustomizableUIBSPass.gSavedState.placements["nav-bar"];
|
||||
Assert.deepEqual(
|
||||
navbarPlacements,
|
||||
getSavedStatePlacements("nav-bar"),
|
||||
oldNavbarPlacements.concat(["downloads-button", "fxa-toolbar-menu-button"]),
|
||||
"Downloads button reinserted in navbar"
|
||||
);
|
||||
|
@ -221,14 +205,13 @@ function test() {
|
|||
"search-container",
|
||||
"other-widget",
|
||||
];
|
||||
CustomizableUIBSPass.gSavedState = {
|
||||
CustomizableUI.setTestOnlyInternalProp("gSavedState", {
|
||||
currentVersion: 10,
|
||||
placements: {
|
||||
"nav-bar": Array.from(oldNavbarPlacements),
|
||||
},
|
||||
};
|
||||
});
|
||||
CustomizableUIInternal._updateForNewVersion();
|
||||
navbarPlacements = CustomizableUIBSPass.gSavedState.placements["nav-bar"];
|
||||
let expectedNavbarPlacements = [
|
||||
"urlbar-container",
|
||||
"customizableui-special-spring3",
|
||||
|
@ -238,7 +221,7 @@ function test() {
|
|||
"fxa-toolbar-menu-button",
|
||||
];
|
||||
Assert.deepEqual(
|
||||
navbarPlacements,
|
||||
getSavedStatePlacements("nav-bar"),
|
||||
expectedNavbarPlacements,
|
||||
"Downloads button inserted in navbar before other widgets"
|
||||
);
|
||||
|
|
|
@ -10,17 +10,13 @@ add_task(async function() {
|
|||
});
|
||||
|
||||
const kPrefCustomizationState = "browser.uiCustomization.state";
|
||||
let bsPass = ChromeUtils.import(
|
||||
"resource:///modules/CustomizableUI.jsm",
|
||||
null
|
||||
);
|
||||
ok(
|
||||
bsPass.gSeenWidgets.has(BUTTONID),
|
||||
CustomizableUI.getTestOnlyInternalProp("gSeenWidgets").has(BUTTONID),
|
||||
"Widget should be seen after createWidget is called."
|
||||
);
|
||||
CustomizableUI.reset();
|
||||
ok(
|
||||
bsPass.gSeenWidgets.has(BUTTONID),
|
||||
CustomizableUI.getTestOnlyInternalProp("gSeenWidgets").has(BUTTONID),
|
||||
"Widget should still be seen after reset."
|
||||
);
|
||||
CustomizableUI.addWidgetToArea(BUTTONID, CustomizableUI.AREA_NAVBAR);
|
||||
|
|
|
@ -9,22 +9,18 @@ function test() {
|
|||
CustomizableUI.AREA_NAVBAR
|
||||
);
|
||||
|
||||
let CustomizableUIBSPass = ChromeUtils.import(
|
||||
"resource:///modules/CustomizableUI.jsm",
|
||||
null
|
||||
let gFuturePlacements = CustomizableUI.getTestOnlyInternalProp(
|
||||
"gFuturePlacements"
|
||||
);
|
||||
|
||||
is(
|
||||
CustomizableUIBSPass.gFuturePlacements.size,
|
||||
gFuturePlacements.size,
|
||||
0,
|
||||
"All future placements should be dealt with by now."
|
||||
);
|
||||
|
||||
let {
|
||||
CustomizableUIInternal,
|
||||
gFuturePlacements,
|
||||
gPalette,
|
||||
} = CustomizableUIBSPass;
|
||||
let CustomizableUIInternal = CustomizableUI.getTestOnlyInternalProp(
|
||||
"CustomizableUIInternal"
|
||||
);
|
||||
|
||||
// Force us to have a saved state:
|
||||
CustomizableUIInternal.saveState();
|
||||
|
@ -49,10 +45,13 @@ function test() {
|
|||
if (!normalizedWidget) {
|
||||
return;
|
||||
}
|
||||
CustomizableUIBSPass.gPalette.set(testWidgetNew.id, normalizedWidget);
|
||||
let gPalette = CustomizableUI.getTestOnlyInternalProp("gPalette");
|
||||
gPalette.set(testWidgetNew.id, normalizedWidget);
|
||||
|
||||
// Now adjust default placements for area:
|
||||
let navbarArea = CustomizableUIBSPass.gAreas.get(CustomizableUI.AREA_NAVBAR);
|
||||
let navbarArea = CustomizableUI.getTestOnlyInternalProp("gAreas").get(
|
||||
CustomizableUI.AREA_NAVBAR
|
||||
);
|
||||
let navbarPlacements = navbarArea.get("defaultPlacements");
|
||||
navbarPlacements.splice(
|
||||
navbarPlacements.indexOf("bookmarks-menu-button") + 1,
|
||||
|
@ -60,8 +59,8 @@ function test() {
|
|||
testWidgetNew.id
|
||||
);
|
||||
|
||||
let savedPlacements =
|
||||
CustomizableUIBSPass.gSavedState.placements[CustomizableUI.AREA_NAVBAR];
|
||||
let savedPlacements = CustomizableUI.getTestOnlyInternalProp("gSavedState")
|
||||
.placements[CustomizableUI.AREA_NAVBAR];
|
||||
// Then call the re-init routine so we re-add the builtin widgets
|
||||
CustomizableUIInternal._updateForNewVersion();
|
||||
is(gFuturePlacements.size, 1, "Should have 1 more future placement");
|
||||
|
|
|
@ -9,24 +9,19 @@ const AREAID = "test-area-saved-earlier";
|
|||
|
||||
var hadSavedState;
|
||||
function test() {
|
||||
// Hack our way into the module to fake a saved state that isn't there...
|
||||
let backstagePass = ChromeUtils.import(
|
||||
"resource:///modules/CustomizableUI.jsm",
|
||||
null
|
||||
);
|
||||
hadSavedState = backstagePass.gSavedState != null;
|
||||
let gSavedState = CustomizableUI.getTestOnlyInternalProp("gSavedState");
|
||||
hadSavedState = gSavedState != null;
|
||||
if (!hadSavedState) {
|
||||
backstagePass.gSavedState = { placements: {} };
|
||||
gSavedState = { placements: {} };
|
||||
CustomizableUI.setTestOnlyInternalProp("gSavedState", gSavedState);
|
||||
}
|
||||
backstagePass.gSavedState.placements[AREAID] = [BUTTONID];
|
||||
gSavedState.placements[AREAID] = [BUTTONID];
|
||||
// Put bogus stuff in the saved state for the nav-bar, so as to check the current placements
|
||||
// override this one...
|
||||
backstagePass.gSavedState.placements[CustomizableUI.AREA_NAVBAR] = [
|
||||
"bogus-navbar-item",
|
||||
];
|
||||
gSavedState.placements[CustomizableUI.AREA_NAVBAR] = ["bogus-navbar-item"];
|
||||
|
||||
backstagePass.gDirty = true;
|
||||
backstagePass.CustomizableUIInternal.saveState();
|
||||
CustomizableUI.setTestOnlyInternalProp("gDirty", true);
|
||||
CustomizableUI.getTestOnlyInternalProp("CustomizableUIInternal").saveState();
|
||||
|
||||
let newSavedState = JSON.parse(
|
||||
Services.prefs.getCharPref("browser.uiCustomization.state")
|
||||
|
@ -41,7 +36,7 @@ function test() {
|
|||
placementArraysEqual(AREAID, newSavedState.placements[AREAID], [BUTTONID]);
|
||||
}
|
||||
ok(
|
||||
!backstagePass.gPlacements.has(AREAID),
|
||||
!CustomizableUI.getTestOnlyInternalProp("gPlacements").has(AREAID),
|
||||
"Placements map shouldn't have been affected"
|
||||
);
|
||||
|
||||
|
@ -59,20 +54,17 @@ function test() {
|
|||
}
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
let backstagePass = ChromeUtils.import(
|
||||
"resource:///modules/CustomizableUI.jsm",
|
||||
null
|
||||
);
|
||||
if (!hadSavedState) {
|
||||
backstagePass.gSavedState = null;
|
||||
CustomizableUI.setTestOnlyInternalProp("gSavedState", null);
|
||||
} else {
|
||||
let savedPlacements = backstagePass.gSavedState.placements;
|
||||
let gSavedState = CustomizableUI.getTestOnlyInternalProp("gSavedState");
|
||||
let savedPlacements = gSavedState.placements;
|
||||
delete savedPlacements[AREAID];
|
||||
let realNavBarPlacements = CustomizableUI.getWidgetIdsInArea(
|
||||
CustomizableUI.AREA_NAVBAR
|
||||
);
|
||||
savedPlacements[CustomizableUI.AREA_NAVBAR] = realNavBarPlacements;
|
||||
}
|
||||
backstagePass.gDirty = true;
|
||||
backstagePass.CustomizableUIInternal.saveState();
|
||||
CustomizableUI.setTestOnlyInternalProp("gDirty", true);
|
||||
CustomizableUI.getTestOnlyInternalProp("CustomizableUIInternal").saveState();
|
||||
});
|
||||
|
|
|
@ -4,14 +4,10 @@
|
|||
"use strict";
|
||||
|
||||
function checkSpacers() {
|
||||
let bsPass = ChromeUtils.import(
|
||||
"resource:///modules/CustomizableUI.jsm",
|
||||
null
|
||||
);
|
||||
let navbarWidgets = CustomizableUI.getWidgetIdsInArea("nav-bar");
|
||||
let currentSetWidgets = bsPass.CustomizableUIInternal._getCurrentWidgetsInContainer(
|
||||
document.getElementById("nav-bar")
|
||||
);
|
||||
let currentSetWidgets = CustomizableUI.getTestOnlyInternalProp(
|
||||
"CustomizableUIInternal"
|
||||
)._getCurrentWidgetsInContainer(document.getElementById("nav-bar"));
|
||||
navbarWidgets = navbarWidgets.filter(w => CustomizableUI.isSpecialWidget(w));
|
||||
currentSetWidgets = currentSetWidgets.filter(w =>
|
||||
CustomizableUI.isSpecialWidget(w)
|
||||
|
|
|
@ -5,8 +5,7 @@
|
|||
*/
|
||||
|
||||
const { PanelView } = ChromeUtils.import(
|
||||
"resource:///modules/PanelMultiView.jsm",
|
||||
null
|
||||
"resource:///modules/PanelMultiView.jsm"
|
||||
);
|
||||
const kHelpButtonId = "appMenu-help-button2";
|
||||
|
||||
|
|
|
@ -4,11 +4,6 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
let CustomizableUIBSPass = ChromeUtils.import(
|
||||
"resource:///modules/CustomizableUI.jsm",
|
||||
null
|
||||
);
|
||||
|
||||
ChromeUtils.defineModuleGetter(
|
||||
this,
|
||||
"HomePage",
|
||||
|
@ -40,7 +35,7 @@ async function testToolbarButtons(aActions) {
|
|||
"sidebar-button",
|
||||
"fxa-toolbar-menu-button",
|
||||
];
|
||||
let oldState = CustomizableUIBSPass.gSavedState;
|
||||
let oldState = CustomizableUI.getTestOnlyInternalProp("gSavedState");
|
||||
|
||||
Assert.equal(
|
||||
Services.prefs.getIntPref(kPrefProtonToolbarVersion),
|
||||
|
@ -48,16 +43,19 @@ async function testToolbarButtons(aActions) {
|
|||
"Toolbar proton version is 0"
|
||||
);
|
||||
|
||||
let { CustomizableUIInternal } = CustomizableUIBSPass;
|
||||
let CustomizableUIInternal = CustomizableUI.getTestOnlyInternalProp(
|
||||
"CustomizableUIInternal"
|
||||
);
|
||||
|
||||
CustomizableUIBSPass.gSavedState = {
|
||||
CustomizableUI.setTestOnlyInternalProp("gSavedState", {
|
||||
placements: {
|
||||
"nav-bar": defaultPlacements,
|
||||
},
|
||||
};
|
||||
});
|
||||
CustomizableUIInternal._updateForNewProtonVersion();
|
||||
|
||||
let navbarPlacements = CustomizableUIBSPass.gSavedState.placements["nav-bar"];
|
||||
let navbarPlacements = CustomizableUI.getTestOnlyInternalProp("gSavedState")
|
||||
.placements["nav-bar"];
|
||||
let includesHomeButton = navbarPlacements.includes("home-button");
|
||||
let includesLibraryButton = navbarPlacements.includes("library-button");
|
||||
let includesSidebarButton = navbarPlacements.includes("sidebar-button");
|
||||
|
@ -86,7 +84,7 @@ async function testToolbarButtons(aActions) {
|
|||
}
|
||||
|
||||
// Cleanup
|
||||
CustomizableUIBSPass.gSavedState = oldState;
|
||||
CustomizableUI.setTestOnlyInternalProp("gSavedState", oldState);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -184,7 +182,7 @@ add_task(async function testNullSavedState() {
|
|||
await SpecialPowers.pushPrefEnv({
|
||||
set: [[kPrefProtonToolbarVersion, 0]],
|
||||
});
|
||||
let oldState = CustomizableUIBSPass.gSavedState;
|
||||
let oldState = CustomizableUI.getTestOnlyInternalProp("gSavedState");
|
||||
|
||||
Assert.equal(
|
||||
Services.prefs.getIntPref(kPrefProtonToolbarVersion),
|
||||
|
@ -192,14 +190,16 @@ add_task(async function testNullSavedState() {
|
|||
"Toolbar proton version is 0"
|
||||
);
|
||||
|
||||
let { CustomizableUIInternal } = CustomizableUIBSPass;
|
||||
let CustomizableUIInternal = CustomizableUI.getTestOnlyInternalProp(
|
||||
"CustomizableUIInternal"
|
||||
);
|
||||
CustomizableUIInternal.initialize();
|
||||
|
||||
Assert.ok(
|
||||
Services.prefs.getIntPref(kPrefProtonToolbarVersion) >= 1,
|
||||
"Toolbar proton version updated"
|
||||
);
|
||||
let navbarPlacements = CustomizableUIBSPass.gAreas
|
||||
let navbarPlacements = CustomizableUI.getTestOnlyInternalProp("gAreas")
|
||||
.get("nav-bar")
|
||||
.get("defaultPlacements");
|
||||
Assert.ok(
|
||||
|
@ -216,7 +216,7 @@ add_task(async function testNullSavedState() {
|
|||
);
|
||||
|
||||
// Cleanup
|
||||
CustomizableUIBSPass.gSavedState = oldState;
|
||||
CustomizableUI.setTestOnlyInternalProp("gSavedState", oldState);
|
||||
await SpecialPowers.popPrefEnv();
|
||||
// Re-initialize to prevent future test failures
|
||||
CustomizableUIInternal.initialize();
|
||||
|
@ -230,7 +230,7 @@ add_task(async function testNoNavbarPlacements() {
|
|||
set: [[kPrefProtonToolbarVersion, 0]],
|
||||
});
|
||||
|
||||
let oldState = CustomizableUIBSPass.gSavedState;
|
||||
let oldState = CustomizableUI.getTestOnlyInternalProp("gSavedState");
|
||||
|
||||
Assert.equal(
|
||||
Services.prefs.getIntPref(kPrefProtonToolbarVersion),
|
||||
|
@ -238,17 +238,19 @@ add_task(async function testNoNavbarPlacements() {
|
|||
"Toolbar proton version is 0"
|
||||
);
|
||||
|
||||
let { CustomizableUIInternal } = CustomizableUIBSPass;
|
||||
let CustomizableUIInternal = CustomizableUI.getTestOnlyInternalProp(
|
||||
"CustomizableUIInternal"
|
||||
);
|
||||
|
||||
CustomizableUIBSPass.gSavedState = {
|
||||
CustomizableUI.setTestOnlyInternalProp("gSavedState", {
|
||||
placements: { "widget-overflow-fixed-list": [] },
|
||||
};
|
||||
});
|
||||
CustomizableUIInternal._updateForNewProtonVersion();
|
||||
|
||||
Assert.ok(true, "_updateForNewProtonVersion didn't throw");
|
||||
|
||||
// Cleanup
|
||||
CustomizableUIBSPass.gSavedState = oldState;
|
||||
CustomizableUI.setTestOnlyInternalProp("gSavedState", oldState);
|
||||
|
||||
await SpecialPowers.popPrefEnv();
|
||||
});
|
||||
|
@ -261,7 +263,7 @@ add_task(async function testNullPlacements() {
|
|||
set: [[kPrefProtonToolbarVersion, 0]],
|
||||
});
|
||||
|
||||
let oldState = CustomizableUIBSPass.gSavedState;
|
||||
let oldState = CustomizableUI.getTestOnlyInternalProp("gSavedState");
|
||||
|
||||
Assert.equal(
|
||||
Services.prefs.getIntPref(kPrefProtonToolbarVersion),
|
||||
|
@ -269,15 +271,17 @@ add_task(async function testNullPlacements() {
|
|||
"Toolbar proton version is 0"
|
||||
);
|
||||
|
||||
let { CustomizableUIInternal } = CustomizableUIBSPass;
|
||||
let CustomizableUIInternal = CustomizableUI.getTestOnlyInternalProp(
|
||||
"CustomizableUIInternal"
|
||||
);
|
||||
|
||||
CustomizableUIBSPass.gSavedState = {};
|
||||
CustomizableUI.setTestOnlyInternalProp("gSavedState", {});
|
||||
CustomizableUIInternal._updateForNewProtonVersion();
|
||||
|
||||
Assert.ok(true, "_updateForNewProtonVersion didn't throw");
|
||||
|
||||
// Cleanup
|
||||
CustomizableUIBSPass.gSavedState = oldState;
|
||||
CustomizableUI.setTestOnlyInternalProp("gSavedState", oldState);
|
||||
|
||||
await SpecialPowers.popPrefEnv();
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче