thread-configuration.js (1785B)
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 const { 8 STATES: THREAD_STATES, 9 } = require("resource://devtools/server/actors/thread.js"); 10 const Targets = require("resource://devtools/server/actors/targets/index.js"); 11 12 module.exports = { 13 async addOrSetSessionDataEntry(targetActor, entries) { 14 // The Browser Toolbox uses the Content Process target's Thread actor to debug all scripts 15 // running into a given process. This includes WindowGlobal scripts. 16 // Because of this, and in such configuration, we have to ignore the WindowGlobal targets. 17 if ( 18 targetActor.sessionContext.type == "all" && 19 !targetActor.sessionContext.enableWindowGlobalThreadActors && 20 targetActor.targetType === Targets.TYPES.FRAME && 21 targetActor.typeName != "parentProcessTarget" 22 ) { 23 return; 24 } 25 26 const threadOptions = {}; 27 28 for (const { key, value } of entries) { 29 threadOptions[key] = value; 30 } 31 32 if (targetActor.threadActor.state == THREAD_STATES.DETACHED) { 33 await targetActor.threadActor.attach(threadOptions); 34 } else if (!targetActor.threadActor.isDestroyed()) { 35 // Regarding `updateType`, `entries` is always a partial set of configurations. 36 // We will acknowledge the passed attribute, but if we had set some other attributes 37 // before this call, they will stay as-is. 38 // So it is as if this session data was also using "add" updateType. 39 await targetActor.threadActor.reconfigure(threadOptions); 40 } 41 }, 42 43 removeSessionDataEntry() { 44 // configuration data entries are always added/updated, never removed. 45 }, 46 };