@speedkit/cli 4.40.0 → 4.41.1

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.
@@ -124,9 +124,6 @@ export class BrowserContext {
124
124
  ...(this.userAgent ? [`--user-agent=${this.userAgent}`] : []),
125
125
  ];
126
126
  }
127
- isChromeBrowser() {
128
- return !!/chrome/i.test(this.browserVersionString);
129
- }
130
127
  getBrowserExtensionPath() {
131
128
  if (this.environment?.settings.chromeExtensionPaths) {
132
129
  return this.environment.settings.chromeExtensionPaths.split(",");
@@ -164,16 +161,14 @@ export class BrowserContext {
164
161
  /** Args that depend on how Chrome is launched, added after the customer's chromeFlags. */
165
162
  getLaunchOnlyArgs() {
166
163
  const args = [];
167
- if (this.environment?.settings.chromeExtensionPaths) {
168
- if (this.isChromeBrowser()) {
169
- args.push("--remote-debugging-pipe");
170
- }
171
- else {
172
- args.push(`--load-extension=${this.environment?.settings.chromeExtensionPaths}`, `--disable-extensions-except=${this.environment?.settings.chromeExtensionPaths}`);
173
- }
174
- }
175
164
  if (this.debuggingPort || this.headless) {
176
165
  args.push(`--remote-debugging-port=${this.debugPort}`);
166
+ // Puppeteer adds the pipe switch for `pipe: true` only when no other
167
+ // `--remote-debugging-*` switch is present, and it refuses
168
+ // `enableExtensions` without the switch. The port above suppresses it.
169
+ if (this.environment?.settings.chromeExtensionPaths) {
170
+ args.push("--remote-debugging-pipe");
171
+ }
177
172
  }
178
173
  return args;
179
174
  }
@@ -196,8 +191,13 @@ export class BrowserContext {
196
191
  ...(this.headless ? HEADLESS_DEFAULT_ARGS_TO_DROP : []),
197
192
  ],
198
193
  };
199
- if (this.environment?.settings.chromeExtensionPaths &&
200
- this.isChromeBrowser()) {
194
+ // One way for every Chromium build. Branded Chrome ignores
195
+ // `--load-extension` since 137, so extensions are installed over the pipe
196
+ // with `Extensions.loadUnpacked`, which also makes Puppeteer pass
197
+ // `--enable-unsafe-extension-debugging`. Those two are the documented
198
+ // preconditions of the `Extensions` domain, which ExtensionBridge writes
199
+ // the devtools panel's storage through.
200
+ if (this.environment?.settings.chromeExtensionPaths) {
201
201
  options["enableExtensions"] = this.getBrowserExtensionPath();
202
202
  options["pipe"] = true;
203
203
  }
@@ -45,6 +45,7 @@ export declare class OnboardingServiceFactory {
45
45
  private getFetchEventHandler;
46
46
  private getSpeedKitServerConfig;
47
47
  private getIntegrationFiles;
48
+ private sessionInfo;
48
49
  private getUrlForTest;
49
50
  private ensureHttps;
50
51
  }
@@ -43,7 +43,7 @@ import { StaticRecipe } from "../integration-api/virtual/static-recipe.js";
43
43
  import { DiffAgainstCurrentPage } from "./dashboard/diff-against-current-page.js";
44
44
  import { ExtensionDownloader } from "./browser/extension/extension-downloader.js";
45
45
  import { ExecutableValidator } from "./browser/executable/executable-validator.js";
46
- import { applyOriginProxy, withOriginProxyFlag, } from "../../helpers/origin-proxy.js";
46
+ import { PROXY_ENVIRONMENT_VARIABLE, applyOriginProxy, currentOriginProxy, formatProxy, withOriginProxyFlag, } from "../../helpers/origin-proxy.js";
47
47
  import { QueryBuilderFactory } from "../query-builder/query-builder-factory.js";
48
48
  import { ParameterQueryServiceBuildContext } from "../query-builder/query-builder-service-build-context.js";
49
49
  import { formatChromeFeatureFinding, formatChromeFlagDuplicate, } from "../../helpers/chrome-flags.js";
@@ -169,8 +169,7 @@ export class OnboardingServiceFactory {
169
169
  id: "skCli",
170
170
  data: {
171
171
  version: this.context.environment.oclif.version,
172
- app: customerConfig.app,
173
- customerConfigPath: path.resolve(this.context.customerPath, this.context.configName),
172
+ session: this.sessionInfo(customerConfig),
174
173
  },
175
174
  });
176
175
  messageHandler.addMessage({
@@ -330,6 +329,28 @@ export class OnboardingServiceFactory {
330
329
  }
331
330
  return integrationApi.run(integrationApiArray);
332
331
  }
332
+ sessionInfo(customerConfig) {
333
+ // Read back rather than recomputed: `applyOriginProxy` has already decided
334
+ // which proxy wins, and the panel should see that decision, not a second one.
335
+ const proxy = currentOriginProxy();
336
+ return {
337
+ app: customerConfig.app,
338
+ customerConfigPath: path.resolve(this.context.customerPath, this.context.configName),
339
+ origins: customerConfig.origins ?? [],
340
+ swPath: customerConfig.swPath,
341
+ scope: customerConfig.scope,
342
+ local: Boolean(this.context.local),
343
+ forceInstall: Boolean(customerConfig.forceInstall),
344
+ proxy: proxy
345
+ ? {
346
+ url: formatProxy(proxy),
347
+ source: process.env[PROXY_ENVIRONMENT_VARIABLE]?.trim()
348
+ ? "environment"
349
+ : "chromeFlags",
350
+ }
351
+ : null,
352
+ };
353
+ }
333
354
  async getUrlForTest(customerConfig, cli) {
334
355
  // Consider startup domain based on the following priority:
335
356
  // 1. domain flag (-d)
@@ -41,6 +41,14 @@ export declare class OnboardingService {
41
41
  * sk-cli. Without a loaded devtools extension there is nothing to attach
42
42
  * to — ExtensionValidator already reported why — so it is skipped.
43
43
  */
44
+ /**
45
+ * Open the run's DevTools on the Speed Kit panel rather than on Elements.
46
+ *
47
+ * Headed only: that is where `devtools: true` opens a DevTools window for the
48
+ * tab, and where someone is looking at it. The selection reaches into
49
+ * DevTools' internals, so a failure is a warning and nothing more.
50
+ */
51
+ private showDevtoolsPanelOnStart;
44
52
  private attachExtensionBridge;
45
53
  private findPage;
46
54
  private prepareCleanState;
@@ -1,4 +1,5 @@
1
1
  import { BROWSER_EVENTS, CDP_SESSION, } from "./onboarding-model.js";
2
+ import { PanelNotFoundError, showDevtoolsPanel, } from "./browser/extension/devtools-panel.js";
2
3
  import { safe } from "../../helpers/safe.js";
3
4
  import { isEmptyServiceWorkerUrl } from "./empty-service-worker.js";
4
5
  import { launchBrowser, resetBrowserState } from "./browser/launch-browser.js";
@@ -51,6 +52,9 @@ export class OnboardingService {
51
52
  await this.attachExtensionBridge(browser);
52
53
  const page = await this.preparePage(browser, shutdownSignal);
53
54
  this.cli.successAction("ONBOARDING:PREPARE:BROWSER");
55
+ // Not awaited: the panel registers a moment after DevTools opens, and the
56
+ // run has no reason to wait for a convenience.
57
+ void this.showDevtoolsPanelOnStart(page);
54
58
  await this.navigate(page, `${this.customerConfig.scope}speed-kit-install.html?url=${this.customerConfig.scope}`);
55
59
  await waitForAbort(shutdownSignal);
56
60
  await safe(browser.close());
@@ -87,6 +91,30 @@ export class OnboardingService {
87
91
  * sk-cli. Without a loaded devtools extension there is nothing to attach
88
92
  * to — ExtensionValidator already reported why — so it is skipped.
89
93
  */
94
+ /**
95
+ * Open the run's DevTools on the Speed Kit panel rather than on Elements.
96
+ *
97
+ * Headed only: that is where `devtools: true` opens a DevTools window for the
98
+ * tab, and where someone is looking at it. The selection reaches into
99
+ * DevTools' internals, so a failure is a warning and nothing more.
100
+ */
101
+ async showDevtoolsPanelOnStart(page) {
102
+ const extensionId = this.extensionBridge.devtoolsExtensionId;
103
+ if (this.browserContext.headless || !extensionId) {
104
+ return;
105
+ }
106
+ const result = await safe(showDevtoolsPanel(page, extensionId).catch((error) => {
107
+ // Name the tabs DevTools did show, so a missing panel can be told
108
+ // from a renamed one.
109
+ if (!(error instanceof PanelNotFoundError))
110
+ throw error;
111
+ throw new Error(`${error.message} — DevTools shows ${error.tabs.join(", ") || "no tabs at all"}`);
112
+ }));
113
+ if (result.success === true) {
114
+ return;
115
+ }
116
+ this.cli.writeWarning(`DevTools did not open on the Speed Kit panel: ${result.error}`);
117
+ }
90
118
  async attachExtensionBridge(browser) {
91
119
  if (!this.extensionBridge.isAvailable) {
92
120
  return;
@@ -0,0 +1,99 @@
1
+ import { expect } from "chai";
2
+ import { describe, it } from "mocha";
3
+ import { PanelNotFoundError, showDevtoolsPanel, } from "../../../browser/extension/devtools-panel.js";
4
+ const ID = "gbiigacjibjkoldfdgjkomkddifgkeja";
5
+ const PANEL = `chrome-extension://${ID}Speed-Kit`;
6
+ const BUILT_IN = ["elements", "console", "network"];
7
+ /**
8
+ * A page whose DevTools frontend answers the selection script.
9
+ *
10
+ * `answers` is what DevTools shows on each successive poll: the extension's
11
+ * panel registers a moment after DevTools opens, so the first few polls can
12
+ * find nothing.
13
+ */
14
+ function pageWith({ devtoolsOpen = true, answers, }) {
15
+ const expressions = [];
16
+ let poll = 0;
17
+ const devtools = {
18
+ evaluate: async (expression) => {
19
+ expressions.push(expression);
20
+ const tabs = answers[Math.min(poll++, answers.length - 1)];
21
+ const prefix = JSON.parse(expression.slice(expression.lastIndexOf("(") + 1, -1));
22
+ const selected = tabs.find((id) => id.startsWith(prefix)) ?? null;
23
+ return { tabs, selected };
24
+ },
25
+ };
26
+ const page = {
27
+ hasDevTools: async () => devtoolsOpen,
28
+ openDevTools: async () => devtools,
29
+ };
30
+ return { page: page, expressions };
31
+ }
32
+ describe("showDevtoolsPanel", () => {
33
+ it("switches an open DevTools to the panel", async () => {
34
+ const { page } = pageWith({ answers: [[...BUILT_IN, PANEL]] });
35
+ const shown = await showDevtoolsPanel(page, ID);
36
+ expect(shown).to.deep.equal({ panel: PANEL, openedDevTools: false });
37
+ });
38
+ it("says when it opened DevTools rather than switching tabs", async () => {
39
+ const { page } = pageWith({
40
+ devtoolsOpen: false,
41
+ answers: [[...BUILT_IN, PANEL]],
42
+ });
43
+ const shown = await showDevtoolsPanel(page, ID);
44
+ expect(shown.openedDevTools).to.equal(true);
45
+ });
46
+ it("waits for the extension to register its panel", async () => {
47
+ const { page, expressions } = pageWith({
48
+ answers: [BUILT_IN, BUILT_IN, [...BUILT_IN, PANEL]],
49
+ });
50
+ const shown = await showDevtoolsPanel(page, ID);
51
+ expect(shown.panel).to.equal(PANEL);
52
+ expect(expressions).to.have.length(3);
53
+ });
54
+ it("waits for a DevTools window it just opened to initialise", async () => {
55
+ // Asked too early, the frontend has no settings yet and InspectorView
56
+ // throws — which is what a freshly opened window answers at first.
57
+ let polls = 0;
58
+ const starting = {
59
+ hasDevTools: async () => false,
60
+ openDevTools: async () => ({
61
+ evaluate: async () => {
62
+ if (polls++ < 2) {
63
+ throw new Error("Unable to create settings");
64
+ }
65
+ return { tabs: [PANEL], selected: PANEL };
66
+ },
67
+ }),
68
+ };
69
+ const shown = await showDevtoolsPanel(starting, ID);
70
+ expect(shown).to.deep.equal({ panel: PANEL, openedDevTools: true });
71
+ });
72
+ it("reports internals it cannot use once the time is up", async () => {
73
+ const broken = {
74
+ hasDevTools: async () => true,
75
+ openDevTools: async () => ({
76
+ evaluate: async () => {
77
+ throw new Error("InspectorView is not defined");
78
+ },
79
+ }),
80
+ };
81
+ let error;
82
+ await showDevtoolsPanel(broken, ID, 50).catch((e) => (error = e));
83
+ expect(error?.message).to.equal("InspectorView is not defined");
84
+ });
85
+ it("looks for this run's extension, not any extension's panel", async () => {
86
+ const other = "chrome-extension://abcdefghijklmnopabcdefghijklmnopReact";
87
+ const { page } = pageWith({ answers: [[...BUILT_IN, other, PANEL]] });
88
+ const shown = await showDevtoolsPanel(page, ID);
89
+ expect(shown.panel).to.equal(PANEL);
90
+ });
91
+ it("gives up with the tabs DevTools did show", async () => {
92
+ const { page } = pageWith({ answers: [BUILT_IN] });
93
+ let error;
94
+ await showDevtoolsPanel(page, ID, 50).catch((e) => (error = e));
95
+ expect(error).to.be.instanceOf(PanelNotFoundError);
96
+ expect(error.message).to.contain("did not appear");
97
+ expect(error.tabs).to.deep.equal(BUILT_IN);
98
+ });
99
+ });
@@ -0,0 +1,235 @@
1
+ import { expect } from "chai";
2
+ import { describe, it } from "mocha";
3
+ import { ExtensionBridge } from "../../../browser/extension/extension-bridge.js";
4
+ const ID = "gbiigacjibjkoldfdgjkomkddifgkeja";
5
+ const WORKER_URL = `chrome-extension://${ID}/background.js`;
6
+ function session(handlers) {
7
+ return {
8
+ send: async (method, params = {}) => {
9
+ const handler = handlers[method];
10
+ if (!handler)
11
+ throw new Error(`'${method}' wasn't found`);
12
+ return handler(params);
13
+ },
14
+ detach: async () => undefined,
15
+ };
16
+ }
17
+ /**
18
+ * A browser with the devtools extension installed, as CDP shows it.
19
+ *
20
+ * `worker` is whether its service worker is running, which is the whole
21
+ * point: the panel's updates used to need one, and nothing restarted a worker
22
+ * that had stopped.
23
+ */
24
+ function browserWith({ listed = true, worker = true, pages = ["https://shop.example/"], direct = true, } = {}) {
25
+ const state = {
26
+ worker,
27
+ direct,
28
+ pages,
29
+ /** Every snapshot stored, and through which path. */
30
+ stored: [],
31
+ /** Holds the next direct write until released. */
32
+ gate: null,
33
+ };
34
+ const listeners = {};
35
+ const workerTarget = {
36
+ type: () => "service_worker",
37
+ url: () => WORKER_URL,
38
+ createCDPSession: async () => session({
39
+ "Runtime.evaluate": ({ expression }) => {
40
+ const text = String(expression);
41
+ if (text.includes("getManifest")) {
42
+ return { result: { value: "speed-kit DevTools" } };
43
+ }
44
+ const json = text.slice(text.indexOf("(") + 1, text.lastIndexOf(")"));
45
+ state.stored.push({ via: "worker", value: JSON.parse(json).skCli });
46
+ return { result: { value: undefined } };
47
+ },
48
+ }),
49
+ };
50
+ const browser = {
51
+ targets: () => (state.worker ? [workerTarget] : []),
52
+ waitForTarget: async () => {
53
+ throw new Error("Waiting for target failed: timeout");
54
+ },
55
+ target: () => ({
56
+ createCDPSession: async () => session(listed
57
+ ? {
58
+ "Extensions.getExtensions": () => ({
59
+ extensions: [
60
+ { id: "abcdefghijklmnopabcdefghijklmnop", name: "Other" },
61
+ { id: ID, name: "speed-kit DevTools" },
62
+ ],
63
+ }),
64
+ }
65
+ : {}),
66
+ }),
67
+ pages: async () => state.pages.map((url) => ({
68
+ url: () => url,
69
+ createCDPSession: async () => session({
70
+ "Extensions.setStorageItems": async (params) => {
71
+ if (!state.direct) {
72
+ throw new Error("Extensions.setStorageItems wasn't found");
73
+ }
74
+ if (!isWebUrl(url))
75
+ throw new Error("Extension not found.");
76
+ expect(params.id).to.equal(ID);
77
+ expect(params.storageArea).to.equal("local");
78
+ const gate = state.gate;
79
+ state.gate = null;
80
+ await gate;
81
+ state.stored.push({
82
+ via: "direct",
83
+ value: params.values.skCli,
84
+ });
85
+ },
86
+ }),
87
+ })),
88
+ on: (event, listener) => {
89
+ (listeners[event] ??= []).push(listener);
90
+ },
91
+ };
92
+ return {
93
+ browser,
94
+ state,
95
+ /** A page finishing a navigation to `url`, as Puppeteer reports it. */
96
+ navigated(url) {
97
+ state.pages = [url];
98
+ for (const listener of listeners.targetchanged ?? []) {
99
+ listener({ type: () => "page", url: () => url });
100
+ }
101
+ },
102
+ };
103
+ }
104
+ function isWebUrl(url) {
105
+ return /^https?:\/\//.test(url);
106
+ }
107
+ function recordingCli() {
108
+ const lines = [];
109
+ return {
110
+ lines,
111
+ cli: {
112
+ writeWarning: (message) => lines.push({ level: "warning", message }),
113
+ writeError: (message) => lines.push({ level: "error", message }),
114
+ writeSuccess: (message) => lines.push({ level: "success", message }),
115
+ },
116
+ };
117
+ }
118
+ function messagesOf(value) {
119
+ return value.messages;
120
+ }
121
+ const settle = () => new Promise((resolve) => setTimeout(resolve, 0));
122
+ describe("ExtensionBridge", () => {
123
+ describe("init", () => {
124
+ it("finds the extension without a running service worker", async () => {
125
+ const { browser } = browserWith({ worker: false });
126
+ const bridge = new ExtensionBridge(recordingCli().cli, true);
127
+ await bridge.init(browser);
128
+ expect(bridge.available).to.equal(true);
129
+ });
130
+ it("falls back to the worker's manifest name when the list is refused", async () => {
131
+ const { browser, state } = browserWith({ listed: false });
132
+ const bridge = new ExtensionBridge(recordingCli().cli, true);
133
+ await bridge.init(browser);
134
+ await bridge.writeMessages([]);
135
+ expect(bridge.available).to.equal(true);
136
+ expect(state.stored).to.have.length(1);
137
+ });
138
+ it("refuses to start without a devtools extension", async () => {
139
+ const { browser } = browserWith();
140
+ const bridge = new ExtensionBridge(recordingCli().cli, false);
141
+ let error;
142
+ await bridge.init(browser).catch((e) => (error = e));
143
+ expect(error?.message).to.contain("no devtools extension loaded");
144
+ });
145
+ });
146
+ describe("writeMessages", () => {
147
+ it("writes the storage directly, from the page on the customer origin", async () => {
148
+ const { browser, state } = browserWith({
149
+ pages: ["about:blank", "https://shop.example/"],
150
+ });
151
+ const bridge = new ExtensionBridge(recordingCli().cli, true);
152
+ await bridge.init(browser);
153
+ await bridge.writeMessages([{ id: "todo", data: [] }]);
154
+ expect(state.stored).to.have.length(1);
155
+ expect(state.stored[0].via).to.equal("direct");
156
+ expect(messagesOf(state.stored[0].value)).to.deep.equal([
157
+ { id: "todo", data: [] },
158
+ ]);
159
+ });
160
+ it("still reaches the panel after the service worker stopped", async () => {
161
+ // The failure this replaced: every write after the worker stopped
162
+ // answered "service-worker target not found", for the rest of the run.
163
+ const { browser, state } = browserWith();
164
+ const { cli, lines } = recordingCli();
165
+ const bridge = new ExtensionBridge(cli, true);
166
+ await bridge.init(browser);
167
+ state.worker = false;
168
+ await bridge.writeMessages([]);
169
+ expect(state.stored.map((s) => s.via)).to.deep.equal(["direct"]);
170
+ expect(lines).to.deep.equal([]);
171
+ });
172
+ it("goes through the service worker when the direct write is refused", async () => {
173
+ const { browser, state } = browserWith({ direct: false });
174
+ const bridge = new ExtensionBridge(recordingCli().cli, true);
175
+ await bridge.init(browser);
176
+ await bridge.writeMessages([]);
177
+ expect(state.stored.map((s) => s.via)).to.deep.equal(["worker"]);
178
+ });
179
+ it("writes only the newest snapshot once the one in flight has landed", async () => {
180
+ const { browser, state } = browserWith();
181
+ const bridge = new ExtensionBridge(recordingCli().cli, true);
182
+ await bridge.init(browser);
183
+ let release;
184
+ state.gate = new Promise((resolve) => (release = resolve));
185
+ const writes = [
186
+ bridge.writeMessages(["a"]),
187
+ bridge.writeMessages(["b"]),
188
+ bridge.writeMessages(["c"]),
189
+ ];
190
+ await settle();
191
+ release();
192
+ await Promise.all(writes);
193
+ expect(state.stored.map((s) => messagesOf(s.value))).to.deep.equal([
194
+ ["a"],
195
+ ["c"],
196
+ ]);
197
+ });
198
+ it("reports an outage once and retries on the next page load", async () => {
199
+ const { browser, state, navigated } = browserWith({
200
+ worker: false,
201
+ pages: ["about:blank"],
202
+ });
203
+ const { cli, lines } = recordingCli();
204
+ const bridge = new ExtensionBridge(cli, true);
205
+ await bridge.init(browser);
206
+ await bridge.writeMessages(["a"]);
207
+ await bridge.writeMessages(["b"]);
208
+ expect(state.stored).to.deep.equal([]);
209
+ expect(lines.map((l) => l.level)).to.deep.equal(["warning"]);
210
+ expect(lines[0].message).to.contain("not receiving updates");
211
+ navigated("https://shop.example/");
212
+ await settle();
213
+ await settle();
214
+ expect(state.stored.map((s) => messagesOf(s.value))).to.deep.equal([
215
+ ["b"],
216
+ ]);
217
+ expect(lines.map((l) => l.level)).to.deep.equal(["warning", "success"]);
218
+ });
219
+ it("does not retry on a navigation when nothing is pending", async () => {
220
+ const { browser, state, navigated } = browserWith();
221
+ const bridge = new ExtensionBridge(recordingCli().cli, true);
222
+ await bridge.init(browser);
223
+ await bridge.writeMessages([]);
224
+ navigated("https://shop.example/other");
225
+ await settle();
226
+ expect(state.stored).to.have.length(1);
227
+ });
228
+ it("warns instead of writing before init", async () => {
229
+ const { cli, lines } = recordingCli();
230
+ const bridge = new ExtensionBridge(cli, true);
231
+ await bridge.writeMessages([]);
232
+ expect(lines[0].message).to.contain("before init()");
233
+ });
234
+ });
235
+ });
@@ -158,3 +158,49 @@ describe("BrowserContext system chromeFlags", () => {
158
158
  expect(newContext(true).findFeatureFindings()).to.deep.equal([]);
159
159
  });
160
160
  });
161
+ describe("BrowserContext launch options", () => {
162
+ it("installs extensions over the pipe on every Chromium build", () => {
163
+ const withExtensions = {
164
+ settings: {
165
+ ...environment.settings,
166
+ chromeExtensionPaths: "/ext/devtools,/ext/other",
167
+ },
168
+ };
169
+ for (const browserVersionString of [
170
+ "Google Chrome for Testing 154.0.8037.57",
171
+ "Chromium 153.0.8010.52 Arch Linux",
172
+ ]) {
173
+ const options = new BrowserContext("example.com", browserVersionString, [], withExtensions, undefined, false, false, undefined).getPuppeteerLaunchOptions();
174
+ // The pipe and Puppeteer's --enable-unsafe-extension-debugging are what
175
+ // the `Extensions` domain requires, and ExtensionBridge writes through it.
176
+ expect(options.pipe).to.equal(true);
177
+ expect(options.enableExtensions).to.deep.equal([
178
+ "/ext/devtools",
179
+ "/ext/other",
180
+ ]);
181
+ expect(options.args.filter((arg) => /extension/.test(arg))).to.deep.equal([]);
182
+ }
183
+ });
184
+ it("keeps the pipe next to a debugging port", () => {
185
+ const withExtensions = {
186
+ settings: {
187
+ ...environment.settings,
188
+ chromeExtensionPaths: "/ext/devtools",
189
+ },
190
+ };
191
+ for (const [debuggingPort, headless] of [
192
+ [true, false],
193
+ [false, true],
194
+ [true, true],
195
+ ]) {
196
+ const { args } = new BrowserContext("example.com", "Google Chrome for Testing 154.0.8037.57", [], withExtensions, undefined, debuggingPort, headless, 9333).getPuppeteerLaunchOptions();
197
+ expect(args).to.include("--remote-debugging-port=9333");
198
+ expect(args).to.include("--remote-debugging-pipe");
199
+ }
200
+ });
201
+ it("launches without extensions when none are configured", () => {
202
+ const options = newContext(false).getPuppeteerLaunchOptions();
203
+ expect(options.enableExtensions).to.equal(undefined);
204
+ expect(options.pipe).to.equal(undefined);
205
+ });
206
+ });