ScreenshotChild.sys.mjs (929B)
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 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 export class ScreenshotChild extends JSWindowActorChild { 6 receiveMessage(message) { 7 if (message.name == "GetDimensions") { 8 return this.getDimensions(); 9 } 10 return null; 11 } 12 13 async getDimensions() { 14 if (this.document.readyState != "complete") { 15 await new Promise(resolve => 16 this.contentWindow.addEventListener("load", resolve, { once: true }) 17 ); 18 } 19 20 let { contentWindow } = this; 21 22 return { 23 innerWidth: contentWindow.innerWidth, 24 innerHeight: contentWindow.innerHeight, 25 scrollMinX: contentWindow.scrollMinX, 26 scrollMaxX: contentWindow.scrollMaxX, 27 scrollMinY: contentWindow.scrollMinY, 28 scrollMaxY: contentWindow.scrollMaxY, 29 }; 30 } 31 }