responsive-command.js (924B)
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 "use strict"; 6 7 class ResponsiveCommand { 8 constructor({ commands }) { 9 this.#commands = commands; 10 } 11 #commands = null; 12 13 async getAllResponsiveFronts() { 14 return this.#commands.targetCommand.getAllFronts( 15 [this.#commands.targetCommand.TYPES.FRAME], 16 "responsive" 17 ); 18 } 19 20 async setElementPickerState(state, pickerType) { 21 const fronts = await this.getAllResponsiveFronts(); 22 await Promise.all( 23 fronts.map(async front => { 24 try { 25 await front.setElementPickerState(state, pickerType); 26 } catch (e) { 27 if (front.isDestroyed()) { 28 return; 29 } 30 throw e; 31 } 32 }) 33 ); 34 } 35 } 36 37 module.exports = ResponsiveCommand;