Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

202
Vistas
How to network throttle in iframe like we have a devtool

How to network throttle in iframe like we have in a devtool, let say want to open my own website inside iframe, and i want to throttle with a slow 3g mode how can we acheive this .

If i want to do this using chrome extension, is there any api to do this.

I have added the below code to enable the chrome debugger, but this is for the page or tab not for the particular iframe.

   await chrome.tabs.query(
      { currentWindow: true, active: true },
      function (tabs) {
        console.log("tabs--->", tabs);
        console.log(tabs[0].id);

        chrome.debugger.attach({ tabId: "8C206DBB36086B4E52EB465197CE01ED" }, "1.3", () => {
          if (chrome.runtime.lastError) {
            console.log("runtime.lastError", chrome.runtime.lastError.message);
            return;
          }
          console.log("Debugger attached");
        });

        chrome.debugger.sendCommand(
          { tabId: tabs[0].id },
          "Network.enable",
          () => {
            if (chrome.runtime.lastError) {
              console.log(
                "runtime.lastError",
                chrome.runtime.lastError.message
              );
              return;
            }
            console.log("Debugger attached");
          }
        );

        const newtworkThrottleValues = {
          offline: {
            downloadThroughput: 0,
            uploadThroughput: 0,
            latency: 0,
            offline: true,
          },
          slow3G: {
            downloadThroughput: ((500 * 1024) / 8) * 0.8,
            uploadThroughput: ((500 * 1024) / 8) * 0.8,
            latency: 400 * 5,
            offline: false,
          },
          fast3G: {
            downloadThroughput: ((1.6 * 1024 * 1024) / 8) * 0.9,
            uploadThroughput: ((750 * 1024) / 8) * 0.9,
            latency: 150 * 3.75,
            offline: false,
          },
          online: {
            downloadThroughput: -1,
            uploadThroughput: -1,
            latency: 0,
            offline: false,
          },
        };

        chrome.debugger.getTargets((result) => {
          console.log("result", result);
        });
        chrome.tabs.query(
          { currentWindow: true, active: true },
          function (tabs) {
            settabid(tabs[0].id);
            console.log(tabs[0]);
          }
        );
        chrome.debugger.sendCommand(
          { tabId: tabs[0].id },
          "Network.emulateNetworkConditions",
          newtworkThrottleValues["offline"],
          () => {
            if (chrome.runtime.lastError) {
              console.log(
                "runtime.lastError",
                chrome.runtime.lastError.message
              );
              return;
            }
            console.log("Debugger attached 3");
          }
        );
      }
    );
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

To throttle network for page we have to use tabId and for iframes we have to pass targetId in place of tabId

    chrome.tabs.query(
      { currentWindow: true, active: true },
      function async(tabs) {
        await chrome.debugger.getTargets(async (result) => {
          const d = result.filter((value) => value.url.includes("url"));
          await chrome.debugger.attach(
            { tabId: tabs[0].id,},
            "1.3",
            () => {
              if (chrome.runtime.lastError) {
                console.log(
                  "runtime.lastError",
                  chrome.runtime.lastError.message
                );
                return;
              }
              console.log("Debugger attached");
            }
          );

          await chrome.debugger.sendCommand(
            { tabId: tabs[0].id },
            "Network.enable",
            () => {
              if (chrome.runtime.lastError) {
                console.log(
                  "runtime.lastError",
                  chrome.runtime.lastError.message
                );
                return;
              }
              console.log("Debugger attached");
            }
          );

          const newtworkThrottleValues = {
            offline: {
              downloadThroughput: 0,
              uploadThroughput: 0,
              latency: 0,
              offline: true,
            },
            slow3G: {
              downloadThroughput: ((500 * 1024) / 8) * 0.8,
              uploadThroughput: ((500 * 1024) / 8) * 0.8,
              latency: 400 * 5,
              offline: false,
            },
            fast3G: {
              downloadThroughput: ((1.6 * 1024 * 1024) / 8) * 0.9,
              uploadThroughput: ((750 * 1024) / 8) * 0.9,
              latency: 150 * 3.75,
              offline: false,
            },
            online: {
              downloadThroughput: -1,
              uploadThroughput: -1,
              latency: 0,
              offline: false,
            },
          };
          await chrome.debugger.sendCommand(
            { tabId: tabs[0].id },
            "Network.emulateNetworkConditions",
            newtworkThrottleValues["offline"],
            () => {
              if (chrome.runtime.lastError) {
                console.log(
                  "runtime.lastError",
                  chrome.runtime.lastError.message
                );
                return;
              }
              console.log("Debugger attached 3");
            }
          );
        });
      }
    );
  };```
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda