webRequest.StreamFilter.suspend()

Suspends a request. After this is called, no more data will be delivered until the request is resumed with a call to resume().

You can't call this function until after the onstart event has fired.

Syntax

filter.suspend()

Parameters

None.

Return value

None.

Browser compatibility

BCD tables only load in the browser

Examples

This example uses suspend/resume to delay a web request.

function listener(details) {
  let filter = browser.webRequest.filterResponseData(details.requestId);

  filter.onstart = event => {
    filter.suspend();

    setTimeout(() => {
      filter.resume();
      filter.disconnect();
    }, 1000);

  }
}

browser.webRequest.onBeforeRequest.addListener(
  listener,
  {urls: ["https://example.org/"], types: ["main_frame"]},
  ["blocking"]
);