reftest.js (1604B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 3 * You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 /* eslint-env mozilla/frame-script */ 6 7 "use strict"; 8 9 const { XPCOMUtils } = ChromeUtils.importESModule( 10 "resource://gre/modules/XPCOMUtils.sys.mjs" 11 ); 12 13 XPCOMUtils.defineLazyScriptGetter( 14 this, 15 "PrintUtils", 16 "chrome://global/content/printUtils.js" 17 ); 18 19 // This is an implementation of nsIBrowserDOMWindow that handles only opening 20 // print browsers, because the "open a new window fallback" is just too slow 21 // in some cases and causes timeouts. 22 function BrowserDOMWindow() {} 23 BrowserDOMWindow.prototype = { 24 QueryInterface: ChromeUtils.generateQI(["nsIBrowserDOMWindow"]), 25 26 _maybeOpen(aOpenWindowInfo, aWhere) { 27 if (aWhere == Ci.nsIBrowserDOMWindow.OPEN_PRINT_BROWSER) { 28 return PrintUtils.handleStaticCloneCreatedForPrint(aOpenWindowInfo); 29 } 30 return null; 31 }, 32 33 createContentWindow(aURI, aOpenWindowInfo, aWhere) { 34 return this._maybeOpen(aOpenWindowInfo, aWhere)?.browsingContext; 35 }, 36 37 openURI(aURI, aOpenWindowInfo, aWhere) { 38 return this._maybeOpen(aOpenWindowInfo, aWhere)?.browsingContext; 39 }, 40 41 createContentWindowInFrame(aURI, aParams, aWhere) { 42 return this._maybeOpen(aParams.openWindowInfo, aWhere); 43 }, 44 45 openURIInFrame(aURI, aParams, aWhere) { 46 return this._maybeOpen(aParams.openWindowInfo, aWhere); 47 }, 48 49 canClose() { 50 return true; 51 }, 52 53 get tabCount() { 54 return 1; 55 }, 56 }; 57 58 window.browserDOMWindow = new BrowserDOMWindow();