Index: chrome/test/data/webui/print_preview/plugin_stub.js |
diff --git a/chrome/test/data/webui/print_preview/plugin_stub.js b/chrome/test/data/webui/print_preview/plugin_stub.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..490d177807072ebd025607fc39b1fa709c5dc078 |
--- /dev/null |
+++ b/chrome/test/data/webui/print_preview/plugin_stub.js |
@@ -0,0 +1,51 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+cr.define('print_preview', function() { |
+ /** |
+ * Test version of the print preview plugin |
+ * @param {print_preview.PreviewArea} The PreviewArea that owns this plugin. |
dpapad
2017/07/06 00:24:17
!print_preview.PreviewArea
rbpotter
2017/07/06 01:57:27
Done.
|
+ * @constructor |
+ */ |
+ function PDFPluginStub(area) { |
dpapad
2017/07/06 00:24:17
Can we use the new ES6 class syntax, which we rece
rbpotter
2017/07/06 01:57:28
Done.
|
+ /** @private {Object} The callback to run when the plugin has loaded. */ |
dpapad
2017/07/06 00:24:17
?Function
rbpotter
2017/07/06 01:57:27
Done.
|
+ this.loadCallback_ = null; |
+ |
+ /** @private {EventTracker} The plugin stub's event tracker. */ |
dpapad
2017/07/06 00:24:17
!EventTracker
rbpotter
2017/07/06 01:57:28
Done.
|
+ this.tracker_ = new EventTracker(); |
+ |
+ // Call documentLoadComplete as soon as the preview area starts the preview. |
+ this.tracker_.add( |
+ area, |
+ print_preview.PreviewArea.EventType.PREVIEW_GENERATION_IN_PROGRESS, |
+ this.documentLoadComplete.bind(this)); |
+ } |
+ |
+ PDFPluginStub.prototype = { |
+ /** |
+ * @param {Object} callback The callback to run when the plugin has loaded. |
+ */ |
+ setLoadCallback: function(callback) { |
+ this.loadCallback_ = callback; |
+ }, |
+ |
+ documentLoadComplete: function() { |
+ if (this.loadCallback_) |
+ this.loadCallback_(); |
+ }, |
+ |
+ /** |
+ * Stubbed out since some tests result in a call. |
+ * @param {string} url The url to initialize the plugin to. |
+ * @param {boolean} color Whether the preview should be in color. |
+ * @param {Array<int>} pages The pages to preview. |
dpapad
2017/07/06 00:24:17
!Array<number>
rbpotter
2017/07/06 01:57:28
Done.
|
+ * @param {boolean} modifiable Whether the source document is modifiable. |
+ */ |
+ resetPrintPreviewMode: function(url, color, pages, modifiable) {}, |
+ }; |
+ |
+ return { |
+ PDFPluginStub: PDFPluginStub, |
+ }; |
+}); |