@bigbinary/neeto-playwright-commons 1.8.31 → 1.8.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs.js CHANGED
@@ -13031,6 +13031,27 @@ const USER_AGENTS = {
13031
13031
  mac: "Mozilla/5.0 (Macintosh; Intel Mac OS X 14_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
13032
13032
  };
13033
13033
 
13034
+ const networkConditions = {
13035
+ "Slow 3G": {
13036
+ downloadThroughput: ((500 * 1000) / 8) * 0.8,
13037
+ uploadThroughput: ((500 * 1000) / 8) * 0.8,
13038
+ latency: 400 * 5,
13039
+ offline: false,
13040
+ },
13041
+ "Fast 3G": {
13042
+ downloadThroughput: ((1.6 * 1000 * 1000) / 8) * 0.9,
13043
+ uploadThroughput: ((750 * 1000) / 8) * 0.9,
13044
+ latency: 150 * 3.75,
13045
+ offline: false,
13046
+ },
13047
+ "No Throttling": {
13048
+ downloadThroughput: -1,
13049
+ uploadThroughput: -1,
13050
+ latency: 0,
13051
+ offline: false,
13052
+ },
13053
+ };
13054
+
13034
13055
  const NEETO_EDITOR_SELECTORS = {
13035
13056
  boldOption: "neeto-editor-fixed-menu-bold-option",
13036
13057
  italicOption: "neeto-editor-fixed-menu-italic-option",
@@ -146075,6 +146096,32 @@ const initializeTotp = ({ issuer, secret, }) => {
146075
146096
  });
146076
146097
  };
146077
146098
 
146099
+ // Util to throttle network via CDP (only available for chrome)
146100
+ // Based on https://github.com/microsoft/playwright/issues/6038#issuecomment-812521882
146101
+ // Feature request issue: https://github.com/microsoft/playwright/issues/8622
146102
+ const networkThrottlingUsingCDP = ({ cdpSession, emulateNetworkConditionsParameters = networkConditions["Fast 3G"], }) => cdpSession.send("Network.emulateNetworkConditions", emulateNetworkConditionsParameters);
146103
+ // Util to throttle CPU via CDP (only available for chrome)
146104
+ // Throttling rate as a slowdown factor
146105
+ // Default value is 1.25; means it will slow down CPU by 1.25 times
146106
+ const cpuThrottlingUsingCDP = ({ cdpSession, rate = 1.25, }) => cdpSession.send("Emulation.setCPUThrottlingRate", { rate });
146107
+ const executeWithThrottledResources = async ({ code: emulatedCode, kind = "both", networkCondition, cpuThrottlingRate, cdpSession, }) => {
146108
+ if (kind === "network" || kind === "both") {
146109
+ await networkThrottlingUsingCDP({
146110
+ cdpSession,
146111
+ emulateNetworkConditionsParameters: networkCondition,
146112
+ });
146113
+ }
146114
+ else if (kind === "cpu" || kind === "both") {
146115
+ await cpuThrottlingUsingCDP({ cdpSession, rate: cpuThrottlingRate });
146116
+ }
146117
+ await emulatedCode();
146118
+ await networkThrottlingUsingCDP({
146119
+ cdpSession,
146120
+ emulateNetworkConditionsParameters: networkConditions["No Throttling"],
146121
+ });
146122
+ await cpuThrottlingUsingCDP({ cdpSession, rate: 1 });
146123
+ };
146124
+
146078
146125
  var main$2 = {exports: {}};
146079
146126
 
146080
146127
  var name = "dotenv";
@@ -146658,8 +146705,10 @@ exports.USER_AGENTS = USER_AGENTS;
146658
146705
  exports.WebhooksPage = WebhooksPage;
146659
146706
  exports.clearCredentials = clearCredentials;
146660
146707
  exports.commands = commands;
146708
+ exports.cpuThrottlingUsingCDP = cpuThrottlingUsingCDP;
146661
146709
  exports.decodeQRCodeFromFile = decodeQRCodeFromFile;
146662
146710
  exports.definePlaywrightConfig = definePlaywrightConfig;
146711
+ exports.executeWithThrottledResources = executeWithThrottledResources;
146663
146712
  exports.extractSubdomainFromError = extractSubdomainFromError;
146664
146713
  exports.generateStagingData = generateStagingData;
146665
146714
  exports.getGlobalUserState = getGlobalUserState;
@@ -146673,6 +146722,8 @@ exports.joinString = joinString;
146673
146722
  exports.login = login;
146674
146723
  exports.loginWithoutSSO = loginWithoutSSO;
146675
146724
  exports.memberUtils = memberUtils;
146725
+ exports.networkConditions = networkConditions;
146726
+ exports.networkThrottlingUsingCDP = networkThrottlingUsingCDP;
146676
146727
  exports.readFileSyncIfExists = readFileSyncIfExists;
146677
146728
  exports.removeCredentialFile = removeCredentialFile;
146678
146729
  exports.shouldSkipSetupAndTeardown = shouldSkipSetupAndTeardown;