forked from mirrors/gecko-dev
		
	The Netmonitor used to call the WebConsoleFront `getString` method to get the full text of a long string. This could make some test to fail with Fission and target switching. Since the webconsole actor is not even involved in the webconsole method, there's no reason to keep using it. A similar function is added into a util file; the only difference is that it doesn't cache the front it creates, which does not matter as the netmonitor only calls this once and then put the full text in its redux store. This allows us to re-enable `browser_ext_devtools_network.js` with Fission. Differential Revision: https://phabricator.services.mozilla.com/D120333
		
			
				
	
	
		
			38 lines
		
	
	
	
		
			1.2 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			38 lines
		
	
	
	
		
			1.2 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
/* This Source Code Form is subject to the terms of the Mozilla Public
 | 
						|
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 | 
						|
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 | 
						|
"use strict";
 | 
						|
 | 
						|
const { LongStringFront } = require("devtools/client/fronts/string");
 | 
						|
 | 
						|
/**
 | 
						|
 * Fetches the full text of a LongString.
 | 
						|
 *
 | 
						|
 * @param {DevToolsClient} client
 | 
						|
 * @param {object|string} stringGrip: A long string grip. If the param is a simple string,
 | 
						|
 *                                    it will be returned as is.
 | 
						|
 * @return {Promise<String>} The full string content.
 | 
						|
 */
 | 
						|
async function getLongStringFullText(client, stringGrip) {
 | 
						|
  if (typeof stringGrip !== "object" || stringGrip.type !== "longString") {
 | 
						|
    return stringGrip;
 | 
						|
  }
 | 
						|
 | 
						|
  const { initial, length } = stringGrip;
 | 
						|
  const longStringFront = new LongStringFront(
 | 
						|
    client
 | 
						|
    // this.commands.targetCommand.targetFront
 | 
						|
  );
 | 
						|
  longStringFront.form(stringGrip);
 | 
						|
  // The front has to be managed to be able to call the actor method.
 | 
						|
  longStringFront.manage(longStringFront);
 | 
						|
 | 
						|
  const response = await longStringFront.substring(initial.length, length);
 | 
						|
  const payload = initial + response;
 | 
						|
 | 
						|
  longStringFront.destroy();
 | 
						|
 | 
						|
  return payload;
 | 
						|
}
 | 
						|
 | 
						|
exports.getLongStringFullText = getLongStringFullText;
 |