MCPcopy
hub / github.com/webpack/webpack-dev-server / runPage

Function runPage

test/helpers/run-browser.js:19–61  ·  view source on GitHub ↗
(browser, device)

Source from the content-addressed store, hash-verified

17 * @returns {Promise<Page>} page
18 */
19export function runPage(browser, device) {
20 /**
21 * @type {Page}
22 */
23 let page;
24
25 const options = {
26 viewport: {
27 width: 500,
28 height: 500,
29 },
30 userAgent: "",
31 ...device,
32 };
33
34 return Promise.resolve()
35 .then(() => browser.newPage())
36 .then((newPage) => {
37 page = newPage;
38 page.emulate(options);
39
40 return page.setRequestInterception(true);
41 })
42 .then(() => {
43 page.on("request", (interceptedRequest) => {
44 if (interceptedRequest.isInterceptResolutionHandled()) return;
45 if (interceptedRequest.url().includes("favicon.ico")) {
46 interceptedRequest.respond({
47 status: 200,
48 contentType: "image/png",
49 body: "Empty",
50 });
51 } else {
52 interceptedRequest.continue(
53 interceptedRequest.continueRequestOverrides(),
54 10,
55 );
56 }
57 });
58
59 return page;
60 });
61}
62
63/**
64 * @param {Device} device device

Callers 2

api.test.jsFile · 0.90
runBrowserFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…