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