@malloy-publisher/server 0.17.3 → 0.18.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.
Files changed (32) hide show
  1. package/dist/admin-api-doc.yaml +757 -22
  2. package/dist/app/api-doc.yaml +160 -28
  3. package/dist/app/assets/{EnvironmentPage-Cpetyfj1.js → EnvironmentPage-CsFUI8IX.js} +1 -1
  4. package/dist/app/assets/{HomePage-RlrpQRV8.js → HomePage-B_FVtnN-.js} +1 -1
  5. package/dist/app/assets/{MainPage-C1559_mQ.js → MainPage-wFF9nPEr.js} +1 -1
  6. package/dist/app/assets/{ModelPage-D8T03Bd7.js → ModelPage-CxenqDcz.js} +2 -2
  7. package/dist/app/assets/PackagePage-dcF6vrvw.js +1 -0
  8. package/dist/app/assets/PackageSplatRoute-CASBZk0k.js +2 -0
  9. package/dist/app/assets/{RenderedResult-Cm0Wwtek.es-CfBPkvGU.js → RenderedResult--fYcsY1h.es-DzOt5Lwv.js} +3 -3
  10. package/dist/app/assets/{RouteError-DRuMstfb.js → RouteError-CUIolYwb.js} +1 -1
  11. package/dist/app/assets/{ThemeEditorPage-ss_tmVWo.js → ThemeEditorPage-DgU2YYq6.js} +1 -1
  12. package/dist/app/assets/{ToggleButtonGroup-DA9EfQQB.js → ToggleButtonGroup-Dmr-hVlD.js} +1 -1
  13. package/dist/app/assets/{documentRoutes-_ma0jaCp.js → documentRoutes-Drv-WDwO.js} +1 -1
  14. package/dist/app/assets/{editPageMounted-DxNTqmFg.js → editPageMounted-C5yJiIVi.js} +2 -2
  15. package/dist/app/assets/{index-w1w5RvZI.js → index-BIoSdsU9.js} +1 -1
  16. package/dist/app/assets/{index-BL_7q21Q.js → index-BSyL0zds.js} +97 -97
  17. package/dist/app/assets/{index-BZA1HAyp.js → index-Dtw4eTxH.js} +1 -1
  18. package/dist/app/assets/{index-DrkXqbpl.js → index-DxF3kMLJ.js} +1 -1
  19. package/dist/app/assets/{index.es-XV_AUlWO.js → index.es-CX9m4CBD.js} +10 -10
  20. package/dist/app/assets/usePackageLinkNavigate-qNjcXPcY.js +1 -0
  21. package/dist/app/assets/{usePackageRoute-ev5b1KRn.js → usePackageRoute-wJGaZEiY.js} +1 -1
  22. package/dist/app/index.html +1 -1
  23. package/dist/instrumentation.mjs +31 -17
  24. package/dist/package_load_worker.mjs +528 -377
  25. package/dist/runtime/publisher.colorScheme.spec.ts +167 -0
  26. package/dist/runtime/publisher.js +173 -3
  27. package/dist/runtime/publisher_embed.spec.ts +108 -0
  28. package/dist/server.mjs +10361 -4009
  29. package/package.json +2 -1
  30. package/dist/app/assets/PackagePage-BIl1r9eP.js +0 -1
  31. package/dist/app/assets/PackageSplatRoute-DJlJXk6p.js +0 -2
  32. package/dist/app/assets/usePackageLinkNavigate-BKkPNdJ4.js +0 -1
@@ -0,0 +1,167 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ /// <reference types="bun-types" />
5
+
6
+ /**
7
+ * The runtime's half of the "publisher:color-scheme" contract
8
+ * (packages/sdk/src/utils/dataAppEmbed.ts): a framed page asks its host for
9
+ * the reader's mode, follows what the host says, and answers once the page
10
+ * says it drew it. Evaluated in a vm sandbox standing in for a framed window.
11
+ */
12
+ import { describe, expect, it } from "bun:test";
13
+ import { readFileSync } from "fs";
14
+ import path from "path";
15
+ import vm from "vm";
16
+
17
+ const SOURCE = readFileSync(path.join(import.meta.dir, "publisher.js"), "utf8");
18
+
19
+ type Publisher = {
20
+ colorScheme: string | null;
21
+ onColorScheme: (fn: (m: string) => void) => () => void;
22
+ colorSchemeApplied: (m: string) => void;
23
+ };
24
+
25
+ function framedPage() {
26
+ const posted: { data: unknown; origin: string }[] = [];
27
+ const parent = {
28
+ postMessage: (data: unknown, origin: string) =>
29
+ posted.push({ data, origin }),
30
+ };
31
+ const handlers: ((e: unknown) => void)[] = [];
32
+ const sandbox: Record<string, unknown> = {
33
+ fetch: () => Promise.reject(new Error("no network")),
34
+ location: {
35
+ pathname: "/environments/e/packages/p/index.html",
36
+ origin: "https://data.example",
37
+ search: "",
38
+ },
39
+ console,
40
+ setInterval: () => 0,
41
+ setTimeout: () => 0,
42
+ parent,
43
+ // Enough of a document for the runtime's resize reporting, which runs in any frame.
44
+ document: {
45
+ readyState: "complete",
46
+ body: null,
47
+ documentElement: { scrollHeight: 0 },
48
+ addEventListener: () => {},
49
+ },
50
+ addEventListener: (type: string, fn: (e: unknown) => void) =>
51
+ type === "message" && handlers.push(fn),
52
+ };
53
+ sandbox.self = sandbox;
54
+ sandbox.top = parent;
55
+ sandbox.window = sandbox;
56
+ vm.runInContext(SOURCE, vm.createContext(sandbox), {
57
+ filename: "publisher.js",
58
+ });
59
+ const publisher = (sandbox.window as { Publisher: Publisher }).Publisher;
60
+ const send = (
61
+ data: unknown,
62
+ source: unknown = parent,
63
+ origin = "https://app.example",
64
+ ) => handlers.forEach((h) => h({ data, source, origin }));
65
+ return { publisher, posted, send };
66
+ }
67
+
68
+ describe("Publisher runtime color scheme", () => {
69
+ it("asks the host for the mode when the page starts", () => {
70
+ const { posted } = framedPage();
71
+ expect(posted.map((p) => p.data)).toContainEqual({
72
+ type: "publisher:color-scheme-request",
73
+ });
74
+ });
75
+
76
+ it("follows the host's mode and tells the page", () => {
77
+ const { publisher, send } = framedPage();
78
+ const seen: string[] = [];
79
+ publisher.onColorScheme((m) => seen.push(m));
80
+ send({ type: "publisher:color-scheme", mode: "dark" });
81
+ send({ type: "publisher:color-scheme", mode: "dark" });
82
+ send({ type: "publisher:color-scheme", mode: "light" });
83
+ expect(publisher.colorScheme).toBe("light");
84
+ expect(seen).toEqual(["dark", "light"]);
85
+ });
86
+
87
+ it("ignores another window, an unknown mode and another message", () => {
88
+ const { publisher, send } = framedPage();
89
+ send(
90
+ { type: "publisher:color-scheme", mode: "dark" },
91
+ { not: "the parent" },
92
+ );
93
+ send({ type: "publisher:color-scheme", mode: "sepia" });
94
+ send({ type: "credible:color-scheme", mode: "dark" });
95
+ expect(publisher.colorScheme).toBe(null);
96
+ });
97
+
98
+ it("answers the host, at its origin, once the page says it drew the mode", () => {
99
+ const { publisher, posted, send } = framedPage();
100
+ send({ type: "publisher:color-scheme", mode: "dark" });
101
+ publisher.colorSchemeApplied("dark");
102
+ expect(posted).toContainEqual({
103
+ data: { type: "publisher:color-scheme-applied", mode: "dark" },
104
+ origin: "https://app.example",
105
+ });
106
+ });
107
+
108
+ it("answers the same mode again when the host sends it again, so a host that reloaded the frame hears it", () => {
109
+ const { publisher, posted, send } = framedPage();
110
+ send({ type: "publisher:color-scheme", mode: "dark" });
111
+ publisher.colorSchemeApplied("dark");
112
+ posted.length = 0;
113
+ send({ type: "publisher:color-scheme", mode: "dark" });
114
+ expect(posted).toEqual([
115
+ {
116
+ data: { type: "publisher:color-scheme-applied", mode: "dark" },
117
+ origin: "https://app.example",
118
+ },
119
+ ]);
120
+ });
121
+
122
+ it("answers a repeated mode with the mode the page drew, when that differs", () => {
123
+ const { publisher, posted, send } = framedPage();
124
+ send({ type: "publisher:color-scheme", mode: "dark" });
125
+ publisher.colorSchemeApplied("light"); // a page fixed to light by its address
126
+ posted.length = 0;
127
+ send({ type: "publisher:color-scheme", mode: "dark" });
128
+ expect(posted).toEqual([
129
+ {
130
+ data: { type: "publisher:color-scheme-applied", mode: "light" },
131
+ origin: "https://app.example",
132
+ },
133
+ ]);
134
+ });
135
+
136
+ it("keeps a listener's error out of the page that adds it", () => {
137
+ const { publisher, send } = framedPage();
138
+ send({ type: "publisher:color-scheme", mode: "dark" });
139
+ expect(() =>
140
+ publisher.onColorScheme(() => {
141
+ throw new Error("listener");
142
+ }),
143
+ ).not.toThrow();
144
+ });
145
+
146
+ it("tells the other listeners when one throws, and stops one that asks to stop", () => {
147
+ const { publisher, send } = framedPage();
148
+ const seen: string[] = [];
149
+ publisher.onColorScheme(() => {
150
+ throw new Error("listener");
151
+ });
152
+ const stop = publisher.onColorScheme((m) => seen.push(`stopped:${m}`));
153
+ publisher.onColorScheme((m) => seen.push(m));
154
+ send({ type: "publisher:color-scheme", mode: "dark" });
155
+ stop();
156
+ send({ type: "publisher:color-scheme", mode: "light" });
157
+ expect(seen).toEqual(["stopped:dark", "dark", "light"]);
158
+ });
159
+
160
+ it("tells a listener added later the mode already known", () => {
161
+ const { publisher, send } = framedPage();
162
+ send({ type: "publisher:color-scheme", mode: "dark" });
163
+ const seen: string[] = [];
164
+ publisher.onColorScheme((m) => seen.push(m));
165
+ expect(seen).toEqual(["dark"]);
166
+ });
167
+ });
@@ -9,11 +9,22 @@
9
9
  // - Publisher.query(model, malloy, opts?) → Promise<rows[]>
10
10
  // - Publisher.queryFull(model, malloy, opts?) → Promise<MalloyResult> (envelope for <malloy-render>)
11
11
  // opts: { environment?, package?, sourceName?, queryName?, filterParams?,
12
- // bypassFilters?, givens?, versionId? }. versionId names a published
12
+ // bypassFilters?, givens?, versionId?, meta? }. meta, an object, is filled
13
+ // with { servedFrom, path, executionTimeMs } from the response (path is
14
+ // the path report: the table that served it and the ones considered)
15
+ // and versionId, the version the query was pinned to, or null. opts.versionId names a published
13
16
  // version; a page opened with `?versionId=` queries its own
14
17
  // package at that version by default. givens is a name→value map bound as
15
18
  // Malloy given: runtime parameters for this query (safe parameterization,
16
19
  // not string interpolation) — see the malloy-html-data-apps skill (reference/runtime.md).
20
+ // - Publisher.model(modelPath, opts?) → Promise<Model> (its sources, their docs)
21
+ // - Publisher.packageResource(name, opts?) → Promise<JSON>, name "build-plan" or
22
+ // "materializations": what Publisher builds for the package and its runs,
23
+ // newest first (opts.limit reads the newest runs only).
24
+ // Both read the page's own version when it is pinned, as queries do.
25
+ // - Publisher.colorScheme, Publisher.onColorScheme(fn), Publisher.colorSchemeApplied(mode):
26
+ // the reader's light or dark mode from the host ("publisher:color-scheme"),
27
+ // and the page's answer that it drew it ("publisher:color-scheme-applied").
17
28
  // - Publisher.embed(selector, { src, height?, token? })
18
29
  // - Publisher.context ({ environment, package } inferred from URL)
19
30
  // - Publisher.setToken(token) (override Bearer token; default uses cookies)
@@ -189,11 +200,149 @@
189
200
  err.status = res.status;
190
201
  throw err;
191
202
  }
203
+ if (opts.meta && typeof opts.meta === "object") {
204
+ opts.meta.servedFrom =
205
+ json.servedFrom == null ? null : json.servedFrom;
206
+ opts.meta.path = json.path == null ? null : json.path;
207
+ opts.meta.executionTimeMs =
208
+ json.executionTimeMs == null ? null : json.executionTimeMs;
209
+ opts.meta.versionId = body.versionId || null;
210
+ }
192
211
  // The server's QueryResult always has `result` as a JSON-encoded string.
193
212
  // Parse it before handing it back so callers see real JS values.
194
213
  return JSON.parse(json.result);
195
214
  }
196
215
 
216
+ // A read of the package itself, at the page's pinned version when the read is
217
+ // of the page's own package, as a query is.
218
+ async function packageGet(sub, opts) {
219
+ opts = opts || {};
220
+ var target = resolveTarget(opts);
221
+ var url =
222
+ apiBase +
223
+ "/environments/" +
224
+ encodeURIComponent(target.env) +
225
+ "/packages/" +
226
+ encodeURIComponent(target.pkg) +
227
+ "/" +
228
+ sub;
229
+ var versionId =
230
+ opts.versionId ||
231
+ (target.env === ctx.environment && target.pkg === ctx.package
232
+ ? await pinnedVersion()
233
+ : undefined);
234
+ var params = [];
235
+ if (versionId) params.push("versionId=" + encodeURIComponent(versionId));
236
+ // A list (the package's runs) reads its newest `limit` entries.
237
+ if (opts.limit > 0 && Number.isInteger(opts.limit))
238
+ params.push("limit=" + opts.limit);
239
+ if (params.length) url += "?" + params.join("&");
240
+ var res = await fetch(url, {
241
+ credentials: "include",
242
+ headers: authHeaders(),
243
+ });
244
+ if (!res.ok) {
245
+ var err = new Error("Publisher: " + sub + " (" + res.status + ")");
246
+ err.status = res.status;
247
+ throw err;
248
+ }
249
+ return res.json();
250
+ }
251
+ function model(modelPath, opts) {
252
+ return packageGet("models/" + encodeURIComponent(modelPath), opts);
253
+ }
254
+ var PACKAGE_RESOURCES = { "build-plan": true, materializations: true };
255
+ function packageResource(name, opts) {
256
+ if (!Object.prototype.hasOwnProperty.call(PACKAGE_RESOURCES, name)) {
257
+ return Promise.reject(
258
+ new Error(
259
+ 'Publisher.packageResource: "' +
260
+ name +
261
+ '" is not one of build-plan, materializations',
262
+ ),
263
+ );
264
+ }
265
+ return packageGet(name, opts);
266
+ }
267
+
268
+ // --- Light and dark, from the host -------------------------------------
269
+ // The "publisher:color-scheme*" messages are the same contract as
270
+ // PUBLISHER_COLOR_SCHEME_MESSAGE_TYPE and its two siblings in
271
+ // packages/sdk/src/utils/dataAppEmbed.ts; keep the two in sync. The host
272
+ // tells the page the reader's mode; the page, once it has drawn it, answers
273
+ // with colorSchemeApplied, so a host holding the frame light can let it go.
274
+ var colorScheme = null;
275
+ var appliedScheme = null;
276
+ var colorSchemeListeners = [];
277
+ var hostOrigin = null;
278
+ function onColorScheme(fn) {
279
+ colorSchemeListeners.push(fn);
280
+ if (colorScheme) {
281
+ try {
282
+ fn(colorScheme);
283
+ } catch (_e) {
284
+ /* a listener's error is its own */
285
+ }
286
+ }
287
+ return function () {
288
+ colorSchemeListeners = colorSchemeListeners.filter(function (f) {
289
+ return f !== fn;
290
+ });
291
+ };
292
+ }
293
+ function colorSchemeApplied(mode) {
294
+ if (mode !== "light" && mode !== "dark") return;
295
+ appliedScheme = mode;
296
+ if (!window.parent || window.parent === window) return;
297
+ try {
298
+ window.parent.postMessage(
299
+ { type: "publisher:color-scheme-applied", mode: mode },
300
+ hostOrigin || "*",
301
+ );
302
+ } catch (_e) {
303
+ /* ignore */
304
+ }
305
+ }
306
+ function setUpColorScheme() {
307
+ if (!window.parent || window.parent === window) return;
308
+ if (typeof window.addEventListener !== "function") return;
309
+ window.addEventListener("message", function (e) {
310
+ var d = e.data;
311
+ if (
312
+ e.source !== window.parent ||
313
+ !d ||
314
+ d.type !== "publisher:color-scheme"
315
+ )
316
+ return;
317
+ if (d.mode !== "light" && d.mode !== "dark") return;
318
+ hostOrigin = e.origin && e.origin !== "null" ? e.origin : null;
319
+ // The same mode again: a host that forgot the answer (a frame it reloaded) hears it again.
320
+ if (d.mode === colorScheme) {
321
+ // What the page drew, which a page with a fixed mode (?mode=) may differ from.
322
+ if (appliedScheme) colorSchemeApplied(appliedScheme);
323
+ return;
324
+ }
325
+ colorScheme = d.mode;
326
+ colorSchemeListeners.slice().forEach(function (fn) {
327
+ try {
328
+ fn(colorScheme);
329
+ } catch (_e) {
330
+ /* a listener's error is its own */
331
+ }
332
+ });
333
+ });
334
+ // In case the host spoke before this page was listening. It carries
335
+ // nothing, so it goes to the host's own origin where the browser says it.
336
+ try {
337
+ window.parent.postMessage(
338
+ { type: "publisher:color-scheme-request" },
339
+ (location.ancestorOrigins && location.ancestorOrigins[0]) || "*",
340
+ );
341
+ } catch (_e) {
342
+ /* ignore */
343
+ }
344
+ }
345
+
197
346
  function query(modelPath, malloyQuery, opts) {
198
347
  return rawQuery(modelPath, malloyQuery, opts, true);
199
348
  }
@@ -232,10 +381,23 @@
232
381
  } else {
233
382
  iframe.style.height = "0px"; // will be sized via postMessage
234
383
  }
235
- if (options.allow) iframe.allow = options.allow;
384
+ // The page can save a file, open a link in a new tab, and use the
385
+ // clipboard and full screen. Never top navigation, which would move the
386
+ // host page away, or modal dialogs, and an opened tab keeps the sandbox:
387
+ // in Firefox one that escaped it could redirect the host page. Same as
388
+ // Publisher's own viewer (DataAppViewer).
389
+ // A host passes its own `allow` or `sandbox` to replace the default.
390
+ // `allow: ""` delegates no feature. A host's own `sandbox` replaces every
391
+ // token, so it must keep `allow-scripts allow-same-origin` for the page
392
+ // to run, query and resize; `sandbox: ""` is the strictest frame, where
393
+ // the page draws nothing.
394
+ iframe.allow =
395
+ options.allow == null ? "clipboard-write; fullscreen" : options.allow;
236
396
  iframe.setAttribute(
237
397
  "sandbox",
238
- "allow-scripts allow-same-origin allow-forms",
398
+ options.sandbox == null
399
+ ? "allow-scripts allow-same-origin allow-forms allow-downloads allow-popups"
400
+ : options.sandbox,
239
401
  );
240
402
 
241
403
  // Resize listener
@@ -432,8 +594,15 @@
432
594
  window.Publisher = {
433
595
  query: query,
434
596
  queryFull: queryFull,
597
+ model: model,
598
+ packageResource: packageResource,
435
599
  embed: embed,
436
600
  context: ctx,
601
+ get colorScheme() {
602
+ return colorScheme;
603
+ },
604
+ onColorScheme: onColorScheme,
605
+ colorSchemeApplied: colorSchemeApplied,
437
606
  setToken: function (token) {
438
607
  bearerToken = token || null;
439
608
  },
@@ -442,5 +611,6 @@
442
611
  // Auto-init the in-iframe behaviors and live-reload subscription.
443
612
  // Both are no-ops if not applicable.
444
613
  setUpEmbeddedSelfBehaviors();
614
+ setUpColorScheme();
445
615
  setUpLiveReload();
446
616
  })();
@@ -0,0 +1,108 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ /**
5
+ * What `Publisher.embed` lets the frame it creates do, read from the frame the
6
+ * real runtime builds on a host page. The same rules as the Console's viewer
7
+ * (DataAppViewer): downloads, new tabs, the clipboard and full screen, and never anything
8
+ * over the host.
9
+ */
10
+ import { describe, expect, it } from "bun:test";
11
+ import fs from "fs";
12
+ import path from "path";
13
+ import { Window } from "happy-dom";
14
+
15
+ const RUNTIME = fs.readFileSync(path.join(__dirname, "publisher.js"), "utf8");
16
+
17
+ function embedFrame(options: Record<string, unknown> = {}) {
18
+ const window = new Window({ url: "https://host.example.com/page" });
19
+ window.document.body.innerHTML = '<div id="slot"></div>';
20
+ // A host page, not a framed one: the runtime sees it is the top window and
21
+ // installs only window.Publisher.
22
+ new Function("window", "document", "location", "MutationObserver", RUNTIME)(
23
+ window,
24
+ window.document,
25
+ window.location,
26
+ window.MutationObserver,
27
+ );
28
+ const publisher = (
29
+ window as unknown as {
30
+ Publisher: {
31
+ embed: (
32
+ selector: string,
33
+ options: Record<string, unknown>,
34
+ ) => { iframe: HTMLIFrameElement };
35
+ };
36
+ }
37
+ ).Publisher;
38
+ const { iframe } = publisher.embed("#slot", {
39
+ src: "https://data.example.com/environments/e/packages/p/index.html",
40
+ ...options,
41
+ });
42
+ const sandboxAttribute = iframe.getAttribute("sandbox");
43
+ const sandbox = (sandboxAttribute ?? "").split(/\s+/);
44
+ const allow = (iframe.getAttribute("allow") ?? "")
45
+ .split(";")
46
+ .map((feature: string) => feature.trim())
47
+ .filter(Boolean);
48
+ void window.happyDOM.close();
49
+ return { sandbox, sandboxAttribute, allow };
50
+ }
51
+
52
+ describe("Publisher.embed frame permissions", () => {
53
+ it("lets the page save a file, open a link in a new tab, copy and go full screen", () => {
54
+ const { sandbox, allow } = embedFrame();
55
+ expect(sandbox).toEqual(
56
+ expect.arrayContaining(["allow-downloads", "allow-popups"]),
57
+ );
58
+ expect(allow).toEqual(["clipboard-write", "fullscreen"]);
59
+ });
60
+
61
+ it("keeps what the page needs to run, query as the reader and report its size", () => {
62
+ expect(embedFrame().sandbox).toEqual(
63
+ expect.arrayContaining([
64
+ "allow-scripts",
65
+ "allow-same-origin",
66
+ "allow-forms",
67
+ ]),
68
+ );
69
+ });
70
+
71
+ it("grants nothing else: no top navigation, dialogs, clipboard reads, tabs that leave the sandbox or other features", () => {
72
+ const { sandbox, allow } = embedFrame();
73
+ expect([...sandbox].sort()).toEqual([
74
+ "allow-downloads",
75
+ "allow-forms",
76
+ "allow-popups",
77
+ "allow-same-origin",
78
+ "allow-scripts",
79
+ ]);
80
+ expect([...allow].sort()).toEqual(["clipboard-write", "fullscreen"]);
81
+ });
82
+
83
+ it("takes the host's own allow, and an empty one turns the default off", () => {
84
+ expect(embedFrame({ allow: "fullscreen" }).allow).toEqual(["fullscreen"]);
85
+ expect(embedFrame({ allow: "" }).allow).toEqual([]);
86
+ });
87
+
88
+ it("reads a null allow as the default, not as a policy named null", () => {
89
+ expect(embedFrame({ allow: null }).allow).toEqual([
90
+ "clipboard-write",
91
+ "fullscreen",
92
+ ]);
93
+ });
94
+
95
+ it("takes the host's own sandbox, so a host can keep the old frame", () => {
96
+ expect(
97
+ embedFrame({ sandbox: "allow-scripts allow-same-origin allow-forms" })
98
+ .sandbox,
99
+ ).toEqual(["allow-scripts", "allow-same-origin", "allow-forms"]);
100
+ expect(embedFrame({ sandbox: null }).sandbox).toEqual(
101
+ expect.arrayContaining(["allow-downloads", "allow-popups"]),
102
+ );
103
+ });
104
+
105
+ it("keeps an empty sandbox empty, the strictest frame, rather than the default", () => {
106
+ expect(embedFrame({ sandbox: "" }).sandboxAttribute).toBe("");
107
+ });
108
+ });