Commit cde6d580 authored by rbpotter's avatar rbpotter Committed by Commit Bot

Print Preview: Remove workaround for blink bug

crbug.com/804047 has been fixed, and the DCHECK referenced in the
Print Preview JS no longer occurs. Remove the async(..., 1) workaround.

Bug: None
Change-Id: I0a8f38a697965e912265092d33ef7a2d0e58f85f
Reviewed-on: https://chromium-review.googlesource.com/c/1281912Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#600146}
parent 3bf60675
......@@ -42,12 +42,7 @@ Polymer({
attached: function() {
this.metrics_.record(print_preview.Metrics.PrintSettingsUiBucket
.ADVANCED_SETTINGS_DIALOG_SHOWN);
// This async() call is a workaround to prevent a DCHECK - see
// https://crbug.com/804047.
// TODO(rbpotter): Remove after Polymer2 migration is complete.
this.async(() => {
this.$.dialog.showModal();
}, 1);
this.$.dialog.showModal();
},
/**
......
......@@ -87,12 +87,7 @@ Polymer({
this.destinationStore.startLoadAllDestinations();
this.invitationStore.startLoadingInvitations();
const dialog = this.$.destinationDialog.get();
// This async() call is a workaround to prevent a DCHECK - see
// https://crbug.com/804047.
// TODO(rbpotter): Remove after Polymer2 migration is complete.
this.async(() => {
dialog.show();
}, 1);
dialog.show();
},
showCloudPrintPromo: function() {
......
......@@ -61,7 +61,7 @@ cr.define('advanced_dialog_test', function() {
dialog.destination = destination;
document.body.appendChild(dialog);
return test_util.eventToPromise('cr-dialog-open', dialog);
Polymer.dom.flush();
}
/**
......@@ -99,93 +99,88 @@ cr.define('advanced_dialog_test', function() {
// Tests that the search box does not appear when there is only one option,
// and that the vendor item is correctly displayed.
test(assert(TestNames.AdvancedSettings1Option), function() {
return setupDialog(1).then(() => verifyListWithItemCount(1));
setupDialog(1);
verifyListWithItemCount(1);
});
// Tests that the search box appears when there are two options, and that
// the items are correctly displayed.
test(assert(TestNames.AdvancedSettings2Options), function() {
return setupDialog(2).then(() => verifyListWithItemCount(2));
setupDialog(2);
verifyListWithItemCount(2);
});
// Tests that the advanced settings dialog correctly updates the settings
// value for vendor items when the apply button is clicked.
test(assert(TestNames.AdvancedSettingsApply), function() {
return setupDialog(3)
.then(() => {
setItemValues();
const buttons = dialog.shadowRoot.querySelectorAll('paper-button');
assertEquals(2, buttons.length);
const whenDialogClose = test_util.eventToPromise('close', dialog);
// Click apply button.
buttons[1].click();
return whenDialogClose;
})
.then(() => {
// Check that the setting has been set.
const setting = dialog.getSettingValue('vendorItems');
assertEquals(6, setting.printArea);
assertEquals(1, setting.paperType);
assertEquals('XYZ', setting.watermark);
});
setupDialog(3);
setItemValues();
const buttons = dialog.shadowRoot.querySelectorAll('paper-button');
assertEquals(2, buttons.length);
const whenDialogClose = test_util.eventToPromise('close', dialog);
// Click apply button.
buttons[1].click();
return whenDialogClose.then(() => {
// Check that the setting has been set.
const setting = dialog.getSettingValue('vendorItems');
assertEquals(6, setting.printArea);
assertEquals(1, setting.paperType);
assertEquals('XYZ', setting.watermark);
});
});
// Tests that the advanced settings dialog does not update the settings
// value for vendor items when the close button is clicked.
test(assert(TestNames.AdvancedSettingsClose), function() {
return setupDialog(3)
.then(() => {
setItemValues();
const buttons = dialog.shadowRoot.querySelectorAll('paper-button');
assertEquals(2, buttons.length);
const whenDialogClose = test_util.eventToPromise('close', dialog);
// Click close button.
buttons[0].click();
return whenDialogClose;
})
.then(() => {
// Check that the setting has not been set.
const setting = dialog.getSettingValue('vendorItems');
assertEquals(undefined, setting.printArea);
assertEquals(undefined, setting.paperType);
assertEquals(undefined, setting.watermark);
});
setupDialog(3);
setItemValues();
const buttons = dialog.shadowRoot.querySelectorAll('paper-button');
assertEquals(2, buttons.length);
const whenDialogClose = test_util.eventToPromise('close', dialog);
// Click close button.
buttons[0].click();
return whenDialogClose.then(() => {
// Check that the setting has not been set.
const setting = dialog.getSettingValue('vendorItems');
assertEquals(undefined, setting.printArea);
assertEquals(undefined, setting.paperType);
assertEquals(undefined, setting.watermark);
});
});
// Tests that the dialog correctly shows and hides settings based on the
// value of the search query.
test(assert(TestNames.AdvancedSettingsFilter), function() {
return setupDialog(3).then(() => {
const searchBox = dialog.$.searchBox;
const items = dialog.shadowRoot.querySelectorAll(
'print-preview-advanced-settings-item');
const noMatchHint = dialog.$$('.no-settings-match-hint');
// Query is initialized to null. All items are shown and the hint is
// hidden.
items.forEach(item => assertFalse(item.hidden));
assertTrue(noMatchHint.hidden);
// Searching for Watermark should show only the watermark setting.
searchBox.searchQuery = /(Watermark)/i;
items.forEach((item, index) => assertEquals(index != 2, item.hidden));
assertTrue(noMatchHint.hidden);
// Searching for A4 should show only the print area setting.
searchBox.searchQuery = /(A4)/i;
items.forEach((item, index) => assertEquals(index != 0, item.hidden));
assertTrue(noMatchHint.hidden);
// Searching for WXYZ should show no settings and display the "no match"
// hint.
searchBox.searchQuery = /(WXYZ)/i;
items.forEach(item => assertTrue(item.hidden));
assertFalse(noMatchHint.hidden);
});
setupDialog(3);
const searchBox = dialog.$.searchBox;
const items = dialog.shadowRoot.querySelectorAll(
'print-preview-advanced-settings-item');
const noMatchHint = dialog.$$('.no-settings-match-hint');
// Query is initialized to null. All items are shown and the hint is
// hidden.
items.forEach(item => assertFalse(item.hidden));
assertTrue(noMatchHint.hidden);
// Searching for Watermark should show only the watermark setting.
searchBox.searchQuery = /(Watermark)/i;
items.forEach((item, index) => assertEquals(index != 2, item.hidden));
assertTrue(noMatchHint.hidden);
// Searching for A4 should show only the print area setting.
searchBox.searchQuery = /(A4)/i;
items.forEach((item, index) => assertEquals(index != 0, item.hidden));
assertTrue(noMatchHint.hidden);
// Searching for WXYZ should show no settings and display the "no match"
// hint.
searchBox.searchQuery = /(WXYZ)/i;
items.forEach(item => assertTrue(item.hidden));
assertFalse(noMatchHint.hidden);
});
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment