Chromium Code Reviews| Index: chrome/test/data/webui/print_preview.js |
| diff --git a/chrome/test/data/webui/print_preview.js b/chrome/test/data/webui/print_preview.js |
| index 1ed192e674149d91c9ae2fb8536fb8ebef68a5bd..9ef1745d187c98ea5d1df651243ecee46bc7ed4c 100644 |
| --- a/chrome/test/data/webui/print_preview.js |
| +++ b/chrome/test/data/webui/print_preview.js |
| @@ -1253,3 +1253,47 @@ TEST_F('PrintPreviewWebUITest', 'TestAdvancedSettings2Options', function() { |
| this.waitForAnimationToEnd('more-settings'); |
| }); |
| +// Test that initialization with saved destination only issues one call |
| +// to startPreview. |
| +TEST_F('PrintPreviewWebUITest', 'TestInitIssuesOneRequest', function() { |
| + // Load in a bunch of recent destinations with non null capabilities. |
| + var initSettings = { |
| + version: 2, |
| + recentDestinations: [1, 2, 3].map(function(i) { |
| + return { |
| + id: 'ID' + i, origin: 'local', account: '', |
| + capabilities: JSON.stringify(getCddTemplate('ID' + i)), name: '', |
|
dpapad
2017/01/13 21:37:41
capabilities is JSONified twice now? I would expec
rbpotter
2017/01/13 22:52:19
Done.
|
| + extensionId: '', extensionName: '' |
| + }; |
| + }), |
| + }; |
| + this.initialSettings_.serializedAppStateStr_ = JSON.stringify(initSettings); |
| + this.setCapabilities(getCddTemplate('ID1')); |
| + this.setCapabilities(getCddTemplate('ID2')); |
| + this.setCapabilities(getCddTemplate('ID3')); |
| + |
| + var previewGenerator = mock(print_preview.PreviewGenerator); |
| + printPreview.previewArea_.previewGenerator_ = previewGenerator.proxy(); |
| + |
| + // On initialization we expect 18 calls to requestPreview. requestPreview |
| + // is called each time a ticket item that updates the preview changes and |
| + // each time there is a DocumentInfo.CHANGE event or a CAPABILITIES_CHANGE |
| + // event. So we have: |
| + // - 1 call from documentInfo initialization (triggers DocumentInfo.CHANGE). |
| + // - 10 calls from Ticket item updates triggered by the DocumentInfo.CHANGE. |
| + // - 2 calls from HeaderFooter ticket item updates triggered by the updates |
| + // to marginsType and customMargins ticket items. |
| + // - 1 call from CAPABILITIES_CHANGE event called from setting the |
| + // destination. |
| + // - 4 calls from ticket item updates that are triggered by the |
| + // CAPABILITIES_CHANGE event. |
| + // == 18 calls total. |
| + // If more calls occur, this indicates that additional CAPABILITIES_CHANGE or |
| + // DocumentInfo.CHANGE events may have been fired. This would cause multiple |
| + // startPreview calls will be issued from requestPreview, which leads to |
| + // a race condition: see crbug.com/666595. |
| + previewGenerator.expects(exactly(18)).requestPreview(); |
| + |
| + this.setInitialSettings(); |
| + testDone(); |
| +}); |