Bug 1661663 - Allow overriding @page margin rules r=sfoster

Differential Revision: https://phabricator.services.mozilla.com/D132284
This commit is contained in:
Mark Striemer 2021-11-30 15:59:11 +00:00
Родитель e1611c9885
Коммит b87567e7b1
2 изменённых файлов: 29 добавлений и 0 удалений

Просмотреть файл

@ -1397,6 +1397,7 @@ var PrintSettingsViewProxy = {
for (let [settingName, presetValue] of Object.entries(marginPresets)) {
target[settingName] = presetValue;
}
target.honorPageRuleMargins = value == "default";
break;
case "paperId": {

Просмотреть файл

@ -154,11 +154,13 @@ add_task(async function testPresetMargins() {
ok(customMargins.hidden, "Custom margins are hidden");
is(marginSelect.value, "default", "Default margins set");
helper.assertSettingsMatch({ honorPageRuleMargins: true });
changeDefaultToCustom(helper);
is(marginSelect.value, "custom", "Custom margins are now set");
ok(!customMargins.hidden, "Custom margins are present");
// Check that values are initialized to correct values
is(
helper.get("custom-margin-top").value,
@ -1031,3 +1033,29 @@ add_task(async function testCustomMarginUnits() {
await helper.closeDialog();
});
});
add_task(async function testHonorPageRuleMargins() {
await PrintHelper.withTestPage(async helper => {
await helper.startPrint();
await helper.openMoreSettings();
let marginsPicker = helper.get("margins-picker");
is(marginsPicker.value, "default", "Started with default margins");
helper.assertSettingsMatch({ honorPageRuleMargins: true });
await helper.waitForSettingsEvent(() => changeDefaultToCustom(helper));
is(marginsPicker.value, "custom", "Changed to custom margins");
helper.assertSettingsMatch({ honorPageRuleMargins: false });
await helper.waitForSettingsEvent(() => changeCustomToNone(helper));
is(marginsPicker.value, "none", "Changed to no margins");
helper.assertSettingsMatch({ honorPageRuleMargins: false });
await helper.waitForSettingsEvent(() => changeCustomToDefault(helper));
is(marginsPicker.value, "default", "Back to default margins");
helper.assertSettingsMatch({ honorPageRuleMargins: true });
});
});