2013-06-04 00:12:00 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2013-12-17 03:00:34 +04:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
registerCleanupFunction(removeCustomToolbars);
|
|
|
|
|
|
|
|
// Sanity checks
|
|
|
|
add_task(function sanityChecks() {
|
2015-09-23 12:36:20 +03:00
|
|
|
SimpleTest.doesThrow(
|
|
|
|
() => CustomizableUI.registerArea("@foo"),
|
2013-12-17 03:00:34 +04:00
|
|
|
"Registering areas with an invalid ID should throw."
|
|
|
|
);
|
|
|
|
|
2015-09-23 12:36:20 +03:00
|
|
|
SimpleTest.doesThrow(
|
|
|
|
() => CustomizableUI.registerArea([]),
|
2013-12-17 03:00:34 +04:00
|
|
|
"Registering areas with an invalid ID should throw."
|
|
|
|
);
|
|
|
|
|
2015-09-23 12:36:20 +03:00
|
|
|
SimpleTest.doesThrow(
|
|
|
|
() => CustomizableUI.unregisterArea("@foo"),
|
2013-12-17 03:00:34 +04:00
|
|
|
"Unregistering areas with an invalid ID should throw."
|
|
|
|
);
|
|
|
|
|
2015-09-23 12:36:20 +03:00
|
|
|
SimpleTest.doesThrow(
|
|
|
|
() => CustomizableUI.unregisterArea([]),
|
2013-12-17 03:00:34 +04:00
|
|
|
"Unregistering areas with an invalid ID should throw."
|
|
|
|
);
|
|
|
|
|
2015-09-23 12:36:20 +03:00
|
|
|
SimpleTest.doesThrow(
|
|
|
|
() => CustomizableUI.unregisterArea("unknown"),
|
2013-12-17 03:00:34 +04:00
|
|
|
"Unregistering an area that's not registered should throw."
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
// Check areas are loaded with their default placements.
|
|
|
|
add_task(function checkLoadedAres() {
|
|
|
|
ok(
|
|
|
|
CustomizableUI.inDefaultState,
|
|
|
|
"Everything should be in its default state."
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
// Check registering and unregistering a new area.
|
|
|
|
add_task(function checkRegisteringAndUnregistering() {
|
|
|
|
const kToolbarId = "test-registration-toolbar";
|
|
|
|
const kButtonId = "test-registration-button";
|
|
|
|
createDummyXULButton(kButtonId);
|
|
|
|
createToolbarWithPlacements(kToolbarId, ["spring", kButtonId, "spring"]);
|
|
|
|
assertAreaPlacements(kToolbarId, [
|
|
|
|
/customizableui-special-spring\d+/,
|
|
|
|
kButtonId,
|
|
|
|
/customizableui-special-spring\d+/,
|
|
|
|
]);
|
2014-02-07 20:20:23 +04:00
|
|
|
ok(
|
|
|
|
!CustomizableUI.inDefaultState,
|
|
|
|
"With a new toolbar it is no longer in a default state."
|
|
|
|
);
|
2013-12-17 03:00:34 +04:00
|
|
|
removeCustomToolbars(); // Will call unregisterArea for us
|
|
|
|
ok(
|
|
|
|
CustomizableUI.inDefaultState,
|
|
|
|
"When the toolbar is unregistered, " +
|
2014-02-07 20:20:23 +04:00
|
|
|
"everything will return to the default state."
|
|
|
|
);
|
2013-12-17 03:00:34 +04:00
|
|
|
});
|
|
|
|
|
2016-01-23 22:55:27 +03:00
|
|
|
add_task(async function asyncCleanup() {
|
2013-06-17 18:37:41 +04:00
|
|
|
await resetCustomization();
|
2013-12-17 03:00:34 +04:00
|
|
|
});
|