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({ ...@@ -42,12 +42,7 @@ Polymer({
attached: function() { attached: function() {
this.metrics_.record(print_preview.Metrics.PrintSettingsUiBucket this.metrics_.record(print_preview.Metrics.PrintSettingsUiBucket
.ADVANCED_SETTINGS_DIALOG_SHOWN); .ADVANCED_SETTINGS_DIALOG_SHOWN);
// This async() call is a workaround to prevent a DCHECK - see this.$.dialog.showModal();
// https://crbug.com/804047.
// TODO(rbpotter): Remove after Polymer2 migration is complete.
this.async(() => {
this.$.dialog.showModal();
}, 1);
}, },
/** /**
......
...@@ -87,12 +87,7 @@ Polymer({ ...@@ -87,12 +87,7 @@ Polymer({
this.destinationStore.startLoadAllDestinations(); this.destinationStore.startLoadAllDestinations();
this.invitationStore.startLoadingInvitations(); this.invitationStore.startLoadingInvitations();
const dialog = this.$.destinationDialog.get(); const dialog = this.$.destinationDialog.get();
// This async() call is a workaround to prevent a DCHECK - see dialog.show();
// https://crbug.com/804047.
// TODO(rbpotter): Remove after Polymer2 migration is complete.
this.async(() => {
dialog.show();
}, 1);
}, },
showCloudPrintPromo: function() { showCloudPrintPromo: function() {
......
...@@ -61,7 +61,7 @@ cr.define('advanced_dialog_test', function() { ...@@ -61,7 +61,7 @@ cr.define('advanced_dialog_test', function() {
dialog.destination = destination; dialog.destination = destination;
document.body.appendChild(dialog); 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() { ...@@ -99,93 +99,88 @@ cr.define('advanced_dialog_test', function() {
// Tests that the search box does not appear when there is only one option, // Tests that the search box does not appear when there is only one option,
// and that the vendor item is correctly displayed. // and that the vendor item is correctly displayed.
test(assert(TestNames.AdvancedSettings1Option), function() { 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 // Tests that the search box appears when there are two options, and that
// the items are correctly displayed. // the items are correctly displayed.
test(assert(TestNames.AdvancedSettings2Options), function() { 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 // Tests that the advanced settings dialog correctly updates the settings
// value for vendor items when the apply button is clicked. // value for vendor items when the apply button is clicked.
test(assert(TestNames.AdvancedSettingsApply), function() { test(assert(TestNames.AdvancedSettingsApply), function() {
return setupDialog(3) setupDialog(3);
.then(() => { setItemValues();
setItemValues();
const buttons = dialog.shadowRoot.querySelectorAll('paper-button');
const buttons = dialog.shadowRoot.querySelectorAll('paper-button'); assertEquals(2, buttons.length);
assertEquals(2, buttons.length); const whenDialogClose = test_util.eventToPromise('close', dialog);
const whenDialogClose = test_util.eventToPromise('close', dialog);
// Click apply button.
// Click apply button. buttons[1].click();
buttons[1].click(); return whenDialogClose.then(() => {
return whenDialogClose; // Check that the setting has been set.
}) const setting = dialog.getSettingValue('vendorItems');
.then(() => { assertEquals(6, setting.printArea);
// Check that the setting has been set. assertEquals(1, setting.paperType);
const setting = dialog.getSettingValue('vendorItems'); assertEquals('XYZ', setting.watermark);
assertEquals(6, setting.printArea); });
assertEquals(1, setting.paperType);
assertEquals('XYZ', setting.watermark);
});
}); });
// Tests that the advanced settings dialog does not update the settings // Tests that the advanced settings dialog does not update the settings
// value for vendor items when the close button is clicked. // value for vendor items when the close button is clicked.
test(assert(TestNames.AdvancedSettingsClose), function() { test(assert(TestNames.AdvancedSettingsClose), function() {
return setupDialog(3) setupDialog(3);
.then(() => { setItemValues();
setItemValues();
const buttons = dialog.shadowRoot.querySelectorAll('paper-button');
const buttons = dialog.shadowRoot.querySelectorAll('paper-button'); assertEquals(2, buttons.length);
assertEquals(2, buttons.length); const whenDialogClose = test_util.eventToPromise('close', dialog);
const whenDialogClose = test_util.eventToPromise('close', dialog);
// Click close button.
// Click close button. buttons[0].click();
buttons[0].click(); return whenDialogClose.then(() => {
return whenDialogClose; // Check that the setting has not been set.
}) const setting = dialog.getSettingValue('vendorItems');
.then(() => { assertEquals(undefined, setting.printArea);
// Check that the setting has not been set. assertEquals(undefined, setting.paperType);
const setting = dialog.getSettingValue('vendorItems'); assertEquals(undefined, setting.watermark);
assertEquals(undefined, setting.printArea); });
assertEquals(undefined, setting.paperType);
assertEquals(undefined, setting.watermark);
});
}); });
// Tests that the dialog correctly shows and hides settings based on the // Tests that the dialog correctly shows and hides settings based on the
// value of the search query. // value of the search query.
test(assert(TestNames.AdvancedSettingsFilter), function() { test(assert(TestNames.AdvancedSettingsFilter), function() {
return setupDialog(3).then(() => { setupDialog(3);
const searchBox = dialog.$.searchBox; const searchBox = dialog.$.searchBox;
const items = dialog.shadowRoot.querySelectorAll( const items = dialog.shadowRoot.querySelectorAll(
'print-preview-advanced-settings-item'); 'print-preview-advanced-settings-item');
const noMatchHint = dialog.$$('.no-settings-match-hint'); const noMatchHint = dialog.$$('.no-settings-match-hint');
// Query is initialized to null. All items are shown and the hint is // Query is initialized to null. All items are shown and the hint is
// hidden. // hidden.
items.forEach(item => assertFalse(item.hidden)); items.forEach(item => assertFalse(item.hidden));
assertTrue(noMatchHint.hidden); assertTrue(noMatchHint.hidden);
// Searching for Watermark should show only the watermark setting. // Searching for Watermark should show only the watermark setting.
searchBox.searchQuery = /(Watermark)/i; searchBox.searchQuery = /(Watermark)/i;
items.forEach((item, index) => assertEquals(index != 2, item.hidden)); items.forEach((item, index) => assertEquals(index != 2, item.hidden));
assertTrue(noMatchHint.hidden); assertTrue(noMatchHint.hidden);
// Searching for A4 should show only the print area setting. // Searching for A4 should show only the print area setting.
searchBox.searchQuery = /(A4)/i; searchBox.searchQuery = /(A4)/i;
items.forEach((item, index) => assertEquals(index != 0, item.hidden)); items.forEach((item, index) => assertEquals(index != 0, item.hidden));
assertTrue(noMatchHint.hidden); assertTrue(noMatchHint.hidden);
// Searching for WXYZ should show no settings and display the "no match" // Searching for WXYZ should show no settings and display the "no match"
// hint. // hint.
searchBox.searchQuery = /(WXYZ)/i; searchBox.searchQuery = /(WXYZ)/i;
items.forEach(item => assertTrue(item.hidden)); items.forEach(item => assertTrue(item.hidden));
assertFalse(noMatchHint.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