ext-tabs.js (713B)
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 "use strict"; 5 6 this.tabs = class extends ExtensionAPI { 7 getAPI(context) { 8 return { 9 tabs: { 10 connect(tabId, options) { 11 let { frameId = null, name = "" } = options || {}; 12 return context.messenger.connect({ name, tabId, frameId }); 13 }, 14 15 sendMessage(tabId, message, options, callback) { 16 let arg = { tabId, frameId: options?.frameId, message, callback }; 17 return context.messenger.sendRuntimeMessage(arg); 18 }, 19 }, 20 }; 21 } 22 };